Harden Codebase
Scope: $ARGUMENTS (default: full)
Systematic quality tightening. Nine phases, each with a clear gate.
KISS: tighten one level at a time — never jump to max strictness.
Phase 1: ARCHITECTURE (read-only)
- Identify entry points, module boundaries, and dependency flow
- Map layering: which modules depend on which?
- Flag circular dependencies and boundary violations
- Output module map as indented text tree (plain markdown, no diagrams)
- Note undocumented coupling, god modules, misplaced responsibilities
Gate: Module map + issue list. Present to user before
proceeding.
Phase 2: AUDIT (read-only)
- Does
make setup_all (or equivalent) work from scratch?
- What lint rules are enabled? Gap vs recommended?
See
references/lint-tightening-checklist.md
- Type checker strictness level?
- Do tests pass? Are slow/hardware tests filtered?
- Is check-only gate separate from auto-fix?
Gate: Issue list ranked HIGH/MEDIUM/LOW. Present to user before
proceeding.
Phase 3: TIGHTEN (config only — no code changes)
- Enable next-level lint rules (baseline → recommended, not strict)
- Bump type checker one level
- Split auto-fix from check-only gate if missing
- Add test marker filters for slow/hardware/network
- Count new violations — report before fixing
Gate: Config committed. Violation count known.
Phase 4: FIX (mechanical)
- Run auto-fix
- Fix remaining violations manually
- Update tests broken by signature changes
make validate must pass
Gate: All checks green. Commit fixes.
Phase 5: DOCS QUALITY
- Does README exist and reflect current state?
- Are public APIs documented (docstrings, JSDoc, rustdoc)?
- Are architecture decisions recorded (ADRs or equivalent)?
- Do inline comments explain why, not what?
- Are there stale/misleading docs that contradict the code?
- Enforce KISS in docs — no walls of text, no redundant sections
- Enforce DRY — single source of truth, no copy-pasted explanations
- Enforce YAGNI — remove docs for features that don't exist
Gate: Docs findings list. Present to user before fixing.
Phase 6: TEST OVERHAUL (meaningful tests only)
- Classify every test: behavioral / implementation / trivial
- Rewrite implementation tests as behavioral (assert outcomes, not internals)
- Delete trivial tests that add no value
- Add missing behavioral tests for error recovery, state transitions, edge cases
- Add property-based tests (Hypothesis) for invariants
- Add complexity gate (complexipy, max 15/function)
make validate must pass with coverage gate
Gate: All tests behavioral. Coverage ≥ 80%. Complexity ≤ 15.
Phase 7: REVIEW (4 parallel agents)
Launch all four from references/review-agents.md:
- Reuse: duplication, missing shared helpers
- Quality: boundary violations, magic strings, abstractions, bugs
- Efficiency: unnecessary work, missed caching
- KISS/DRY/YAGNI: over-engineering, dead code, speculative features, deletion candidates
Gate: Ranked findings presented to user.
Phase 8: REFACTOR (apply findings)
- Fix HIGH and MEDIUM only (80/20)
- Skip LOW unless trivial
make validate after each fix
- Commit by topic
Gate: All checks green. Findings addressed.
Phase 9: SHIP
- Push branch
- Create PR with summary + test plan
Scope shortcuts
arch — Phase 1 only (architecture research + module map)
audit — Phase 2 only (read-only report)
tighten — Phases 2-4 (config + fix)
docs — Phase 5 only (docs quality)
tests — Phase 6 only (test overhaul)
review — Phase 7 only (4-agent review)
fix — Phase 8 only (apply existing findings)
full — All phases
References
See references/lint-tightening-checklist.md for language-specific
rule progressions and references/review-agents.md for agent prompts.
1---2name: hardening-codebase3description: Audit and tighten codebase quality gates — architecture, lint, types, tests, docs, code review. Use when onboarding a project, before a release, or when validation is too permissive.4---56# Harden Codebase78**Scope**: $ARGUMENTS (default: full)910Systematic quality tightening. Nine phases, each with a clear gate.11KISS: tighten one level at a time — never jump to max strictness.1213## Phase 1: ARCHITECTURE (read-only)14151. Identify entry points, module boundaries, and dependency flow162. Map layering: which modules depend on which?173. Flag circular dependencies and boundary violations184. Output module map as indented text tree (plain markdown, no diagrams)195. Note undocumented coupling, god modules, misplaced responsibilities2021**Gate**: Module map + issue list. Present to user before22proceeding.2324## Phase 2: AUDIT (read-only)25261. Does `make setup_all` (or equivalent) work from scratch?272. What lint rules are enabled? Gap vs recommended?28 See `references/lint-tightening-checklist.md`293. Type checker strictness level?304. Do tests pass? Are slow/hardware tests filtered?315. Is check-only gate separate from auto-fix?3233**Gate**: Issue list ranked HIGH/MEDIUM/LOW. Present to user before34proceeding.3536## Phase 3: TIGHTEN (config only — no code changes)37381. Enable next-level lint rules (baseline → recommended, not strict)392. Bump type checker one level403. Split auto-fix from check-only gate if missing414. Add test marker filters for slow/hardware/network425. Count new violations — report before fixing4344**Gate**: Config committed. Violation count known.4546## Phase 4: FIX (mechanical)47481. Run auto-fix492. Fix remaining violations manually503. Update tests broken by signature changes514. `make validate` must pass5253**Gate**: All checks green. Commit fixes.5455## Phase 5: DOCS QUALITY56571. Does README exist and reflect current state?582. Are public APIs documented (docstrings, JSDoc, rustdoc)?593. Are architecture decisions recorded (ADRs or equivalent)?604. Do inline comments explain *why*, not *what*?615. Are there stale/misleading docs that contradict the code?626. Enforce KISS in docs — no walls of text, no redundant sections637. Enforce DRY — single source of truth, no copy-pasted explanations648. Enforce YAGNI — remove docs for features that don't exist6566**Gate**: Docs findings list. Present to user before fixing.6768## Phase 6: TEST OVERHAUL (meaningful tests only)69701. Classify every test: behavioral / implementation / trivial712. Rewrite implementation tests as behavioral (assert outcomes, not internals)723. Delete trivial tests that add no value734. Add missing behavioral tests for error recovery, state transitions, edge cases745. Add property-based tests (Hypothesis) for invariants756. Add complexity gate (complexipy, max 15/function)767. `make validate` must pass with coverage gate7778**Gate**: All tests behavioral. Coverage ≥ 80%. Complexity ≤ 15.7980## Phase 7: REVIEW (4 parallel agents)8182Launch all four from `references/review-agents.md`:8384- **Reuse**: duplication, missing shared helpers85- **Quality**: boundary violations, magic strings, abstractions, bugs86- **Efficiency**: unnecessary work, missed caching87- **KISS/DRY/YAGNI**: over-engineering, dead code, speculative features, deletion candidates8889**Gate**: Ranked findings presented to user.9091## Phase 8: REFACTOR (apply findings)92931. Fix HIGH and MEDIUM only (80/20)942. Skip LOW unless trivial953. `make validate` after each fix964. Commit by topic9798**Gate**: All checks green. Findings addressed.99100## Phase 9: SHIP1011021. Push branch1032. Create PR with summary + test plan104105## Scope shortcuts106107- `arch` — Phase 1 only (architecture research + module map)108- `audit` — Phase 2 only (read-only report)109- `tighten` — Phases 2-4 (config + fix)110- `docs` — Phase 5 only (docs quality)111- `tests` — Phase 6 only (test overhaul)112- `review` — Phase 7 only (4-agent review)113- `fix` — Phase 8 only (apply existing findings)114- `full` — All phases115116## References117118See `references/lint-tightening-checklist.md` for language-specific119rule progressions and `references/review-agents.md` for agent prompts.