Skip to main content
Run it in the project’s folder, or name it with --dir. Your agent drives it through /specpilot-compact: the agent judges and writes the plans, and this command moves the text and keeps the originals.

Options

--report can’t be used with --apply.

What it does

On its own, it lists each development/context.md entry with its status, line count, size and title, then the project/requirements.md items, largest first, with their key, size and line count. The statuses are finished (every task it names is in tasks-archive.md), completed, open, unknown, no-id and no-lead. They are hints for the agent, not decisions. Nothing is written. With --report, it prints one row per file (tasks.md, prompts.md, context.md, requirements.md): its size, estimated tokens (bytes ÷ 4) and the saving. The saving is exact for what specpilot archive would move, and likely for the agent’s part. The last line is what the agent’s run costs once and after how many reads it pays back, or Nothing for the agent to compact. Nothing is written. With --apply, it reads the two plans and applies both or neither:
  • Each context.md entry marked archive moves, unchanged, to development/context-archive.md, and a one-line marker takes its place.
  • Each rewritten requirement replaces the item in place, and the original is kept unchanged in project/requirements-archive.md.
  • On success it prints Moved N entries to context-archive.md and Rewrote N requirements (X KB shorter); originals in requirements-archive.md, and deletes the plans.
It refuses, and writes nothing, when an entry names a task that’s still open, or a rewrite is longer, out of date or not a single list item ending in the same [REQ-…] key. It then prints each reason and Nothing was written. Items without a bracketed key are never rewritten. With --apply --dry-run, it shows the entries that would move, each requirement’s size before and after with the backticked strings and IDs the rewrite drops, and the exact saving per file.

What it writes

Only with --apply: development/context.md, development/context-archive.md, project/requirements.md and project/requirements-archive.md. It deletes the two plan files when it’s done.

The branch question

With --apply on a branch other than main or master, it asks before writing. Compact after you merge, so the change happens once. --force skips the question.

Exit status

1 when it refuses, when there’s no .specs/ folder, no context.md or no plan, or when an option is wrong. Otherwise 0.

Examples

Checked against SpecPilot 2.22.0.