Skill in 《Compact with Memory》

Skill Description

Executes /compact correctly — generates a high-quality conversation summary that preserves reasoning, decisions, and current state, with a memory pre-pass to persist institutional knowledge before compression.

Skill.md

Compact with Memory

Standard /compact replaces conversation history with a summary — fast, but lossy. The architectural decisions you spent hours reasoning through, the approaches you tried and abandoned, the rules the user corrected you on — all flattened. The next session starts blind.

This skill adds two things before compression: a memory pre-pass that extracts institutional knowledge to durable files, and a structured 8-section summary that gives a fresh session exactly what it needs to continue the work. Core principle: only persist what can't be derived from reading the code or git history — everything else is noise.

Four Signal Types

TypeContentExample
feedbackCollaboration rules (corrections AND confirmations)"Don't auto-retry Stripe calls"; "yes, keep doing it this way"
projectIn-progress work, decision rationale, eliminated approaches"Chose optimistic locking because pessimistic locks deadlock at this scale"
userRole, domain expertise, preferences"Senior backend engineer, first time touching the React side"
referencePointers to external systems"Bugs tracked in Linear project INGEST"

How to Execute

Step 1 — Memory pre-pass

Scan the conversation for signals that can't be derived from code or git history. Write them to memory files now — they will be gone after compaction. Quality bar: if a signal lacks a Why:, skip it. One good entry beats five generic ones.

Step 2 — Generate the summary

The summary replaces the entire conversation history. It must be self-contained: a fresh session with only this summary should be able to continue the work without asking what happened.

Eight sections — write every one that has content:

  1. Task — What was being worked on and why — the goal, not the steps taken
  2. Current state — Exactly where things stand at the end of this session: done, not done, in progress. Most critical section — must reflect the conversation endpoint, not the starting point
  3. Key decisions — Choices made and the reasoning behind them; non-obvious decisions especially
  4. Eliminated approaches — What was tried and ruled out, and why; prevents re-exploring dead ends
  5. Open questions / blockers — Unresolved issues the next session needs to address first
  6. Files changed — Which files were modified and what changed in each
  7. Next steps — Concrete actions remaining, in priority order
  8. Context for next session — Anything a fresh session needs that didn't fit the above

Quality criteria:

  • A fresh session reading only this summary can continue the work
  • Reasoning over facts: why decisions were made, not just what was decided
  • Current state accurately reflects where the conversation ends
  • No padding: omit any section that genuinely has nothing to say
Step 3 — Execute /compact

Run /compact. In the summary note, reference what was persisted to memory: "Key decisions written to memory — see [filename] for [topic]."

Step 4 — Confirm

Report:

  • Compact: completed, with a one-line description of what the summary covers
  • Memory: how many files were written/updated and which files
  • MEMORY.md line count: current count (must stay under 200 lines)

When to Use

  • Type /compact or "compress context"
  • When the context window indicator is approaching the limit
  • At natural session checkpoints after significant decisions

What NOT to Save

  • Code patterns, file paths, architecture overviews — read the code
  • Git history or who changed what — git log is authoritative
  • Debugging steps or fix recipes — the code is the record; commit messages have context
  • Anything already in CLAUDE.md files
  • Ephemeral task status, in-progress work from this session

Boundary test: "Would a fresh session benefit from knowing this before reading any code?" If no — skip it.

Relationship with memory-architect

compact-with-memory is the write path: it extracts knowledge at each compression point. memory-architect is the cleanup path: when MEMORY.md has accumulated redundant, duplicate, or stale entries, use it for structural reorganization. They work best together.

Limitations

This skill depends on what was explicitly discussed in the session. If architectural decisions were made without stating the "why," the extracted memory will lack a Why: rationale. For best results, state your reasoning out loud when making important decisions — it makes the compact extraction substantially more useful.

Install & Use

Install command

npx skills add simbajigege/book2skills/skills/compact-with-memory
OR

Direct download

Related Skills

Tool Permission System AI Skill

Design a configurable, layered permission/safety system for agent tools: one permission pipeline decides allow / ask / deny across enterprise/user/project scopes.

Session Dream AI Skill

On-demand session memory distillation — extracts key decisions, eliminated approaches, new discoveries, and current b...

Agent Memory Implementation Guide AI Skill

Restructures a bloated or chaotic MEMORY.md into the 2-layer architecture Claude Code's autoDream service uses intern...

Harness Step 1 — Create AGENTS.md & Knowledge Base AI Skill

Scans your codebase and generates AGENTS.md (the agent's orientation file) plus a complete docs/ knowledge base skele...

Compact Memory Implementation Guide AI Skill

A developer implementation guide for adding compact memory to an Agent built with the Anthropic API or Claude Agent S...

Harness Step 2 — Fill docs/ with Real Content AI Skill

Deep-reads your codebase and fills every docs/ file with specific, accurate content grounded in what the code actuall...

Harness Step 3 — Session State Management AI Skill

Creates init.sh (environment health check), tasks.json (structured task queue), and progress.md (append-only session ...

LangChain Tool Builder AI Skill

Build LangChain (Python) tools using Claude Code's fail-closed design pattern — unified name, schema, security, and e...

Query Loop Implementation AI Skill

Implement a production-ready LLM query loop for AI applications: tool calling, structured tool_result feedback, ReAct...

Understanding Financial Statements AI Skill

Analyze company financials using Tsinghua Professor Xiao Xing's three-statement framework. Apply to any company: bala...

Business Adventures Analysis AI Skill

Apply John Brooks's Business Adventures to diagnose corporate failures, market panics, product timing errors, governa...