Skip to content

/pre-compact

Pre-compaction housekeeping. Walks a checklist (persistent memory updates, git hygiene, trash cleanup) plus an open-judgment audit, produces an SBAR with a go/no-go recommendation, and emits a copy-pasteable resume prompt for the post-compaction agent if work remains. Run this

shell
$ npx -y skills add chrisallenlane/claude-swe-workflows --skill pre-compact --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/pre-compact
How auto-invocation works

Context preview

The summary Claude sees to decide when to auto-load this skill.

Pre-compaction housekeeping. Walks a checklist (persistent memory updates, git hygiene, trash cleanup) plus an open-judgment audit, produces an SBAR with a go/no-go recommendation, and emits a copy-pasteable resume prompt for the post-compaction agent if work remains. Run this

SKILL.md

pre-compact.SKILL.md
name: pre-compact
description: Pre-compaction housekeeping. Walks a checklist (persistent memory updates, git hygiene, trash cleanup) plus an open-judgment audit, produces an SBAR with a go/no-go recommendation, and emits a copy-pasteable resume prompt for the post-compaction agent if work remains. Run this immediately before /compact.
model: opus

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

For each candidate:

  • Check existing memory files first. Update an existing memory rather

than writing a duplicate.

  • Skip anything already saved, derivable from `git log` / current

code, or ephemeral to this conversation.

  • Honor the exclusion rules in the user's memory instructions

(architecture, conventions, fix recipes, ephemeral state).

2. Git hygiene pass

Run `git status` and assess:

  • **Uncommitted intentional changes**: surface them. Ask the user

whether to commit. If yes, draft a commit message and ask for approval before running `git commit`.

  • **Uncommitted in-progress changes**: surface them. The filesystem

survives compaction, so the *files* are not at risk — but the *context* about what is in flight may be. Either commit as WIP, or capture the in-flight state in the SBAR.

  • **Untracked files**: route each to step 3 (trash) or surface as

work product that should be tracked.

  • **Branch state**: note any unusual condition (detached HEAD,

mid-rebase, mid-merge, conflicts) so the user is aware before compacting.

Do not commit or stage on the user's behalf without explicit per-invocation permission. Match the scope of any granted permission exactly.

3. Trash cleanup pass

Identify candidate trash:

  • Untracked scratch files created during this session (`/tmp/*`,

`*.bak`, ad-hoc test scripts, debug dumps)

  • Files matching obvious throwaway patterns (`scratch.*`, `debug.*`,

`tmp_*`, `nohup.out`)

  • Stray build artifacts that should have been gitignored

For each candidate:

  • **Clearly trash and clearly mine**: delete and report.
  • **Ambiguous origin or intent**: ask the user. When in doubt, do

not delete.

  • **Not mine**: leave alone.

A false delete loses the user's work-in-progress. A false retain costs nothing. Bias accordingly.

4. Open audit (judgment)

Walk the session and look for anything else that would be hard to reconstruct from `git log` + persistent memory + the issue tracker after compaction. Examples (non-exhaustive — the point of this step is to think past the checklist):

  • Decisions made during the session that are not captured in any

ticket, commit message, code comment, or memory

  • Pending TODOs from the conversation that have no durable home
  • Open threads with the user — questions asked but not answered,

options proposed but not chosen

  • Work-in-progress with no plan/task/ticket capturing the current

state

  • Long-running background processes (`run_in_background` tasks, dev

servers, watchers) that the user may have forgotten about

  • Active worktrees, stashes, or branches that need a decision before

context is lost

For each item: either persist it now (memory, ticket, comment) or flag it explicitly in the SBAR.

5. Produce SBAR

Per the user's session handoff format:

  • **Situation:** state of the working tree, repo, and any in-flight

work right now

  • **Background:** what was tried this session, what was rejected,

what surprised

  • **Assessment:** what you believe is true, calibrated by confidence

— *verified* (ran the command, read the file), *inferred* (reasoned from observation), or *recalled* (training knowledge, possibly stale)

  • **Recommendation:** exactly one of:
  • **Safe to compact.** All housekeeping done, nothing material

at risk.

  • **Safe to compact after [X].** A small action remains for the

user (commit a staged change, answer a pending question); after that, compaction is fine.

  • **Do
Read more
Read it on GitHub ↗

Showing the first part of this file.

Ships withclaude-swe-workflows

A system of composable software engineering workflows for Claude Code. Plan projects, implement tickets, and run quality passes — from a single ticket to a multi-batch project, using the same layered architecture.

Get the whole plugin, auto-invoked
Stats
18
Stars
0
Views
4
Forks
Maintained
Maintenance
MIT
License
2mo ago
Last commit
6mo ago
Created

Repo: chrisallenlane/claude-swe-workflows

Other skills on claude-swe-workflows.