### Install and set up a project Source: https://github.com/arifahmedjoy/leantoken/blob/main/README.md Install LeanToken globally, then initialize a project. The init command detects AI tools; add --dry-run to preview. The doctor command confirms setup and --fix repairs issues. ```sh npm install -g @arifahmedjoy/leantoken cd your-project lean init # add --dry-run to preview first lean doctor # confirms everything works (lean doctor --fix repairs what it finds) ``` -------------------------------- ### LeanToken command examples Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/usage.md Shows the main CLI commands: init (with dry-run), doctor (with fix), prune, symbols, audit, learn, stats, remove, and uninstall. `init` configures only the AI tools used; `--dry-run` previews changes. ```sh lean init --dry-run lean init lean doctor lean doctor --fix lean prune git status lean symbols src/core/pruner.js lean symbols docs/spec.md lean audit lean learn lean stats lean remove lean uninstall ``` -------------------------------- ### Global Setup and Run Coding Agent Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/07-curated-engine-spec.md Two-step workflow: initialize LeanToken globally with `lean init -g`, then run a coding agent like Claude Code normally. No addon checkboxes or prompt instructions needed. ```bash # 1. Global Setup (Done once) lean init -g # 2. Run coding agent normally (Claude Code, Cursor, OpenCode) claude ``` -------------------------------- ### Run tests and benchmark Source: https://github.com/arifahmedjoy/leantoken/blob/main/CONTRIBUTING.md Run the full test suite and benchmark before opening a pull request. Savings and latency figures must be measured with these commands. ```sh npm test npm run benchmark ``` -------------------------------- ### Run LeanToken from a checkout Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/usage.md Clone the repository and run the CLI directly with Node.js 18 or later. For a globally available `lean` command, run `npm link` in the repository; remove with `npm unlink -g`. ```sh git clone https://github.com/arifahmedjoy/leantoken.git cd leantoken node bin/lean.js help ``` -------------------------------- ### Activate PowerShell shell hook Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/usage.md Dot-source the PowerShell hook from the repository root to redirect selected commands through `lean prune` in the current shell. Use the CLI directly if you do not want that shell behavior. ```powershell . .\src\shell\hooks.ps1 ``` -------------------------------- ### Daily use commands Source: https://github.com/arifahmedjoy/leantoken/blob/main/README.md Common commands for daily use: symbols shows a section map with line ranges, audit shows token usage, learn refreshes memory (also done by Claude Code hook at session start), and stats shows what the hook has pruned. ```sh lean symbols docs/spec.md # section map with line ranges; read only what you need lean audit # where this project's tokens went in real sessions lean learn # refresh .lean/MEMORY.md now (Claude Code's hook also does it at session start) lean stats # what the hook has pruned so far ``` -------------------------------- ### Activate Bash or Zsh shell hook Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/usage.md Source the shell hook from the repository root to redirect selected commands through `lean prune` in the current shell. Use the CLI directly if you do not want that shell behavior. ```bash source ./src/shell/hooks.sh ``` -------------------------------- ### Run one component's test group Source: https://github.com/arifahmedjoy/leantoken/blob/main/CONTRIBUTING.md Run a single test group by requiring its test module and calling run(). Replace 'pruner' with the component name. ```sh node -e "require('./test/pruner.test').run()" ``` -------------------------------- ### Clone, link, test, and benchmark LeanToken Source: https://github.com/arifahmedjoy/leantoken/blob/main/README.md Sets up the repository for development. `npm link` puts the `lean` command on PATH from this checkout; undo with `npm unlink -g`. Run tests and benchmarks after linking. ```sh git clone https://github.com/arifahmedjoy/leantoken.git cd leantoken npm link # puts `lean` on PATH from this checkout (undo: npm unlink -g) npm test npm run benchmark ``` -------------------------------- ### Run test runner, benchmark, and prune command Source: https://github.com/arifahmedjoy/leantoken/blob/main/test-results/qa-evidence-report.md Commands executed from the repository root to run the test harness, the 1,000-iteration latency benchmark, and validate command pruning. ```bash # Run from the repository root node test/runner.js # Run the 1,000-iteration latency benchmark node test/benchmark.js # Validate command pruning node bin/lean.js prune git status ``` -------------------------------- ### lean init command output Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/08-cli-ux-spec.md Initializes LeanToken in the current directory, auto-detecting the environment and applying curated settings. Shows detected environment, injected files, and shell alias hooks. ```bash $ lean init ⚡ LeanToken v0.1.0 initialized ✓ Detected: Claude Code + Git repository ✓ Injected: CLAUDE.md (Unified Cognitive Shaper, 312 tokens) ✓ Spooled: .lean/logs/ & .lean/MEMORY.md ✓ Shell: Added alias hooks to your active shell profile ``` -------------------------------- ### LeanToken v0.1 Curated Engine Architecture Diagram Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/07-curated-engine-spec.md ASCII diagram showing the four subsystems of the LeanToken v0.1 curated engine: Unified Output & Diff Engine, Deterministic Tool Pruner, Lean Symbol Navigator, and Out-of-Band Session Learner. The diagram is part of the specification document and illustrates the single-install architecture. ```text ┌────────────────────────────────────────────────────────────────────────┐ │ LeanToken v0.1 Curated Engine │ │ (Single Install: `lean init`) │ └────────────────────────────────────────────────────────────────────────┘ │ ┌───────────────────────────────┼───────────────────────────────┐ ▼ ▼ ▼ [Subsystem 1] [Subsystem 2] [Subsystem 3] Unified Output & Diff Engine Deterministic Tool Pruner Lean Symbol Navigator - Merged Caveman + Ponytail - Embedded RTK / lean-prune - AST / Tree-sitter - Single static instruction - Intercepts test/diff/git - Sub-150 token schema - Zero prompt collision - Sub-3ms runtime (<5ms gate) - Replaces heavy graphs │ ▼ [Subsystem 4] Out-of-Band Session Learner - Standalone `lean-learn` hook - Analyzes transcript on close - Updates CLAUDE.md / MEMORY.md ``` -------------------------------- ### Uninstall LeanToken Source: https://github.com/arifahmedjoy/leantoken/blob/main/README.md Remove LeanToken from the current project, all projects, and globally. The remove command supports --purge to also delete .lean/. Uninstall restores files to their pre-init state and deletes created files. ```sh lean remove # this project only (--purge also deletes .lean/) lean uninstall # every project LeanToken was set up in, plus user-level config npm rm -g @arifahmedjoy/leantoken ``` -------------------------------- ### Prune Git Status Command Source: https://github.com/arifahmedjoy/leantoken/blob/main/test-results/aricon-real-scenario-2026-11-26.md Runs the lean prune command on git status. Returns exit status 0, compact output with 53% token reduction on first run and 50% on sequential verification, with 1.03-1.24 ms overhead. Full raw output is logged to .lean/logs/last-command.log. ```text lean prune git status ``` -------------------------------- ### lean learn command output Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/08-cli-ux-spec.md Out-of-band analyzer of Claude Code sessions, writing .lean/MEMORY.md with hot files and failing commands. Shows scan results and saved file. ```bash $ lean learn ⚡ LeanToken Learn: scanned 8 session(s) ✓ Hot files recorded: 10 ✓ Failed commands recorded: 0 ✓ Saved to: .lean/MEMORY.md ``` -------------------------------- ### Extract Symbols from File and Directory Source: https://github.com/arifahmedjoy/leantoken/blob/main/test-results/aricon-real-scenario-2026-11-26.md Extracts symbols from a file and a directory. For CLAUDE.md, 10 signatures with 90% savings; for docs directory, one Markdown file entry summarized with 85% savings. Directory results are limited to files in that directory, not nested. ```text lean symbols CLAUDE.md ``` ```text lean symbols docs ``` -------------------------------- ### lean symbols command output Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/08-cli-ux-spec.md Zero-MCP symbol extractor emitting minimal file signature outline for rapid context consumption. Shows file language, class methods, and token savings. ```bash $ lean symbols src/core/pruner.js FILE: src/core/pruner.js (Language: JavaScript) class CommandPruner method prune(command, rawOutput): { pruned: string, rawTokens: number, prunedTokens: number, savedPct: number } method pruneGitStatus(output): string method pruneTestOutput(output): string method pruneJson(output, maxDepth=2): string [Tokens: 68 | Full File: 840 tokens | -91.9% saved] ``` -------------------------------- ### lean stats command output Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/08-cli-ux-spec.md Displays measured pruning counters for the project, no estimated figures. Shows outputs pruned, token counts, savings, and pruning time. ```bash $ lean stats ════════════════════════════════════════════════════════════ LeanToken pruning stats (this project, measured) ════════════════════════════════════════════════════════════ Outputs pruned: 1 Tokens before pruning: 121 Tokens sent to agent: 52 Tokens saved: 69 (-57%) Pruning time (avg): 10.73 ms (excludes Node.js start-up per hook call) ════════════════════════════════════════════════════════════ Whole-session picture (reads, skipped outputs, tokens): lean audit ``` -------------------------------- ### lean prune command output Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/08-cli-ux-spec.md Runs a command, intercepts stdout/stderr, and returns pruned agent-optimized payload while saving full raw stream to local CCR. Shows pruned output and token savings. ```bash $ lean prune git status On branch main Changes not staged for commit: modified: src/core/pruner.js (5 lines) modified: test/pruner.test.js (2 lines) [LeanToken: pruned 84 verbose lines (-82% tokens) | Raw: .lean/logs/last-command.log] ``` -------------------------------- ### lean audit command output Source: https://github.com/arifahmedjoy/leantoken/blob/main/docs/08-cli-ux-spec.md Measures real sessions: model tokens, shell output pruned and skipped with reasons, file reads, re-reads, large whole-file reads, most-read files. Shows token usage and pruning statistics. ```bash $ lean audit Shell output total: ~100,117 tokens pruned: 3 outputs, ~311 tokens saved (0.3% of shell output) not pruned: 83 × ~ 92,184 tok compound command (pipes, ;, &&) File reads (the largest lever: content is never pruned, only read less) whole-file reads over 8k chars: 7 (~39,176 tokens): use `lean symbols `, then read one range ``` -------------------------------- ### LeanToken statusline command Source: https://github.com/arifahmedjoy/leantoken/blob/main/test-results/aricon-real-scenario-2026-11-26.md Command used in Claude statusline to display LeanToken status. It remains active after removing Headroom and ANTHROPIC_BASE_URL from Claude settings. ```text node "D:/lean-token/bin/lean.js" statusline ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.