Open-source token-saving layer
Save tokens across AI coding agents.
Install TokenKlaw, install into your runtime, then activate with /tokenklaw or /tk. Claude Code now recognizes both commands through plugin-style integration, with clean activation responses and no reasoning leakage.
Example repeated-context savings
Before
████████████████████ 12,000 tokens
After TokenKlaw
██████ 3,480 tokens
Saved
71%
Works Inside Claude Code
Validated plugin-style runtime integration: command recognition + clean activation behavior.
Verified command recognition
/tokenklaw -> recognized /tk -> recognized Expected clean activation: TokenKlaw active.
Public activation behavior is refined for final-output only responses (no internal reasoning narration).
Claude plugin structure
~/.claude/.claude-plugin/plugin.json ~/.claude/.claude-plugin/marketplace.json ~/.claude/commands/tokenklaw.toml ~/.claude/commands/tk.toml ~/.claude/skills/tokenklaw/SKILL.md ~/.claude/hooks/tokenklaw.pre-response.md ~/.claude/CLAUDE.md
Install → Integrate → Activate → Save Tokens
Central activation flow across runtimes.
Step 1
Install TokenKlaw
Build once locally and run the installer.
Step 2
Install into Claude / Roo / Cursor / others
Runtime-specific installer adapters generate the right artifacts.
Step 3
Activate with /tokenklaw or /tk
Native command path inside supported runtime UX.
Step 4
Token-saving mode enabled
Context compression, duplicate suppression, cleaner responses.
Supported runtimes
Universal runtime installer architecture across current targets and future scaffolds.
Future scaffold
Before / after examples
Realistic prompt compression and cache-hit scenarios.
React rerender debugging
Without: "Let me explain your React rerender in detail..." [1,280 tokens] With TokenKlaw: "Inline object ref causes rerender. Memoize with useMemo." [312 tokens] Saved: 75%
Auth middleware bug
Without: Long branch-by-branch explanation with repeated logs [2,050 tokens] With TokenKlaw: "Duplicate auth checks. Consolidate guard + avoid full request logs." [640 tokens] Saved: 69%
One-command install
Public install UX for macOS/Linux/WSL and Windows PowerShell.
macOS / Linux / WSL
curl -fsSL https://token.klaw.at/install.sh | bash # runtime example: curl -fsSL https://raw.githubusercontent.com/janpaul80/tokenklaw/main/install.sh | bash -s -- --runtime claude
Windows PowerShell
irm https://token.klaw.at/install.ps1 | iex # runtime example: powershell -ExecutionPolicy Bypass -File .\install.ps1 -Runtime claude
Then activate in your agent
/tokenklaw /tk
Benchmarks
Example repeated-context scenarios. Results vary by workflow and cache hit rate.
| Task | Without | With TokenKlaw | Saved |
|---|---|---|---|
| Repeated repo analysis | 12,000 | 3,480 | 71% |
| Duplicate logs in debug loop | 8,500 | 4,200 | 50% |
| Repeated stack trace explanation | 5,200 | 2,100 | 60% |
| Exact prompt repeat (cache hit) | 6,000 | 0 | up to 100% |
How it works
Simple request path, local-first internals.
Agent ↓ TokenKlaw ↓ Fingerprint + Context Reduction + Cache ↓ OpenAI / Anthropic / Gemini / Local models
CLI preview
Install + activation commands first, then regular token/cost stats.
$ tokenklaw install claude --dry-run ok: true agent: claude written: tokenklaw.rules.md tokenklaw.skill.md tokenklaw.prompt.md tokenklaw.slash-commands.md $ tokenklaw activate on TokenKlaw active. Context reduction: on Duplicate detection: on Cache guidance: on Verbose replies: reduced Token-saving mode: enabled $ tokenklaw activate stats active: true token_saving_mode: enabled
Media
Responsive placeholders for upcoming demos, recordings, and validation assets.
MP4 Placeholder
Terminal installation walkthrough recording.
GIF Placeholder
Claude Code command recognition and activation flow.
PNG/JPG Placeholder
Plugin structure visuals and architecture diagrams.
Token Comparison Placeholder
Before/after token reduction and context compression charts.
Created by Paul Hartmann (@janpaul80)
Building practical infrastructure for AI-native development.
