Skip to main content
command CX Codex

compact-prep — Claude Code command: what it does, how to install

compact-prep — a Claude slash command that tidies the work state before the context window fills up, then hands you prompts for compacting the session and resuming it.

Apache-2.0 ★ 173 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/compact-prep.md
Open on GitHub

What compact-prep does

Reach for this command when a Claude session is running out of context. It tells the agent to tidy up the work state first, then hands you two short prompts: one for whatever compacts the transcript, one for picking the work back up.

State updates happen only where they apply. A development plan gets refreshed, CLAUDE.md too if that is where you keep in-flight work rather than rules, stale lines are dropped and next steps corrected. Mid-debug, the agent writes down how far it got and which attempts failed.

Then come the prompts. The compacting agent already knows its job, so it only needs the parts that are easy to lose, above all the reasoning behind decisions. The continuation prompt assumes the next session opens the same files under the same CLAUDE.md rules. Neither is indented or decorated, so you can paste it straight in. Extra instructions can be passed as an argument. Skip the state step and the compactor works from the transcript alone, while your plan keeps yesterday's next steps.

What it helps with

  • Keep the dev plan current before compaction
  • Drop stale next steps from CLAUDE.md
  • Record how far a tricky debugging session got
  • Hand the compactor the reasoning, not just the task list
  • Restart work in a fresh session without losing the thread

Example prompts for the agent

  • /compact-prep context is nearly full, get the state and the prompts ready
  • /compact-prep we already ruled out the mutex fix, keep that in mind
  • /compact-prep we track this work in the dev plan, update it first

How to install compact-prep

Manually: put the files in place

.claude/commands/compact-prep.md

Call it with /compact-prep. For all projects use ~/.claude/commands/

Questions about compact-prep

How do I install compact-prep in Claude Code?

Copy the command file to .claude/commands/compact-prep.md in your project. It is then available as /compact-prep.

What does compact-prep do?

It asks the agent to bring the current work state up to date, then produces two short prompts: one for the compaction step, one for continuing afterwards.

Do I have to pass an argument?

No. [optional additional instructions] is optional and only adds extra guidance to the request.

Source text

compact-prep.md · Apache-2.0
---
description: Ask the agent to prepare for conversation compaction by updating any relevant state and providing guidance for the compaction agent and to kick off the session there after
argument-hint: "[optional additional instructions]"
---

# 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`

© sammcj · Apache-2.0 · sammcj/agentic-coding

Similar slash commands

All slash commands for Agent setup: memory, context, orchestration →

From the same set73

The whole set →
edit-article edit-article restructures draft articles around heading dependencies and rewrites each section into short paragraphs under 240 characters. CX Codex +1 ★ 173repo stars llm-prompting-guide llm-prompting-guide is a Claude Code skill with prompt format rules for MiniMax H3 and MiniMax Music 3. Consult it when drafting prompts for these models in ComfyUI or other tools. CX Codex +1 ★ 173repo stars backlog Tracks bugs and features in local Markdown files or GitHub Issues. Keeps backlogs tidy without drafting heavy PRDs or specifications. CX Codex +1 ★ 173repo stars github This skill sets rules for using gh to work with GitHub, from reading PR feedback to checking GitHub Actions. It fits tasks involving issues and code review. CX Codex +1 ★ 173repo stars subagent-delegation subagent-delegation guides Claude Code in scoping sub-tasks, assigning file ownership, and choosing between clean named sub-agents or session forks. CX Codex +1 ★ 173repo stars openspeccer openspeccer opens a read-only local dashboard for an OpenSpec repository and reports active changes, artifacts, and tasks. Useful when you need project status. CX Codex +1 ★ 173repo stars json-schema-lookup json-schema-lookup — a skill that points Claude at the SchemaStore catalog so it can validate config files and look up allowed options. CX Codex +1 ★ 173repo stars deferred-task-execution deferred-task-execution delays command execution in Claude Code for a specific duration or until a chosen time. Handy when builds or scripts need to wait. CX Codex +1 ★ 173repo stars

Project sponsors

Companies that keep this analytics open