claude-learn is an autonomous background daemon for Claude Code that reduces token consumption by 45-55%. It watches your sessions, detects repeated token-wasting patterns, and auto-applies safe optimizations to your CLAUDE.md files, enforcement hooks, skills, and RTK config
curl -fsSL https://raw.githubusercontent.com/ArhanCodes/claude-learn/main/install.sh | bashiwr -useb https://raw.githubusercontent.com/ArhanCodes/claude-learn/main/install.ps1 | iexAfter installing, add ~/.local/bin to your shell's PATH so the claude-learn command is available in every terminal:
# zsh (default on modern macOS)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
# bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
# fish
fish_add_path ~/.local/binOpen a new terminal or source your rc file to activate.
| User type | Savings |
|---|---|
| Light (few sessions/week) | 10–20% |
| Regular (daily, 2–3 projects) | 45–55% |
| Heavy (daily, long projects) | 55–65% |
| + Anthropic API key (LLM summaries) | 60–70% |
After installing the daemon is already running. You don't need to do anything, but if you want to peek:
# See what it's detected in your usage
claude-learn analyze
# See concrete suggestions
claude-learn suggest
# See what's been auto-applied
claude-learn history
# Check token savings so far
claude-learn savingsTo adjust behavior:
claude-learn config set interval_seconds 30 # more frequent
claude-learn config set threshold 3 # more aggressive
claude-learn config set enabled false # pause without uninstalling- Claude Code writes JSONL transcripts to ~/.claude/projects/
- claude-learn daemon polls every 60s
─ parses new sessions
- runs 12 pattern detectors
- filters for safe + not-already-applied
- applies ≤5 changes per tick
- Auto-writes to:
- CLAUDE.md (real extracted summaries + rules)
- .claude/settings.json (enforcement hooks)
- ~/.claude/skills/ (generated skills)
- rtk-enabled.txt (commands routed through RTK)
- Next Claude Code session reads optimised config → tokens saved
claude-learn configures Claude Code rather than proxying it. After apply, savings compound on every future session with zero runtime overhead.
Twelve patterns across four layers:
repeated-file-read- same file read 3+ times → inline real summary (imports, signatures, classes)repeated-bash— same command re-run → document or RTK-routebloated-output—npm install,git log, etc. → RTK-routevendor-exploration— Claude enteringnode_modules/.git/target/→ ignore rulesrepeated-grep— same search → document target locationcache-miss— low cache hit rate → restructureCLAUDE.mdfor cachingcross-project-pattern— same waste in multiple projects → globalCLAUDE.md
verbose-output— responses averaging >2000 tokens/turn → adds "be concise" rulewrite-for-small-change—Writeused for tiny edits → installs Write→Edit hooktool-sequence— repeated 3-tool sequences → suggests bundling
- Write → Edit gate — blocks
Writefor files <40 lines - Bash bloat filter — warns when bloated commands bypass RTK
- Read interceptor — nudges Claude to check
CLAUDE.mdsummary before re-reading
context-overflow→ generates session primer per projectunsummarized-file→ inline structural summary- Cross-session memory at
~/.claude/claude-learn-memory.json
claude-learn install / uninstall # register/deregister auto-start
claude-learn start / stop # control daemon
claude-learn status # daemon state + savings so far
claude-learn config [set <k> <v>] # show/edit settings liveclaude-learn analyze [-v] # patterns + potential savings
claude-learn suggest [--threshold N] # concrete suggestions
claude-learn apply [--dry-run] # interactive apply with preview
claude-learn apply --yes # bulk apply
claude-learn savings # token accounting
claude-learn projects # list tracked projects