Skip to content

code-remover

Code remover — evidence-based dead-code PR

Finds code nothing calls, tries hard to prove it IS used, deletes only what survives — one commit each, suite green after every one — and writes a PR a reviewer can check line by line. Two human gates; dry_run stops before any push.

Source templates/code-remover/workflow.yaml
Category development
Trigger manual (wfx run) · schedule 0 6 * * 1
Steps 13
Human approval before remove, publish
Providers named claude-cli, codex-cli
Terminal window
wfx templates code-remover
wfx new code-remover --as my-code-remover
wfx dryrun my-code-remover

Evidence-based dead-code removal. Machine finders (deadcode, staticcheck U1000, go mod tidy -diff, knip) inventory candidates; machine checks search every tracked file, call shapes, indirect use and history; an agent tries to prove each one is used; a calibrated classifier scores what is left and a decision table decides remove / keep / bug / needs-a-human. After a person approves the plan, each removal is its own commit with the suite green after it, re-proven independently, reviewed by a different model, and described in a PR whose every claim is checked against the evidence. Nothing is pushed until a person approves.

  • scope: point it at one module or directory — cleanup agents do best on a portion of the repo
  • the publish step’s base branch, if your default branch is not what gh reports
  • TYPESAFE_API_KEY in the env store (wfx env set TYPESAFE_API_KEY) for the calibrated verdicts
Input Type Default Required Meaning
repo_path string
repo_url string
base_branch string
scope string "."
max_removals integer 10
pr_prefix string "[dead-code]"
dry_run boolean true
isolate boolean true
# Step Kind Skills Gates
1 baseline
Baseline build and test counts
shell (run:) exitCode = 70 → fail
exitCode = 78 → skip to report
2 inventory
Inventory candidates (dead-code-finder)
shell (run:) exitCode = 70 → fail
exitCode = 78 → skip to report
3 checks
Machine usage checks
shell (run:) exitCode = 70 → fail
4 prove
Prove each candidate IS used (usage-prover)
agent
on claude-cli
usage-prover repo-navigator
5 plan
Judge and plan (JEV + decision table)
shell (run:) exitCode = 70 → fail
exitCode = 78 → skip to report
6 remove
Remove the approved candidates (safe-remover)
agent
on claude-cli
safe-remover human approval first
7 verify
Prove the branch (before vs after)
shell (run:) exitCode = 70 → fail
8 review
Adversarial review on a different model (change-reviewer)
agent
on codex-cli
change-reviewer approved = false → needs_input
9 write_pr
Write the cleanup PR (cleanup-pr-writer)
agent
on claude-cli
cleanup-pr-writer
10 claims
Re-check every claim (JEV) and the numbers
shell (run:) exitCode = 20 → needs_input
exitCode = 70 → fail
11 dry_run_stop
Stop here on a dry run
shell (run:) exitCode = 78 → skip to report
12 publish
Push and open the PR (pr-publisher)
agent
on claude-cli
pr-publisher human approval first
13 report
Report
shell (run:)
  • remove waits for wfx approve <run-id> (or wfx reject <run-id> -m "why") before it runs.
  • publish waits for wfx approve <run-id> (or wfx reject <run-id> -m "why") before it runs.
  • review pauses for input when approved is false: “The codex reviewer blocked the branch: {{ .Output.verdict }}”. Resume with wfx answer <run-id> -m "...".
  • claims pauses for input when exitCode is 20: “PR claims not supported by the evidence — {{ .Output.stdout }}”. Resume with wfx answer <run-id> -m "...".