Claude-to-IM Bridge Skill
You are managing the Claude-to-IM bridge.
User data is stored at ~/.claude-to-im/.
First, locate the skill directory by finding this SKILL.md file:
- Use Glob with pattern
**/skills/**/claude-to-im/SKILL.md to find its path, then derive the skill root directory from it.
- Store that path mentally as SKILL_DIR for all subsequent file references.
Command parsing
Parse the user's intent from $ARGUMENTS into one of these subcommands:
| User says (examples) |
Subcommand |
setup, configure, 配置 |
setup |
start, start bridge, 启动, 启动桥接 |
start |
stop, stop bridge, 停止, 停止桥接 |
stop |
status, bridge status, 状态 |
status |
logs, logs 200, 查看日志, 查看日志 200 |
logs |
reconfigure, 修改配置 |
reconfigure |
doctor, diagnose, 诊断 |
doctor |
Extract optional numeric argument for logs (default 50).
IMPORTANT: Before asking users for any platform credentials, first read SKILL_DIR/references/setup-guides.md to get the detailed step-by-step guidance for that platform. Present the relevant guide text to the user via AskUserQuestion so they know exactly what to do.
Runtime detection
Before executing any subcommand, detect which environment you are running in:
- Claude Code —
AskUserQuestion tool is available. Use it for interactive setup wizards.
- Codex / other —
AskUserQuestion is NOT available. Fall back to non-interactive guidance: explain the steps, show SKILL_DIR/config.env.example, and ask the user to create ~/.claude-to-im/config.env manually.
You can test this by checking if AskUserQuestion is in your available tools list.
Config check (applies to start, stop, status, logs, reconfigure, doctor)
Before running any subcommand other than setup, check if ~/.claude-to-im/config.env exists:
- If it does NOT exist:
- In Claude Code: tell the user "No configuration found" and automatically start the
setup wizard using AskUserQuestion.
- In Codex: tell the user "No configuration found. Please create
~/.claude-to-im/config.env based on the example:" then show the contents of SKILL_DIR/config.env.example and stop. Do NOT attempt to start the daemon.
- If it exists: proceed with the requested subcommand.
Subcommands
setup
Run an interactive setup wizard. This subcommand requires AskUserQuestion. If it is not available (Codex environment), instead show the contents of SKILL_DIR/config.env.example with field-by-field explanations and instruct the user to create the config file manually.
When AskUserQuestion IS available, collect input one field at a time. After each answer, confirm the value back to the user (masking secrets to last 4 chars only) before moving to the next question.
Step 1 — Choose channels
Ask which channels to enable (telegram, discord, feishu). Accept comma-separated input. Briefly describe each:
- telegram — Best for personal use. Streaming preview, inline permission buttons.
- discord — Good for team use. Server/channel/user-level access control.
- feishu (Lark) — For Feishu/Lark teams. Event-based messaging.
Step 2 — Collect tokens per channel
For each enabled channel, read SKILL_DIR/references/setup-guides.md and present the relevant platform guide to the user. Collect one credential at a time:
- Telegram: Bot Token → confirm (masked) → Chat ID (see guide for how to get it) → confirm → Allowed User IDs (optional). Important: At least one of Chat ID or Allowed User IDs must be set, otherwise the bot will reject all messages.
- Discord: Bot Token → confirm (masked) → Allowed User IDs → Allowed Channel IDs (optional) → Allowed Guild IDs (optional). Important: At least one of Allowed User IDs or Allowed Channel IDs must be set, otherwise the bot will reject all messages (default-deny).
- Feishu: App ID → confirm → App Secret → confirm (masked) → Domain (optional) → Allowed User IDs (optional). Guide through all 4 steps (A: batch permissions, B: enable bot, C: events & callbacks with long connection, D: publish version).
Step 3 — General settings
Ask for runtime, default working directory, model, and mode:
- Runtime:
claude (default), codex, auto
claude — uses Claude Code CLI + Claude Agent SDK (requires claude CLI installed)
codex — uses OpenAI Codex SDK (requires codex CLI; auth via codex auth login or OPENAI_API_KEY)
auto — tries Claude first, falls back to Codex if Claude CLI not found
- Working Directory: default
$CWD
- Model (optional): Leave blank to inherit the runtime's own default model. If the user wants to override, ask them to enter a model name. Do NOT hardcode or suggest specific model names — the available models change over time.
- Mode:
code (default), plan, ask
Step 4 — Write config and validate
- Show a final summary table with all settings (secrets masked to last 4 chars)
- Ask user to confirm before writing
- Use Bash to create directory structure:
mkdir -p ~/.claude-to-im/{data,logs,runtime,data/messages}
- Use Write to create
~/.claude-to-im/config.env with all settings in KEY=VALUE format
- Use Bash to set permissions:
chmod 600 ~/.claude-to-im/config.env
- Validate tokens:
- Telegram:
curl -s "https://api.telegram.org/bot${TOKEN}/getMe" — check for "ok":true
- Feishu:
curl -s -X POST "${DOMAIN}/open-apis/auth/v3/tenant_access_token/internal" -H "Content-Type: application/json" -d '{"app_id":"...","app_secret":"..."}' — check for "code":0
- Discord: verify token matches format
[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+
- Report results with a summary table. If any validation fails, explain what might be wrong and how to fix it.
- On success, tell the user: "Setup complete! Run
/claude-to-im start to start the bridge."
start
Pre-check: Verify ~/.claude-to-im/config.env exists (see "Config check" above). Do NOT proceed without it.
Run: bash "SKILL_DIR/scripts/daemon.sh" start
Show the output to the user. If it fails, tell the user:
- Run
doctor to diagnose: /claude-to-im doctor
- Check recent logs:
/claude-to-im logs
stop
Run: bash "SKILL_DIR/scripts/daemon.sh" stop
status
Run: bash "SKILL_DIR/scripts/daemon.sh" status
logs
Extract optional line count N from arguments (default 50).
Run: bash "SKILL_DIR/scripts/daemon.sh" logs N
reconfigure
- Read current config from
~/.claude-to-im/config.env
- Show current settings in a clear table format, with all secrets masked (only last 4 chars visible)
- Use AskUserQuestion to ask what the user wants to change
- When collecting new values, read
SKILL_DIR/references/setup-guides.md and present the relevant guide for that field
- Update the config file atomically (write to tmp, rename)
- Re-validate any changed tokens
- Remind user: "Run
/claude-to-im stop then /claude-to-im start to apply the changes."
doctor
Run: bash "SKILL_DIR/scripts/doctor.sh"
Show results and suggest fixes for any failures. Common fixes:
- SDK cli.js missing →
cd SKILL_DIR && npm install
- dist/daemon.mjs stale →
cd SKILL_DIR && npm run build
- Config missing → run
setup
Notes
- Always mask secrets in output (show only last 4 characters)
- Never start the daemon without a valid config.env — always check first, redirect to setup or show config example
- The daemon runs as a background Node.js process managed by platform supervisor (launchd on macOS, setsid on Linux, WinSW/NSSM on Windows)
- Config persists at
~/.claude-to-im/config.env — survives across sessions
1---2name: claude-to-im3description: This skill bridges Claude Code to IM platforms (Telegram, Discord, Feishu/Lark). It should be used when the user wants to start a background daemon that forwards IM messages to Claude Code sessions, or manage that daemon's lifecycle. Trigger on: "claude-to-im", "start bridge", "stop bridge", "bridge status", "查看日志", "启动桥接", "停止桥接", or any mention of IM bridge management. Subcommands: setup, start, stop, status, logs, reconfigure, doctor.4---56# Claude-to-IM Bridge Skill78You are managing the Claude-to-IM bridge.9User data is stored at `~/.claude-to-im/`.1011First, locate the skill directory by finding this SKILL.md file:12- Use Glob with pattern `**/skills/**/claude-to-im/SKILL.md` to find its path, then derive the skill root directory from it.13- Store that path mentally as SKILL_DIR for all subsequent file references.1415## Command parsing1617Parse the user's intent from `$ARGUMENTS` into one of these subcommands:1819| User says (examples) | Subcommand |20|---|---|21| `setup`, `configure`, `配置` | setup |22| `start`, `start bridge`, `启动`, `启动桥接` | start |23| `stop`, `stop bridge`, `停止`, `停止桥接` | stop |24| `status`, `bridge status`, `状态` | status |25| `logs`, `logs 200`, `查看日志`, `查看日志 200` | logs |26| `reconfigure`, `修改配置` | reconfigure |27| `doctor`, `diagnose`, `诊断` | doctor |2829Extract optional numeric argument for `logs` (default 50).3031**IMPORTANT:** Before asking users for any platform credentials, first read `SKILL_DIR/references/setup-guides.md` to get the detailed step-by-step guidance for that platform. Present the relevant guide text to the user via AskUserQuestion so they know exactly what to do.3233## Runtime detection3435Before executing any subcommand, detect which environment you are running in:36371. **Claude Code** — `AskUserQuestion` tool is available. Use it for interactive setup wizards.382. **Codex / other** — `AskUserQuestion` is NOT available. Fall back to non-interactive guidance: explain the steps, show `SKILL_DIR/config.env.example`, and ask the user to create `~/.claude-to-im/config.env` manually.3940You can test this by checking if AskUserQuestion is in your available tools list.4142## Config check (applies to `start`, `stop`, `status`, `logs`, `reconfigure`, `doctor`)4344Before running any subcommand other than `setup`, check if `~/.claude-to-im/config.env` exists:4546- **If it does NOT exist:**47 - In Claude Code: tell the user "No configuration found" and automatically start the `setup` wizard using AskUserQuestion.48 - In Codex: tell the user "No configuration found. Please create `~/.claude-to-im/config.env` based on the example:" then show the contents of `SKILL_DIR/config.env.example` and stop. Do NOT attempt to start the daemon.49- **If it exists:** proceed with the requested subcommand.5051## Subcommands5253### `setup`5455Run an interactive setup wizard. This subcommand requires `AskUserQuestion`. If it is not available (Codex environment), instead show the contents of `SKILL_DIR/config.env.example` with field-by-field explanations and instruct the user to create the config file manually.5657When AskUserQuestion IS available, collect input **one field at a time**. After each answer, confirm the value back to the user (masking secrets to last 4 chars only) before moving to the next question.5859**Step 1 — Choose channels**6061Ask which channels to enable (telegram, discord, feishu). Accept comma-separated input. Briefly describe each:62- **telegram** — Best for personal use. Streaming preview, inline permission buttons.63- **discord** — Good for team use. Server/channel/user-level access control.64- **feishu** (Lark) — For Feishu/Lark teams. Event-based messaging.6566**Step 2 — Collect tokens per channel**6768For each enabled channel, read `SKILL_DIR/references/setup-guides.md` and present the relevant platform guide to the user. Collect one credential at a time:6970- **Telegram**: Bot Token → confirm (masked) → Chat ID (see guide for how to get it) → confirm → Allowed User IDs (optional). **Important:** At least one of Chat ID or Allowed User IDs must be set, otherwise the bot will reject all messages.71- **Discord**: Bot Token → confirm (masked) → Allowed User IDs → Allowed Channel IDs (optional) → Allowed Guild IDs (optional). **Important:** At least one of Allowed User IDs or Allowed Channel IDs must be set, otherwise the bot will reject all messages (default-deny).72- **Feishu**: App ID → confirm → App Secret → confirm (masked) → Domain (optional) → Allowed User IDs (optional). Guide through all 4 steps (A: batch permissions, B: enable bot, C: events & callbacks with long connection, D: publish version).7374**Step 3 — General settings**7576Ask for runtime, default working directory, model, and mode:77- **Runtime**: `claude` (default), `codex`, `auto`78 - `claude` — uses Claude Code CLI + Claude Agent SDK (requires `claude` CLI installed)79 - `codex` — uses OpenAI Codex SDK (requires `codex` CLI; auth via `codex auth login` or `OPENAI_API_KEY`)80 - `auto` — tries Claude first, falls back to Codex if Claude CLI not found81- **Working Directory**: default `$CWD`82- **Model** (optional): Leave blank to inherit the runtime's own default model. If the user wants to override, ask them to enter a model name. Do NOT hardcode or suggest specific model names — the available models change over time.83- **Mode**: `code` (default), `plan`, `ask`8485**Step 4 — Write config and validate**86871. Show a final summary table with all settings (secrets masked to last 4 chars)882. Ask user to confirm before writing893. Use Bash to create directory structure: `mkdir -p ~/.claude-to-im/{data,logs,runtime,data/messages}`904. Use Write to create `~/.claude-to-im/config.env` with all settings in KEY=VALUE format915. Use Bash to set permissions: `chmod 600 ~/.claude-to-im/config.env`926. Validate tokens:93 - Telegram: `curl -s "https://api.telegram.org/bot${TOKEN}/getMe"` — check for `"ok":true`94 - Feishu: `curl -s -X POST "${DOMAIN}/open-apis/auth/v3/tenant_access_token/internal" -H "Content-Type: application/json" -d '{"app_id":"...","app_secret":"..."}'` — check for `"code":0`95 - Discord: verify token matches format `[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+`967. Report results with a summary table. If any validation fails, explain what might be wrong and how to fix it.978. On success, tell the user: "Setup complete! Run `/claude-to-im start` to start the bridge."9899### `start`100101**Pre-check:** Verify `~/.claude-to-im/config.env` exists (see "Config check" above). Do NOT proceed without it.102103Run: `bash "SKILL_DIR/scripts/daemon.sh" start`104105Show the output to the user. If it fails, tell the user:106- Run `doctor` to diagnose: `/claude-to-im doctor`107- Check recent logs: `/claude-to-im logs`108109### `stop`110111Run: `bash "SKILL_DIR/scripts/daemon.sh" stop`112113### `status`114115Run: `bash "SKILL_DIR/scripts/daemon.sh" status`116117### `logs`118119Extract optional line count N from arguments (default 50).120Run: `bash "SKILL_DIR/scripts/daemon.sh" logs N`121122### `reconfigure`1231241. Read current config from `~/.claude-to-im/config.env`1252. Show current settings in a clear table format, with all secrets masked (only last 4 chars visible)1263. Use AskUserQuestion to ask what the user wants to change1274. When collecting new values, read `SKILL_DIR/references/setup-guides.md` and present the relevant guide for that field1285. Update the config file atomically (write to tmp, rename)1296. Re-validate any changed tokens1307. Remind user: "Run `/claude-to-im stop` then `/claude-to-im start` to apply the changes."131132### `doctor`133134Run: `bash "SKILL_DIR/scripts/doctor.sh"`135136Show results and suggest fixes for any failures. Common fixes:137- SDK cli.js missing → `cd SKILL_DIR && npm install`138- dist/daemon.mjs stale → `cd SKILL_DIR && npm run build`139- Config missing → run `setup`140141## Notes142143- Always mask secrets in output (show only last 4 characters)144- **Never start the daemon without a valid config.env** — always check first, redirect to setup or show config example145- The daemon runs as a background Node.js process managed by platform supervisor (launchd on macOS, setsid on Linux, WinSW/NSSM on Windows)146- Config persists at `~/.claude-to-im/config.env` — survives across sessions