Agent skill

context-compactor

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.

Stars 1
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/fubira/claude-code-settings/tree/main/skills/context-compactor

SKILL.md

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

  1. Count lines and estimate tokens for each target file
  2. Present a summary table with file sizes
  3. Identify the largest contributors to context

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:

markdown
| 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

MUST preserve

  • User-specified behavioral instructions (personality, output style, preferences)
  • Active project conventions and standards
  • Security-related rules and constraints
  • Information that exists nowhere else (sole source of truth)

Safe to compact

  • Duplicated content (keep in the most appropriate location)
  • Verbose explanations of standard practices (LLMs already know these)
  • Completed/obsolete memory entries
  • Boilerplate sections repeated across files

Requires user judgment

  • Content the user may consider important even if technically redundant
  • Trade-offs between token savings and clarity
  • Whether to convert Japanese → English for token efficiency

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

Expand your agent's capabilities with these related and highly-rated skills.

fubira/claude-code-settings

refactoring-assistant

Assists with code refactoring by detecting code smells, suggesting improvements, and providing refactoring patterns. Activates when writing/editing code, explicitly requested refactoring, or when code quality issues are detected. Maintains awareness of core principles while providing detailed patterns and examples.

1 0
Explore
fubira/claude-code-settings

code-reviewer

Assists with code review by analyzing code changes for quality, best practices, security, and potential issues. Activates after implementing code features, bug fixes, or refactorings. Provides structured feedback with critical issues, suggestions, and positive highlights.

1 0
Explore
fubira/claude-code-settings

test-executor

Executes tests, analyzes test results, checks test coverage, and provides comprehensive testing status overview. Primarily for Go projects. Activates after implementing/modifying code to verify correctness, or when explicitly requested to assess test suite health.

1 0
Explore
fubira/claude-code-settings

knowledge-manager

Manages a structured knowledge base of patterns, troubleshooting guides, best practices, and workflows. Activates when discovering reusable insights, solving technical problems, or establishing new standards. Records knowledge in categorized files for future reference without bloating global CLAUDE.md.

1 0
Explore
fubira/claude-code-settings

release-assistant

Automates and ensures reliable release workflows with automatic version bump based on commit history, mandatory lint/build/test execution before release, and safe tag creation and push.

1 0
Explore
fubira/claude-code-settings

git-commit-assistant

Assists with careful Git commits in any repository. Activates when committing changes, checking .gitignore, or generating commit messages. Ensures proper file exclusion (credentials, MCP configs, personal settings), identifies untracked files, and generates Conventional Commits messages with Japanese explanations.

1 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results