agentleFS
rhvdberghrhvdbergh/claude-skills/prep-compact/SKILL.md

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.

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
  1. Distinctive:

    Check the current state with read-only tools before writing anything.

    line 20
  2. Very specific:

    Write the brief in the reply, under the heading ## Retention brief.

    line 28
  3. Very specific:

    If the file exists, overwrite it only when it is from this same session.

    line 47
  4. Very specific:

    Run printf '%s' '<the command>' | pbcopy (macOS).

    line 61
  5. Distinctive:

    Do not make code changes, commits, or ticket updates in this skill.

    line 71

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 list when 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.

  1. Goal — what the user wants, in one to three sentences. Quote the user's own words where the wording matters.
  2. Location — repo, worktree path, branch, and the directory to work in.
  3. Plan — the plan file path, which steps are done, which step is in progress, and every %% note still open.
  4. Decisions — each decision made, with the reason, and options the user rejected (so they do not come back).
  5. User rules for this task — corrections and preferences the user gave in this session that are not in any CLAUDE.md.
  6. Changes so far — files created, edited, or deleted, one line each with what changed.
  7. Verification state — the last build and test results, with pass and fail counts and the exact error text of any failure.
  8. 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.
  9. Key references — ticket links, PR numbers, URLs, function and type names that the next step needs.
  10. 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 of git rev-parse --show-toplevel, or no-repo outside 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.