CLI output compression for LLM context efficiency. Use when setting up repos, optimizing token usage, or when users ask about reducing noise from build/test/git output in Claude Code sessions.
Compresses CLI command output to save LLM context tokens by filtering build, test, and git noise.
npx claudepluginhub rbergman/dark-matter-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
tokf is a config-driven CLI that compresses command output before it reaches your LLM context. It intercepts commands like cargo test, git push, and docker build, applies TOML-based filters, and emits only the signal — reducing noise by 60-99%.
Related skills:
mise use tokf)| Command | Before | After | Reduction |
|---|---|---|---|
cargo test (61 lines) | 1.7 KB | 35 B | 98% |
git push (8 lines) | 389 B | 8 B | 98% |
docker build | 1.8 KB | ~320 B | 82% |
gradle test | ~47 KB | 35 B | 99.9% |
Every token saved on command output is a token available for reasoning. In a typical session, build/test/git output can consume 20-40% of context — tokf reclaims most of it.
# Homebrew (macOS/Linux)
brew install mpecan/tokf/tokf
# Cargo (from source)
cargo install tokf
# Mise (if already using mise)
mise use -g tokf
Install the PreToolUse hook so tokf automatically filters Bash command output:
tokf hook install
This adds a hook to your Claude Code settings that rewrites commands through tokf transparently — zero friction, no manual tokf run prefixing needed.
Enable Claude Code to author and manage custom filters:
tokf skill install
This gives the agent knowledge of filter TOML syntax and the ability to create project-specific filters on the fly.
tokf run git status # Should produce compressed output
tokf which "cargo test" # Show which filter matches
tokf ls # List all available filters
Filters resolve in priority order (first match wins):
.tokf/filters/ # Project-local (committed with repo)
└── ~/.config/tokf/filters/ # User-level (personal overrides)
└── <built-in stdlib> # 47 filters embedded in binary
command = "cargo test" # Pattern to match (supports arrays)
strip_ansi = true # Remove ANSI escape codes
trim_lines = true # Trim whitespace per line
strip_empty_lines = true
dedup = true # Collapse consecutive identical lines
skip = ["^Compiling", "^Downloading", "^Fresh"] # Drop matching lines
keep = ["^error", "^test result"] # Keep only matching
[[replace]]
pattern = '^(\S+)\s+\S+\s+(\S+)\s+(\S+)'
output = "{1}: {2} -> {3}"
[on_success]
output = "ok"
[on_failure]
tail = 10 # Keep last N lines on failure
Key fields:
| Field | Purpose |
|---|---|
command | Match pattern — string or array, supports wildcards and basename matching |
skip / keep | Regex-powered line filtering (mutually exclusive) |
replace | Pattern-based line transformations with capture groups |
dedup | Collapse consecutive identical lines |
on_success / on_failure | Conditional output based on exit code |
strip_ansi | Remove color/formatting escape codes |
Override any built-in filter without recompilation:
# Project-local override (committed to repo)
tokf eject cargo/build
# User-level override (personal preference)
tokf eject cargo/build --global
Ejected filters land in .tokf/filters/ or ~/.config/tokf/filters/ for editing.
Commands that invoke different underlying tools use variants for context-aware filtering:
command = ["npm test", "pnpm test", "yarn test"]
strip_ansi = true
[[variant]]
name = "vitest"
detect.files = ["vitest.config.ts", "vitest.config.js"]
filter = "npm/test-vitest"
[[variant]]
name = "jest"
detect.files = ["jest.config.js", "jest.config.ts"]
filter = "npm/test-jest"
Detection is two-phase: file-based (before execution) wins first; output pattern matching is fallback.
For logic beyond TOML capabilities, embed Luau scripts:
[lua_script]
lang = "luau"
source = '''
if exit_code == 0 then
return "passed"
else
return "FAILED: " .. output
end
'''
Template pipes also support filter chains:
{output | lines | keep: "^error" | join: "\n"}
{output | truncate: 50}
Add tokf-aware recipes to your justfile:
# Run tests with compressed output (for CI/agent use)
test-quiet:
tokf run just test
# Show token savings
tokf-stats:
tokf gain
# Verify all project filters pass their test suites
tokf-verify:
tokf verify
tokf records byte counts per run in a local SQLite database:
tokf gain # Total savings summary
tokf gain --daily # Day-by-day breakdown
tokf gain --by-filter # Per-filter breakdown
Test suites live in <filter>_test/ directories adjacent to filter TOML files:
# .tokf/filters/cargo/test_test/success.toml
name = "passing tests show ok"
fixture = "tests/fixtures/cargo_test_pass.txt"
exit_code = 0
[[expect]]
equals = "ok"
tokf verify # Run all test suites
tokf verify cargo/test # Run specific suite
tokf verify --require-all # Fail if any filter lacks tests
Copy and paste this prompt to have an agent integrate tokf into an already-running project:
Install and configure tokf for this project.
- Install tokf:
brew install mpecan/tokf/tokf(orcargo install tokf)- Set up the Claude Code hook:
tokf hook install- Install the filter authoring skill:
tokf skill install- Check which built-in filters already cover our toolchain:
tokf ls- For any commands we run frequently that lack filters (check
just --listfor candidates), eject and customize the closest built-in:tokf eject <filter> && $EDITOR .tokf/filters/<filter>.toml- If no close match exists, create a new filter in
.tokf/filters/following the TOML format above- Test filters:
tokf verify- Add
.tokf/to the repo so the team shares filters:git add .tokf/- Verify savings:
tokf gain
tokf which "your command here" # See which filter would match
tokf run --verbose your command # Show matched filter name
tokf run --no-filter command # Bypass filtering entirely
By default tokf masks exit codes to 0. To preserve original exit codes:
tokf run --no-mask-exit-code cargo test
Or set in the filter TOML:
no_mask_exit_code = true
If you need colors preserved (e.g., for human-readable output):
tokf run --preserve-color cargo test
# or
TOKF_PRESERVE_COLOR=1 tokf run cargo test
tokf run --timing cargo test # Shows filtering duration
# Run commands through filters
tokf run cargo test # Filtered execution
tokf run git push origin main # Works with any command
# Discover and manage filters
tokf ls # List all available filters
tokf which "npm test" # Show matching filter
tokf show git/push # Display filter TOML source
tokf eject cargo/build # Override locally
tokf eject cargo/build --global # Override at user level
# Test and verify
tokf verify # Run all filter test suites
tokf verify --require-all # Strict mode
tokf test filter.toml fixture.txt --exit-code 0 # Test single filter
# Stats
tokf gain # Total token savings
tokf gain --daily # Daily breakdown
tokf gain --by-filter # Per-filter breakdown
# Claude Code integration
tokf hook install # Install PreToolUse hook
tokf skill install # Enable agent filter authoring
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.