---
description: Install Upfyn-Code locally for this project — sets up .claude integration, commands, and config
---

# Upfyn-Code — Local Installation

You are the Upfyn-Code assistant. The user wants to install Upfyn-Code locally for the current project. This sets up the full integration between this project's Claude Code CLI and the web UI.

## What to do

### Step 1: Install the npm package globally (if not already)
```
npm list -g upfynai-code --depth=0 2>/dev/null || npm install -g upfynai-code
```

### Step 2: Create user-level commands directory
```
mkdir -p ~/.claude/commands
```

### Step 3: Copy all Upfyn-Code slash commands to user commands
Copy the following command files from the upfynai-code package into `~/.claude/commands/`:
- `upfynai.md`
- `upfynai-connect.md`
- `upfynai-disconnect.md`
- `upfynai-doctor.md`
- `upfynai-local.md`
- `upfynai-uninstall.md`
- `upfynai-export.md`
- `upfynai-status.md`
- `upfynai-stop.md`

Find the package location:
```
npm root -g
```
Then copy from `[global_modules]/upfynai-code/commands/` to `~/.claude/commands/`.

### Step 4: Set up project .claude directory
```
mkdir -p .claude/commands
```

### Step 5: Read existing project configuration
If `.claude/` directory already exists, read and preserve:
- `CLAUDE.md` — project instructions
- `.claude/settings.json` — project settings
- `.claude/mcp.json` — MCP server config
- `.claude/commands/` — project-level custom commands

Report what was found to the user.

### Step 6: Create/update project CLAUDE.md with Upfyn-Code context
If CLAUDE.md exists, append an Upfyn-Code section. If not, mention that the user can create one.
Do NOT overwrite existing CLAUDE.md content.

### Step 7: Display completion
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Upfyn-Code installed locally!

📁 Project: [current directory]
📂 .claude/ directory: [found/created]
📄 CLAUDE.md: [found/created note]
🔧 MCP servers: [count found]
⚡ Slash commands installed to ~/.claude/commands/

Available commands:
  /upfynai          — Start the web UI server
  /upfynai-connect  — Connect this session to web UI
  /upfynai-disconnect — Disconnect from web UI
  /upfynai-status   — Show connection status
  /upfynai-doctor   — Run diagnostics
  /upfynai-export   — Export session/canvas data
  /upfynai-stop     — Stop the web UI server
  /upfynai-uninstall — Remove Upfyn-Code

Next step: Run /upfynai to start the web UI
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

$ARGUMENTS
