[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M777955WQDJ03T80VXGJW2KF":3,"skill-same:01M777955WQDJ03T80VXGJW2KF":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M777955WQDJ03T80VXGJW2KF","claude-code-task",null,"Launch Claude Code async in background with automatic delivery to Telegram\u002FWhatsApp. Use for coding, refactoring, codebase research, file generation, and complex multi-step automations. NOT for quick one-off questions or real-time interactive tasks. Includes strict thread-safe routing + E2E operator validation workflow.","javimosch\u002Fopen-claw-skills","javimosch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12900508?v=4","01M6D3F2AS6PV75ET9PZ1QGP8J","Javier Leandro Arancibia","01M75B8NCTAJG9WH5YNZH7C3D8",0,"MIT","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvsevolodustinov\u002Fclaude-code-task\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: claude-code-task\ndescription: \"Launch Claude Code async in background with automatic delivery to Telegram\u002FWhatsApp. Use for coding, refactoring, codebase research, file generation, and complex multi-step automations. NOT for quick one-off questions or real-time interactive tasks. Includes strict thread-safe routing + E2E operator validation workflow.\"\n---\n\n# Claude Code Task (Async)\n\nRun Claude Code in background — zero OpenClaw tokens while it works. Results delivered to WhatsApp or Telegram automatically.\n\n## Important: Claude Code = General AI Agent\n\nClaude Code is NOT just a coding tool. It's a full-powered AI agent with web search, file access, and deep reasoning. Use it for ANY complex task:\n\n- **Research** — web search, synthesis, competitive analysis, user experience reports\n- **Coding** — create tools, scripts, APIs, refactor codebases\n- **Analysis** — read and analyze files, data, logs, source code\n- **Content** — write docs, presentations, reports, summaries\n- **Automations** — complex multi-step workflows with file system access\n\nGive it prompts the same way you'd talk to a smart human — natural language, focused on WHAT you need, not HOW to do it.\n\n**NOT for:**\n- Quick questions (just answer directly)\n- Tasks needing real-time interaction\n\n## Quick Start\n\n## What \"run tests\" means for this skill (critical)\n\nWhen user asks things like:\n- \"прогони все тесты\"\n- \"run tests\"\n- \"проверь что всё работает\"\n\nit means **run the full E2E operator validation flow** for `run-task.py` routing + notifications.\n\nIt does **NOT** mean `pytest`\u002F`unittest` discovery by default.\n\nRequired behavior:\n1. Run routing validation first (`--validate-only`).\n2. Launch smoke\u002FE2E scenario via `nohup` and file-based prompt.\n3. Wait for completion through normal async flow (wake\u002Fevent), not same-turn blocking.\n4. Report PASS\u002FFAIL against E2E criteria (routing, heartbeat, mid-task update, completion delivery).\n\nUse the canonical protocol: **[references\u002Ftesting-protocol.md](references\u002Ftesting-protocol.md)** and the section below **Full E2E Test (reference)**.\n\n## Async Boundary Rule (mandatory)\n\n`run-task.py` is asynchronous orchestration.\n\nAfter a successful `nohup` launch, the correct behavior is:\n1. Send a short launch acknowledgment (PID\u002Flog\u002Fsession), then\n2. **Stop this turn immediately**.\n3. Continue only when wake\u002Fcompletion event arrives in the same session.\n\nDo **not** keep waiting in the same turn for Claude Code completion.\nDo **not** poll and then summarize in the same turn unless user explicitly asked for active live monitoring.\n\nAnti-pattern:\n- ❌ Launch `run-task.py` and keep responding as if completion should appear in this turn.\n\nCorrect pattern:\n- ✅ Launch `run-task.py` → acknowledge launch → stop → wait for wake.\n\n## Launch Confirmation Gate (mandatory)\n\nNever claim \"launched\" until you have **positive launch proof**.\n\nRequired proof checklist (all):\n1. `nohup` command returned a PID,\n2. process is alive (`ps -p \u003CPID>`),\n3. run log contains `🔧 Starting Claude Code...` (or equivalent startup marker),\n4. routing was validated (`--validate-only`) for Telegram thread runs.\n\nIf launch fails with `❌ Invalid routing`:\n- resolve via `sessions_list`,\n- rerun with explicit `--notify-channel telegram --notify-thread-id \u003Cid> --notify-session-id \u003Cuuid>`,\n- re-check proof checklist,\n- only then send launch acknowledgment.\n\nDo not send \"Claude Code ушёл в работу\" before this gate is satisfied.\n\n## Pre-launch planning note (mandatory)\n\nBefore launching Claude Code, post a short plan in chat:\n- how you plan to solve the task,\n- what result you expect from this run,\n- any clarifying questions\u002Fassumptions,\n- whether you expect one iteration or a staged multi-iteration approach.\n\nIf staged: explicitly say this run is \"phase 1\" and what signal will decide phase 2.\n\n## Telegram Thread Safety (must-follow)\n\nFor Telegram thread runs, `run-task.py` is designed to either route correctly or fail immediately.\n\n### Mandatory step before launch\nResolve the **current runtime session key** first (source of truth), then launch with it.\n\n- Get current key via `sessions_list` (or existing runtime context)\n- If key is `agent:main:main:thread:\u003CTHREAD_ID>` → use it directly in `--session`\n- Never derive `--session` from `chat_id`\u002Fsender id heuristics\n\n### Rules\n- Use only `--session \"agent:main:main:thread:\u003CTHREAD_ID>\"` for thread tasks\n- Never use `agent:main:telegram:user:\u003Cid>` for thread tasks\n- If routing metadata is inconsistent (thread\u002Fsession UUID\u002Ftarget mismatch), script exits with `❌ Invalid routing`\n- Default mode is `--telegram-routing-mode auto`:\n  - allows non-thread Telegram for setups without thread sessions\n  - blocks ambiguous user-scope session key (`agent:main:telegram:user:\u003Cid>`) unless explicitly forced\n  - blocks non-thread launch if a recent thread session exists for same target (likely misroute)\n- Force strict thread-only behavior with `--telegram-routing-mode thread-only`\n- Force non-thread behavior with `--telegram-routing-mode allow-non-thread` or `--allow-main-telegram`\n\nThis is intentional: **abort fast > silent misroute**.\n\n⚠️ **ALWAYS launch via nohup** — exec timeout (2 min) will kill the process!\n\n⚠️ **NEVER put the task text directly in the shell command** — quotes, special characters, and newlines WILL break argument parsing. Always save the prompt to a file first, then use `$(cat file)`.\n\n### WhatsApp\n\n```bash\n# Step 1: Save prompt to a temp file\nwrite \u002Ftmp\u002Fcc-prompt.txt with your task text\n\n# Step 2: Launch with $(cat ...)\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:whatsapp:group:\u003CJID>\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\nThe `--session` key (e.g. `agent:main:whatsapp:group:120363425246977860@g.us`) is used to auto-detect the WhatsApp target.\n\n### Telegram (thread-safe default)\n\n```bash\n# ALWAYS use the current thread session key from context:\n# agent:main:main:thread:\u003CTHREAD_ID>\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n> Do **NOT** use `agent:main:telegram:user:\u003Cid>` for thread tests\u002Fruns.\n> That routes to main chat scope and can drift from the source thread.\n\n### Telegram Threaded Mode (1:1 DM with threads)\n\nWhen Marvin is used in Telegram Threaded Mode, each thread has its own session key like `agent:main:main:thread:369520`.\n\n**Fail-safe routing (NEW):** `run-task.py` now enforces strict thread routing.\n- If `--session` contains `:thread:\u003Cid>`, the script **refuses to start** unless Telegram target + thread session UUID are resolved.\n- It auto-resolves missing values from `sessions_list` when possible.\n- If the session is inactive and not returned by API, it falls back to local session files: `~\u002F.openclaw\u002Fagents\u002Fmain\u002Fsessions\u002F*-topic-\u003Cthread_id>.jsonl`.\n- If provided `--notify-session-id` mismatches the session key, it exits with error.\n- Result: misrouted launches\u002Fheartbeats to main chat are blocked before Claude starts.\n\nUse `--notify-session-id` to wake the exact thread session:\n\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:369520\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\nAll 5 notification types route to the DM thread when `--session` key contains `:thread:\u003Cid>` ✅\n\n- `--notify-session-id` — optional override. Usually auto-resolved from session metadata\u002Ffiles.\n- `--notify-thread-id` — optional override. Usually auto-extracted from `--session`.\n- `--reply-to-message-id` — optional debug field; avoid for DM thread routing.\n- `--validate-only` — resolve routing and exit (no Claude run). Use this to verify thread launch args safely.\n\n- `--notify-channel` — optional channel hint (`telegram`\u002F`whatsapp`); target is always auto-resolved from session metadata\n- `--timeout` — max runtime in seconds (default: 7200 = 2 hours)\n- `--completion-mode` — optional legacy hint (`single` default, `iterate` if explicitly needed)\n- `--max-iterations` — optional budget hint when using iterate mode\n- `--trace-live` — emit live technical trace markers into the same chat\u002Fthread (debug mode)\n- Always redirect stdout\u002Fstderr to a log file\n\n### Why file-based prompts?\nResearch\u002Fcomplex prompts contain single quotes, double quotes, markdown, backticks — any of these break shell argument parsing. Saving to a file and reading with `$(cat ...)` avoids all quoting issues.\n\n## Channel Detection\n\nThe `detect_channel()` function determines where to send notifications:\n\n1. **Deterministic auto-resolve** — target is resolved from session metadata\u002Fsession key (no manual target flag)\n2. **WhatsApp auto-detect** — if the session key contains `@g.us` (WhatsApp group JID), WhatsApp is used\n3. **Fail fast on unresolved Telegram target** — script exits with `❌ Invalid routing` instead of silent misroute\n\n```python\ndef detect_channel(session_key):\n    if NOTIFY_CHANNEL_OVERRIDE and NOTIFY_TARGET_OVERRIDE:\n        return NOTIFY_CHANNEL_OVERRIDE, NOTIFY_TARGET_OVERRIDE\n    jid = extract_group_jid(session_key)\n    if jid:\n        return \"whatsapp\", jid\n    return None, None\n```\n\n## How It Works\n\n```\n┌─────────────┐     nohup      ┌──────────────┐\n│    Agent     │ ──────────────▶│  run-task.py  │\n│  (OpenClaw)  │                │  (detached)   │\n└─────────────┘                └──────┬───────┘\n                                      │\n                                      ▼\n                               ┌──────────────┐\n                               │  Claude Code  │  ← runs on Max subscription ($0 API)\n                               │  (-p mode)    │\n                               └──────┬───────┘\n                                      │\n                          ┌───────────┼───────────┐\n                          ▼           ▼           ▼\n                    Every 60s    On complete   On error\u002Ftimeout\n                    ┌────────┐  ┌──────────┐  ┌──────────────┐\n                    │ ⏳ ping │  │ ✅ result │  │ ❌\u002F⏰\u002F💥 error│\n                    │ silent │  │ channel  │  │   channel    │\n                    └────────┘  └──────────┘  └──────────────┘\n```\n\n### WhatsApp notification flow:\n1. **Heartbeat pings** (every 60s) → WhatsApp direct (informational, no agent wake)\n2. **Final result** → WhatsApp direct (human sees immediately) + `sessions_send` (agent wakes up)\n3. **Agent receives** completion payload via sessions_send → processes it → sends summary via `message(send)` to WhatsApp group\n4. Human sees both: raw result + agent's analysis\u002Fnext steps\n\n### Iterative continuation mode (wake behavior)\n`--completion-mode` is optional (default `single`) and acts as a hint:\n- `single` = one run → continuation summary → stop\n- `iterate` = continuation summary + exactly one next iteration when gaps remain\n\nWake payload now frames continuation as the **same ongoing assistant conversation** (same agent identity, same session, same history) after Claude Code replies to the previous launch.\n\nIn `iterate` mode the continuation flow is:\n- react briefly to Claude result\n- evaluate goal completion (gap analysis)\n- if gaps remain: explain next fix and launch exactly one follow-up iteration\n- if complete: report final outcome and stop\n\n### Deterministic wake guard (anti-duplicate)\n- Each run now carries `run_id` and `wake_id` in wake payload.\n- `run-task.py` keeps per-project state in `\u002Ftmp\u002Fcc-orchestrator-state-\u003Chash>.json`.\n- Duplicate\u002Fstale wake dispatches (same output or same wake_id) are skipped before wake delivery.\n- In debug mode (`--trace-live`), skipped wakes are announced as `[TRACE][TECH][TELEGRAM][WAKE][SKIP]`.\n\n### No silent launch policy (always-on)\n- Silent launch is forbidden (not only in debug mode).\n- On wake, agent must first post a visible decision turn:\n  - `[TRACE][AGENT][WAKE_RECEIVED] ...`\n  - `[TRACE][AGENT][DECISION] continue|stop ...`\n- Only after that visible decision may the next Claude iteration be launched.\n### Telegram notification flow (DM Threaded Mode — full pipeline):\n1. 🚀 **Launch notification** → thread ✅ (silent; HTML; `\u003Cblockquote expandable>` for prompt; via `send_telegram_direct`; includes `Resume: \u003Csession-id|new>`)\n2. ⏳ **Heartbeat** (every 60s) → thread ✅ (silent; plain text; via `send_telegram_direct`)\n3. 📡 **Claude Code mid-task updates** → thread ✅ (on-disk Python script `\u002Ftmp\u002Fcc-notify-{pid}.py`; CC calls file; prefix `\"📡 🟢 CC: \"` auto-added)\n4. ✅\u002F❌\u002F⏰\u002F💥 **Result notification** → thread ✅ (HTML; `\u003Cblockquote expandable>` for result; via `send_telegram_direct`)\n5. 🤖 **Agent continuation reply** → delivered to chat via `openclaw agent --deliver` ✅ (same session continuation is visible to user)\n\n**`send_telegram_direct()`** is the core mechanism for all thread-targeted notifications from external scripts. It calls `api.telegram.org` directly with `message_thread_id` — bypasses the OpenClaw message tool entirely (which cannot route to DM threads from outside a session context).\n\n**Fallback** — if agent wake fails (session locked\u002Fbusy): `already_sent=True` is set after the direct send, so no duplicate is sent.\n\n### Key detail: Telegram vs WhatsApp delivery\n\n**WhatsApp:** Raw result sent directly (human sees it immediately) + `sessions_send` wakes agent for analysis.\n\n**Telegram:** Result sent via `send_telegram_direct` → then agent is woken via `openclaw agent --session-id --deliver` so the continuation turn is visible in chat by default. This is the intended “same agent, same conversation” behavior after Claude completion.\n\n**Why not `sessions_send` for Telegram?** `sessions_send` is blocked in the HTTP `\u002Ftools\u002Finvoke` deny list by architectural design. The `openclaw agent` CLI bypasses this limitation.\n\n## Reliability Features\n\n### Timeout (default 2 hours)\n- `--timeout 7200` → after 7200s: SIGTERM → wait 10s → SIGKILL\n- Timeout notification sent to channel with tool call count and last activity\n- Partial output saved to file\n\n### Crash safety\n- `try\u002Fexcept` wraps entire main → crash notification always sent\n- Both channel notification and agent wake attempted on any failure\n\n### PID tracking\n- PID file written to `skills\u002Fclaude-code-task\u002Fpids\u002F`\n- Stale PIDs cleaned on startup\n- Can check running tasks: `ls skills\u002Fclaude-code-task\u002Fpids\u002F`\n\n### Silent mode (Telegram only)\nTelegram supports silent notifications (no sound).\n\nCurrent policy: **all Claude Code notifications are silent** in Telegram:\n- Heartbeat pings → `silent=True`\n- Launch notifications → `silent=True`\n- Mid-task updates (`📡 🟢 CC`) → `silent=True`\n- Final results → `silent=True`\n- Wake-summary instruction requests `silent=True`\n\nWhatsApp does NOT support silent mode — the flag is ignored for WhatsApp.\n\n### Telegram DM Threads vs Forum Groups\n\nTelegram has two distinct thread models. The key difference for run-task.py is how to route messages to the thread.\n\n**The core problem with external scripts:**\n- The OpenClaw `message` tool's `threadId` parameter is **Discord-specific** — ignored for Telegram\n- Target format `\"chatId:topic:threadId\"` is rejected by the message tool's target resolver\n- Session auto-routing (`currentThreadTs`) works ONLY inside active sessions — external scripts have no session context\n- **Solution:** `send_telegram_direct()` bypasses the message tool entirely; calls `api.telegram.org` directly with `message_thread_id`\n\n**DM Threaded Mode** (bot-user private chat with threads):\n- All notifications use `send_telegram_direct(chat_id, text, thread_id=..., parse_mode=...)` ✅\n- `thread_id` auto-extracted from session key `*:thread:\u003Cid>` by `extract_thread_id()`\n- Launch + finish: `parse_mode=\"HTML\"` with `\u003Cblockquote expandable>` for prompt\u002Fresult\n- Heartbeats + mid-task: `parse_mode=None` (plain text, avoid Markdown parse errors)\n- **`parse_mode=\"Markdown\"` trap**: finish messages contain `**text**` (CommonMark bold); Telegram MarkdownV1 rejects this with HTTP 400 — messages silently don't arrive\n- **`replyTo` trap**: combining `replyTo` + `message_thread_id` → Telegram rejects request → fallback strips thread_id → message lands in main chat\n- Agent continuation reply: `openclaw agent --session-id \u003Cuuid> --deliver` publishes the wake turn to chat so the user sees the same ongoing assistant conversation.\n\n**Forum Groups** (supergroup with Forum topics enabled):\n- Same `send_telegram_direct()` approach works; `message_thread_id` is standard Bot API for Forum topics\n- Auto-detected from session key pattern `*:thread:\u003Cid>`\n\n**Claude Code mid-task updates:**\n- DO NOT embed bot tokens or curl commands in the task prompt — Claude Code flags this as prompt injection\n- run-task.py writes `\u002Ftmp\u002Fcc-notify-{pid}.py` to disk before launching Claude Code\n- Task prompt prepended with `[Automation context: ... python3 \u002Ftmp\u002Fcc-notify-{pid}.py 'msg' ...]`\n- Claude Code calls the file (legitimate local script pattern, no safety warning)\n- Script automatically prepends `\"📡 🟢 CC: \"` to all messages; cleaned up in `finally` block\n\n### Notification types\n\n| Event | Emoji | WhatsApp delivery | Telegram delivery | DM thread? |\n|-------|-------|-------------------|-------------------|------------|\n| Launch | 🚀 | send_channel (Markdown) | send_telegram_direct (HTML, silent) | ✅ message_thread_id |\n| Heartbeat | ⏳ | send_channel (Markdown) | send_telegram_direct (plain, silent) | ✅ message_thread_id |\n| CC mid-task update | 📡 | — | \u002Ftmp\u002Fcc-notify-{pid}.py (Bot API, silent) | ✅ message_thread_id |\n| Success | ✅ | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Error | ❌ | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Timeout | ⏰ | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Crash | 💥 | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Agent continuation reply | 🤖 | — | openclaw agent wake (`--deliver`) | ✅ visible in chat |\n\n## Claude Code Flags\n\n- `-p \"task\"` — print mode (non-interactive, outputs result)\n- `--dangerously-skip-permissions` — no confirmation prompts\n- `--verbose --output-format stream-json` — real-time activity tracking for heartbeats\n\n### Why NOT exec\u002Fpty?\n- `exec` has 2 min default timeout → kills long tasks\n- Even with `pty:true`, output has escape codes, hard to parse\n- `nohup` + `-p` mode: clean, detached, reliable\n\n### Git requirement\nClaude Code needs a git repo. `run-task.py` auto-inits if missing.\n\n## Python 3.9 Compatibility\n\n`run-task.py` uses `Optional[X]` from `typing` (not `X | None`) for compatibility with Python 3.9. The union syntax (`X | None`) requires Python 3.10+.\n\n```python\n# Correct (3.9+)\nfrom typing import Optional\ndef foo(x: Optional[str]) -> Optional[str]: ...\n\n# Would break on 3.9\ndef foo(x: str | None) -> str | None: ...\n```\n\n## Full E2E Test (reference)\n\nUse this when you need to validate the **entire pipeline** in one run:\n- launch notification in source thread\n- heartbeat after >60s\n- Claude mid-task progress update (📡 🟢 CC)\n- final result in source thread\n- agent wake attempt with summary step\n\n### Pass criteria\n1. Launch message appears in the same thread (with expandable prompt quote)\n2. At least one wrapper heartbeat appears after ~60s\n3. At least one mid-task CC update appears (via `\u002Ftmp\u002Fcc-notify-\u003Cpid>.py`)\n4. Final result appears in the same thread (expandable result quote)\n5. Agent wake continuation is delivered (`openclaw agent --session-id ... --deliver`) and appears visibly in chat\n\n### Interactive test rule (time budget)\nFor interactive\u002Fiterate-mode testing, do **exactly one** continuation step after phase 1.\n- Phase 1: intentionally incomplete output (prove gap detected)\n- Continuation #1: close the gap and finish\n- Stop there; do not run multi-hop continuation loops during routine tests\n\nReason: keeps regression runs fast (minutes, not 20+ minutes) while still validating the critical iterate path.\n\n### Visibility rule (mandatory)\nBetween `✅ Claude Code completed` and any next `🚀 Claude Code started`, there must be a user-facing analysis message in the thread.\n- The agent must first post: what was done, what gaps remain, and the decision to continue\u002Fstop.\n- Only after that message may it launch the next iteration.\n- No silent jump from completion directly to next start.\n\n### Canonical full test prompt pattern\n- keep prompt **compact** (about 10 lines) for routine testing\n- ensure prompt length is **>4500 chars** to verify quote truncation\u002Fcollapse behavior in Telegram\n- force runtime >60s (`sleep 70`) to trigger wrapper heartbeat\n- explicitly instruct Claude to call the notify script at least twice\n- include a short structured report so output is easy to verify\n- the >4500-char filler can be useful work (not just junk): use it for any creative\u002Foutput-generating task the agent genuinely wants to do in that moment, as long as it remains safe and relevant to the test context\n\n## Long-running task guidance\n\nIf a Claude Code task is expected to run longer than ~1 minute, explicitly ask Claude to send intermediate progress updates during execution.\n\nRecommended wording to include in prompt:\n- \"Send a progress update when you start\"\n- \"Send another update after major milestone(s)\"\n- \"If task exceeds 60 seconds, send at least one heartbeat-style update\"\n\nFor thread-safe Telegram runs, updates should use the injected automation script (`\u002Ftmp\u002Fcc-notify-\u003Cpid>.py`).\n\n### Canonical launch (minimal mode)\n```bash\ncat > \u002Ftmp\u002Fcc-full-test-prompt.txt \u003C\u003C 'EOF'\n# ~10 lines, but total >4500 chars:\n# 1) notify script now\n# 2) create test file with repeated text (to exceed 4500 chars)\n# 3) sleep 70 + notify script again\n# 4) run several shell commands\n# 5) return short structured report\nEOF\n\npython3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-full-test-prompt.txt)\" \\\n  --project \u002Ftmp\u002Fcc-e2e-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --validate-only\n\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-full-test-prompt.txt)\" \\\n  --project \u002Ftmp\u002Fcc-e2e-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-full-test.log 2>&1 &\n```\n\n### Verification artifacts\n- wrapper log: `\u002Ftmp\u002Fcc-full-test.log`\n- Claude output: `\u002Ftmp\u002Fcc-YYYYMMDD-HHMMSS.txt`\n- session registry entry in `~\u002F.openclaw\u002Fclaude_sessions.json`\n\n## Examples\n\n### WhatsApp: Create a tool\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  -t \"Create a Python CLI tool that converts markdown to HTML with syntax highlighting. Save as convert.py\" \\\n  -p ~\u002Fprojects\u002Fmd-converter \\\n  -s \"agent:main:whatsapp:group:120363425246977860@g.us\" \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Telegram: Research codebase (thread-safe)\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 1800 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Telegram Threaded Mode: Research codebase\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:369520\" \\\n  --timeout 1800 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n# thread_id auto-extracted from session key\n# target + session UUID auto-resolved from API\u002Flocal session files\n```\n\n### Telegram Threaded Mode: Mid-task updates from Claude Code\n\nrun-task.py automatically creates an on-disk notification script before launching Claude Code, so CC can send progress updates without seeing the bot token in the prompt (which triggers safety refusals):\n\n```bash\n# Just write a normal task prompt — run-task.py handles the rest\ncat > \u002Ftmp\u002Fcc-prompt.txt \u003C\u003C 'EOF'\nSTEP 1: Write analysis to \u002Ftmp\u002Freport.txt (600+ words)...\n\nAfter step 1, send a progress notification using the script from the\nautomation context above: python3 \u002Ftmp\u002Fcc-notify-\u003CPID>.py \"Step 1 done.\"\n\nSTEP 2: Write summary to \u002Ftmp\u002Fsummary.txt...\nEOF\n\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 1800 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n# run-task.py writes \u002Ftmp\u002Fcc-notify-{pid}.py before launch\n# Prepends \"[Automation context: use python3 \u002Ftmp\u002Fcc-notify-{pid}.py 'msg']\" to task\n# Claude Code calls the file; prefix \"📡 🟢 CC: \" auto-added; file cleaned up on exit\n```\n\n> ⚠️ **Never embed bot tokens or curl commands in the task prompt** — Claude Code correctly identifies hardcoded tokens + external API calls as prompt injection and refuses. Use the on-disk script pattern above instead.\n\n> **Quick reference: launching from a Telegram DM thread (minimal mode)**\n> ```bash\n> # 1) Validate routing first (no Claude run)\n> python3 {baseDir}\u002Frun-task.py \\\n>   --task \"probe\" \\\n>   --project ~\u002Fprojects\u002Fx \\\n>   --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n>   --validate-only\n>\n> # 2) Real launch (only 3 required params)\n> nohup python3 {baseDir}\u002Frun-task.py \\\n>   --task \"$(cat \u002Ftmp\u002Fprompt.txt)\" \\\n>   --project ~\u002Fprojects\u002Fx \\\n>   --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n>   --timeout 900 \\\n>   > \u002Ftmp\u002Fcc-run.log 2>&1 &\n> ```\n> - Required: `--task`, `--project`, `--session`\n- Safety: Telegram launches without `:thread:\u003Cid>` are blocked by default (`❌ Unsafe routing blocked`)\n- For non-thread Telegram deployments, use `--telegram-routing-mode allow-non-thread`.\n> - `THREAD_ID` is auto-extracted from session key\n> - Target + session UUID are auto-resolved (API, then local session-file fallback)\n> - If routing is inconsistent\u002Funresolved, script exits with `❌ Invalid routing` before run\n> - All notifications from run-task (launch\u002Fheartbeat\u002Fresult) stay on the source thread ✅\n\n### Long task with extended timeout\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  -t \"Refactor the entire auth module to use JWT tokens\" \\\n  -p ~\u002Fprojects\u002Fbackend \\\n  -s \"agent:main:whatsapp:group:120363425246977860@g.us\" \\\n  --timeout 3600 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n## Cost\n\n- Claude Code runs on Max subscription ($200\u002Fmo) — NOT API tokens\n- Zero OpenClaw API cost while Claude Code works\n- Only cost: message delivery + brief agent turn for summary\n\n## Session Resumption\n\nClaude Code sessions can be resumed to continue previous conversations. This is useful for:\n- Follow-up tasks building on previous research\n- Continuing after timeouts or interruptions\n- Multi-step workflows where context matters\n\n### ⚠️ Resume ID — Critical Rule\n`--resume` takes the **Claude Code session ID**, not the `run_id` or `wake_id`.\n\nCorrect source — look for this line in the run log:\n```\n📝 Session registered: \u003Csession-id-here>\n```\nThat is the value to pass as `--resume \u003Csession-id>`.\n\n**Do NOT use:**\n- `run_id` from wake payload\n- `wake_id` from wake payload\n- session IDs from previous unrelated runs\n\nWhen in doubt: skip `--resume` and start fresh.\n\n### How to Resume\n\nWhen a task completes, the session ID is automatically captured and saved to the registry (`~\u002F.openclaw\u002Fclaude_sessions.json`).\n\nTo resume a session, use the `--resume` flag:\n\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"SESSION_KEY\" \\\n  --resume \u003Csession-id> \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Session Labels\n\nUse `--session-label` to give sessions human-readable names for easier tracking:\n\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"SESSION_KEY\" \\\n  --session-label \"Research on Jackson Berler\" \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Listing Recent Sessions\n\nThe agent can read the session registry to find recent sessions:\n\n```python\n# Python code (for agent automation)\nfrom session_registry import list_recent_sessions, find_session_by_label\n\n# List sessions from last 72 hours\nrecent = list_recent_sessions(hours=72)\nfor session in recent:\n    print(f\"{session['session_id']}: {session['label']} ({session['status']})\")\n\n# Find session by label (fuzzy match)\nsession = find_session_by_label(\"Jackson\")\nif session:\n    print(f\"Found: {session['session_id']}\")\n```\n\nOr manually inspect the registry:\n\n```bash\ncat ~\u002F.openclaw\u002Fclaude_sessions.json\n```\n\n### When to Resume vs Start Fresh\n\n**Resume when:**\n- You need context from previous conversation\n- Building on previous research\u002Fanalysis\n- Continuing interrupted work\n- Following up with clarifications or next steps\n\n**Start fresh when:**\n- Completely unrelated task\n- Previous session was exploratory\u002Fexperimental\n- You want a clean slate\n- Previous session context might cause confusion\n\n### Resume Failure Handling\n\nIf a session ID is invalid or expired:\n- Error message sent to channel with suggestion to start fresh\n- Process exits cleanly (no partial work)\n- Check stderr in `\u002Ftmp\u002Fcc-run.log` for details\n\nCommon resume failures:\n- Session expired (Claude Code has retention limits)\n- Invalid session ID (typo, wrong format)\n- Session from different project\u002Fcontext\n\n### Example Workflow\n\n**Step 1: Initial research**\n```bash\n# Save prompt\nwrite \u002Ftmp\u002Fresearch-prompt.txt with \"Research the codebase architecture for project X\"\n\n# Launch task (Telegram thread-safe example)\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fresearch-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fproject-x \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --session-label \"Project X architecture research\" \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n**Step 2: Check result and find session ID**\n```bash\n# Session ID printed in stderr: \"📝 Session registered: \u003Cid>\"\ntail \u002Ftmp\u002Fcc-run.log\n\n# Or read from registry\ncat ~\u002F.openclaw\u002Fclaude_sessions.json | grep \"Project X\"\n```\n\n**Step 3: Follow-up implementation**\n```bash\n# Save follow-up prompt\nwrite \u002Ftmp\u002Fimplement-prompt.txt with \"Based on your research, implement the authentication module\"\n\n# Resume session\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fimplement-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fproject-x \\\n  --session \"SESSION_KEY\" \\\n  --resume \u003Csession-id-from-step-1> \\\n  --session-label \"Project X auth implementation\" \\\n  > \u002Ftmp\u002Fcc-run2.log 2>&1 &\n```\n\n## Wake Troubleshooting\n\nWhen the agent wake \u002F continue chain fails (no agent summary, wrong thread, session not resolved,\niterative loop stalls, etc.), see the dedicated guide:\n\n→ **[WAKE-TROUBLESHOOTING.md](WAKE-TROUBLESHOOTING.md)**\n\nIncludes a **Quick Triage Checklist (60 seconds)** plus detailed items: agent not waking,\ndouble messages, wrong thread routing, UUID resolution failures, session-locked wake,\n`❌ Invalid routing`, Telegram HTTP 400 silent drops, mid-task update failures, stale\u002Fduplicate wake skips, and more.\n\n## Current Stable Behavior (2026-03-03)\n\nThis is the version validated in live Telegram thread tests.\n\n- Wake continuity: Telegram wake is delivered (`openclaw agent --deliver`) so continuation turns are visible in chat.\n- No silent launch policy: agent must post a visible decision turn before launching next iteration.\n- Deterministic wake guard: duplicate\u002Fstale wake dispatch is skipped by per-project state + `wake_id`\u002Foutput dedupe.\n- Trace mode: `--trace-live` emits technical milestones (`RUN_TASK START\u002FCOMPLETE`, `WAKE`, `WAKE SKIP`) into the same thread.\n- Resume safety: `--resume` must use the Claude session id from `📝 Session registered: ...` in the run log.\n- Compact heartbeat now includes active subagents count as `sub:\u003CN>` (example: `🟢 CC (3min) | sub:1 | 12K tok | 18 calls | 🔧 Bash`).\n- `output_tokens` is aggregated from all assistant stream messages (main agent + subagents).\n- `last_activity` \u002F last tool signal is unified: whichever actor (main or subagent) emitted the latest tool event is shown.\n- Active subagents are tracked via Task\u002FAgent lifecycle in stream-json (`tool_use id` add, matching `tool_result`\u002F`task_notification` remove).\n\n## Files\n\n```\nskills\u002Fclaude-code-task\u002F\n├── SKILL.md                    # This file\n├── WAKE-TROUBLESHOOTING.md     # Wake\u002Fcontinue chain diagnostics\n├── run-task.py                 # Async runner with notifications\n├── session_registry.py         # Session metadata storage\n└── pids\u002F                       # PID files for running tasks (auto-managed)\n```\n","# Claude Code Task (Async)\n\nRun Claude Code in background — zero OpenClaw tokens while it works. Results delivered to WhatsApp or Telegram automatically.\n\n## Important: Claude Code = General AI Agent\n\nClaude Code is NOT just a coding tool. It's a full-powered AI agent with web search, file access, and deep reasoning. Use it for ANY complex task:\n\n- **Research** — web search, synthesis, competitive analysis, user experience reports\n- **Coding** — create tools, scripts, APIs, refactor codebases\n- **Analysis** — read and analyze files, data, logs, source code\n- **Content** — write docs, presentations, reports, summaries\n- **Automations** — complex multi-step workflows with file system access\n\nGive it prompts the same way you'd talk to a smart human — natural language, focused on WHAT you need, not HOW to do it.\n\n**NOT for:**\n- Quick questions (just answer directly)\n- Tasks needing real-time interaction\n\n## Quick Start\n\n## What \"run tests\" means for this skill (critical)\n\nWhen user asks things like:\n- \"прогони все тесты\"\n- \"run tests\"\n- \"проверь что всё работает\"\n\nit means **run the full E2E operator validation flow** for `run-task.py` routing + notifications.\n\nIt does **NOT** mean `pytest`\u002F`unittest` discovery by default.\n\nRequired behavior:\n1. Run routing validation first (`--validate-only`).\n2. Launch smoke\u002FE2E scenario via `nohup` and file-based prompt.\n3. Wait for completion through normal async flow (wake\u002Fevent), not same-turn blocking.\n4. Report PASS\u002FFAIL against E2E criteria (routing, heartbeat, mid-task update, completion delivery).\n\nUse the canonical protocol: **[references\u002Ftesting-protocol.md](references\u002Ftesting-protocol.md)** and the section below **Full E2E Test (reference)**.\n\n## Async Boundary Rule (mandatory)\n\n`run-task.py` is asynchronous orchestration.\n\nAfter a successful `nohup` launch, the correct behavior is:\n1. Send a short launch acknowledgment (PID\u002Flog\u002Fsession), then\n2. **Stop this turn immediately**.\n3. Continue only when wake\u002Fcompletion event arrives in the same session.\n\nDo **not** keep waiting in the same turn for Claude Code completion.\nDo **not** poll and then summarize in the same turn unless user explicitly asked for active live monitoring.\n\nAnti-pattern:\n- ❌ Launch `run-task.py` and keep responding as if completion should appear in this turn.\n\nCorrect pattern:\n- ✅ Launch `run-task.py` → acknowledge launch → stop → wait for wake.\n\n## Launch Confirmation Gate (mandatory)\n\nNever claim \"launched\" until you have **positive launch proof**.\n\nRequired proof checklist (all):\n1. `nohup` command returned a PID,\n2. process is alive (`ps -p \u003CPID>`),\n3. run log contains `🔧 Starting Claude Code...` (or equivalent startup marker),\n4. routing was validated (`--validate-only`) for Telegram thread runs.\n\nIf launch fails with `❌ Invalid routing`:\n- resolve via `sessions_list`,\n- rerun with explicit `--notify-channel telegram --notify-thread-id \u003Cid> --notify-session-id \u003Cuuid>`,\n- re-check proof checklist,\n- only then send launch acknowledgment.\n\nDo not send \"Claude Code ушёл в работу\" before this gate is satisfied.\n\n## Pre-launch planning note (mandatory)\n\nBefore launching Claude Code, post a short plan in chat:\n- how you plan to solve the task,\n- what result you expect from this run,\n- any clarifying questions\u002Fassumptions,\n- whether you expect one iteration or a staged multi-iteration approach.\n\nIf staged: explicitly say this run is \"phase 1\" and what signal will decide phase 2.\n\n## Telegram Thread Safety (must-follow)\n\nFor Telegram thread runs, `run-task.py` is designed to either route correctly or fail immediately.\n\n### Mandatory step before launch\nResolve the **current runtime session key** first (source of truth), then launch with it.\n\n- Get current key via `sessions_list` (or existing runtime context)\n- If key is `agent:main:main:thread:\u003CTHREAD_ID>` → use it directly in `--session`\n- Never derive `--session` from `chat_id`\u002Fsender id heuristics\n\n### Rules\n- Use only `--session \"agent:main:main:thread:\u003CTHREAD_ID>\"` for thread tasks\n- Never use `agent:main:telegram:user:\u003Cid>` for thread tasks\n- If routing metadata is inconsistent (thread\u002Fsession UUID\u002Ftarget mismatch), script exits with `❌ Invalid routing`\n- Default mode is `--telegram-routing-mode auto`:\n  - allows non-thread Telegram for setups without thread sessions\n  - blocks ambiguous user-scope session key (`agent:main:telegram:user:\u003Cid>`) unless explicitly forced\n  - blocks non-thread launch if a recent thread session exists for same target (likely misroute)\n- Force strict thread-only behavior with `--telegram-routing-mode thread-only`\n- Force non-thread behavior with `--telegram-routing-mode allow-non-thread` or `--allow-main-telegram`\n\nThis is intentional: **abort fast > silent misroute**.\n\n⚠️ **ALWAYS launch via nohup** — exec timeout (2 min) will kill the process!\n\n⚠️ **NEVER put the task text directly in the shell command** — quotes, special characters, and newlines WILL break argument parsing. Always save the prompt to a file first, then use `$(cat file)`.\n\n### WhatsApp\n\n```bash\n# Step 1: Save prompt to a temp file\nwrite \u002Ftmp\u002Fcc-prompt.txt with your task text\n\n# Step 2: Launch with $(cat ...)\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:whatsapp:group:\u003CJID>\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\nThe `--session` key (e.g. `agent:main:whatsapp:group:120363425246977860@g.us`) is used to auto-detect the WhatsApp target.\n\n### Telegram (thread-safe default)\n\n```bash\n# ALWAYS use the current thread session key from context:\n# agent:main:main:thread:\u003CTHREAD_ID>\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n> Do **NOT** use `agent:main:telegram:user:\u003Cid>` for thread tests\u002Fruns.\n> That routes to main chat scope and can drift from the source thread.\n\n### Telegram Threaded Mode (1:1 DM with threads)\n\nWhen Marvin is used in Telegram Threaded Mode, each thread has its own session key like `agent:main:main:thread:369520`.\n\n**Fail-safe routing (NEW):** `run-task.py` now enforces strict thread routing.\n- If `--session` contains `:thread:\u003Cid>`, the script **refuses to start** unless Telegram target + thread session UUID are resolved.\n- It auto-resolves missing values from `sessions_list` when possible.\n- If the session is inactive and not returned by API, it falls back to local session files: `~\u002F.openclaw\u002Fagents\u002Fmain\u002Fsessions\u002F*-topic-\u003Cthread_id>.jsonl`.\n- If provided `--notify-session-id` mismatches the session key, it exits with error.\n- Result: misrouted launches\u002Fheartbeats to main chat are blocked before Claude starts.\n\nUse `--notify-session-id` to wake the exact thread session:\n\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:369520\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\nAll 5 notification types route to the DM thread when `--session` key contains `:thread:\u003Cid>` ✅\n\n- `--notify-session-id` — optional override. Usually auto-resolved from session metadata\u002Ffiles.\n- `--notify-thread-id` — optional override. Usually auto-extracted from `--session`.\n- `--reply-to-message-id` — optional debug field; avoid for DM thread routing.\n- `--validate-only` — resolve routing and exit (no Claude run). Use this to verify thread launch args safely.\n\n- `--notify-channel` — optional channel hint (`telegram`\u002F`whatsapp`); target is always auto-resolved from session metadata\n- `--timeout` — max runtime in seconds (default: 7200 = 2 hours)\n- `--completion-mode` — optional legacy hint (`single` default, `iterate` if explicitly needed)\n- `--max-iterations` — optional budget hint when using iterate mode\n- `--trace-live` — emit live technical trace markers into the same chat\u002Fthread (debug mode)\n- Always redirect stdout\u002Fstderr to a log file\n\n### Why file-based prompts?\nResearch\u002Fcomplex prompts contain single quotes, double quotes, markdown, backticks — any of these break shell argument parsing. Saving to a file and reading with `$(cat ...)` avoids all quoting issues.\n\n## Channel Detection\n\nThe `detect_channel()` function determines where to send notifications:\n\n1. **Deterministic auto-resolve** — target is resolved from session metadata\u002Fsession key (no manual target flag)\n2. **WhatsApp auto-detect** — if the session key contains `@g.us` (WhatsApp group JID), WhatsApp is used\n3. **Fail fast on unresolved Telegram target** — script exits with `❌ Invalid routing` instead of silent misroute\n\n```python\ndef detect_channel(session_key):\n    if NOTIFY_CHANNEL_OVERRIDE and NOTIFY_TARGET_OVERRIDE:\n        return NOTIFY_CHANNEL_OVERRIDE, NOTIFY_TARGET_OVERRIDE\n    jid = extract_group_jid(session_key)\n    if jid:\n        return \"whatsapp\", jid\n    return None, None\n```\n\n## How It Works\n\n```\n┌─────────────┐     nohup      ┌──────────────┐\n│    Agent     │ ──────────────▶│  run-task.py  │\n│  (OpenClaw)  │                │  (detached)   │\n└─────────────┘                └──────┬───────┘\n                                      │\n                                      ▼\n                               ┌──────────────┐\n                               │  Claude Code  │  ← runs on Max subscription ($0 API)\n                               │  (-p mode)    │\n                               └──────┬───────┘\n                                      │\n                          ┌───────────┼───────────┐\n                          ▼           ▼           ▼\n                    Every 60s    On complete   On error\u002Ftimeout\n                    ┌────────┐  ┌──────────┐  ┌──────────────┐\n                    │ ⏳ ping │  │ ✅ result │  │ ❌\u002F⏰\u002F💥 error│\n                    │ silent │  │ channel  │  │   channel    │\n                    └────────┘  └──────────┘  └──────────────┘\n```\n\n### WhatsApp notification flow:\n1. **Heartbeat pings** (every 60s) → WhatsApp direct (informational, no agent wake)\n2. **Final result** → WhatsApp direct (human sees immediately) + `sessions_send` (agent wakes up)\n3. **Agent receives** completion payload via sessions_send → processes it → sends summary via `message(send)` to WhatsApp group\n4. Human sees both: raw result + agent's analysis\u002Fnext steps\n\n### Iterative continuation mode (wake behavior)\n`--completion-mode` is optional (default `single`) and acts as a hint:\n- `single` = one run → continuation summary → stop\n- `iterate` = continuation summary + exactly one next iteration when gaps remain\n\nWake payload now frames continuation as the **same ongoing assistant conversation** (same agent identity, same session, same history) after Claude Code replies to the previous launch.\n\nIn `iterate` mode the continuation flow is:\n- react briefly to Claude result\n- evaluate goal completion (gap analysis)\n- if gaps remain: explain next fix and launch exactly one follow-up iteration\n- if complete: report final outcome and stop\n\n### Deterministic wake guard (anti-duplicate)\n- Each run now carries `run_id` and `wake_id` in wake payload.\n- `run-task.py` keeps per-project state in `\u002Ftmp\u002Fcc-orchestrator-state-\u003Chash>.json`.\n- Duplicate\u002Fstale wake dispatches (same output or same wake_id) are skipped before wake delivery.\n- In debug mode (`--trace-live`), skipped wakes are announced as `[TRACE][TECH][TELEGRAM][WAKE][SKIP]`.\n\n### No silent launch policy (always-on)\n- Silent launch is forbidden (not only in debug mode).\n- On wake, agent must first post a visible decision turn:\n  - `[TRACE][AGENT][WAKE_RECEIVED] ...`\n  - `[TRACE][AGENT][DECISION] continue|stop ...`\n- Only after that visible decision may the next Claude iteration be launched.\n### Telegram notification flow (DM Threaded Mode — full pipeline):\n1. 🚀 **Launch notification** → thread ✅ (silent; HTML; `\u003Cblockquote expandable>` for prompt; via `send_telegram_direct`; includes `Resume: \u003Csession-id|new>`)\n2. ⏳ **Heartbeat** (every 60s) → thread ✅ (silent; plain text; via `send_telegram_direct`)\n3. 📡 **Claude Code mid-task updates** → thread ✅ (on-disk Python script `\u002Ftmp\u002Fcc-notify-{pid}.py`; CC calls file; prefix `\"📡 🟢 CC: \"` auto-added)\n4. ✅\u002F❌\u002F⏰\u002F💥 **Result notification** → thread ✅ (HTML; `\u003Cblockquote expandable>` for result; via `send_telegram_direct`)\n5. 🤖 **Agent continuation reply** → delivered to chat via `openclaw agent --deliver` ✅ (same session continuation is visible to user)\n\n**`send_telegram_direct()`** is the core mechanism for all thread-targeted notifications from external scripts. It calls `api.telegram.org` directly with `message_thread_id` — bypasses the OpenClaw message tool entirely (which cannot route to DM threads from outside a session context).\n\n**Fallback** — if agent wake fails (session locked\u002Fbusy): `already_sent=True` is set after the direct send, so no duplicate is sent.\n\n### Key detail: Telegram vs WhatsApp delivery\n\n**WhatsApp:** Raw result sent directly (human sees it immediately) + `sessions_send` wakes agent for analysis.\n\n**Telegram:** Result sent via `send_telegram_direct` → then agent is woken via `openclaw agent --session-id --deliver` so the continuation turn is visible in chat by default. This is the intended “same agent, same conversation” behavior after Claude completion.\n\n**Why not `sessions_send` for Telegram?** `sessions_send` is blocked in the HTTP `\u002Ftools\u002Finvoke` deny list by architectural design. The `openclaw agent` CLI bypasses this limitation.\n\n## Reliability Features\n\n### Timeout (default 2 hours)\n- `--timeout 7200` → after 7200s: SIGTERM → wait 10s → SIGKILL\n- Timeout notification sent to channel with tool call count and last activity\n- Partial output saved to file\n\n### Crash safety\n- `try\u002Fexcept` wraps entire main → crash notification always sent\n- Both channel notification and agent wake attempted on any failure\n\n### PID tracking\n- PID file written to `skills\u002Fclaude-code-task\u002Fpids\u002F`\n- Stale PIDs cleaned on startup\n- Can check running tasks: `ls skills\u002Fclaude-code-task\u002Fpids\u002F`\n\n### Silent mode (Telegram only)\nTelegram supports silent notifications (no sound).\n\nCurrent policy: **all Claude Code notifications are silent** in Telegram:\n- Heartbeat pings → `silent=True`\n- Launch notifications → `silent=True`\n- Mid-task updates (`📡 🟢 CC`) → `silent=True`\n- Final results → `silent=True`\n- Wake-summary instruction requests `silent=True`\n\nWhatsApp does NOT support silent mode — the flag is ignored for WhatsApp.\n\n### Telegram DM Threads vs Forum Groups\n\nTelegram has two distinct thread models. The key difference for run-task.py is how to route messages to the thread.\n\n**The core problem with external scripts:**\n- The OpenClaw `message` tool's `threadId` parameter is **Discord-specific** — ignored for Telegram\n- Target format `\"chatId:topic:threadId\"` is rejected by the message tool's target resolver\n- Session auto-routing (`currentThreadTs`) works ONLY inside active sessions — external scripts have no session context\n- **Solution:** `send_telegram_direct()` bypasses the message tool entirely; calls `api.telegram.org` directly with `message_thread_id`\n\n**DM Threaded Mode** (bot-user private chat with threads):\n- All notifications use `send_telegram_direct(chat_id, text, thread_id=..., parse_mode=...)` ✅\n- `thread_id` auto-extracted from session key `*:thread:\u003Cid>` by `extract_thread_id()`\n- Launch + finish: `parse_mode=\"HTML\"` with `\u003Cblockquote expandable>` for prompt\u002Fresult\n- Heartbeats + mid-task: `parse_mode=None` (plain text, avoid Markdown parse errors)\n- **`parse_mode=\"Markdown\"` trap**: finish messages contain `**text**` (CommonMark bold); Telegram MarkdownV1 rejects this with HTTP 400 — messages silently don't arrive\n- **`replyTo` trap**: combining `replyTo` + `message_thread_id` → Telegram rejects request → fallback strips thread_id → message lands in main chat\n- Agent continuation reply: `openclaw agent --session-id \u003Cuuid> --deliver` publishes the wake turn to chat so the user sees the same ongoing assistant conversation.\n\n**Forum Groups** (supergroup with Forum topics enabled):\n- Same `send_telegram_direct()` approach works; `message_thread_id` is standard Bot API for Forum topics\n- Auto-detected from session key pattern `*:thread:\u003Cid>`\n\n**Claude Code mid-task updates:**\n- DO NOT embed bot tokens or curl commands in the task prompt — Claude Code flags this as prompt injection\n- run-task.py writes `\u002Ftmp\u002Fcc-notify-{pid}.py` to disk before launching Claude Code\n- Task prompt prepended with `[Automation context: ... python3 \u002Ftmp\u002Fcc-notify-{pid}.py 'msg' ...]`\n- Claude Code calls the file (legitimate local script pattern, no safety warning)\n- Script automatically prepends `\"📡 🟢 CC: \"` to all messages; cleaned up in `finally` block\n\n### Notification types\n\n| Event | Emoji | WhatsApp delivery | Telegram delivery | DM thread? |\n|-------|-------|-------------------|-------------------|------------|\n| Launch | 🚀 | send_channel (Markdown) | send_telegram_direct (HTML, silent) | ✅ message_thread_id |\n| Heartbeat | ⏳ | send_channel (Markdown) | send_telegram_direct (plain, silent) | ✅ message_thread_id |\n| CC mid-task update | 📡 | — | \u002Ftmp\u002Fcc-notify-{pid}.py (Bot API, silent) | ✅ message_thread_id |\n| Success | ✅ | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Error | ❌ | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Timeout | ⏰ | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Crash | 💥 | send_channel + sessions_send | send_telegram_direct (HTML) + openclaw agent | ✅ message_thread_id |\n| Agent continuation reply | 🤖 | — | openclaw agent wake (`--deliver`) | ✅ visible in chat |\n\n## Claude Code Flags\n\n- `-p \"task\"` — print mode (non-interactive, outputs result)\n- `--dangerously-skip-permissions` — no confirmation prompts\n- `--verbose --output-format stream-json` — real-time activity tracking for heartbeats\n\n### Why NOT exec\u002Fpty?\n- `exec` has 2 min default timeout → kills long tasks\n- Even with `pty:true`, output has escape codes, hard to parse\n- `nohup` + `-p` mode: clean, detached, reliable\n\n### Git requirement\nClaude Code needs a git repo. `run-task.py` auto-inits if missing.\n\n## Python 3.9 Compatibility\n\n`run-task.py` uses `Optional[X]` from `typing` (not `X | None`) for compatibility with Python 3.9. The union syntax (`X | None`) requires Python 3.10+.\n\n```python\n# Correct (3.9+)\nfrom typing import Optional\ndef foo(x: Optional[str]) -> Optional[str]: ...\n\n# Would break on 3.9\ndef foo(x: str | None) -> str | None: ...\n```\n\n## Full E2E Test (reference)\n\nUse this when you need to validate the **entire pipeline** in one run:\n- launch notification in source thread\n- heartbeat after >60s\n- Claude mid-task progress update (📡 🟢 CC)\n- final result in source thread\n- agent wake attempt with summary step\n\n### Pass criteria\n1. Launch message appears in the same thread (with expandable prompt quote)\n2. At least one wrapper heartbeat appears after ~60s\n3. At least one mid-task CC update appears (via `\u002Ftmp\u002Fcc-notify-\u003Cpid>.py`)\n4. Final result appears in the same thread (expandable result quote)\n5. Agent wake continuation is delivered (`openclaw agent --session-id ... --deliver`) and appears visibly in chat\n\n### Interactive test rule (time budget)\nFor interactive\u002Fiterate-mode testing, do **exactly one** continuation step after phase 1.\n- Phase 1: intentionally incomplete output (prove gap detected)\n- Continuation #1: close the gap and finish\n- Stop there; do not run multi-hop continuation loops during routine tests\n\nReason: keeps regression runs fast (minutes, not 20+ minutes) while still validating the critical iterate path.\n\n### Visibility rule (mandatory)\nBetween `✅ Claude Code completed` and any next `🚀 Claude Code started`, there must be a user-facing analysis message in the thread.\n- The agent must first post: what was done, what gaps remain, and the decision to continue\u002Fstop.\n- Only after that message may it launch the next iteration.\n- No silent jump from completion directly to next start.\n\n### Canonical full test prompt pattern\n- keep prompt **compact** (about 10 lines) for routine testing\n- ensure prompt length is **>4500 chars** to verify quote truncation\u002Fcollapse behavior in Telegram\n- force runtime >60s (`sleep 70`) to trigger wrapper heartbeat\n- explicitly instruct Claude to call the notify script at least twice\n- include a short structured report so output is easy to verify\n- the >4500-char filler can be useful work (not just junk): use it for any creative\u002Foutput-generating task the agent genuinely wants to do in that moment, as long as it remains safe and relevant to the test context\n\n## Long-running task guidance\n\nIf a Claude Code task is expected to run longer than ~1 minute, explicitly ask Claude to send intermediate progress updates during execution.\n\nRecommended wording to include in prompt:\n- \"Send a progress update when you start\"\n- \"Send another update after major milestone(s)\"\n- \"If task exceeds 60 seconds, send at least one heartbeat-style update\"\n\nFor thread-safe Telegram runs, updates should use the injected automation script (`\u002Ftmp\u002Fcc-notify-\u003Cpid>.py`).\n\n### Canonical launch (minimal mode)\n```bash\ncat > \u002Ftmp\u002Fcc-full-test-prompt.txt \u003C\u003C 'EOF'\n# ~10 lines, but total >4500 chars:\n# 1) notify script now\n# 2) create test file with repeated text (to exceed 4500 chars)\n# 3) sleep 70 + notify script again\n# 4) run several shell commands\n# 5) return short structured report\nEOF\n\npython3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-full-test-prompt.txt)\" \\\n  --project \u002Ftmp\u002Fcc-e2e-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --validate-only\n\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-full-test-prompt.txt)\" \\\n  --project \u002Ftmp\u002Fcc-e2e-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 900 \\\n  > \u002Ftmp\u002Fcc-full-test.log 2>&1 &\n```\n\n### Verification artifacts\n- wrapper log: `\u002Ftmp\u002Fcc-full-test.log`\n- Claude output: `\u002Ftmp\u002Fcc-YYYYMMDD-HHMMSS.txt`\n- session registry entry in `~\u002F.openclaw\u002Fclaude_sessions.json`\n\n## Examples\n\n### WhatsApp: Create a tool\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  -t \"Create a Python CLI tool that converts markdown to HTML with syntax highlighting. Save as convert.py\" \\\n  -p ~\u002Fprojects\u002Fmd-converter \\\n  -s \"agent:main:whatsapp:group:120363425246977860@g.us\" \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Telegram: Research codebase (thread-safe)\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 1800 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Telegram Threaded Mode: Research codebase\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:369520\" \\\n  --timeout 1800 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n# thread_id auto-extracted from session key\n# target + session UUID auto-resolved from API\u002Flocal session files\n```\n\n### Telegram Threaded Mode: Mid-task updates from Claude Code\n\nrun-task.py automatically creates an on-disk notification script before launching Claude Code, so CC can send progress updates without seeing the bot token in the prompt (which triggers safety refusals):\n\n```bash\n# Just write a normal task prompt — run-task.py handles the rest\ncat > \u002Ftmp\u002Fcc-prompt.txt \u003C\u003C 'EOF'\nSTEP 1: Write analysis to \u002Ftmp\u002Freport.txt (600+ words)...\n\nAfter step 1, send a progress notification using the script from the\nautomation context above: python3 \u002Ftmp\u002Fcc-notify-\u003CPID>.py \"Step 1 done.\"\n\nSTEP 2: Write summary to \u002Ftmp\u002Fsummary.txt...\nEOF\n\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --timeout 1800 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n# run-task.py writes \u002Ftmp\u002Fcc-notify-{pid}.py before launch\n# Prepends \"[Automation context: use python3 \u002Ftmp\u002Fcc-notify-{pid}.py 'msg']\" to task\n# Claude Code calls the file; prefix \"📡 🟢 CC: \" auto-added; file cleaned up on exit\n```\n\n> ⚠️ **Never embed bot tokens or curl commands in the task prompt** — Claude Code correctly identifies hardcoded tokens + external API calls as prompt injection and refuses. Use the on-disk script pattern above instead.\n\n> **Quick reference: launching from a Telegram DM thread (minimal mode)**\n> ```bash\n> # 1) Validate routing first (no Claude run)\n> python3 {baseDir}\u002Frun-task.py \\\n>   --task \"probe\" \\\n>   --project ~\u002Fprojects\u002Fx \\\n>   --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n>   --validate-only\n>\n> # 2) Real launch (only 3 required params)\n> nohup python3 {baseDir}\u002Frun-task.py \\\n>   --task \"$(cat \u002Ftmp\u002Fprompt.txt)\" \\\n>   --project ~\u002Fprojects\u002Fx \\\n>   --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n>   --timeout 900 \\\n>   > \u002Ftmp\u002Fcc-run.log 2>&1 &\n> ```\n> - Required: `--task`, `--project`, `--session`\n- Safety: Telegram launches without `:thread:\u003Cid>` are blocked by default (`❌ Unsafe routing blocked`)\n- For non-thread Telegram deployments, use `--telegram-routing-mode allow-non-thread`.\n> - `THREAD_ID` is auto-extracted from session key\n> - Target + session UUID are auto-resolved (API, then local session-file fallback)\n> - If routing is inconsistent\u002Funresolved, script exits with `❌ Invalid routing` before run\n> - All notifications from run-task (launch\u002Fheartbeat\u002Fresult) stay on the source thread ✅\n\n### Long task with extended timeout\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  -t \"Refactor the entire auth module to use JWT tokens\" \\\n  -p ~\u002Fprojects\u002Fbackend \\\n  -s \"agent:main:whatsapp:group:120363425246977860@g.us\" \\\n  --timeout 3600 \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n## Cost\n\n- Claude Code runs on Max subscription ($200\u002Fmo) — NOT API tokens\n- Zero OpenClaw API cost while Claude Code works\n- Only cost: message delivery + brief agent turn for summary\n\n## Session Resumption\n\nClaude Code sessions can be resumed to continue previous conversations. This is useful for:\n- Follow-up tasks building on previous research\n- Continuing after timeouts or interruptions\n- Multi-step workflows where context matters\n\n### ⚠️ Resume ID — Critical Rule\n`--resume` takes the **Claude Code session ID**, not the `run_id` or `wake_id`.\n\nCorrect source — look for this line in the run log:\n```\n📝 Session registered: \u003Csession-id-here>\n```\nThat is the value to pass as `--resume \u003Csession-id>`.\n\n**Do NOT use:**\n- `run_id` from wake payload\n- `wake_id` from wake payload\n- session IDs from previous unrelated runs\n\nWhen in doubt: skip `--resume` and start fresh.\n\n### How to Resume\n\nWhen a task completes, the session ID is automatically captured and saved to the registry (`~\u002F.openclaw\u002Fclaude_sessions.json`).\n\nTo resume a session, use the `--resume` flag:\n\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"SESSION_KEY\" \\\n  --resume \u003Csession-id> \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Session Labels\n\nUse `--session-label` to give sessions human-readable names for easier tracking:\n\n```bash\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fcc-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fmy-project \\\n  --session \"SESSION_KEY\" \\\n  --session-label \"Research on Jackson Berler\" \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n### Listing Recent Sessions\n\nThe agent can read the session registry to find recent sessions:\n\n```python\n# Python code (for agent automation)\nfrom session_registry import list_recent_sessions, find_session_by_label\n\n# List sessions from last 72 hours\nrecent = list_recent_sessions(hours=72)\nfor session in recent:\n    print(f\"{session['session_id']}: {session['label']} ({session['status']})\")\n\n# Find session by label (fuzzy match)\nsession = find_session_by_label(\"Jackson\")\nif session:\n    print(f\"Found: {session['session_id']}\")\n```\n\nOr manually inspect the registry:\n\n```bash\ncat ~\u002F.openclaw\u002Fclaude_sessions.json\n```\n\n### When to Resume vs Start Fresh\n\n**Resume when:**\n- You need context from previous conversation\n- Building on previous research\u002Fanalysis\n- Continuing interrupted work\n- Following up with clarifications or next steps\n\n**Start fresh when:**\n- Completely unrelated task\n- Previous session was exploratory\u002Fexperimental\n- You want a clean slate\n- Previous session context might cause confusion\n\n### Resume Failure Handling\n\nIf a session ID is invalid or expired:\n- Error message sent to channel with suggestion to start fresh\n- Process exits cleanly (no partial work)\n- Check stderr in `\u002Ftmp\u002Fcc-run.log` for details\n\nCommon resume failures:\n- Session expired (Claude Code has retention limits)\n- Invalid session ID (typo, wrong format)\n- Session from different project\u002Fcontext\n\n### Example Workflow\n\n**Step 1: Initial research**\n```bash\n# Save prompt\nwrite \u002Ftmp\u002Fresearch-prompt.txt with \"Research the codebase architecture for project X\"\n\n# Launch task (Telegram thread-safe example)\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fresearch-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fproject-x \\\n  --session \"agent:main:main:thread:\u003CTHREAD_ID>\" \\\n  --session-label \"Project X architecture research\" \\\n  > \u002Ftmp\u002Fcc-run.log 2>&1 &\n```\n\n**Step 2: Check result and find session ID**\n```bash\n# Session ID printed in stderr: \"📝 Session registered: \u003Cid>\"\ntail \u002Ftmp\u002Fcc-run.log\n\n# Or read from registry\ncat ~\u002F.openclaw\u002Fclaude_sessions.json | grep \"Project X\"\n```\n\n**Step 3: Follow-up implementation**\n```bash\n# Save follow-up prompt\nwrite \u002Ftmp\u002Fimplement-prompt.txt with \"Based on your research, implement the authentication module\"\n\n# Resume session\nnohup python3 {baseDir}\u002Frun-task.py \\\n  --task \"$(cat \u002Ftmp\u002Fimplement-prompt.txt)\" \\\n  --project ~\u002Fprojects\u002Fproject-x \\\n  --session \"SESSION_KEY\" \\\n  --resume \u003Csession-id-from-step-1> \\\n  --session-label \"Project X auth implementation\" \\\n  > \u002Ftmp\u002Fcc-run2.log 2>&1 &\n```\n\n## Wake Troubleshooting\n\nWhen the agent wake \u002F continue chain fails (no agent summary, wrong thread, session not resolved,\niterative loop stalls, etc.), see the dedicated guide:\n\n→ **[WAKE-TROUBLESHOOTING.md](WAKE-TROUBLESHOOTING.md)**\n\nIncludes a **Quick Triage Checklist (60 seconds)** plus detailed items: agent not waking,\ndouble messages, wrong thread routing, UUID resolution failures, session-locked wake,\n`❌ Invalid routing`, Telegram HTTP 400 silent drops, mid-task update failures, stale\u002Fduplicate wake skips, and more.\n\n## Current Stable Behavior (2026-03-03)\n\nThis is the version validated in live Telegram thread tests.\n\n- Wake continuity: Telegram wake is delivered (`openclaw agent --deliver`) so continuation turns are visible in chat.\n- No silent launch policy: agent must post a visible decision turn before launching next iteration.\n- Deterministic wake guard: duplicate\u002Fstale wake dispatch is skipped by per-project state + `wake_id`\u002Foutput dedupe.\n- Trace mode: `--trace-live` emits technical milestones (`RUN_TASK START\u002FCOMPLETE`, `WAKE`, `WAKE SKIP`) into the same thread.\n- Resume safety: `--resume` must use the Claude session id from `📝 Session registered: ...` in the run log.\n- Compact heartbeat now includes active subagents count as `sub:\u003CN>` (example: `🟢 CC (3min) | sub:1 | 12K tok | 18 calls | 🔧 Bash`).\n- `output_tokens` is aggregated from all assistant stream messages (main agent + subagents).\n- `last_activity` \u002F last tool signal is unified: whichever actor (main or subagent) emitted the latest tool event is shown.\n- Active subagents are tracked via Task\u002FAgent lifecycle in stream-json (`tool_use id` add, matching `tool_result`\u002F`task_notification` remove).\n\n## Files\n\n```\nskills\u002Fclaude-code-task\u002F\n├── SKILL.md                    # This file\n├── WAKE-TROUBLESHOOTING.md     # Wake\u002Fcontinue chain diagnostics\n├── run-task.py                 # Async runner with notifications\n├── session_registry.py         # Session metadata storage\n└── pids\u002F                       # PID files for running tasks (auto-managed)\n```\n",{"name":5,"description":7},"main","f9d3fe7cf9ac8f1ea63a0d96e98e1f510a3814db","skills\u002Fvsevolodustinov\u002Fclaude-code-task",1,"https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills","https:\u002F\u002Fgithub.com\u002Fjavimosch","intrane.fr","Building robust, open-source infrastructure for the commons. AI-leveraged, self-hosted, built to last.","2026-06-07 03:34:58",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add javimosch\u002Fopen-claw-skills --skill claude-code-task",{"tool":39,"command":40},"bunx","bunx skills add javimosch\u002Fopen-claw-skills --skill claude-code-task",{"tool":42,"command":43},"pnpm","pnpm dlx skills add javimosch\u002Fopen-claw-skills --skill claude-code-task","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvsevolodustinov\u002Fclaude-code-task\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M778GGXG2VQ0YF31W2MKGMQZ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M778G7BH8SBJ9FJ6C3G7CB1K","ceaser","Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir\u002FUltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M778FYCJQZWFKKX5FYMK3S47","ceaser-send","Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir\u002FUltraHonk zero-knowledge proofs.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser-send\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M778FQQNSEYA3HJKZBPQ4M9Z","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M778FGVZX7QA2TF9BFMM37FY","moldium","Post and manage content on the Moldium blog platform. Triggered by \"post to Moldium\", \"write a blog post\", \"publish an article\", etc.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyom45\u002Fmoldium\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M778F88D8PQ9MQ0KNW2TJ8ZH","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http:\u002F\u002Fweakaccept.top:8000\u002F.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[]]