shrike clean --all is current-state cleanup: it plans every removable file and symbol in the current tree, not just what this branch orphaned. It is explicit, mutating, and verified by the project’s own checks.
Before you start
- A clean working tree. Worktree mode refuses a dirty tree;
--allow-dirtywith--in-placeis the alternative. - At least one verification check: configured in
shrike.config.ts, or discoverable from the repository’s typecheck, lint, or test scripts by tier. With none, the command exits4. - A baseline is captured before any edit, so pre-existing failures are separated from new ones.
- Agreement that verified means the configured checks passed after removal relative to that baseline. It does not prove the code is semantically unused in production or that external consumers cannot import it.
clean --all as a routine formatting or lint step. It is cleanup of code the engine proves is orphaned in the current graph.
1. Preview the plan
Add
--json to print the plan object instead of the human summary. The dry run is the read-only equivalent of shrike plan for current-state cleanup; it can still write engine snapshots to .shrike/cache/.
Review the batch counts and the blocked items. A whole file appears as a file item; a symbol appears as path#Name. Protected items are not in the plan.
2. Run the verified cleanup
- Shrike analyzes the current tree once and builds a current-state plan from the snapshot. It never reads a branch base;
--alland--basecannot be combined. - A branch worktree is created under
.shrike/worktrees/from the currentHEAD, and the baseline checks run there before any edit. - Each batch is applied in the worktree — symbol spans and eligible whole files — and the checks run again.
- A regression triggers bisection. Shrike reverts the failing unit, retries the remainder, and commits only the edits that pass. Outcomes are recorded as
verified,flaky,rejected,interaction-failure,error, orrevert-failed. - Passing batches are committed on a branch named
<branchPrefix>-<plan-id without the plan_ prefix>(default prefixshrike/cleanup). The temporary worktree is removed after the run; the commits and receipts stay. - Add
--prto push the branch and open a draft PR withgh.
Verified <batch-id>: N symbols, N files. for passing batches, then the removed count, the branch, and the receipt paths:
--json returns { plan, outcome, receipts, branch, worktree }, plus "scope": "current". Receipt and worktree paths are repository-relative and sorted. receipts is [] when nothing passed.
Options
--no-checks is rejected: a verified deletion requires at least one project check. --all cannot be combined with --base; current-state cleanup has no branch base.
Whole files
A file is removed only when every one of these holds: the engine reports no witness for the module, the file is eligible (not generated, not public API, parsed successfully), and the file is not live. Whole-file deletion uses the same checks, bisection, revert, and receipt path as symbol deletion. It never follows a path outside the repository.3. Inspect the result
- Receipts are content-addressed JSON under
.shrike/receipts/. Each records the graph hashes, plan and batch IDs, removed symbols and files, per-check status and baseline comparison, outcome, rejected items, policy, content hash, and a recovery reference when applicable. - The branch is local until you push it.
clean --allnever rewrites or commits tomain. - Re-run the project’s checks yourself before opening the PR. The receipt records what Shrike ran, not a guarantee that the tests are adequate.
Failure and recovery
If the command exits
5, stop and run the printed restore command:
recover restores only the files listed in the snapshot and rejects absolute or traversal paths. See Troubleshooting for the other failure modes.
Limits and safety
- Protected items — entries, public API, generated files, unparsed files, unknown or probable edges, test entries, workspace boundaries, blast-radius caps, and policy protections — are reported and not deleted.
- Dependencies are advisory.
clean --allnever editspackage.jsonto remove a dependency. - A build graph can add liveness evidence but can never authorize a deletion.
- The command cannot prove that code is unused in production; it proves that the configured checks still pass after removal relative to the baseline.
- The default worktree is temporary. If you want to inspect changes before they are committed elsewhere, use
--dry-runand review the plan, or run the cleanup on a dedicated branch.
Next
- Verified pruning — how batches, bisection, receipts, and recovery work.
- Branch cleanup — remove only what this branch orphaned.
- Configuration — checks, tiers, batch policy, and build evidence.