{
  "schemaVersion": "1.0",
  "item": {
    "slug": "claude-skill",
    "name": "Claude Skill",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/feiskyer/claude-skill",
    "canonicalUrl": "https://clawhub.ai/feiskyer/claude-skill",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/claude-skill",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=claude-skill",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "references/examples.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/claude-skill"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/claude-skill",
    "agentPageUrl": "https://openagent3.xyz/skills/claude-skill/agent",
    "manifestUrl": "https://openagent3.xyz/skills/claude-skill/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/claude-skill/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Claude Code Agent Skill",
        "body": "Operate Claude Code as a managed coding agent — from worktree setup through PR merge."
      },
      {
        "title": "Prerequisites",
        "body": "claude --version  # Verify installed\n# Install: npm install -g @anthropic-ai/claude-code\ntmux -V             # tmux required for full workflow"
      },
      {
        "title": "CLI Quick Reference",
        "body": "FlagEffect-p \"prompt\"Non-interactive one-shot, exits when done--dangerously-skip-permissionsSkip all permission prompts (safe in containers/VMs)--permission-mode acceptEditsAuto-accept file edits, still prompt for shell commands--permission-mode planRead-only analysis, no modifications--model <model>Model selection (e.g. claude-sonnet-4-6)--allowedTools \"Bash,Read,Write,Edit\"Restrict available tools--disallowedTools \"Bash,Write\"Block specific tools--append-system-prompt \"...\"Add custom instructions to system prompt--output-format jsonStructured JSON output with cost/duration metadata--output-format stream-jsonStreaming JSON (each message as it arrives)--continue / -cContinue most recent conversation--resume <id> / -r <id>Resume specific session by ID--mcp-config <file>Load MCP server configuration--verboseEnable verbose debug logging"
      },
      {
        "title": "Quick Mode — Small Tasks",
        "body": "For trivial fixes, one-file changes, or analysis. Use -p (non-interactive).\n\nOutput capture: Always redirect output to a log file so it's readable regardless\nof PTY availability. Use --output-format stream-json for structured, parseable\nprogress events (each message arrives as a separate JSON line).\n\nLOG_FILE=\"/tmp/claude-quick-${TASK_ID:-$$}.log\"\n\n# Via OpenClaw exec — use background=true + pty=true, NO hard timeout\n# pty=true ensures claude CLI flushes output properly (no buffering issues)\n# (hard timeout kills the process; instead we poll and extend)\n# Redirect both stdout and stderr to log file via tee so output is always captured.\n# In -p mode (non-interactive), | tee is safe — no TTY detection issues.\nexec(command=\"claude -p 'fix the typo in README.md' --dangerously-skip-permissions --output-format stream-json 2>&1 | tee -a $LOG_FILE\",\n     workdir=\"/path/to/project\", background=true, pty=true)\n\nPTY fallback: If pty=true is unavailable (some containers, CI runners), the\ncommand still works because -p mode is non-interactive — it doesn't rely on\nisatty(stdout). The 2>&1 | tee ensures both stdout and stderr are captured\nto the log file regardless of PTY status. Without PTY, you lose color output\nbut all content is preserved.\n\nAdaptive Timeout (Poll-and-Extend)\n\nDo NOT use timeout= for claude tasks. Instead, use background execution\nwith periodic polling. This prevents premature kills on long-running tasks:\n\nLaunch with background=true (no timeout)\nPoll every ~5 min with process(action=\"poll\", sessionId=<id>, timeout=300000)\nIf process is still running → check log file for new output\nIf process exited → check exit code and log file, done\nSafety net: if no new output for 12 hours, ask user before killing\nSafety net: if output is repeating (loop detection), ask user\n\nPersistent polling state: Store polling metadata in the task registry so a\nrestarted orchestrator agent can resume monitoring without losing state:\n\nRegistry fields for Quick Mode tasks:\n  \"lastOutputHash\": \"<sha256 of last 20 lines>\",\n  \"lastCheckedAt\": <unix timestamp>,\n  \"silentRounds\": <int>,\n  \"repeatingRounds\": <int>\n\nPoll loop (agent behavior, not a script):\n\n  poll_interval = 5 min (300000 ms)\n  max_silent_rounds = 144  (= 12 hours with no new output → ask user)\n  max_repeating_rounds = 12 (= 1 hour of identical output → likely stuck)\n\n  # Restore state from registry if resuming after agent restart\n  silent_rounds = registry[task_id].silentRounds ?? 0\n  repeating_rounds = registry[task_id].repeatingRounds ?? 0\n  last_output_hash = registry[task_id].lastOutputHash ?? \"\"\n\n  repeat:\n    result = process(action=\"poll\", sessionId=<id>, timeout=300000)\n    if result.completed:\n      → check exit code, read $LOG_FILE, report result\n      → break\n    else:\n      # Read latest output directly from the log file\n      new_output = tail -20 \"$LOG_FILE\"\n      new_hash = sha256(new_output)\n\n      if new_hash != last_output_hash and new_output != \"\":\n        if last_output_hash != \"\" and output_looks_similar(new_output, last_output):\n          repeating_rounds += 1   # output changing but repetitive (loop)\n          silent_rounds = 0\n        else:\n          silent_rounds = 0       # genuinely new output, keep going\n          repeating_rounds = 0\n        last_output_hash = new_hash\n      else:\n        silent_rounds += 1\n\n      # Persist state to registry (survives agent restart)\n      update_registry(task_id, {\n        lastOutputHash: new_hash,\n        lastCheckedAt: now(),\n        silentRounds: silent_rounds,\n        repeatingRounds: repeating_rounds\n      })\n\n      if silent_rounds >= max_silent_rounds:\n        → notify user: \"Claude has been silent for 12 hours, kill or keep waiting?\"\n        → wait for user decision\n      if repeating_rounds >= max_repeating_rounds:\n        → notify user: \"Claude appears stuck in a loop (1h of repeated output), kill or keep waiting?\"\n        → wait for user decision\n\nThis way tasks that need 5 min or several hours both work without premature kills."
      },
      {
        "title": "Full Mode — Features, Bugfixes, Refactors",
        "body": "For non-trivial tasks, use the full workflow below. This gives you:\n\nIsolated worktree — no conflicts with other work\ntmux session — mid-task steering without killing the agent\nTask tracking — know what's running at all times\nQuality gates — Definition of Done checklist\nSmart retries — don't waste tokens on repeated failures"
      },
      {
        "title": "Step 1: Create Worktree",
        "body": "Isolate each task in its own worktree and branch:\n\nTASK_ID=\"feat-custom-templates\"\nBRANCH=\"feat/$TASK_ID\"\nREPO_ROOT=$(git rev-parse --show-toplevel)\nWORKTREE=\"/tmp/worktrees/$TASK_ID\"\n\ngit worktree add -b \"$BRANCH\" \"$WORKTREE\" origin/main\ncd \"$WORKTREE\"\n\n# Install dependencies (adapt to your stack)\npnpm install   # or: npm install / go mod tidy / pip install -r requirements.txt"
      },
      {
        "title": "Step 2: Launch Agent in tmux",
        "body": "Start Claude Code in interactive mode (no -p) so you can steer mid-task.\nImportant: Use tmux pipe-pane to log output — do NOT use | tee because it\nturns stdout into a pipe, which breaks interactive mode (claude detects !isatty(stdout)\nand may disable interactive features, breaking send-keys steering).\n\nCritical: Set up pipe-pane BEFORE sending the command. Otherwise early output\n(startup messages, fast crashes) is lost.\n\nLOG_FILE=\"/tmp/worktrees/$TASK_ID/claude-output.log\"\nMAX_LOG_SIZE=$((100 * 1024 * 1024))  # 100 MB safety cap\n\n# 1. Create session with an idle shell first\ntmux new-session -d -s \"$TASK_ID\" -c \"$WORKTREE\"\n\n# 2. Start pipe-pane BEFORE the command runs — captures ALL output from the start\n#    Strip ANSI escape codes so log files are clean and grep-parseable\ntmux pipe-pane -t \"$TASK_ID\" -o \"sed 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE\"\n\n# 3. NOW send the command — all output is captured\ntmux send-keys -t \"$TASK_ID\" \"claude --dangerously-skip-permissions \\\n  'Your detailed prompt here.\n\nWhen completely finished:\n1. Commit all changes with descriptive messages\n2. Push the branch: git push -u origin $BRANCH\n3. Create PR: gh pr create --fill\n4. Notify: openclaw system event --text \\\"Done: $TASK_ID\\\" --mode now'\" Enter\n\nLog file management: For very long-running tasks, the log file can grow large.\nMonitor its size and rotate if needed:\n\nLOG_SIZE=$(stat -c%s \"$LOG_FILE\" 2>/dev/null || echo 0)\nif [ \"$LOG_SIZE\" -gt \"$MAX_LOG_SIZE\" ]; then\n  mv \"$LOG_FILE\" \"${LOG_FILE}.old\"\n  # pipe-pane will create a new file on next write\nfi\n\nWhy interactive mode (no -p)?\n\nAllows mid-task steering via tmux send-keys\nAgent can be redirected without killing and restarting\n--dangerously-skip-permissions is safe in container/sandbox environments\n\nNote on stdout/stderr: In tmux, both stdout and stderr from the process flow\nthrough the PTY and are captured by pipe-pane. They are mixed together — you\ncannot separate them after capture. For error diagnosis, grep for keywords like\nerror, fail, panic in the clean (ANSI-stripped) log file."
      },
      {
        "title": "Step 3: Register Task",
        "body": "Track all active tasks in a JSON registry. Use flock for atomic updates to\nprevent race conditions when multiple agents run in parallel.\n\nmkdir -p \"$REPO_ROOT/.clawd\"\nTASKS_FILE=\"$REPO_ROOT/.clawd/active-tasks.json\"\n\n# Initialize if not exists\n[ -f \"$TASKS_FILE\" ] || echo '{\"tasks\":[]}' > \"$TASKS_FILE\"\n\n# Get the PID of the claude process inside tmux for reliable status checks\nPANE_PID=$(tmux display-message -t \"$TASK_ID\" -p '#{pane_pid}')\n\n# Register — use flock to prevent concurrent write races\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" --arg branch \"$BRANCH\" --arg wt \"$WORKTREE\" \\\n    --arg pane_pid \"$PANE_PID\" \\\n    '.tasks += [{\n      \"id\": $id,\n      \"agent\": \"claude\",\n      \"branch\": $branch,\n      \"worktree\": $wt,\n      \"tmuxSession\": $id,\n      \"panePid\": ($pane_pid | tonumber),\n      \"status\": \"running\",\n      \"startedAt\": (now|floor),\n      \"pr\": null,\n      \"retries\": 0,\n      \"checks\": {},\n      \"lastOutputHash\": \"\",\n      \"lastCheckedAt\": (now|floor),\n      \"silentRounds\": 0,\n      \"repeatingRounds\": 0\n    }]' \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\""
      },
      {
        "title": "Step 4: Monitor & Steer",
        "body": "# --- Process status check (reliable — checks actual process, not just tmux session) ---\n\n# Method 1: Check if the claude process inside the pane is alive\nPANE_PID=$(tmux display-message -t \"$TASK_ID\" -p '#{pane_pid}' 2>/dev/null)\nif [ -z \"$PANE_PID\" ]; then\n  echo \"tmux session gone\"\nelif pgrep -P \"$PANE_PID\" > /dev/null 2>&1; then\n  echo \"running\"\nelse\n  echo \"process exited (tmux session still open)\"\n  # Get exit code from the shell inside tmux\n  tmux send-keys -t \"$TASK_ID\" 'echo \"EXIT_CODE=$?\"' Enter\nfi\n\n# Method 2: Use tmux's pane_dead flag (if remain-on-exit is set)\n# tmux display-message -t \"$TASK_ID\" -p '#{pane_dead}'  # 1 = process exited\n\n# --- View output ---\n\n# Full output history from log file (ANSI-stripped, grep-friendly)\ntail -100 \"/tmp/worktrees/$TASK_ID/claude-output.log\"\n\n# Search for errors in clean log\ngrep -i \"error\\|fail\\|panic\" \"/tmp/worktrees/$TASK_ID/claude-output.log\"\n\n# Live view (raw tmux pane, may contain ANSI codes — use for quick glance only)\ntmux capture-pane -t \"$TASK_ID\" -p -S -50\n\n# --- Mid-task steering (DON'T kill — redirect!) ---\n\n# Agent going the wrong direction?\ntmux send-keys -t \"$TASK_ID\" \"Stop. Focus on the API layer first, not the UI.\" Enter\n\n# Agent missing context?\ntmux send-keys -t \"$TASK_ID\" \"The schema is in src/types/template.ts. Use that.\" Enter\n\n# Agent's context window filling up?\ntmux send-keys -t \"$TASK_ID\" \"Focus only on these 3 files: api.ts, handler.ts, types.ts\" Enter\n\n# Agent needs test guidance?\ntmux send-keys -t \"$TASK_ID\" \"Run 'npm test -- --grep auth' to verify your changes.\" Enter\n\nMonitoring cadence: Check every 5-10 minutes, not every 30 seconds. Agents need time to work."
      },
      {
        "title": "Step 5: Definition of Done",
        "body": "A PR is NOT ready for review until all checks pass:\n\n✅ PR created              → gh pr list --head \"$BRANCH\"\n✅ No merge conflicts       → gh pr view $PR_NUM --json mergeable -q '.mergeable'\n✅ CI passing               → gh pr checks $PR_NUM\n✅ AI code review passed    → at least one cross-model review (see Step 6)\n✅ UI screenshots included  → (if applicable) screenshot in PR description\n\nQuick inline check:\n\nPR_NUM=$(gh pr list --head \"$BRANCH\" --json number -q '.[0].number')\necho \"PR: #$PR_NUM\"\ngh pr checks \"$PR_NUM\"\ngh pr view \"$PR_NUM\" --json mergeable -q '.mergeable'"
      },
      {
        "title": "Step 6: Multi-Model Code Review",
        "body": "Review with a different model than the one that wrote the code. Different models catch different issues:\n\nDIFF=$(gh pr diff \"$PR_NUM\")\n\n# Option A: Codex reviews Claude's code (best for edge cases & logic errors)\necho \"$DIFF\" | codex exec -s read-only \\\n  \"Review this PR diff. Focus on: bugs, edge cases, missing error handling, \n   race conditions, security issues. Be specific — cite file and line numbers.\n   Output format: list of issues with severity (critical/warning/info).\"\n\n# Option B: Claude reviews with security focus\necho \"$DIFF\" | claude -p \\\n  --append-system-prompt \"You are a security-focused code reviewer. Flag only critical issues.\" \\\n  \"Review this diff for security vulnerabilities, injection risks, and logic errors.\"\n\nPost review results to PR:\n\ngh pr comment \"$PR_NUM\" --body \"## AI Code Review\n\n$REVIEW_OUTPUT\"\n\nUpdate task registry:\n\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" \\\n    '(.tasks[] | select(.id == $id)).checks.codeReviewPassed = true' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\""
      },
      {
        "title": "Step 7: Notify",
        "body": "If you included the notify command in the agent prompt (Step 2), the agent self-notifies on completion.\n\nOtherwise, notify after DoD passes:\n\nopenclaw system event --text \"✅ PR #$PR_NUM ready for review: $TASK_ID — all checks passed\" --mode now\n\nUpdate task status:\n\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" --argjson pr \"$PR_NUM\" \\\n    '(.tasks[] | select(.id == $id)) |= (.status = \"done\" | .pr = $pr | .completedAt = (now|floor))' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\""
      },
      {
        "title": "Step 8: Cleanup",
        "body": "After PR is merged:\n\ngit worktree remove \"$WORKTREE\" 2>/dev/null\ngit branch -d \"$BRANCH\" 2>/dev/null\n\n# Remove from registry\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" '.tasks = [.tasks[] | select(.id != $id)]' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\""
      },
      {
        "title": "Smart Retry Strategy",
        "body": "When an agent fails, analyze the failure and adapt the prompt — don't just re-run blindly.\n\nFailure TypeSymptomRetry StrategyContext overflowAgent loops, produces garbage, or stops mid-taskNarrow scope: \"Focus only on files X, Y, Z\"Wrong directionAgent implements something unrelated to intentCorrect intent: \"Stop. Customer wanted X, not Y. Spec: ...\"Missing infoAgent makes wrong assumptions about architectureAdd context: \"Auth uses JWT, see src/auth/jwt.ts\"CI failureTests, lint, or typecheck fail after PRAttach CI log: \"Fix these test failures: ...\"Build failureDependencies missing or incompatiblePre-install deps before retry\n\nMax 3 retries. After that, escalate to human.\n\nRETRY=$((RETRY + 1))\nif [ \"$RETRY\" -gt 3 ]; then\n  openclaw system event --text \"BLOCKED: $TASK_ID failed after 3 retries — needs human help\" --mode now\n  (\n    flock -x 200\n    jq --arg id \"$TASK_ID\" '(.tasks[] | select(.id == $id)).status = \"blocked\"' \\\n      \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n  ) 200>\"$TASKS_FILE.lock\"\n  exit 1\nfi\n\n# Capture what went wrong — prefer log file over tmux scrollback\nLOG_FILE=\"/tmp/worktrees/$TASK_ID/claude-output.log\"\nif [ -f \"$LOG_FILE\" ]; then\n  # Log file is ANSI-stripped (clean text) — extract error-relevant lines\n  # Take last 500 lines, but also grep for error context\n  FAILURE_LOG=$(tail -500 \"$LOG_FILE\")\n  ERROR_LINES=$(grep -n -i \"error\\|fail\\|panic\\|exception\\|traceback\" \"$LOG_FILE\" | tail -50)\n  if [ -n \"$ERROR_LINES\" ]; then\n    FAILURE_LOG=\"=== Error lines ===\n$ERROR_LINES\n\n=== Last 500 lines ===\n$FAILURE_LOG\"\n  fi\nelse\n  FAILURE_LOG=$(tmux capture-pane -t \"$TASK_ID\" -p -S -200)\nfi\nCI_LOG=$(gh pr checks \"$PR_NUM\" 2>/dev/null || echo \"no PR yet\")\ntmux kill-session -t \"$TASK_ID\" 2>/dev/null\n\n# Archive old log, start fresh for retry\n[ -f \"$LOG_FILE\" ] && mv \"$LOG_FILE\" \"${LOG_FILE}.retry$((RETRY - 1))\"\n\n# Respawn — set up pipe-pane BEFORE sending command (captures all output)\ntmux new-session -d -s \"$TASK_ID\" -c \"$WORKTREE\"\ntmux pipe-pane -t \"$TASK_ID\" -o \"sed 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE\"\ntmux send-keys -t \"$TASK_ID\" \"claude --dangerously-skip-permissions \\\n  'Previous attempt failed. Error output:\n$FAILURE_LOG\n\nCI status: $CI_LOG\n\nFix the issues above and complete the original task.\n[...your enriched instructions here...]\n\nWhen done: commit, push, gh pr create --fill, then run:\nopenclaw system event --text \\\"Done: $TASK_ID (retry $RETRY)\\\" --mode now'\" Enter\n\n# Update registry with flock\nPANE_PID=$(tmux display-message -t \"$TASK_ID\" -p '#{pane_pid}')\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" --argjson r \"$RETRY\" --arg pane_pid \"$PANE_PID\" \\\n    '(.tasks[] | select(.id == $id)) |= (.retries = $r | .status = \"running\" | .panePid = ($pane_pid | tonumber) | .silentRounds = 0 | .repeatingRounds = 0 | .lastOutputHash = \"\")' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\""
      },
      {
        "title": "Parallel Execution",
        "body": "Run multiple agents simultaneously on different tasks.\nImportant: Always set up pipe-pane before sending the command to avoid losing\nearly output. Use ANSI stripping for clean logs.\n\n# Helper: launch an agent in tmux with proper output capture\nlaunch_agent() {\n  local TASK_ID=\"$1\" WORKTREE=\"$2\" PROMPT=\"$3\"\n  local LOG_FILE=\"$WORKTREE/claude-output.log\"\n\n  # 1. Create session with idle shell\n  tmux new-session -d -s \"$TASK_ID\" -c \"$WORKTREE\"\n  # 2. Start pipe-pane BEFORE command (captures everything, ANSI-stripped)\n  tmux pipe-pane -t \"$TASK_ID\" -o \"sed 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE\"\n  # 3. Send command\n  tmux send-keys -t \"$TASK_ID\" \"$PROMPT\" Enter\n}\n\n# Task 1: Feature\ngit worktree add -b feat/auth /tmp/worktrees/feat-auth origin/main\nlaunch_agent \"feat-auth\" \"/tmp/worktrees/feat-auth\" \\\n  \"cd /tmp/worktrees/feat-auth && pnpm install && claude --dangerously-skip-permissions 'Implement JWT auth...'\"\n\n# Task 2: Bugfix\ngit worktree add -b fix/payments /tmp/worktrees/fix-payments origin/main\nlaunch_agent \"fix-payments\" \"/tmp/worktrees/fix-payments\" \\\n  \"cd /tmp/worktrees/fix-payments && pnpm install && claude --dangerously-skip-permissions 'Fix payment webhook...'\"\n\n# Dashboard: check all agents (uses process check, not just has-session)\necho \"=== Agent Status ===\"\nfor s in $(tmux ls -F '#{session_name}' 2>/dev/null); do\n  PANE_PID=$(tmux display-message -t \"$s\" -p '#{pane_pid}' 2>/dev/null)\n  if [ -z \"$PANE_PID\" ]; then\n    STATUS=\"(session gone)\"\n  elif pgrep -P \"$PANE_PID\" > /dev/null 2>&1; then\n    STATUS=\"running\"\n  else\n    STATUS=\"process exited\"\n  fi\n  LOG=\"/tmp/worktrees/$s/claude-output.log\"\n  LAST_LINE=$(tail -1 \"$LOG\" 2>/dev/null || echo \"(no log)\")\n  echo \"  $s: $STATUS | last: $LAST_LINE\"\ndone"
      },
      {
        "title": "Multi-Turn Conversations",
        "body": "For complex tasks that need iterative refinement:\n\n# Start session, capture ID\nsession_id=$(claude -p \"analyze the codebase architecture\" \\\n  --output-format json | jq -r '.session_id')\n\n# Continue with context from previous turn\nclaude -r \"$session_id\" -p \"now implement the changes we discussed\" \\\n  --dangerously-skip-permissions\n\n# Resume in non-interactive mode\nclaude -r \"$session_id\" -p \"fix the remaining test failures\" \\\n  --dangerously-skip-permissions"
      },
      {
        "title": "Prompt Quality",
        "body": "Include file paths: \"The entry point is src/index.ts, config in src/config/\"\nInclude schemas/types: Paste relevant type definitions into the prompt\nInclude test commands: \"Verify with: npm test -- --grep auth\"\nInclude commit convention: \"Use conventional commits: feat:, fix:, chore:\"\nInclude error logs: When retrying, always attach the failure output"
      },
      {
        "title": "Scope Management",
        "body": "One task per agent — don't ask for \"refactor everything\"\nPre-install dependencies before launching the agent\nBe specific — \"Add rate limiting to POST /api/users\" not \"improve the API\""
      },
      {
        "title": "When to Interrupt (Ask Human)",
        "body": "Destructive operations (drop tables, force push main)\nSecurity decisions (expose credentials, change auth)\nAmbiguous requirements with significant trade-offs\nAll other decisions: proceed autonomously"
      },
      {
        "title": "Examples",
        "body": "See references/examples.md for additional usage scenarios."
      }
    ],
    "body": "Claude Code Agent Skill\n\nOperate Claude Code as a managed coding agent — from worktree setup through PR merge.\n\nPrerequisites\nclaude --version  # Verify installed\n# Install: npm install -g @anthropic-ai/claude-code\ntmux -V             # tmux required for full workflow\n\nCLI Quick Reference\nFlag\tEffect\n-p \"prompt\"\tNon-interactive one-shot, exits when done\n--dangerously-skip-permissions\tSkip all permission prompts (safe in containers/VMs)\n--permission-mode acceptEdits\tAuto-accept file edits, still prompt for shell commands\n--permission-mode plan\tRead-only analysis, no modifications\n--model <model>\tModel selection (e.g. claude-sonnet-4-6)\n--allowedTools \"Bash,Read,Write,Edit\"\tRestrict available tools\n--disallowedTools \"Bash,Write\"\tBlock specific tools\n--append-system-prompt \"...\"\tAdd custom instructions to system prompt\n--output-format json\tStructured JSON output with cost/duration metadata\n--output-format stream-json\tStreaming JSON (each message as it arrives)\n--continue / -c\tContinue most recent conversation\n--resume <id> / -r <id>\tResume specific session by ID\n--mcp-config <file>\tLoad MCP server configuration\n--verbose\tEnable verbose debug logging\nExecution Modes\nQuick Mode — Small Tasks\n\nFor trivial fixes, one-file changes, or analysis. Use -p (non-interactive).\n\nOutput capture: Always redirect output to a log file so it's readable regardless of PTY availability. Use --output-format stream-json for structured, parseable progress events (each message arrives as a separate JSON line).\n\nLOG_FILE=\"/tmp/claude-quick-${TASK_ID:-$$}.log\"\n\n# Via OpenClaw exec — use background=true + pty=true, NO hard timeout\n# pty=true ensures claude CLI flushes output properly (no buffering issues)\n# (hard timeout kills the process; instead we poll and extend)\n# Redirect both stdout and stderr to log file via tee so output is always captured.\n# In -p mode (non-interactive), | tee is safe — no TTY detection issues.\nexec(command=\"claude -p 'fix the typo in README.md' --dangerously-skip-permissions --output-format stream-json 2>&1 | tee -a $LOG_FILE\",\n     workdir=\"/path/to/project\", background=true, pty=true)\n\n\nPTY fallback: If pty=true is unavailable (some containers, CI runners), the command still works because -p mode is non-interactive — it doesn't rely on isatty(stdout). The 2>&1 | tee ensures both stdout and stderr are captured to the log file regardless of PTY status. Without PTY, you lose color output but all content is preserved.\n\nAdaptive Timeout (Poll-and-Extend)\n\nDo NOT use timeout= for claude tasks. Instead, use background execution with periodic polling. This prevents premature kills on long-running tasks:\n\nLaunch with background=true (no timeout)\nPoll every ~5 min with process(action=\"poll\", sessionId=<id>, timeout=300000)\nIf process is still running → check log file for new output\nIf process exited → check exit code and log file, done\nSafety net: if no new output for 12 hours, ask user before killing\nSafety net: if output is repeating (loop detection), ask user\n\nPersistent polling state: Store polling metadata in the task registry so a restarted orchestrator agent can resume monitoring without losing state:\n\nRegistry fields for Quick Mode tasks:\n  \"lastOutputHash\": \"<sha256 of last 20 lines>\",\n  \"lastCheckedAt\": <unix timestamp>,\n  \"silentRounds\": <int>,\n  \"repeatingRounds\": <int>\n\nPoll loop (agent behavior, not a script):\n\n  poll_interval = 5 min (300000 ms)\n  max_silent_rounds = 144  (= 12 hours with no new output → ask user)\n  max_repeating_rounds = 12 (= 1 hour of identical output → likely stuck)\n\n  # Restore state from registry if resuming after agent restart\n  silent_rounds = registry[task_id].silentRounds ?? 0\n  repeating_rounds = registry[task_id].repeatingRounds ?? 0\n  last_output_hash = registry[task_id].lastOutputHash ?? \"\"\n\n  repeat:\n    result = process(action=\"poll\", sessionId=<id>, timeout=300000)\n    if result.completed:\n      → check exit code, read $LOG_FILE, report result\n      → break\n    else:\n      # Read latest output directly from the log file\n      new_output = tail -20 \"$LOG_FILE\"\n      new_hash = sha256(new_output)\n\n      if new_hash != last_output_hash and new_output != \"\":\n        if last_output_hash != \"\" and output_looks_similar(new_output, last_output):\n          repeating_rounds += 1   # output changing but repetitive (loop)\n          silent_rounds = 0\n        else:\n          silent_rounds = 0       # genuinely new output, keep going\n          repeating_rounds = 0\n        last_output_hash = new_hash\n      else:\n        silent_rounds += 1\n\n      # Persist state to registry (survives agent restart)\n      update_registry(task_id, {\n        lastOutputHash: new_hash,\n        lastCheckedAt: now(),\n        silentRounds: silent_rounds,\n        repeatingRounds: repeating_rounds\n      })\n\n      if silent_rounds >= max_silent_rounds:\n        → notify user: \"Claude has been silent for 12 hours, kill or keep waiting?\"\n        → wait for user decision\n      if repeating_rounds >= max_repeating_rounds:\n        → notify user: \"Claude appears stuck in a loop (1h of repeated output), kill or keep waiting?\"\n        → wait for user decision\n\n\nThis way tasks that need 5 min or several hours both work without premature kills.\n\nFull Mode — Features, Bugfixes, Refactors\n\nFor non-trivial tasks, use the full workflow below. This gives you:\n\nIsolated worktree — no conflicts with other work\ntmux session — mid-task steering without killing the agent\nTask tracking — know what's running at all times\nQuality gates — Definition of Done checklist\nSmart retries — don't waste tokens on repeated failures\nFull Workflow: Task → Merged PR\nStep 1: Create Worktree\n\nIsolate each task in its own worktree and branch:\n\nTASK_ID=\"feat-custom-templates\"\nBRANCH=\"feat/$TASK_ID\"\nREPO_ROOT=$(git rev-parse --show-toplevel)\nWORKTREE=\"/tmp/worktrees/$TASK_ID\"\n\ngit worktree add -b \"$BRANCH\" \"$WORKTREE\" origin/main\ncd \"$WORKTREE\"\n\n# Install dependencies (adapt to your stack)\npnpm install   # or: npm install / go mod tidy / pip install -r requirements.txt\n\nStep 2: Launch Agent in tmux\n\nStart Claude Code in interactive mode (no -p) so you can steer mid-task. Important: Use tmux pipe-pane to log output — do NOT use | tee because it turns stdout into a pipe, which breaks interactive mode (claude detects !isatty(stdout) and may disable interactive features, breaking send-keys steering).\n\nCritical: Set up pipe-pane BEFORE sending the command. Otherwise early output (startup messages, fast crashes) is lost.\n\nLOG_FILE=\"/tmp/worktrees/$TASK_ID/claude-output.log\"\nMAX_LOG_SIZE=$((100 * 1024 * 1024))  # 100 MB safety cap\n\n# 1. Create session with an idle shell first\ntmux new-session -d -s \"$TASK_ID\" -c \"$WORKTREE\"\n\n# 2. Start pipe-pane BEFORE the command runs — captures ALL output from the start\n#    Strip ANSI escape codes so log files are clean and grep-parseable\ntmux pipe-pane -t \"$TASK_ID\" -o \"sed 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE\"\n\n# 3. NOW send the command — all output is captured\ntmux send-keys -t \"$TASK_ID\" \"claude --dangerously-skip-permissions \\\n  'Your detailed prompt here.\n\nWhen completely finished:\n1. Commit all changes with descriptive messages\n2. Push the branch: git push -u origin $BRANCH\n3. Create PR: gh pr create --fill\n4. Notify: openclaw system event --text \\\"Done: $TASK_ID\\\" --mode now'\" Enter\n\n\nLog file management: For very long-running tasks, the log file can grow large. Monitor its size and rotate if needed:\n\nLOG_SIZE=$(stat -c%s \"$LOG_FILE\" 2>/dev/null || echo 0)\nif [ \"$LOG_SIZE\" -gt \"$MAX_LOG_SIZE\" ]; then\n  mv \"$LOG_FILE\" \"${LOG_FILE}.old\"\n  # pipe-pane will create a new file on next write\nfi\n\n\nWhy interactive mode (no -p)?\n\nAllows mid-task steering via tmux send-keys\nAgent can be redirected without killing and restarting\n--dangerously-skip-permissions is safe in container/sandbox environments\n\nNote on stdout/stderr: In tmux, both stdout and stderr from the process flow through the PTY and are captured by pipe-pane. They are mixed together — you cannot separate them after capture. For error diagnosis, grep for keywords like error, fail, panic in the clean (ANSI-stripped) log file.\n\nStep 3: Register Task\n\nTrack all active tasks in a JSON registry. Use flock for atomic updates to prevent race conditions when multiple agents run in parallel.\n\nmkdir -p \"$REPO_ROOT/.clawd\"\nTASKS_FILE=\"$REPO_ROOT/.clawd/active-tasks.json\"\n\n# Initialize if not exists\n[ -f \"$TASKS_FILE\" ] || echo '{\"tasks\":[]}' > \"$TASKS_FILE\"\n\n# Get the PID of the claude process inside tmux for reliable status checks\nPANE_PID=$(tmux display-message -t \"$TASK_ID\" -p '#{pane_pid}')\n\n# Register — use flock to prevent concurrent write races\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" --arg branch \"$BRANCH\" --arg wt \"$WORKTREE\" \\\n    --arg pane_pid \"$PANE_PID\" \\\n    '.tasks += [{\n      \"id\": $id,\n      \"agent\": \"claude\",\n      \"branch\": $branch,\n      \"worktree\": $wt,\n      \"tmuxSession\": $id,\n      \"panePid\": ($pane_pid | tonumber),\n      \"status\": \"running\",\n      \"startedAt\": (now|floor),\n      \"pr\": null,\n      \"retries\": 0,\n      \"checks\": {},\n      \"lastOutputHash\": \"\",\n      \"lastCheckedAt\": (now|floor),\n      \"silentRounds\": 0,\n      \"repeatingRounds\": 0\n    }]' \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\"\n\nStep 4: Monitor & Steer\n# --- Process status check (reliable — checks actual process, not just tmux session) ---\n\n# Method 1: Check if the claude process inside the pane is alive\nPANE_PID=$(tmux display-message -t \"$TASK_ID\" -p '#{pane_pid}' 2>/dev/null)\nif [ -z \"$PANE_PID\" ]; then\n  echo \"tmux session gone\"\nelif pgrep -P \"$PANE_PID\" > /dev/null 2>&1; then\n  echo \"running\"\nelse\n  echo \"process exited (tmux session still open)\"\n  # Get exit code from the shell inside tmux\n  tmux send-keys -t \"$TASK_ID\" 'echo \"EXIT_CODE=$?\"' Enter\nfi\n\n# Method 2: Use tmux's pane_dead flag (if remain-on-exit is set)\n# tmux display-message -t \"$TASK_ID\" -p '#{pane_dead}'  # 1 = process exited\n\n# --- View output ---\n\n# Full output history from log file (ANSI-stripped, grep-friendly)\ntail -100 \"/tmp/worktrees/$TASK_ID/claude-output.log\"\n\n# Search for errors in clean log\ngrep -i \"error\\|fail\\|panic\" \"/tmp/worktrees/$TASK_ID/claude-output.log\"\n\n# Live view (raw tmux pane, may contain ANSI codes — use for quick glance only)\ntmux capture-pane -t \"$TASK_ID\" -p -S -50\n\n# --- Mid-task steering (DON'T kill — redirect!) ---\n\n# Agent going the wrong direction?\ntmux send-keys -t \"$TASK_ID\" \"Stop. Focus on the API layer first, not the UI.\" Enter\n\n# Agent missing context?\ntmux send-keys -t \"$TASK_ID\" \"The schema is in src/types/template.ts. Use that.\" Enter\n\n# Agent's context window filling up?\ntmux send-keys -t \"$TASK_ID\" \"Focus only on these 3 files: api.ts, handler.ts, types.ts\" Enter\n\n# Agent needs test guidance?\ntmux send-keys -t \"$TASK_ID\" \"Run 'npm test -- --grep auth' to verify your changes.\" Enter\n\n\nMonitoring cadence: Check every 5-10 minutes, not every 30 seconds. Agents need time to work.\n\nStep 5: Definition of Done\n\nA PR is NOT ready for review until all checks pass:\n\n✅ PR created              → gh pr list --head \"$BRANCH\"\n✅ No merge conflicts       → gh pr view $PR_NUM --json mergeable -q '.mergeable'\n✅ CI passing               → gh pr checks $PR_NUM\n✅ AI code review passed    → at least one cross-model review (see Step 6)\n✅ UI screenshots included  → (if applicable) screenshot in PR description\n\n\nQuick inline check:\n\nPR_NUM=$(gh pr list --head \"$BRANCH\" --json number -q '.[0].number')\necho \"PR: #$PR_NUM\"\ngh pr checks \"$PR_NUM\"\ngh pr view \"$PR_NUM\" --json mergeable -q '.mergeable'\n\nStep 6: Multi-Model Code Review\n\nReview with a different model than the one that wrote the code. Different models catch different issues:\n\nDIFF=$(gh pr diff \"$PR_NUM\")\n\n# Option A: Codex reviews Claude's code (best for edge cases & logic errors)\necho \"$DIFF\" | codex exec -s read-only \\\n  \"Review this PR diff. Focus on: bugs, edge cases, missing error handling, \n   race conditions, security issues. Be specific — cite file and line numbers.\n   Output format: list of issues with severity (critical/warning/info).\"\n\n# Option B: Claude reviews with security focus\necho \"$DIFF\" | claude -p \\\n  --append-system-prompt \"You are a security-focused code reviewer. Flag only critical issues.\" \\\n  \"Review this diff for security vulnerabilities, injection risks, and logic errors.\"\n\n\nPost review results to PR:\n\ngh pr comment \"$PR_NUM\" --body \"## AI Code Review\n\n$REVIEW_OUTPUT\"\n\n\nUpdate task registry:\n\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" \\\n    '(.tasks[] | select(.id == $id)).checks.codeReviewPassed = true' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\"\n\nStep 7: Notify\n\nIf you included the notify command in the agent prompt (Step 2), the agent self-notifies on completion.\n\nOtherwise, notify after DoD passes:\n\nopenclaw system event --text \"✅ PR #$PR_NUM ready for review: $TASK_ID — all checks passed\" --mode now\n\n\nUpdate task status:\n\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" --argjson pr \"$PR_NUM\" \\\n    '(.tasks[] | select(.id == $id)) |= (.status = \"done\" | .pr = $pr | .completedAt = (now|floor))' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\"\n\nStep 8: Cleanup\n\nAfter PR is merged:\n\ngit worktree remove \"$WORKTREE\" 2>/dev/null\ngit branch -d \"$BRANCH\" 2>/dev/null\n\n# Remove from registry\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" '.tasks = [.tasks[] | select(.id != $id)]' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\"\n\nSmart Retry Strategy\n\nWhen an agent fails, analyze the failure and adapt the prompt — don't just re-run blindly.\n\nFailure Type\tSymptom\tRetry Strategy\nContext overflow\tAgent loops, produces garbage, or stops mid-task\tNarrow scope: \"Focus only on files X, Y, Z\"\nWrong direction\tAgent implements something unrelated to intent\tCorrect intent: \"Stop. Customer wanted X, not Y. Spec: ...\"\nMissing info\tAgent makes wrong assumptions about architecture\tAdd context: \"Auth uses JWT, see src/auth/jwt.ts\"\nCI failure\tTests, lint, or typecheck fail after PR\tAttach CI log: \"Fix these test failures: ...\"\nBuild failure\tDependencies missing or incompatible\tPre-install deps before retry\n\nMax 3 retries. After that, escalate to human.\n\nRETRY=$((RETRY + 1))\nif [ \"$RETRY\" -gt 3 ]; then\n  openclaw system event --text \"BLOCKED: $TASK_ID failed after 3 retries — needs human help\" --mode now\n  (\n    flock -x 200\n    jq --arg id \"$TASK_ID\" '(.tasks[] | select(.id == $id)).status = \"blocked\"' \\\n      \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n  ) 200>\"$TASKS_FILE.lock\"\n  exit 1\nfi\n\n# Capture what went wrong — prefer log file over tmux scrollback\nLOG_FILE=\"/tmp/worktrees/$TASK_ID/claude-output.log\"\nif [ -f \"$LOG_FILE\" ]; then\n  # Log file is ANSI-stripped (clean text) — extract error-relevant lines\n  # Take last 500 lines, but also grep for error context\n  FAILURE_LOG=$(tail -500 \"$LOG_FILE\")\n  ERROR_LINES=$(grep -n -i \"error\\|fail\\|panic\\|exception\\|traceback\" \"$LOG_FILE\" | tail -50)\n  if [ -n \"$ERROR_LINES\" ]; then\n    FAILURE_LOG=\"=== Error lines ===\n$ERROR_LINES\n\n=== Last 500 lines ===\n$FAILURE_LOG\"\n  fi\nelse\n  FAILURE_LOG=$(tmux capture-pane -t \"$TASK_ID\" -p -S -200)\nfi\nCI_LOG=$(gh pr checks \"$PR_NUM\" 2>/dev/null || echo \"no PR yet\")\ntmux kill-session -t \"$TASK_ID\" 2>/dev/null\n\n# Archive old log, start fresh for retry\n[ -f \"$LOG_FILE\" ] && mv \"$LOG_FILE\" \"${LOG_FILE}.retry$((RETRY - 1))\"\n\n# Respawn — set up pipe-pane BEFORE sending command (captures all output)\ntmux new-session -d -s \"$TASK_ID\" -c \"$WORKTREE\"\ntmux pipe-pane -t \"$TASK_ID\" -o \"sed 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE\"\ntmux send-keys -t \"$TASK_ID\" \"claude --dangerously-skip-permissions \\\n  'Previous attempt failed. Error output:\n$FAILURE_LOG\n\nCI status: $CI_LOG\n\nFix the issues above and complete the original task.\n[...your enriched instructions here...]\n\nWhen done: commit, push, gh pr create --fill, then run:\nopenclaw system event --text \\\"Done: $TASK_ID (retry $RETRY)\\\" --mode now'\" Enter\n\n# Update registry with flock\nPANE_PID=$(tmux display-message -t \"$TASK_ID\" -p '#{pane_pid}')\n(\n  flock -x 200\n  jq --arg id \"$TASK_ID\" --argjson r \"$RETRY\" --arg pane_pid \"$PANE_PID\" \\\n    '(.tasks[] | select(.id == $id)) |= (.retries = $r | .status = \"running\" | .panePid = ($pane_pid | tonumber) | .silentRounds = 0 | .repeatingRounds = 0 | .lastOutputHash = \"\")' \\\n    \"$TASKS_FILE\" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json \"$TASKS_FILE\"\n) 200>\"$TASKS_FILE.lock\"\n\nParallel Execution\n\nRun multiple agents simultaneously on different tasks. Important: Always set up pipe-pane before sending the command to avoid losing early output. Use ANSI stripping for clean logs.\n\n# Helper: launch an agent in tmux with proper output capture\nlaunch_agent() {\n  local TASK_ID=\"$1\" WORKTREE=\"$2\" PROMPT=\"$3\"\n  local LOG_FILE=\"$WORKTREE/claude-output.log\"\n\n  # 1. Create session with idle shell\n  tmux new-session -d -s \"$TASK_ID\" -c \"$WORKTREE\"\n  # 2. Start pipe-pane BEFORE command (captures everything, ANSI-stripped)\n  tmux pipe-pane -t \"$TASK_ID\" -o \"sed 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE\"\n  # 3. Send command\n  tmux send-keys -t \"$TASK_ID\" \"$PROMPT\" Enter\n}\n\n# Task 1: Feature\ngit worktree add -b feat/auth /tmp/worktrees/feat-auth origin/main\nlaunch_agent \"feat-auth\" \"/tmp/worktrees/feat-auth\" \\\n  \"cd /tmp/worktrees/feat-auth && pnpm install && claude --dangerously-skip-permissions 'Implement JWT auth...'\"\n\n# Task 2: Bugfix\ngit worktree add -b fix/payments /tmp/worktrees/fix-payments origin/main\nlaunch_agent \"fix-payments\" \"/tmp/worktrees/fix-payments\" \\\n  \"cd /tmp/worktrees/fix-payments && pnpm install && claude --dangerously-skip-permissions 'Fix payment webhook...'\"\n\n# Dashboard: check all agents (uses process check, not just has-session)\necho \"=== Agent Status ===\"\nfor s in $(tmux ls -F '#{session_name}' 2>/dev/null); do\n  PANE_PID=$(tmux display-message -t \"$s\" -p '#{pane_pid}' 2>/dev/null)\n  if [ -z \"$PANE_PID\" ]; then\n    STATUS=\"(session gone)\"\n  elif pgrep -P \"$PANE_PID\" > /dev/null 2>&1; then\n    STATUS=\"running\"\n  else\n    STATUS=\"process exited\"\n  fi\n  LOG=\"/tmp/worktrees/$s/claude-output.log\"\n  LAST_LINE=$(tail -1 \"$LOG\" 2>/dev/null || echo \"(no log)\")\n  echo \"  $s: $STATUS | last: $LAST_LINE\"\ndone\n\nMulti-Turn Conversations\n\nFor complex tasks that need iterative refinement:\n\n# Start session, capture ID\nsession_id=$(claude -p \"analyze the codebase architecture\" \\\n  --output-format json | jq -r '.session_id')\n\n# Continue with context from previous turn\nclaude -r \"$session_id\" -p \"now implement the changes we discussed\" \\\n  --dangerously-skip-permissions\n\n# Resume in non-interactive mode\nclaude -r \"$session_id\" -p \"fix the remaining test failures\" \\\n  --dangerously-skip-permissions\n\nBest Practices\nPrompt Quality\nInclude file paths: \"The entry point is src/index.ts, config in src/config/\"\nInclude schemas/types: Paste relevant type definitions into the prompt\nInclude test commands: \"Verify with: npm test -- --grep auth\"\nInclude commit convention: \"Use conventional commits: feat:, fix:, chore:\"\nInclude error logs: When retrying, always attach the failure output\nScope Management\nOne task per agent — don't ask for \"refactor everything\"\nPre-install dependencies before launching the agent\nBe specific — \"Add rate limiting to POST /api/users\" not \"improve the API\"\nWhen to Interrupt (Ask Human)\nDestructive operations (drop tables, force push main)\nSecurity decisions (expose credentials, change auth)\nAmbiguous requirements with significant trade-offs\nAll other decisions: proceed autonomously\nExamples\n\nSee references/examples.md for additional usage scenarios."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/feiskyer/claude-skill",
    "publisherUrl": "https://clawhub.ai/feiskyer/claude-skill",
    "owner": "feiskyer",
    "version": "0.1.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/claude-skill",
    "downloadUrl": "https://openagent3.xyz/downloads/claude-skill",
    "agentUrl": "https://openagent3.xyz/skills/claude-skill/agent",
    "manifestUrl": "https://openagent3.xyz/skills/claude-skill/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/claude-skill/agent.md"
  }
}