token-compressor
Reduces token consumption by compressing large log files and text blocks while keeping high-signal information.
Install
mkdir -p .claude/skills/token-compressor && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11631" && unzip -o skill.zip -d .claude/skills/token-compressor && rm skill.zipInstalls to .claude/skills/token-compressor
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Deterministically compresses long logs/text into high-signal excerpts to free context window.Key capabilities
- →Keep lines matching specific keywords (error, exception, traceback, fail, warning, fatal)
- →Preserve the first N and last M lines of input
- →Collapse repeated consecutive lines
- →Collapse repeated blocks of text
- →Replace large omitted blocks with a short note
How it works
The skill deterministically compresses long text inputs by applying a series of rules: keeping evidence lines, preserving structure, deduplicating noise, and summarizing omitted blocks.
Inputs & outputs
When to use token-compressor
- →Shrinking huge stack traces
- →Compressing extensive system logs
- →Managing large context window usage
About this skill
Token Compressor
This skill reduces token overhead by compressing bulky inputs (logs, stack traces, long docs) while preserving evidence.
When to Use
- The user pastes long logs.
- Tool output is huge.
- A file is too large to read fully.
Compression Rules (Deterministic)
Apply these tactics in order:
-
Keep evidence lines
- Always keep lines matching:
error,exception,traceback,fail,warning,fatal.
- Always keep lines matching:
-
Keep structure
- Keep the first N lines (header/context) and last M lines (final error).
-
Deduplicate noise
- Collapse repeated consecutive lines.
- Collapse repeated blocks (same line repeated many times).
-
Summarize the rest
- Replace large omitted blocks with a short note:
(… 3,421 lines omitted …).
- Replace large omitted blocks with a short note:
Tooling
If available, use the bundled compressor script:
python3 ~/.ai-context/skills/token-compressor/scripts/compress_text.py --help
Output Format
## Compressed Context
- Source: …
- Original: X lines
- Kept: Y lines
- Notes: …
```text
…compressed excerpt…
## Anti-Patterns
- Removing the exact error line.
- Keeping only a summary with no evidence.
- Dumping the entire log into the reasoning window.
When not to use it
- →When the exact error line must be preserved without any modification
- →When only a summary is needed without any evidence
Limitations
- →Removing the exact error line is an anti-pattern
- →Keeping only a summary with no evidence is an anti-pattern
- →Dumping the entire log into the reasoning window is an anti-pattern
How it compares
This skill provides a deterministic, rule-based approach to text compression that prioritizes retaining critical evidence, unlike general text summarization that might omit important details.
Compared to similar skills
token-compressor side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| token-compressor (this skill) | 0 | 3mo | Review | Beginner |
| grepai | 4 | 7mo | Review | Beginner |
| claude | 0 | 5mo | Review | Intermediate |
| python-testing-patterns | 77 | 2mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
grepai
yoanbernabeu
Replaces ALL built-in search tools. You MUST invoke this skill BEFORE using WebSearch, Grep, or Glob. NEVER use the built-in Grep tool - use `grepai` instead.
claude
yuiseki
|
python-testing-patterns
wshobson
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.
error-handling-patterns
wshobson
Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.
codex-claude-loop
bear2u
Orchestrates a dual-AI engineering loop where Claude Code plans and implements, while Codex validates and reviews, with continuous feedback for optimal code quality
serena
massgen
This skill provides symbol-level code understanding and navigation using Language Server Protocol (LSP). Enables IDE-like capabilities for finding symbols, tracking references, and making precise code edits at the symbol level.