Skill v1.0.0
currentAutomated scan100/100name: heal-scan description: > Phase 1 of 4 in the heal chain. Hunts for bugs in the current project — failing tests, lint and type errors, silent failures, suspicious error handling, dead code paths, and TODO/FIXME/HACK markers — and records every finding in the chain state file. Use this whenever the user wants to find bugs, audit code health, or start healing a codebase. Trigger: "heal-scan", "start the heal chain", "find bugs in this project", "scan this codebase for bugs", "health check this code". metadata: version: "1.0.0"
Heal: Scan
Chain version: 1
Phase 1 of 4: scan → plan → fix → verify
Overview
Finds bugs and code-health problems across the project and writes a structured findings table to the chain state file so the plan phase can prioritize them. This phase is read-only — it never modifies project code.
Quality bar: every finding must name what actually goes wrong at runtime and carry evidence someone else could reproduce (a failing command, or file:line plus a code excerpt). If you can't say what breaks, it's not a finding — drop it. 15 real bugs beat 100 vague smells.
Workflow
Step 1 — Initialize State
This is phase 1, so there is no previous phase to check. If .heal-state.md already exists in the project root:
- With
status: complete→ ask the user whether to start a fresh run (overwrite)
or stop. On a fresh run, read HEAL-REPORT.md if present — its follow-up list seeds this scan.
- Mid-flight (any other status) → ask whether to resume that run (point them at
the next phase for its status) or restart from scratch.
Check for .heal-state.lock — if present, another session may be running this chain. Abort with: "Another session appears to be running the heal chain (lock file present). Remove .heal-state.lock if that's stale."
Create .heal-state.lock, then atomically write a fresh .heal-state.md (temp file + rename, never in-place):
---task: "find bugs and heal this codebase"started: <ISO 8601 timestamp>status: in-progresschain_version: 1---
Step 2 — Detect the Project and Record the Baseline
Identify languages, test runner, linter, type checker, and build command from config files (package.json scripts, pyproject.toml, Cargo.toml, go.mod, Makefile, CI config, etc.). Prefer the project's own script names (npm test, make test) over guessing the underlying tool.
Run each discovered command now and record the exact command and its counts — this baseline is what phase 4 diffs against:
- Tests: command, pass/fail/skip counts
- Type check: command, error count
- Lint: command, error count (correctness classes only)
- Build: command, success or first error
If the project has no test suite, that is itself a finding (severity high): record it, note that verification will be manual, and lean harder on the static passes below. Never invent a test command that doesn't exist. If a command hangs or needs missing dependencies, record "unavailable: <reason>" — don't stall the scan.
Step 3 — Scan
Run each applicable pass and collect findings. Do not fix anything. Skip vendored and generated code (vendor/, node_modules/, dist/, build/, .venv/, target/, *.min.js, lockfiles) and say so in the state file.
- Test suite — every failure from the baseline run is a finding: test
name, assertion or error text.
- Type checker / compiler — every error is a finding. Group repeats of the
same root cause into one finding.
- Linter / static analysis — errors and correctness-class warnings (unused
results, shadowing, unreachable code, undefined names); skip style nits.
- Silent-failure sweep — grep for swallowed errors, per language:
- JS/TS: empty or log-only
catchblocks;.catch(() => {});
@ts-ignore / @ts-expect-error / as any hiding real errors; async calls whose promise is dropped (floating call of an async function where the result matters); JSON.parse without try/catch on external input.
- Python:
except: passand bareexcept:;except Exceptionthat
only logs and continues on a path that needs the result; mutable default args (def f(x=[])); assert used for runtime validation.
- Go:
_ =discarding an error return;if err != nil {}empty bodies. - Rust:
.unwrap()/.expect()in non-test code on fallible external
input; let _ = discarding a Result.
- Dart/Flutter: empty
catch (e) {};// ignore:directives on
correctness lints; unawaited futures in sequential logic.
- Shell: scripts without
set -e(or equivalent) that chain critical
commands; unquoted variable expansions in paths. A match is only a finding if swallowing the error actually loses data, corrupts state, or hides a failure the caller needs to see — read the surrounding code before recording it.
- Marker sweep — TODO, FIXME, HACK, XXX, BUG comments that describe known
defects (not feature wishes).
- Deep logic review — pick the highest-value files and read them fully,
not skimmed. If a git repo: rank by churn (git log --format= --name-only --since="90 days ago" | sort | uniq -c | sort -rn | head) plus anything currently uncommitted; otherwise pick the core modules by imports. Look for: off-by-one loops, inverted or always-true conditions, unhandled null/None/undefined paths, resources opened but not closed, shared state mutated without synchronization, wrong operator (=/==, and/or), copy-paste blocks where one copy wasn't updated.
Assign each finding an ID (B1, B2, …) and a severity:
- critical — data loss, corruption, crash on a normal path, or security
hole
- high — wrong behavior on a common path, or a failing test / broken build
- medium — wrong behavior on an edge path, or an error silently swallowed
where it matters
- low — latent hazard that needs an unlikely trigger
Step 4 — Update State
Atomically rewrite .heal-state.md with status: phase-1-done, the baseline, and the findings:
---task: "find bugs and heal this codebase"started: <same timestamp>status: phase-1-donechain_version: 1---## Phase 1 — Scan**Output**: <N> findings — <counts by severity>; test suite <pass/fail summary>**Key decisions**: <what was skipped and why; which passes had no tooling>### Baseline| Check | Command | Result ||---|---|---|| tests | npm test | 142 pass / 3 fail / 1 skip || types | npx tsc --noEmit | 5 errors || lint | npx eslint src | 2 errors || build | npm run build | ok || ID | Severity | File | Line | Finding | Evidence ||---|---|---|---|---|---|| B1 | high | src/api.py | 108 | race condition on retry | test_retry flakes 3/10 runs || ... | ... | ... | ... | ... | ... |
Delete .heal-state.lock.
Handoff
After completing this phase, output exactly:
Phase 1 complete. State written to.heal-state.md.Run/heal-planto begin Phase 2.
Do not start the next phase. Do not offer to continue. Output only the handoff line and stop.