pre-compact

pre-compact is a skill for Claude Code from chrisallenlane/claude-swe-workflows. It costs 69 tokens per session (1,753 once invoked), scanned A, original, MIT.

A pre-compaction checklist for saving important session information before conversation context is shortened. It reviews memory, Git state, temporary files, and unresolved decisions, then creates a handoff prompt.

In plain words
What is it for?
Use it before /compact to record session state, check whether work is ready to continue, and prepare instructions for the next agent.
Why use it?
It reduces the risk of losing work or important decisions when a long coding session is compacted.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter; mentions CLAUDE.md.

Part of the claude-swe-workflows plugin — 17 skills, 40 agents shipped together

Good fit Use it before /compact to record session state, check whether work is ready to continue, and prepare instructions for the next agent.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chrisallenlane/claude-swe-workflows/pre-compact
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.

Any agent
npx skills add chrisallenlane/claude-swe-workflows --skill pre-compact
Clone the repo
git clone --depth 1 https://github.com/chrisallenlane/claude-swe-workflows

Made for: Claude Code.

Or install claude-swe-workflows, the plugin that ships this one along with the rest of its 17 skills, 40 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pre-compact

README.md
[![agentmods](https://agentmods.dev/badge/skills/chrisallenlane/claude-swe-workflows/pre-compact/github.svg)](https://agentmods.dev/skills/chrisallenlane/claude-swe-workflows/pre-compact)
Your own site
<a href="https://agentmods.dev/skills/chrisallenlane/claude-swe-workflows/pre-compact"><img src="https://agentmods.dev/badge/skills/chrisallenlane/claude-swe-workflows/pre-compact/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pre-compact

Your own site · 80×15
<a href="https://agentmods.dev/skills/chrisallenlane/claude-swe-workflows/pre-compact"><img src="https://agentmods.dev/badge/skills/chrisallenlane/claude-swe-workflows/pre-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 69 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,753 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00069 $0.01753
Opus 5 $0.00034 $0.00877
Sonnet 5 $0.00014 $0.00351
Haiku 4.5 $0.00007 $0.00175

Measured 10d ago against content hash 5bedad706c83, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

pre-compact 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 10d ago.

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.

skills/pre-compact/SKILL.md · 187 lines

How it starts

The opening of the file, as written. The whole thing — 187 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Pre-Compact - Session Housekeeping Before Compaction

The user is about to run /compact. Compaction destroys conversation context. Anything important from this session that is not persisted somewhere durable — memory files, commits, tickets, code, the issue tracker — is lost.

This skill is the last-chance pass to capture session state. Walk a fixed checklist as a floor, then use judgment for anything the checklist does not anticipate, and end with an SBAR-formatted go/no-go report.

Philosophy

  • Persist before you compact. If a fact will matter next session, it goes into persistent memory now. If a change should be in the project, it gets committed (with permission). If an artifact is trash, it gets deleted.
  • Surface uncertainty instead of guessing. When unsure whether something is trash, abandoned, or important, ask the user.
  • Bias toward asking, not committing. Never commit on the user's behalf without per-invocation permission. Standing rules from CLAUDE.md still apply.
  • The checklist is a floor, not a ceiling. Walk every item, but also use judgment to spot session-specific cleanup the checklist cannot anticipate.
  • Do not invoke /compact yourself. Compaction is the user's call.

Workflow

1. Persistent memory pass

Updating persistent memory is the core reason this skill exists. The user invokes /pre-compact because they want memory written before compaction. Do not skip this step or treat it as conditional. Follow whatever memory conventions are documented in the user's global or project CLAUDE.md (auto-memory directory, project notes, etc.).

Re-scan the session for facts worth saving across conversations. Look for:

  • About the user: role, expertise, preferences, current focus
  • Feedback: corrections received OR non-obvious approaches the user confirmed worked. Capture the why the user gave, not just the rule.
  • Project state: ongoing initiatives, constraints, deadlines, decisions, stakeholder context. Convert relative dates to absolute ones.
  • External references: pointers to issue trackers, dashboards, channels, docs the user mentioned

Read the full file on GitHub · 187 lines

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. 10d ago First seen · 187 lines · 69 tokens per session scan A 5bedad706c83

Subscribe to this mod's changes

pre-compact is a skill published in the GitHub repository chrisallenlane/claude-swe-workflows (18 stars, last pushed 3mo ago), licensed MIT. It adds 69 tokens to every session and 1,753 once invoked, about $0.0003 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.