From cc-afk
Remote AFK mode via Telegram — manage permissions and get notifications on your phone
npx claudepluginhub imskinner/cc-afk --plugin cc-afkThis skill uses the workspace's default tool permissions.
You are helping the user manage AFK mode, which bridges Claude Code with Telegram for remote interaction.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
You are helping the user manage AFK mode, which bridges Claude Code with Telegram for remote interaction.
The user may pass arguments after /cc-afk:afk:
/cc-afk:afk refactor the auth module)start → Start AFK mode (wait for Telegram messages)off or stop → Stop AFK modesetup → Configure Telegram bot token and chat IDstatus → Check if bridge is runningIf the argument is not a known command (start, off, stop, setup, status), treat it as a task to execute after entering AFK mode.
If config doesn't exist yet, check BOTH locations:
$CLAUDE_PLUGIN_DATA/config.json (plugin data dir)~/.cc-afk/config.json (fallback)If neither exists, guide the user through setup:
Ask the user for their Telegram Bot Token. Tell them to:
node "${CLAUDE_PLUGIN_ROOT}/dist/setup-validate.js" validate-token "<TOKEN>"
Output: {"ok":true,"botName":"@name"} or {"ok":false,"error":"..."}
If invalid, ask for the token again.
Ask the user for their Chat ID (they can get it from @userinfobot on Telegram), OR offer to auto-detect:
Tell the user to send any message to their bot on Telegram, then run:
node "${CLAUDE_PLUGIN_ROOT}/dist/setup-validate.js" detect-chat "<TOKEN>"
Output: {"ok":true,"chatId":123,"name":"..."} or {"ok":false,"error":"..."}
If auto-detect fails, ask for manual input.
CLAUDE_PLUGIN_DATA="${CLAUDE_PLUGIN_DATA}" node "${CLAUDE_PLUGIN_ROOT}/dist/setup-validate.js" save-config "<TOKEN>" <CHAT_ID> [PORT]
Output: {"ok":true,"path":"..."} or {"ok":false,"error":"..."}
node "${CLAUDE_PLUGIN_ROOT}/dist/setup-validate.js" test-message "<TOKEN>" <CHAT_ID>
Output: {"ok":true} or {"ok":false,"error":"..."}
Tell the user to check Telegram for the test message.
$CLAUDE_PLUGIN_DATA/config.json or ~/.cc-afk/config.json. If not, prompt setup first.$CLAUDE_PLUGIN_DATA/bridge.port (or ~/.cc-afk/bridge.port) and hitting http://127.0.0.1:<port>/api/health.CLAUDE_PLUGIN_DATA="${CLAUDE_PLUGIN_DATA}" nohup node "${CLAUDE_PLUGIN_ROOT}/dist/bridge.js" > /dev/null 2>&1 &
curl -s http://127.0.0.1:19211/api/health
/cc-afk:afk off to deactivate."After starting AFK mode, enter this loop to process messages from Telegram within the current session. This gives full context and normal permission handling.
Read the port from $CLAUDE_PLUGIN_DATA/bridge.port or ~/.cc-afk/bridge.port (default: 19211).
Loop:
curl -s --max-time 60 http://127.0.0.1:<port>/api/wait-for-message
Response: {"status":"message","text":"user's message"} or {"status":"timeout"}
If curl fails (non-zero exit code) — the bridge was shut down (e.g. user sent /stop in Telegram). Immediately exit the loop. Tell the user "AFK mode ended." and stop. Do NOT attempt to restart the bridge or reconnect.
If status is "timeout", go back to step 1 (keep waiting).
If status is "message", process text as if the user typed it here — read files, edit code, run commands, etc. Do whatever the message asks.
After processing, send your response summary to Telegram:
curl -s -X POST http://127.0.0.1:<port>/api/notification -H "Content-Type: application/json" -d '{"title":"Done","message":"<summary of what you did>"}'
Exit conditions — stop the loop immediately and do NOT reconnect:
/api/wait-for-message fails (connection refused, reset, or any non-zero exit code) — bridge was shut down$CLAUDE_PLUGIN_DATA/bridge.port or ~/.cc-afk/bridge.portcurl -s -X POST http://127.0.0.1:<port>/api/shutdown
TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID can be used instead of config file$CLAUDE_PLUGIN_DATA/config.json when installed as a plugin/api/wait-for-message and processes messages within the current session, with full context and normal permissionsclaude -p (fallback): If the loop isn't active, messages spawn independent Claude sessions