rt-remove-dead-code
Skill576 starsChanged 15 days agoApache-2.0View on GitHub
Deletes provably unreachable code using the repo's wired-in analyzers — whole-program deadcode for Go and knip for the dashboard — plus manual cross-language reachability checks before every deletion. Use when the user asks to run the rt-remove-dead-code routine or sweep for unreachable code.
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- dashboard/AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- lego/AGENTS.mdAGENTS.md
- mobile/AGENTS.mdAGENTS.md
- .pm/AGENTS.mdAGENTS.md
- deploy-app-from-localSkill
- deploy-appSkill
- loopxSkill
- mermaidSkill
- mock-clusterSkill
- pm-brainstormSkill
- pmSkill
- qa-find-bugs-cliSkill
- qa-find-bugsSkill
- releaseSkill
- rt-fix-logic-bugsSkill
- rt-fix-prod-crashesSkill
- rt-flatten-abstractionsSkill
- rt-normalize-abstractionsSkill
- rt-prune-useless-testsSkill
- rt-simplify-logicSkill
- rt-unify-duplicatesSkill
- security-auditSkill
- shipSkill
- simplifySkill
- stripe-best-practicesSkill
- stripe-directorySkill
- stripe-docsSkill
- stripe-projectsSkill
- unblockSkill
- upgrade-stripeSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Delete code that provably cannot run, and only that.
- Distinctive: line 15
After the verification phase, follow the shipping phase below without asking the user to invoke ship separately.
- Very specific: line 19
Every change must pass the verification gates for the modules it touched before being reported as done: operator make test + make lint …
- Very specific: line 20
Run npx prettier@3.4.2 --write on any markdown touched.
- Distinctive: line 21
Before shipping, summarize results in commentary using: Fixed (file:line + one-line rationale) / Deferred (item + why) / Skipped (finding + …
- Distinctive: line 42
Remove confirmed-dead symbols and files together with their now-orphaned tests and imports.
- Very specific: line 46
Run gates for touched modules (deadcode runs inside operator make lint).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Routine: Dead-Code Removal
Delete code that provably cannot run, and only that.
Routine ground rules
- A user request to run this routine authorizes the full cycle: plan, fix, verify, then invoke
$ship(Codex) or/ship(Claude) directly in the same run. Honor explicit user limits such as audit-only or no-ship. - Keep a concise execution plan in the conversation and update it as findings are confirmed. Continue into implementation without a planning approval pause. Do not create or file a
.pmmilestone/task as a prerequisite or substitute for fixing; use the board only if the user requests it. - After the verification phase, follow the shipping phase below without asking the user to invoke ship separately. Preserve the ship skill's branch, conflict-resolution, and safety rules.
- Fix everything you find directly in the working tree. If a fix can't be finished safely in this run, revert only your partial work for that fix and list it under Deferred in the report — never leave the tree half-refactored.
- Scope: parse
$ARGUMENTSper Phase 1 — an optional path/module scope or skill-specific target. No argument = the skill's stated default (usually the whole repo via parallel agents per module: lego/types, lego/operator, lego/backend, lego/cli, dashboard). - False-positive discipline: if a finding is intentional, load-bearing, or ambiguous, skip it with a one-line reason — don't argue it into a change.
- Every change must pass the verification gates for the modules it touched before being reported as done: operator
make test+make lint(fromlego/operator/),cd lego/backend && go test ./...,cd lego/cli && go test ./..., dashboardyarn test+ typecheck. - Run
npx prettier@3.4.2 --writeon any markdown touched. - Before shipping, summarize results in commentary using: Fixed (file:line + one-line rationale) / Deferred (item + why) / Skipped (finding + reason) / Gates (commands run + outcomes).
Phase 1 — Scope
Parse $ARGUMENTS: go | dashboard | a path. Empty = both sides.
Phase 2 — Run the analyzers
- Go — exactly what CI runs:
cd lego/operator && make deadcode && bash hack/deadcode.sh "$PWD/bin/deadcode"(the pinneddeadcode, run per module with-tags=e2e -testand the sharedtypesfindings intersected; see the script header).make lintruns the same script after golangci-lint. - Dashboard —
cd dashboard && yarn lint:unused(knip; config indashboard/knip.jsonc).
Phase 3 — Triage every hit
Before deleting anything:
- Public API surface, CRD types, generated code (
zz_generated*, codegen outputs), and entry points → skip. - Helpers used only by the env-gated
t.Skiptests (envtest/e2e/live guards — there are ~87 of them) are NOT dead; check the skipped tests before believing the tool. - Grep the symbol repo-wide, including cross-language edges the analyzers can't see: dashboard clients,
scripts/, workflow YAML, docs examples.
Phase 4 — Delete
Remove confirmed-dead symbols and files together with their now-orphaned tests and imports. Re-run both analyzers; repeat until the output is clean or every remaining hit has a one-line skip reason.
Phase 5 — Verify and report
Run gates for touched modules (deadcode runs inside operator make lint); dashboard also needs a clean yarn lint:unused. Report per the standard format.
Final phase — Ship
After all required gates pass, read and execute the ship skill for the routine's completed changes. Stage only intended changes from this run; preserve unrelated work. Do not end at a plan, findings report, milestone, or request for shipping approval. If there are no changes, report that outcome without creating an empty commit. If a required gate remains blocked or fails after reasonable repairs, report the exact blocker and do not ship unverified changes.
Once the push succeeds, report the shipped HEAD SHA and subject per the ship skill and stop; do not monitor CI or deployment.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

