Context Compactor Skill
Analyze and compact documents that affect context window size. Reduce token usage while preserving essential information.
Activation Triggers
Manual only — never auto-activate.
/compact-context— run full analysis- "コンテキストを整理して", "compact context", "reduce context size"
Target Files
| Target | Path Pattern | Description |
|--------|-------------|-------------|
| Project Memory | .claude/projects/*/memory/*.md | Auto-memory files that grow over time |
| Project CLAUDE.md | {project}/CLAUDE.md | Project-specific instructions |
| Global CLAUDE.md | ~/.claude/CLAUDE.md | Global instructions |
| Skill files | ~/.claude/skills/*/SKILL.md | Skill definitions |
Workflow
Phase 1: Measure
Run ~/.claude/scripts/context-audit.sh to get a per-file size inventory (CLAUDE.md, per-project MEMORY.md and topic files, each SKILL.md with its frontmatter description size). The script reports raw line/char counts only — for actual context usage, check the built-in /context command. Identify the largest contributors from the output.
Phase 2: Analyze
For each target file, detect:
- Redundancy: Content duplicated across files (e.g., CLAUDE.md vs skills, memory vs CLAUDE.md)
- Obsolescence: Outdated information (completed tasks, old decisions, superseded patterns)
- Verbosity: Content that can be expressed more concisely without losing meaning
- Language inefficiency: Japanese text in technical/process docs where English would use fewer tokens
Phase 3: Propose
Present findings as a structured table:
| File | Current | Est. After | Reduction | Changes |
|------|---------|-----------|-----------|---------|
| ... | ... | ... | ... | Brief description |
For each file with proposed changes, show:
- What will be removed/compacted (with reasoning)
- What will be preserved (and why)
Wait for user approval before proceeding.
Phase 4: Execute (after approval)
- Apply approved changes only
- Show before/after line counts
- Suggest committing if in a git repo
Analysis Rules
Classification rules (MUST preserve / Safe to compact / Requires user judgment) are in references/rules.md. Read it before Phase 2 (Analyze).
Important Notes
- Never delete without showing what will be removed
- Preserve meaning even when reducing words
- When in doubt, keep — false deletion is worse than slight verbosity
- This skill does NOT auto-activate — context growth is normal and expected