Harden recently-changed code
An iterative reliability loop over the code changed this session: three specialists advise, you decide and apply every fix, re-run until the code is free of crashes and data-loss risks. The specialists are read-only; you keep final judgment.
Each iteration:
Fan out 3 angles in parallel, same files, fixed set:
- A. Data safety: lost writes, destructive migrations, races on persisted state.
- B. Crashes: null/undefined derefs, unhandled exceptions, broken control flow.
- C. Contracts: changed signatures, schemas, event payloads, config keys.
Agent team if enabled (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS): 1 teammate/angle, persistent across rounds, cross-check each other, keeping only findings that reproduce on a concrete path. Else: 3 parallel sub-agents, no cross-check.
Triage the merged, deduped findings: use judgment on severity and blast radius. Fix what's clearly safe to fix. Stop and check with the user on anything ambiguous, risky, or that could break another caller; show the file and what would change. Dismiss non-issues in one line, and if you disagree with something a teammate flagged as serious, say why.
Re-run on changed files.
Prompt framing. Phrase specialist prompts defensively, never as attacker hypotheticals: "could a malicious user bypass…" style language can trip safety checks even on your own code. Say "verify the access check is correct," not "find a bypass." For an actual security pass, use /security-review instead of adding a fourth angle here.
Exit
Stop when any of:
- Clean: nothing left to fix or confirm, tests passing (the Stop hook confirms; no exit if tests fail).
- Cap: 5 iterations done. Report what remains; don't silently loop.
- No convergence: the count of open findings didn't strictly decrease between two consecutive iterations. A fix likely introduced a new issue, or findings are contested. Stop and escalate.
1---2name: harden-code3description: Iteratively hunts for crashes, data loss, and unintended contract changes in recently-changed files by running three reliability specialists in parallel (an agent team when enabled, otherwise sub-agents), re-running until no breaking findings remain. Use after a refactor or feature, or when the user says "harden", "audit for bugs", or "review for reliability".4---56# Harden recently-changed code78An iterative reliability loop over the code changed this session: three specialists advise, you decide and apply every fix, re-run until the code is free of crashes and data-loss risks. The specialists are read-only; you keep final judgment. 9Each iteration:10111. **Fan out 3 angles in parallel**, same files, fixed set:12 - **A. Data safety:** lost writes, destructive migrations, races on persisted state.13 - **B. Crashes:** null/undefined derefs, unhandled exceptions, broken control flow.14 - **C. Contracts:** changed signatures, schemas, event payloads, config keys.1516 Agent team if enabled (`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`): 1 teammate/angle, persistent across rounds, cross-check each other, keeping only findings that reproduce on a concrete path. Else: 3 parallel sub-agents, no cross-check.172. **Triage** the merged, deduped findings: use judgment on severity and blast radius. Fix what's clearly safe to fix. Stop and check with the user on anything ambiguous, risky, or that could break another caller; show the file and what would change. Dismiss non-issues in one line, and if you disagree with something a teammate flagged as serious, say why.183. **Re-run** on changed files.192021**Prompt framing.** Phrase specialist prompts defensively, never as attacker hypotheticals: "could a malicious user bypass…" style language can trip safety checks even on your own code. Say "verify the access check is correct," not "find a bypass." For an actual security pass, use `/security-review` instead of adding a fourth angle here.2223## Exit2425Stop when any of:2627- **Clean**: nothing left to fix or confirm, tests passing (the Stop hook confirms; no exit if tests fail).28- **Cap**: 5 iterations done. Report what remains; don't silently loop.29- **No convergence**: the count of open findings didn't strictly decrease between two consecutive iterations. A fix likely introduced a new issue, or findings are contested. Stop and escalate.