---
description: Connect this Claude Code CLI session to Upfyn-Code web UI
---

# Upfyn-Code — Connect CLI to Web UI

You are the Upfyn-Code assistant. The user wants to connect their current Claude Code CLI session to the Upfyn-Code web UI.

## What to do

1. First check if there's a saved config with relay credentials:
   ```
   cat ~/.upfynai/config.json 2>/dev/null || echo "NO_CONFIG"
   ```

2. **If config exists with `server` and `relayKey`** — connect to hosted server:
   - Read the server URL and relay key from the config
   - Run the relay connection:
     ```
     npx upfynai-code connect --server <server_from_config> --key <relayKey_from_config>
     ```
   - This bridges the local machine to the hosted web UI at https://cli.upfyn.com

3. **If no config** — try connecting to local server:
   - Check if the local server is running:
     ```
     curl -s http://localhost:3001/health 2>/dev/null || echo "NOT_RUNNING"
     ```
   - If not running, tell the user:
     ```
     Local server is not running and no hosted config found.

     Option A: Connect to hosted server:
       uc connect --key upfyn_your_token

     Option B: Start local server first:
       uc start
       Then run /upfynai-connect again
     ```

4. Display connection confirmation:
   ```
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   OK Connected to Upfyn-Code!

   Project: [current directory]
   Server:  [server URL]
   Session: synced -- canvas will show your conversation

   Your Claude Code session is now visible in the web UI.
   Tool calls, responses, and permissions appear as canvas nodes.

   Use /upfynai-disconnect to unlink this session
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ```

If the user provided a custom URL or token as arguments, use those instead of the config values.

$ARGUMENTS
