compact-prep

A command that prepares an ongoing agent conversation for context compaction, which means shortening the conversation so work can continue within the available context window.

In plain words
What is it for?
Use it before compaction to update relevant planning state and provide concise instructions for the agent that will continue afterward.
Why use it?
It reduces the risk of losing important task state, decisions, and next steps when a long conversation is condensed.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/sammcj/agentic-coding/compact-prep
Clone the repo
git clone --depth 1 https://github.com/sammcj/agentic-coding
Per session 30 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 393 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.00393
Opus 5 $0.00015 $0.00197
Sonnet 5 $0.00006 $0.00079
Haiku 4.5 $0.00003 $0.00039

Measured yesterday against content hash 7fbdda1f5d8b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

compact-prep scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Claude/commands/compact-prep.md · 23 lines

What it actually says

This is an automated message to state that the context window usage is getting high and the user is going to run a compaction

As such, could you please:

  1. (Only if applicable) Update any state that tracks the work currently in progress / the state of the tasks being worked on, e.g. A development plan if operating from one, the CLAUDE.md ( Only if that is where the user has asked you to track in flight work and it does not only contain rules), etc... to ensure it's up to date without any now outdated or invalid information, if it has next steps that they are correct, and if you're mid troubleshooting a complex problem - where you've got to and what you've tried so far (but keep it concise).

  2. Give me a concise prompt that I can provide to the compaction agent that will be compacting our conversation to ensure the signal to noise ratio is kept high and focused. The agent will already be aware of it's task to compact the conversation so only needs additional guidance on specific things that may not be obvious but are important to keep (e.g. the WHY not just the WHAT).

  3. Give me a concise prompt that I can provide to continue our work after compaction is complete. Keep in mind that the new agent / session will have access to the same files and will have the same CLAUDE.md agent rules in context.

Be terse / concise. Don't add filler. Less is more. The agent reading this is a capable model, not an audience. TLDRs are great.

Note: You must not quote, indent or format the prompts in any way that might impact me copying and pasting them without cleaning them up.


$ARGUMENTS

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 23 lines · 30 tokens per session scan A 7fbdda1f5d8b

Subscribe to this mod's changes

compact-prep is a command published in the GitHub repository sammcj/agentic-coding (158 stars, last pushed 7d ago), licensed Apache-2.0. It adds 30 tokens to every session and 393 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.