# Self Repair

> 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. Use when this capability is needed.

- Skill: `tomevault-io/self-repair` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/self-repair`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/self-repair/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/self-repair

---


# 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.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/moshehbenavraham) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

