# Harden Code

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

- Skill: `linardsliepenieks/harden-code` (Agent Skill)
- Install (CLI): `npx skillmds@latest add linardsliepenieks/harden-code`
- Raw SKILL.md: https://api.skillmd.com/api/skills/linardsliepenieks/harden-code/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: LinardsLiepenieks (https://skillmd.com/u/linardsliepenieks)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/linardsliepenieks/harden-code

---


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

1. **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.
2. **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.
3. **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.
