prep-compact
Skill0 starsChanged 26 days agoMITView on GitHub
Prepare for /compact so no important session detail is lost. Writes a full retention brief into the conversation and to a file, then puts a ready-to-paste `/compact …` command on the clipboard. Use when the user types /prep-compact, or asks to get ready for compaction, save the session context before compacting, or write compact instructions.
In this repository13 other files it gives its agents.
- arch-reviewSkill
- explain-diffSkill
- explainSkill
- find-sessionSkill
- prep-prSkill
- prune-commentsSkill
- remove-commentsSkill
- resume-planSkill
- review-pr-comments-loopSkill
- review-pr-commentsSkill
- runbookSkill
- session-review-loopSkill
- session-reviewSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Check the current state with read-only tools before writing anything.
- Very specific: line 28
Write the brief in the reply, under the heading ## Retention brief.
- Very specific: line 47
If the file exists, overwrite it only when it is from this same session.
- Very specific: line 61
Run printf '%s' '<the command>' | pbcopy (macOS).
- Distinctive: line 71
Do not make code changes, commits, or ticket updates in this skill.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
prep-compact
/compact is a built-in CLI command. A skill or tool call cannot run it; only the user can. This skill does everything up to that point, so the user only pastes and presses Enter.
The brief goes in two places on purpose:
- In the reply. The compactor summarizes the conversation, so text in the last reply is the text it is told to keep.
- In a file. The summary can still lose detail. The file is the full copy that Claude re-reads after compaction.
Steps
1. Collect the facts
Check the current state with read-only tools before writing anything. Never fill the brief from memory where a command can confirm it.
pwd,git rev-parse --show-toplevel,git rev-parse --abbrev-ref HEAD,git status --short(skip when not in a git repo).git worktree listwhen the session used worktrees.- Background processes and agents this session started that still run.
2. Write the retention brief
Write the brief in the reply, under the heading ## Retention brief. Include every section that applies; leave out empty ones. Be specific: exact paths, ids, names, numbers, error text. Leave out narration of how the session went.
- Goal — what the user wants, in one to three sentences. Quote the user's own words where the wording matters.
- Location — repo, worktree path, branch, and the directory to work in.
- Plan — the plan file path, which steps are done, which step is in progress, and every
%%note still open. - Decisions — each decision made, with the reason, and options the user rejected (so they do not come back).
- User rules for this task — corrections and preferences the user gave in this session that are not in any CLAUDE.md.
- Changes so far — files created, edited, or deleted, one line each with what changed.
- Verification state — the last build and test results, with pass and fail counts and the exact error text of any failure.
- Open threads — unanswered questions, things blocked on the user (for example codegen to run), and running processes, agents, or review ids (wisplet
rv_…) with what each one waits for. - Key references — ticket links, PR numbers, URLs, function and type names that the next step needs.
- Next step — the exact next action.
3. Save the brief to a file
Save the same brief to ~/.claude/compact-briefs/<repo>_<YYYY-MM-DD>_<slug>.md:
<repo>is the basename ofgit rev-parse --show-toplevel, orno-repooutside a git repo.<slug>is a short kebab-case name for the task.- If the file exists, overwrite it only when it is from this same session; otherwise add
-2,-3, and so on.
4. Build the /compact command
Build one line, with no line breaks, so the paste runs as a slash command:
/compact Keep the "Retention brief" from the last assistant message in full: every path, id, decision, rule, test result, open thread and the next step, word for word where possible. After compaction, re-read <absolute brief file path> before doing anything else.Replace <absolute brief file path> with the real path from step 3. Expand ~ to the full home path.
5. Copy it to the clipboard
Run printf '%s' '<the command>' | pbcopy (macOS). If pbcopy is not available or fails, say so.
6. Report
End the reply with:
- The brief file path.
- The
/compact …line in a code block, so the user can copy it by hand if the clipboard step failed. - One line: "Copied to clipboard. Paste and press Enter to compact." (Only if step 5 succeeded.)
Do not make code changes, commits, or ticket updates in this skill.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

