Agent Skills: Context Compactor Skill

Analyzes and compacts context-affecting documents (project memory, CLAUDE.md, skill files) to reduce token usage and compaction frequency. Manual trigger only. Always requires user approval before making changes.

UncategorizedID: fubira/claude-code-settings/context-compactor

Install this agent skill to your local

pnpm dlx add-skill https://github.com/fubira/claude-code-settings/tree/HEAD/skills/context-compactor

Skill Files

Browse the full folder contents for context-compactor.

Download Skill

Loading file tree…

skills/context-compactor/SKILL.md

Skill Metadata

Name
context-compactor
Description
Analyzes and compacts context-affecting documents (project memory, CLAUDE.md, skill files) to reduce token usage and compaction frequency. Manual trigger only. Always requires user approval before making changes.

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