Add the Dead Code skill with hash-matched keep rows and one tool per language

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-09 22:09:05 -08:00
1 parent 7891c06642
commit a584c45dfd
43 files changed
+3398 -49

No files matched your search

@@ -0,0 +1,73 @@
# Caller Search
> Part of plan2code-dead-code: read in Step 4 before the caller search, and given to every helper that searches. Never invoked as a skill.
A candidate is dead only when nothing in the whole project reaches it. Search the whole project, never only the folder the run covers, and search for more than the plain name: the lists below are what else can reach an item in each language group. Include tests, scripts, config files, docs that act as config (an OpenAPI file, a route table, a cron file) and generated glue (bindings, stubs, registration files).
## Every language
- The plain name, as a whole word, in every text file, not only in source files of the same language.
- The name inside strings and templates: config keys, JSON and YAML values, SQL, HTML attributes, environment files.
- Build files, CI configs, `Dockerfile`, `Makefile`, package scripts and shell scripts that call a file or a function by name.
- A file candidate: its path and its file name without the extension, anywhere.
- Record what each search found in `callers`, even when it found nothing ("no match outside its own file").
## JavaScript and TypeScript
- Re-exports: `export * from`, `export { x } from`, and the barrel files (`index.js`, `index.ts`) that pass a name on.
- Dynamic `import()` with a string or template path, and `require()` with a computed path.
- `package.json` `exports`, `main`, `module`, `bin` and `types`; a workspace's other packages that import this one.
- Framework conventions that load by file name: route folders (`pages/`, `app/`, `routes/`), `*.config.*` files, test setup files.
- Names reached by string: `obj[name]`, event names, `customElements.define`, decorators.
## Python
- `__all__` lists, and `from module import *` that brings them in.
- `getattr`, `importlib.import_module`, `__import__` and string paths such as `"package.module:func"`.
- Decorators that register a function (routes, CLI commands, signal handlers, pytest fixtures used by name).
- Entry points in `pyproject.toml`, `setup.cfg` and `setup.py` (`console_scripts`, plugin groups), and `manage.py` or framework settings that name a module.
## Rust
- `pub use` re-exports and the crate's public API in `lib.rs`.
- Macros that expand to a call (`macro_rules!` bodies, derive and attribute macros).
- `#[cfg(...)]` and feature flags: an item used only under a feature or a target is still used.
- `mod` declarations, `#[path]` attributes, `build.rs`, and binaries under `src/bin/` or `[[bin]]` in `Cargo.toml`.
## Go
- Exported names (capitalized) used from another package or module in the workspace.
- Interface satisfaction: a method with no direct caller may make a type meet an interface used elsewhere.
- `init()` functions, blank imports (`import _ "pkg"`) that run them, and `//go:generate` lines.
- Build tags and file-name suffixes (`_linux.go`, `_test.go`), and reflection (`reflect`, `MethodByName`, struct tags read at runtime).
## Java and Kotlin
- Reflection: `Class.forName`, `getMethod`, `getDeclaredField`, and names in strings.
- Annotations that register or call: `@Bean`, `@Component`, `@Controller`, `@RequestMapping`, `@Test`, `@JsonCreator`, `@Subscribe`, `main` methods.
- Spring and other dependency injection: XML configs, `application.properties` and `application.yml`, component scanning by package.
- `META-INF/services` files, `AndroidManifest.xml`, Gradle and Maven files that name a class, and Kotlin `@JvmStatic` or `companion object` members called from Java.
## C#
- Reflection: `Type.GetType`, `GetMethod`, `Activator.CreateInstance`, `nameof` used as a key.
- Attributes that register or call: `[HttpGet]`, `[Route]`, `[Fact]`, `[Test]`, `[JsonConstructor]`, `[DllImport]`.
- Dependency injection registration (`AddScoped`, `AddTransient`, `AddSingleton`, assembly scanning) and `appsettings.json`.
- Serialization: properties set only by a serializer, and `.csproj`, `.xaml` and `.razor` files that name a type or handler.
## Ruby
- `send`, `public_send`, `method`, `define_method` and `respond_to?` with a symbol or string.
- `constantize`, `const_get` and class names built from strings.
- Rails autoloading and conventions: controllers and actions reached through `config/routes.rb`, callbacks (`before_action`, `after_save`), helpers, jobs, mailers, views that call a helper, and concerns.
- Rake tasks, `Gemfile` and gemspec `executables`, and initializers.
## PHP
- Composer autoload (`psr-4`, `classmap`, `files`) and `bin` entries in `composer.json`.
- `class_exists`, `method_exists`, `call_user_func`, variable functions (`$fn()`) and `new $class`.
- Routes and container config: framework route files, service container definitions (YAML, XML, PHP arrays), event listeners and middleware lists.
- Templates (Blade, Twig) that call a function or helper by name, and attributes such as `#[Route]`.
## Any other language
Search the plain name, strings and config as in "Every language", say which of the language's dynamic features you could not cover, and leave the finding at Check first.
File diff suppressed because it is too large. Load diff
+157
View File
@@ -0,0 +1,157 @@
# 💀 DEAD CODE MODE
Start all DEAD CODE MODE responses with '💀 [DEAD CODE]'
## Role
Finds unused code paths and dead code in the person's own project. Shows each finding with its evidence and a label that says how safe it is to remove, removes only the findings the person picks, then runs the project's tests and build. **Never commits, pushes or stages**, never installs an outside tool, and does no code review of its own (that is the Review skill's job).
## Interface
The FIRST thing you do, before anything else in this file, before running a script: ask **web console** (browser page, suggested) or **terminal**? Console → run `node "<D>/console.mjs" open --workflow dead-code` before reading (<D>: references/web-console/ beside this SKILL.md (~/.agents/skills/plan2code-dead-code/references/web-console/ globally) or the dir in ~/.plan2code/console/console-dir), then read <D>/console.md and <D>/notes/dead-code.md. The start questions, the findings list, the checks, the report and the save offers all go through it. Switchable anytime. If the argument already says which (`--web` or `Use the web console for this session.`), take it and do not ask; drop the flag. Launched by the dashboard? Its session is already open: resume it (console-launches.md), then Project Context.
## Project Context
Read `./AGENTS.md` when it exists: its commands, its `## Test map` and anything it says about slow suites or code reached by name. Dead Code still works without one, but the test map is what tells it which tests and build to run after a removal; without it the scripts read the project's config files, and the person confirms the commands.
## Scripts
`<S>` is `scripts/` beside this SKILL.md (`~/.agents/skills/plan2code-dead-code/scripts/` globally). Run from the project root. Each prints one JSON object; on a non-zero exit read `message` and do what `next` says.
- `node "<S>/dead-code.mjs" detect [--scope <dir>]`: the dead-code tools the project already has (`tools`: `id`, `language`, `marker`, `available`, `command`, `format`), `languages` with file counts, `sourceFiles`, and `overLimit` (a very big project).
- `node "<S>/dead-code.mjs" run --tool <id> [--scope <dir>]`: runs that tool with a timeout and prints `candidates` (`file`, `line`, `name`, `kind`, `rule`, `message`), or `unparsed: true` with the output's `tail`.
- `node "<S>/dead-code.mjs" narrow --candidates <file>`: `folders` ranked by candidate count.
- `node "<S>/dead-code.mjs" keep list|filter|add|remove`: the shared keep list, `.plan2code-dead-code/keep.md`. `filter [--fresh]` reads candidates on stdin and prints `shown`, `hidden`, `kept` and `changed`; `add --file --reason` with `--name --line` for an item, and neither for a whole unused file; `remove --file --name`, plus `--hash` or `--line` when two rows share a name.
- `node "<S>/dead-code.mjs" backup <files...> [--run <id>]` and `restore --run <id> [--files <f>...] [--verify]`: copies outside the project and a checked put-back.
- `node "<S>/dead-code.mjs" report write --findings <file>`: saves `.plan2code-dead-code/reports/DEAD-CODE-<date>.md`, only on a yes.
- `node "<S>/dead-code.mjs" gitignore-check` and `gitignore-add`: whether `reports/` is ignored, and adding the line, only on a yes.
- `node "<S>/test-map.mjs" read`: the project test map (`found`, `rows` of `area`, `paths`, `run`, `shared`, and `problems`).
- `node "<S>/test-commands.mjs" discover`: the project's commands from its config files: `suite`, `runners` (`cmd`, `cwd`, `covers`), `checks` (`kind` lint, types or build, with `cmd`), `builtin`.
- `node "<S>/run-check.mjs" --cmd <c> --cwd <d> --timeout <s> --log <file>`: runs one check and prints `outcome` (`passed`, `failed`, `timeout`, `not-started` with a `reason`), `exit`, `seconds` and `tail`.
## References
- `references/caller-search.md`: what to search besides the plain name, per language group. Read it before Step 4.
- `references/helper-strength.md`: helper strength and effort.
## Rules
- Follow `./AGENTS.md` when it exists.
- **Never** run `git commit`, `git push`, `git add` or `git stash`. Read-only git is fine. The changes stay unstaged for the person to look at.
- **Never install anything**: no `npm install`, `pip install`, `cargo install`, `go install` or download of a tool. A tool the project already has may be run.
- **Write only** code removals, `.plan2code-dead-code/keep.md`, and, on a yes, the saved report and the `.gitignore` line.
- **Nothing is removed before the person picks it.** Nothing is pre-ticked.
- **Silence is not proof.** A finding reaches Safe only when a tool listed it and the caller search agrees.
- **Never partial without saying so.** A narrowed or stopped run says what was and was not checked, and is never called complete.
- **Record honestly.** A check that did not run is never reported as passed.
- US English. No em dashes in any text you write (report, keep reasons, page text). Plain words: name the file, the item and the command.
## Helpers
When your tool can start helpers (subagents) and they are not switched off for this run (on the web console a `Subagents:` block says which, console-subagents.md): the caller search (Step 4), one helper per batch of candidates, each given `references/caller-search.md` and returning, per candidate, what it searched and what it found, never a label. Light strength, low effort, per references/helper-strength.md. Keep the labels, the Safe call, the removals, the checks and every question with you. No helpers? Do the same work yourself.
## Process
### Step 1: Start questions
Run `detect` and `keep list` first, then ask on one card, answered together:
1. **Method.** A tool counts only when its `language` has files in `detect`'s `languages`. Pick one available tool (`available: true`) per language group, preferring one the script reads (`format` other than `agent`) over one you read by hand. With a tool picked: use the project's tool or tools and verify their lists with a caller search (default), or also do a full search of our own. Say each tool used and its `marker`; with several groups each having a tool, one option names them all ("Knip and vulture, checked by a caller search"). A group with no available tool (say which and why) gets a search of our own (Step 3). When no group has one: skip this question and say the run is a search of our own, so every finding is Check first.
2. **Scope.** The whole project (default) or a folder the person names. A folder: run `detect --scope <dir>` again and use its `overLimit` and `sourceFiles` from here on.
3. **Keep list.** When `keep list` has entries: say how many, and offer to use it (default) or do a fresh scan that ignores it. Leave this out when it has none.
4. **Size.** When `overLimit` is true: say the project has `sourceFiles` source files and that a narrow step may follow once the starting list is in (Step 2), and that picking a smaller folder skips it.
The answers are final for the run. A this-branch-only mode is not offered yet.
### Step 2: Scope and size
The scope picks which findings are reported, never where callers are searched: the caller search always covers the whole project, so a folder run never calls something dead that another folder uses.
When `overLimit` is true: run the tool (Step 3), write its `candidates` to a file in the session folder (`open` printed it; in the terminal, the OS temp folder) and run `narrow --candidates <file>`. Ask the person to narrow first, listing the five `folders` with the most candidates, and offer the whole project with a plain warning that it takes longer and costs more. With no tool, list the five biggest top-level source folders instead. Once the person picks, keep only the candidates whose `file` is under the pick (or rerun `run --scope <dir>`), set the report's `scope` to it and put the rest in `notChecked`. Helpers split the work inside what the person picks. Whatever is chosen, the report says so: a narrowed run is `ranFrom: "narrowed"` with what was left out in `notChecked`, never complete.
### Step 3: The starting list
**With a tool:** `run --tool <id>` (add `--scope <dir>` for a folder run), once per chosen tool. Merge their candidates into one list (the same `file`, `line` and `name` from two tools is one candidate); the merged list is what goes to `keep filter`.
- `unparsed: true`: read the `tail` yourself, write the candidates by hand in the same shape, and say the tool's output was read by the agent, not the script.
- A tool that fails, times out or cannot start: report it as missing in one line and continue as a search of our own.
- With the full-search choice, also make your own list (below) and merge it: an item both found is source `both`.
**With no tool, or none for a language in scope:** find candidates yourself: exports, functions, classes, methods and whole files that nothing references. Their source is `own`, every one stays Check first or Warning, and the report and the page say plainly that no tool confirmed them.
Never install, `npm install`, `pip install` or fetch a tool to get a list.
**The keep list, for every candidate.** Whatever the source (the script's `candidates`, ones you wrote from `tail`, the merged full search, or your own list), write the final list as one JSON array and pipe it to `keep filter` (`--fresh` when the person chose a fresh scan). Work on `shown`; the number of `hidden` entries is the hidden count. A shown candidate with `wasKept: true` was kept before but its code changed since: say so in its detail. A `kept` entry marked `gone` is offered for removal from the list in Step 8.
### Step 4: Verify with a caller search
Read `references/caller-search.md`. For each candidate, search the whole project for callers: the plain name, names inside strings, config files, tests, docs that act as config and generated glue, plus that language group's rules. Record what was found in `callers`.
- **A caller found:** the item is live. Drop it from the list and count it ("12 dropped: a caller was found").
- **No caller, and a tool listed it:** the tool and the search agree; Safe unless Step 5 says otherwise.
- **No caller, found only by our own search:** Check first.
A tool's silence about an item is never proof that it is live or dead. On a big list, helpers search in batches (Helpers).
### Step 5: Labels
Every finding gets one label, with its reason:
- **Safe to remove:** a tool listed it and the caller search found nothing.
- **Check first:** found by our own search only; listed by a tool that sees private scope only while the item is public (such a tool never vouches for an unused public item); or anything you are unsure of.
- **Warning:** always for these six kinds, with which one and why shown:
1. called by name from a string or config
2. a plugin or framework hook
3. a public library export
4. a CLI entry point or script
5. a test helper
6. code only tests call
A Warning is never in the quick-removal list (the All Safe preset). The person may still remove one by picking it by hand.
### Step 6: The findings page
Post one `multi` item (`notes/dead-code.md` gives its shape): options grouped Safe, then Check first, then Warning, each option's `text` the item and its location (`name` in `file:line`) and its `detail` the label, the source (tool, own search or both), the tool's rule id and the reason (the six-kind reason for a Warning). Preset: `All Safe` (ticks the Safe group). Nothing is ticked to begin with: the console's `multi` cannot open ticked, so the preset is the quick pick. Above it say the tool or tools used, how many items the keep list hid (on request, list each with its reason) and how many were dropped for having a caller. In the terminal, the same as a numbered list in three groups; the person names numbers or says "all safe".
Nothing picked → skip to Step 8.
### Step 7: Removal and checks
1. **Find the checks.** Run `test-map.mjs read`. With a map, every row's `run`, plus the `build` entries of `test-commands.mjs discover`'s `checks`. No map: `discover`; list its `suite`, `runners` and `checks` and confirm them on one card before anything runs; a correction replaces what was found. None at all: ask the person for the command. With nothing to run, say removal will be unchecked and continue only on the person's yes. The checks run project-wide, even on a folder run.
2. **Back up.** `backup <every file the picks change>`; keep its `run` id.
3. **Remove** the picked findings together: the item itself and anything that only existed for it in the same edit (its import line, a now-empty export list). A whole-file finding deletes the file.
4. **Check once.** Run every check through `run-check.mjs` (`--timeout 600` by default, longer when `AGENTS.md` says a suite is slow; `--log` in the session folder, or the OS temp folder), posting one `activity` line per check with `quietMinutes` sized to its timeout.
5. **All pass:** done; every pick's outcome is `removed`.
6. **Any fail** (any `outcome` other than `passed`: `failed`, `timeout` or `not-started`, with its `reason` or `tail` as the failure text): `restore --run <id>`, then `restore --run <id> --verify`. Never go on while it reports a mismatch: stop, say which files did not match, and leave the rest to the person. Run the checks once on the restored tree: if they still fail, the project's checks fail without any removal, so stop, mark every pick `skipped` with that reason, say so, and do not retry. Otherwise retry the picks one at a time: for each, `backup` the files it touches as a new run, remove it, run the checks; a pass keeps it, a fail restores that run and records `failed: <the end of the failing check's tail>` as its outcome. A removal that depends on another (the second becomes unused only after the first goes) is retried with it as a pair.
Nothing is staged or committed at any point.
### Step 8: Report, keep list and finish
**Report.** Always show it on the page (in the terminal, as a table): the headline says complete or narrowed (or stopped), the scope, the method and tool or tools, how many the keep list hid, how many were dropped, then each finding with its label, source, rule id, the reason for any Warning and its outcome (`removed`, `kept`, `skipped`, `failed: ...`), and whether removal was unchecked.
Offer three things, each acted on only on a yes:
- **Save the report.** Write the findings JSON (`scope`, `mode` of `verify`, `full` (also when any language group had no tool) or `own`, `tool` (an id, a list of ids when several ran, or null), `ranFrom`, `findings`, `hidden` as a number, `notChecked`) to the session folder, each finding `{ file, line, name, kind, source (tool, own or both), rule, label (safe, check or warning), warningKind (which of the six kinds, and why), callers, outcome }`, and run `report write --findings <file>`. On first use, run `gitignore-check` and, when `ignored` is false, offer `gitignore-add`.
- **Keep findings.** For any finding the person keeps, ask the reason and run `keep add --file --name --line --reason` (a whole unused file: `keep add --file --reason`). It is hidden next run, shown as a count.
- **Take entries off.** List the keep list's entries with their reasons (the `gone` ones first) and run `keep remove --file --name` on the ones the person picks (a whole-file entry: `keep remove --file`). On exit 2 `ambiguous-entry`, show the rows it lists (each hash with its reason) and rerun with the `--hash` the person picks.
## Abort
On "stop", "cancel" or similar during a run: confirm. With removals on disk and the checks not yet passed, `restore --run <id>` and `--verify` first, and say so. Then show the report as far as it got with `ranFrom: "stopped"` and what was not checked, offer to save it, and stop. Never call a stopped run complete.
## Session End
Work summary: the scope and whether it was narrowed, the method and tool or tools, how many findings by label, how many were hidden by the keep list or dropped for a caller, what was removed, put back (with why) or left, whether removal was checked, and any file written (the report, `keep.md`, `.gitignore`).
**Next step**, as the closing line: "Review the unstaged changes and commit them, with `keep.md`, using `/plan2code-git`." Nothing removed and no keep-list change: "Nothing to commit."
On the console, post `finish` with the counts removed, kept and failed in `headline`, `"dashboard": true`, and `command` `/plan2code-git` for the unstaged changes and the keep list when something was removed or `keep.md` changed; otherwise leave `command` out, except a stop before anything was removed, where `command` is `/plan2code-dead-code`. Never a `commit` field: the Git skill commits.
```
⋅
╭───╮
╲│ ★ │╱
│ ◡ │ Swept clean!
╰┬─┬╯
```
+2
View File
@@ -69,6 +69,7 @@ Ground truth for menu notes and Ask-tab answers. For anything beyond this table,
| diagnose | the bug, the codebase, `references/building-habits.md` | `DIAGNOSIS-<date>.md`; no code changes |
| pr-prep | git diff and status, the `AGENTS.md` test map, the project's config files, the PR template | the page report and description; `PR-READINESS-<date>.md` on a yes; the `AGENTS.md` test map on a yes; no commits, no push |
| test | the codebase, the `AGENTS.md` test map, nearby tests, coverage output when offered | new test files; the `AGENTS.md` test map on a yes; `PLAN-DRAFT-<date>.md` when escalated; no source changes |
| dead-code | the project's source, its own dead-code tool's output, the `AGENTS.md` test map, `.plan2code-dead-code/keep.md` | code removals the person picks; `.plan2code-dead-code/keep.md`; `.plan2code-dead-code/reports/DEAD-CODE-<date>.md` and the `.gitignore` line on a yes; no commits, no staging |
## A pick arrives
@@ -105,6 +106,7 @@ If `skill` is not in the table below, say so on the page and stay the dashboard.
| plan2code-git | git | | plan2code-changelog | changelog |
| plan2code-xray | xray | | plan2code-diagnose | diagnose |
| plan2code-pr-prep | pr-prep | | plan2code-test | test |
| plan2code-dead-code | dead-code | | | |
## A pick-up arrives
+1 -1
View File
@@ -1,5 +1,5 @@
# Helper Strength
> Shared by the skills that start helpers (subagents): Init, Init Update, Pathfinder, Plan, Revise Plan, Document, Quick Task, Implement, Implement + Review, Review, Finalize, X-ray and Diagnose. Read it when you first start a helper in a session. Never invoked as a skill.
> Shared by the skills that start helpers (subagents): Init, Init Update, Pathfinder, Plan, Revise Plan, Document, Quick Task, Implement, Implement + Review, Review, Finalize, X-ray, Diagnose, PR Prep, Test and Dead Code. Read it when you first start a helper in a session. Never invoked as a skill.
## The words
+1 -1
View File
@@ -6,7 +6,7 @@ The meter is advice and never blocks. The console scores these launches itself w
Per-unit work is yours: `{"run":{"event":"implement-phase","id":"phase-2","tasks":9}}`, one `run` per post, never reaching the page state.
- `event`: `pathfinder-chart`, `pathfinder-question` (scores nothing now), `pathfinder-research`, `plan`, `revise-plan`, `document`, `implement-phase`, `implement-review-phase`, `review`, `quick-task`, `init`, `init-update`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`, `git-commits`, `git-conflict`. An unknown event is exit 3. Post only the events your notes name: a launch the console scores already has its points.
- `event`: `pathfinder-chart`, `pathfinder-question` (scores nothing now), `pathfinder-research`, `plan`, `revise-plan`, `document`, `implement-phase`, `implement-review-phase`, `review`, `quick-task`, `init`, `init-update`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`, `git-commits`, `git-conflict`. An unknown event is exit 3. Post only the events your notes name: a launch the console scores already has its points.
- `id`: the unit (a question's slug, `phase-N`, `map`), non-empty. The same id in the same skill run is ignored.
- `tasks`: only with `implement-phase` and `implement-review-phase`; the tasks completed (`[x]`, not blocked), a whole number 1 to 999. A phase scores one point per 3 tasks rounded up (Implement + Review one more for the review); without it, a flat 2 (or 3). It takes over the count from `headline.cleared`, never adding to it.
- `commits`: only with `git-commits`; commits made, 1 to 999, one point per 2 rounded down.
+1 -1
View File
@@ -1,6 +1,6 @@
# Helpers (Subagents)
The console points here when a `Subagents:` block reaches you. On the skills that offer it (`init`, `init-update`, `pathfinder`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `quick-task`, `review`, `finalize`, `xray`, `diagnose`, `pr-prep`, `test`) the person turns helpers on or off from the top bar's Subagents button, per project and skill. It reaches you as a standing instruction, only when it changes.
The console points here when a `Subagents:` block reaches you. On the skills that offer it (`init`, `init-update`, `pathfinder`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `quick-task`, `review`, `finalize`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`) the person turns helpers on or off from the top bar's Subagents button, per project and skill. It reaches you as a standing instruction, only when it changes.
## What arrives
+1 -1
View File
@@ -6,7 +6,7 @@ A local page where the person answers your questions, reads your drafts and appr
## Start
`node "<CONSOLE>" open --workflow <w>` (add `--spec specs/<idea>` when known). `<w>` is one of `dashboard`, `init`, `init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `review`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`. Launched from the dashboard? The session is open: run the `resume` command the launch carried instead.
`node "<CONSOLE>" open --workflow <w>` (add `--spec specs/<idea>` when known). `<w>` is one of `dashboard`, `init`, `init-update`, `pathfinder`, `quick-task`, `plan`, `revise-plan`, `document`, `implement`, `implement-review`, `review`, `finalize`, `handoff`, `git`, `changelog`, `xray`, `diagnose`, `pr-prep`, `test`, `dead-code`. Launched from the dashboard? The session is open: run the `resume` command the launch carried instead.
Keep `sid`: every later command takes `--session <sid>`. `open` failing: carry on in the terminal. When `open` adds `remote` and a `note`, give the link, ask whether it opened, and move to the terminal if not. Tell the person the link (with `"inApp":true`, never print it: only how many questions are waiting) and end every terminal message with the latest `terminalLine`, verbatim.
+37
View File
@@ -0,0 +1,37 @@
# Dead Code
## Start questions
One `--wait` batch, after `detect` and `keep list`. Only the first card is required; leave out any the prompt says to skip (no method card with no tool, no keep card with an empty list):
```jsonc
{"title":"Clear out dead code","headline":{"stage":"Start","cleared":0,"total":5},"items":[{"id":"method","kind":"choice","title":"How to look","allowOther":false,"body":"This project has Knip (`knip.json`).","options":[{"text":"Knip, checked by a caller search","recommended":true},{"text":"Knip plus a full search of my own","detail":"Slower; finds what Knip cannot see."}]},{"id":"scope","kind":"choice","title":"Where to look","required":false,"body":"Callers are always searched across the whole project.","options":[{"text":"The whole project","recommended":true},{"text":"One folder","detail":"Name it in the note."}]},{"id":"keep","kind":"choice","title":"The keep list","required":false,"allowOther":false,"body":"3 findings were kept on earlier runs.","options":[{"text":"Hide them again","recommended":true},{"text":"A fresh scan that ignores them"}]}]}
```
## Narrow first
Only when `overLimit` is true. One `choice`, `--wait`: the five folders from `narrow` (or the biggest top-level folders with no tool), each with its count in `detail`, then the whole project with the time and cost warning in its `detail`.
## The findings
One `multi`, `--wait`, `required:false`. Options in three groups, in this order: Safe, Check first, Warning. Each option's `text` is `name` in `file:line`; its `detail` starts with the label, then the source (tool, own search or both), the rule id and the reason (the six-kind reason for a Warning). The `body` gives each group's count, how many the keep list hid and how many were dropped for a caller. Nothing starts ticked: the quick pick is the preset `All Safe` (the Safe group's keys). Leave out a preset with no keys (no Safe findings, or a `None`): the page drops it, and a pressed preset clears when pressed again.
```jsonc
{"headline":{"stage":"Findings","cleared":2},"items":[{"id":"findings","kind":"multi","title":"What to remove","required":false,"body":"- Safe to remove: 2\n- Check first: 1\n- Warning: 1\n\n4 hidden by the keep list; 9 dropped: a caller was found. Nothing is removed until you send.","options":[{"k":"1","text":"formatDate in src/dates.js:14","detail":"Safe. Knip (exports): no caller found."},{"k":"2","text":"src/old/legacy.js","detail":"Safe. Knip (files): no caller found."},{"k":"3","text":"parseRow in src/csv.js:40","detail":"Check first. Own search only."},{"k":"4","text":"onLoad in src/plugin.js:8","detail":"Warning. A framework hook: the host calls it by name."}],"presets":[{"label":"All Safe","ks":["1","2"]}]}]}
```
## Checks
With no test map: one `confirm` listing each command and the folder it runs in, `--wait`, `"yesLabel":"Use these","noLabel":"Not right"`, before anything runs. A "Not right" note replaces what was found; with none, ask for the commands as a `text` card.
One progress post per check, no `--wait`, its `activity` naming the check and `quietMinutes` sized to its timeout (600 s is 10 minutes, plus a margin). Run the `chat` check between checks, as a build does.
## The report and the offers
Doc `report`: one `md` block, the headline first (Complete, Narrowed or Stopped), then scope, method and tools, the hidden and dropped counts, and the findings table with each outcome. Then each offer as a `confirm`, `--wait`, `"doc":"report"`: "Save the report" (naming `.plan2code-dead-code/reports/DEAD-CODE-<date>.md`), "Keep these findings" (the reasons asked as a `text` card after a yes), and on first save ".gitignore line".
Helpers are reported as `helpers`, each `done` or `failed` before the findings page goes up. Labels, picks and questions stay with you.
## The finish
`headline` the counts removed, kept and failed; `body` the summary and any file written; `"dashboard":true`; `command` `/plan2code-git` when something was removed or `keep.md` changed, otherwise none; never `commit`. A stop before removal: `body` says nothing was removed, `"command":"/plan2code-dead-code"`.
+7 -7
View File
@@ -259,13 +259,13 @@ export const PICKABLE_SOUNDS = ["startSkill", "sessionStart", "skillReady", "ses
// The file each pickable cue plays until a person picks another.
export const DEFAULT_SOUND_FILE = {
startSkill: "sound-01",
sessionStart: "sound-02",
sessionEnd: "sound-02",
question: "sound-03",
skillReady: "sound-03",
chatReply: "sound-03",
newTab: "sound-04",
startSkill: "sound-14",
sessionStart: "sound-07",
sessionEnd: "sound-15",
question: "sound-14",
skillReady: "sound-16",
chatReply: "sound-06",
newTab: "sound-05",
};
// Every moment the page makes a noise, each switchable on its own in User
+22
View File
@@ -426,6 +426,28 @@ export const SKILLS = Object.freeze([
"When parts of the code have no tests. Test asks where to look (the branch's changes, one folder or the whole project) and finds the files no test covers, and offers a real coverage run when the project already has a coverage tool. It shows a plan that opens with how this project writes tests, so the new tests match the old ones, then writes and runs unit and integration tests. It never changes source code: a test that finds a real bug is handed to Diagnose.",
},
}),
skill({
skill: "plan2code-dead-code",
workflow: "dead-code",
label: "Dead code",
name: "Dead Code",
pose: "dead-code",
builds: false, phased: false, metered: true, templates: false,
weight: 1, started: "Dead Code started", ran: "Dead Code run", resume: null,
subagents: "Use helpers for the caller search, one batch of candidates each, returning what each searched and found, never a label. Keep the labels, the Safe call, the removals, the checks and every question with you. Light strength, low effort.",
states: "any",
greyed: null,
card: {
group: "extra",
chip: "Utility",
title: "Clear out dead code",
icon: "dead-code",
blurb: "Finds code nothing uses, says how safe each piece is to remove, and removes only what you pick.",
help: "Finds unused code, labels each piece Safe, Check first or Warning, removes only what you pick, then runs the tests and build.",
about:
"For code nothing calls anymore. Dead Code uses the project's own dead-code tool when there is one (Knip, vulture, cargo check and others), or searches by itself when there is not, then checks every item for callers across the whole project. Each one gets a label: Safe to remove, Check first or Warning, with the reason. It removes only what you pick, runs the tests and build, and puts back anything that breaks them. It never commits and never installs anything.",
},
}),
skill({
skill: "plan2code-changelog",
workflow: "changelog",
+15
View File
@@ -473,6 +473,21 @@
60%, 85% { transform: translate(4px, -4px); }
}
/* Dead code -- the skull's jaw chatters a few times, then rests; his star
glances over at it while it talks. */
.pose .dd-bone { fill: var(--panel-2); stroke: var(--ink-2); stroke-width: 4; stroke-linejoin: round; }
.pose .dd-jaw { animation: dd-jaw 3.6s ease-in-out infinite; }
@keyframes dd-jaw {
0%, 10%, 60%, 100% { transform: translateY(0); }
18%, 34%, 50% { transform: translateY(4px); }
26%, 42% { transform: translateY(1px); }
}
.pose .dd-look { animation: dd-look 3.6s ease-in-out infinite; }
@keyframes dd-look {
0%, 70%, 100% { transform: translate(2px, 0); }
14%, 56% { transform: translate(5px, -2px); }
}
@media (max-width: 720px) {
.dash { padding-top: 0; }
.launch-stage { height: 140px; }