{
  "markdown": "# Smart Compact\n\n> Save structured session context before `/clear` and auto-prompt to restore it next session. Never lose conversation context again.\n\n## The Problem\n\nClaude Code's `/clear` command wipes all conversation context. If you're mid-project and need a fresh context window, you lose everything — decisions made, problems solved, next steps planned. Starting over means re-explaining everything.\n\n## The Solution\n\nSmart Compact gives you two things:\n\n1. **`/smart-compact` command** — Saves a structured summary of your session (what was done, why, decisions, problems, next steps) to a project-specific file.\n2. **Auto-restore prompt** — On next session start, Claude automatically detects the saved context and asks if you want to load it.\n\n## How It Works\n\n```\nYou: /smart-compact\nClaude: Context saved to smart-compact-context.md (3.2K).\n        Run /clear when you want a fresh start.\n\nYou: /clear\n\n--- Next session ---\n\nClaude: I have saved context from a previous session. Would you like me\n        to load it to pick up where we left off, or start fresh?\n```\n\nContext files are stored per-project at:\n```\n~/.claude/projects/<project-path>/smart-compact-context.md\n```\n\n## What Gets Saved\n\nEach context snapshot includes:\n- **Project status** — Self-contained summary of the current state\n- **Work done** — What and why (not just what)\n- **Decisions made** — With full reasoning and alternatives considered\n- **Problems & solutions** — Root cause, fix, and lesson learned\n- **Next steps** — Remaining work as a checklist\n\nThe file is a **living document** — new sessions are appended, old ones are pruned to keep it under ~2000 tokens.\n\n## Installation\n\n```bash\nclaude /plugin install paolodiana/smart-compact\n```\n\n## Recommended Setup\n\nFor the most reliable experience, add this rule to your `~/.claude/CLAUDE.md`:\n\n```markdown\n**Smart Compact**: If the system prompt mentions \"session context available\"\nor \"smart compact\", your FIRST response MUST ask the user if they want to\nload the saved context, BEFORE responding to anything else.\n```\n\nThis ensures Claude always asks about saved context, even with casual greetings like \"hey\" or \"hi\".\n\n> **Why?** The plugin hook injects context via `additionalContext` (system-reminder priority). With very short user messages, Claude may occasionally skip low-priority instructions. A CLAUDE.md rule has the highest priority and guarantees the behavior.\n\n## Usage\n\n### Save context before clearing\n```\n/smart-compact\n```\n\n### Context is auto-detected on next session\nNo action needed — the SessionStart hook checks for saved context automatically.\n\n## How Context Is Stored\n\n```\nsmart-compact-context.md\n├── Project status (always current)\n├── Session 2026-03-30 14:00\n│   ├── Work done\n│   ├── Files modified\n│   ├── Decisions made\n│   ├── Problems and solutions\n│   └── Next steps\n└── Session 2026-03-29 10:00 (older, pruned to key points)\n```\n\n## Smart Compact vs `/compact`\n\nClaude Code has a built-in `/compact` command. Here's why Smart Compact exists alongside it:\n\n| | `/compact` (built-in) | `/smart-compact` (this plugin) |\n|---|---|---|\n| **What it does** | Summarizes conversation history to free up context | Extracts key decisions, problems, and next steps into a structured file |\n| **Context freed** | Partial — compresses old messages but keeps growing | Full — `/clear` after saving gives you ~100% free context |\n| **Survives `/clear`** | No — cleared along with everything else | Yes — saved to disk, persists across sessions |\n| **Cross-session** | No — lives only in the current session | Yes — auto-detected on next session start |\n| **Format** | Opaque summary (you don't control what's kept) | Structured: decisions with reasoning, problems with root causes, explicit next steps |\n| **Accumulation** | Re-compacts over itself, losing detail each time | Living document — appends new sessions, prunes old ones while keeping key lessons |\n\n**Think of it this way:** `/compact` compresses the tape so you can keep recording a bit longer. `/smart-compact` saves the highlight reel to a separate disk, lets you start with a blank tape, and auto-loads the highlights next time.\n\n**They work best together:** use `/compact` during a session to extend your runway, and `/smart-compact` at the end to preserve what matters before starting fresh.\n\n## Requirements\n\n- Claude Code CLI\n- `jq` is NOT required (the hook uses pure bash)\n\n## License\n\nMIT\n",
  "bytes": 4426,
  "sha": "c8b711786010be832555b4d681f067e73f78638a8c020be6c9f653afb0e766ad",
  "repo_slug": "omacatl94/smart-compact",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_omacatl94_smart_compact_smart_compact_10b5f252/readme"
}