Skip to main content
shrike clean --base <ref> removes code that this branch made unreachable, anywhere in the repository — including files the branch never touched. Without --all, clean is the same verified workflow as prune; prune remains available under its original name.
clean changes repository files and creates commits on a new branch. Review the delta and plan first. It never commits to the base branch; --pr pushes the cleanup branch and opens a draft PR.

Before you start

  • A base ref present locally, such as origin/main. Fetch it first with git fetch origin main if needed.
  • A clean working tree. Worktree mode refuses a dirty tree; use --in-place with --allow-dirty only when you accept in-tree verification.
  • At least one project check, configured or discoverable from package.json scripts by tier. With none, the command exits 4.
  • Agreement on the verified caveat: the configured checks passed after removal relative to a baseline. It does not prove the code is semantically unused in production or that external consumers cannot import it.

1. See what the branch orphaned

The branch report labels items as branch-orphan and separates dead code that already existed before the branch. For the raw delta:
Expected output:
Shrike uses git merge-base <base> HEAD and falls back to git rev-parse <base>. When --base is omitted, it tries origin/main, main, origin/master, then master. If the ref cannot be resolved, the command exits 4.

2. Review the plan

Expected: Plan <id>: N symbols, N files, N lines, one line per batch, and a Blocked count when applicable. The plan is stored under .shrike/ for clean, prune, and verify. A dry run is also available:
A dry run prints the plan, writes no source changes, and exits 0 when the plan is empty or 1 when it contains batches. With --json it prints the plan object. If a symbol is listed as blocked or you want to understand why it is live, ask for the proof:
why --json is exactly the engine’s proof object. Blocked items are never deleted automatically.

3. Run the verified cleanup

What happens, in order:
  1. Shrike resolves the base, analyzes the merge base and HEAD, and asks the engine for the branch orphan delta and deletion plan.
  2. A branch worktree is created under .shrike/worktrees/, and the baseline checks run there before any edit.
  3. Each batch is applied in the worktree and the checks run again. A regression triggers bisection; only the passing remainder is committed.
  4. Passing batches are committed on <branchPrefix>-<plan-id without the plan_ prefix> (default prefix shrike/cleanup). The temporary worktree is removed after the run; the commits and receipts stay.
  5. Add --pr to push the branch and open a draft PR with gh.
Expected human output:
Paths are repository-relative. --json returns { plan, outcome, receipts, branch, worktree }.

Difference from current-state cleanup

Do not use --all as a substitute for reviewing the branch delta. It can remove code that was already dead before your change.

Options

--no-checks is rejected: verified deletion needs at least one check.

4. Inspect and open the PR

Receipts under .shrike/receipts/ record the base and head commits, plan and batch IDs, removed symbols and files, per-check results, outcome, rejected items, policy, content hash, and a recovery reference when applicable. The PR body is generated from the same receipts when you use --pr. The cleanup branch is local unless --pr pushes it. Re-run the project’s checks before review; the receipt records what Shrike ran.

Failure and recovery

If the command exits 5, do not edit the worktree. Run the printed restore command:
It restores only the files in the snapshot and rejects absolute or traversal paths.

Limits and safety

  • Only items the engine proves orphaned by this branch are candidates. Protected items, unknown edges, generated files, and public API stay protected.
  • Dependencies are advisory. This command never edits package.json for dependency findings.
  • A build graph can add liveness evidence but can never authorize a deletion.
  • Shrike does not commit to main and does not open a PR unless you pass --pr.

Next