Compact prepare

From the-agency-ai/the-agency · View interactive version

Compact prepare is an AI agent skill from the GitHub repository the-agency-ai/the-agency. Mid-session compact prep — force-commit the handoff, flush coord work, write continuation-framed handoff, direct to /compact.

How to use this skill

Skill file

<!--

Flag #62/#63: allowed-tools removed. Inherits Bash(*) from

.claude/settings.json. Restricting to specific subcommand patterns at the

skill level silently blocks agents on permission prompts the agent cannot

see — see dispatch #171 for the devex incident that surfaced this trap.

-->

Compact Prepare

Why this exists

Claude Code's /compact summarizes the conversation to free context, but a summary is lossy. The guarantee "I'll remember what I was doing after compact" holds only if a disciplined handoff is written BEFORE compact. This skill is that discipline for mid-session compaction — you commit current coord work, write a continuation-framed handoff, then run /compact.

Framework: this is the PAUSE-for-compact surface. It shells to agency/tools/session-pause --framing continuation. Paired with /compact-resume on the other side.

Required reading

Usage

/compact-prepare
/compact-prepare "context heavy — deep investigation paused"
/compact-prepare "mid-iteration refresh before QG"

[reason] (optional): short label for telemetry + handoff frontmatter. Defaults to compact-prepare.

After this skill reports clean state + handoff written, run /compact next. The skill does not invoke /compact — you do.

Preconditions

  1. You're in a git repository with The Agency tooling installed.
  2. You intend to keep working after /compact. If you don't, use /session-end instead.
  3. Any uncommitted WIP is ready to commit as-is. The skill does not stash.

Idempotent: safe to run multiple times. Archives and re-writes each time.

Flow / Steps

Step 1: Run session-pause primitive

./agency/tools/session-pause --framing continuation --trigger "${REASON:-compact-prepare}"

The primitive (v1.2.0+) force-commits the handoff in its own commit if the tree has non-coord framework files dirty — so the handoff is durable even when the overall PAUSE aborts on framework-code gate. Parse the emitted key=value output:

If status=aborted AND handoff_commit_sha is non-none, the handoff was persisted but framework code is dirty — surface error_reason (which includes the handoff SHA) and stop. Run /quality-gate + /iteration-complete on the framework code, then re-run /compact-prepare.

If status=aborted AND handoff_commit_sha=none, the PAUSE aborted before any commit — surface error_reason and stop. Do NOT author a handoff on an aborted PAUSE.

Step 2: Author continuation-framed handoff

Write the handoff file at handoff_path. Use the standard handoff template with:

Body:

Frame for continuation, not resumption. The agent keeps working after compact — doesn't start fresh.

Step 3: Verify handoff

./agency/tools/handoff read

Confirm the handoff was written correctly and next-action is clear.

Step 4: Report and direct

Report to the user:

Then the directive:

Run /compact now.

Failure modes

What this does NOT do

Status

active (v2, shipped session-lifecycle-refactor Phase 3 Iteration 3.1). Paired with /compact-resume, /session-end, /session-resume.

Related

OFFENDERS WILL BE FED TO THE — CUTE — ATTACK KITTENS!

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.