AgentSkillsCN

self-repair

当用户需要对 crocbot 的代码库进行修复、复杂重构,或深入探索 crocbot 项目结构时,可借助 Claude Code 作为高思考力、低预算的辅助代理,安全地完成代码修复、结构优化与深度探索任务。

SKILL.md
--- frontmatter
name: self-repair
description: Fix, explore, and refactor the crocbot codebase safely using Claude Code as a high-thinking-budget sub-agent. Use when the user requests codebase repairs, complex refactors, or deep exploration of the crocbot project structure.

Self Repair

This skill enables crocbot to safely repair and refactor its own codebase using Claude Code (claude) as a high-thinking-budget sub-agent.

Overview

Self-repair uses a specialized command configuration to ensure Claude Code operates with maximum analytical depth and bypasses routine permission prompts to maintain momentum during autonomous sessions.

Workspace Awareness

The sub-agent is aware of two critical paths:

  1. Source Code: {projectRoot} (where repairs/exploration happen)
  2. Identity Workspace: {workspaceDir} (where research, reports, and persistent documentation are stored)

Workflow

1. Launching a Repair or Research Session

Always use the following command structure. Replace <instructions> with the specific task.

bash
# Launch Claude Code with high thinking budget and identity workspace awareness
# Always use pty:true and background:true for autonomous work
bash pty:true workdir:{projectRoot} background:true command:"claude -p 'Use maximum thinking budget for this prompt and make sure you output a detailed summary end of response. You have permission to write files directly to my identity workspace at {workspaceDir}/ for reporting or research purposes. Instructions: <instructions>' --dangerously-skip-permissions"

2. Full Lifecycle (Repair, Build, Redeploy)

When a sub-agent is tasked with modifying the code, it must follow this completion sequence:

  1. Modify Code: Apply the requested fixes/refactors.
  2. Build: Run pnpm build to ensure the changes are valid and compiled.
  3. Redeploy: Once the build succeeds, it must restart the gateway service:
    bash
    systemctl --user restart crocbot-gateway
    
  4. Continuity: The sub-agent should understand that restarting the gateway will terminate its parent session. It should finalize its report/summary BEFORE the restart command.

2. Monitoring Progress

Once the session is launched, monitor the output using the process tool:

bash
# Check logs
process action:log sessionId:XXX

# Check if finished
process action:poll sessionId:XXX

3. Verification

Once the sub-agent completes the task, review the summary provided by Claude Code to verify the changes.

Safety Rules

  • Targeted Scope: Always set the workdir to {projectRoot}.
  • Deduplication: Before starting a new repair session, check process action:list to ensure a similar session isn't already running.
  • Reporting: Always provide the user with the final "detailed summary" generated by Claude Code.