claude-lean 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. claude_lean-0.1.0/.gitignore +63 -0
  2. claude_lean-0.1.0/LICENSE +21 -0
  3. claude_lean-0.1.0/PKG-INFO +182 -0
  4. claude_lean-0.1.0/README.md +148 -0
  5. claude_lean-0.1.0/docs/faq.md +142 -0
  6. claude_lean-0.1.0/docs/getting-started.md +164 -0
  7. claude_lean-0.1.0/docs/how-it-works.md +282 -0
  8. claude_lean-0.1.0/docs/safety.md +118 -0
  9. claude_lean-0.1.0/docs/superpowers/specs/2026-05-16-claude-lean-design.md +603 -0
  10. claude_lean-0.1.0/pyproject.toml +68 -0
  11. claude_lean-0.1.0/src/claude_lean/__init__.py +9 -0
  12. claude_lean-0.1.0/src/claude_lean/__main__.py +6 -0
  13. claude_lean-0.1.0/src/claude_lean/apply/__init__.py +1 -0
  14. claude_lean-0.1.0/src/claude_lean/apply/generator.py +180 -0
  15. claude_lean-0.1.0/src/claude_lean/apply/memory_cleaner.py +77 -0
  16. claude_lean-0.1.0/src/claude_lean/apply/wizard.py +107 -0
  17. claude_lean-0.1.0/src/claude_lean/audit/__init__.py +7 -0
  18. claude_lean-0.1.0/src/claude_lean/audit/analyzer.py +51 -0
  19. claude_lean-0.1.0/src/claude_lean/audit/report.py +163 -0
  20. claude_lean-0.1.0/src/claude_lean/audit/rules/__init__.py +22 -0
  21. claude_lean-0.1.0/src/claude_lean/audit/rules/_base.py +41 -0
  22. claude_lean-0.1.0/src/claude_lean/audit/rules/forcing_rules.py +55 -0
  23. claude_lean-0.1.0/src/claude_lean/audit/rules/memory_near_cap.py +56 -0
  24. claude_lean-0.1.0/src/claude_lean/audit/rules/stale_memory.py +65 -0
  25. claude_lean-0.1.0/src/claude_lean/audit/rules/unused_plugins.py +59 -0
  26. claude_lean-0.1.0/src/claude_lean/audit/rules/vague_descriptions.py +67 -0
  27. claude_lean-0.1.0/src/claude_lean/audit/scanner.py +273 -0
  28. claude_lean-0.1.0/src/claude_lean/cli.py +333 -0
  29. claude_lean-0.1.0/src/claude_lean/common/__init__.py +1 -0
  30. claude_lean-0.1.0/src/claude_lean/common/backup.py +114 -0
  31. claude_lean-0.1.0/src/claude_lean/common/claude_paths.py +90 -0
  32. claude_lean-0.1.0/src/claude_lean/common/log.py +35 -0
  33. claude_lean-0.1.0/src/claude_lean/common/tokenizer.py +62 -0
  34. claude_lean-0.1.0/src/claude_lean/profile/__init__.py +6 -0
  35. claude_lean-0.1.0/src/claude_lean/profile/manager.py +80 -0
  36. claude_lean-0.1.0/src/claude_lean/profile/schema.py +41 -0
  37. claude_lean-0.1.0/src/claude_lean/profile/stock/frontend-web.toml +43 -0
  38. claude_lean-0.1.0/src/claude_lean/profile/stock/minimal.toml +40 -0
  39. claude_lean-0.1.0/src/claude_lean/profile/stock/python-ml.toml +43 -0
  40. claude_lean-0.1.0/tests/__init__.py +0 -0
  41. claude_lean-0.1.0/tests/conftest.py +22 -0
  42. claude_lean-0.1.0/tests/fixtures/fake_claude_home/CLAUDE.md +2 -0
  43. claude_lean-0.1.0/tests/fixtures/fake_claude_home/plugins/cache/sample-marketplace/engineering-skills/1.0.0/sample-skill/SKILL.md +13 -0
  44. claude_lean-0.1.0/tests/fixtures/fake_claude_home/plugins/cache/sample-marketplace/engineering-skills/1.0.0/sample-skill/agents/sample-agent.md +9 -0
  45. claude_lean-0.1.0/tests/fixtures/fake_claude_home/plugins/cache/sample-marketplace/marketing-skills/1.0.0/marketing-skill/SKILL.md +6 -0
  46. claude_lean-0.1.0/tests/fixtures/fake_claude_home/projects/-fake-project/memory/MEMORY.md +3 -0
  47. claude_lean-0.1.0/tests/fixtures/fake_claude_home/projects/-fake-project/memory/good_memory.md +8 -0
  48. claude_lean-0.1.0/tests/fixtures/fake_claude_home/projects/-fake-project/memory/stale_memory.md +10 -0
  49. claude_lean-0.1.0/tests/fixtures/fake_claude_home/projects/-fake-project/memory/vague_memory.md +8 -0
  50. claude_lean-0.1.0/tests/fixtures/fake_claude_home/settings.json +8 -0
  51. claude_lean-0.1.0/tests/test_backup.py +52 -0
  52. claude_lean-0.1.0/tests/test_cli.py +68 -0
  53. claude_lean-0.1.0/tests/test_rules.py +75 -0
  54. claude_lean-0.1.0/tests/test_scanner.py +57 -0
  55. claude_lean-0.1.0/tests/test_tokenizer.py +32 -0
@@ -0,0 +1,63 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+ MANIFEST
23
+
24
+ # Virtual environments
25
+ .venv/
26
+ venv/
27
+ env/
28
+ ENV/
29
+
30
+ # Testing
31
+ .pytest_cache/
32
+ .coverage
33
+ .coverage.*
34
+ htmlcov/
35
+ .tox/
36
+ .cache
37
+ nosetests.xml
38
+ coverage.xml
39
+ *.cover
40
+ .hypothesis/
41
+
42
+ # Linting / type checking
43
+ .ruff_cache/
44
+ .mypy_cache/
45
+ .dmypy.json
46
+ dmypy.json
47
+
48
+ # IDE
49
+ .vscode/
50
+ .idea/
51
+ *.swp
52
+ *.swo
53
+ *~
54
+
55
+ # macOS
56
+ .DS_Store
57
+
58
+ # Backups (claude-lean's own backups during dev)
59
+ .claude-lean-backups/
60
+
61
+ # Local
62
+ *.local
63
+ .env
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vipin <contact@buffercode.in>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: claude-lean
3
+ Version: 0.1.0
4
+ Summary: Get 5x more from your Claude Code token budget — audit, trim, and switch context profiles per project.
5
+ Project-URL: Homepage, https://github.com/vipin/claude-lean
6
+ Project-URL: Repository, https://github.com/vipin/claude-lean
7
+ Project-URL: Documentation, https://github.com/vipin/claude-lean#readme
8
+ Project-URL: Issues, https://github.com/vipin/claude-lean/issues
9
+ Author-email: vipin <contact@buffercode.in>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: anthropic,claude-code,context,optimization,tokens
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: rich>=13.0.0
27
+ Provides-Extra: accurate
28
+ Requires-Dist: tiktoken>=0.5.0; extra == 'accurate'
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
31
+ Requires-Dist: pytest>=7.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ <div align="center">
36
+
37
+ # `claude-lean`
38
+
39
+ **Get 5× more from your Claude Code token budget.**
40
+
41
+ *Audit, trim, and switch context profiles per project — without touching Claude Code itself.*
42
+
43
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org)
44
+ [![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
45
+ [![Status](https://img.shields.io/badge/status-alpha-orange)](#status)
46
+
47
+ </div>
48
+
49
+ ---
50
+
51
+ ## Why
52
+
53
+ By default, Claude Code loads **every enabled plugin's metadata into your context on every turn**. For a fresh install with the default plugin set, that's often **500,000+ tokens** of agent descriptions, skill metadata, and MCP preambles — *regardless of whether you ever invoke them*.
54
+
55
+ The result: shorter conversations before compaction, slower responses, higher cost, and a tax on multi-agent workflows. `claude-lean` makes that hidden cost visible — and gives you four levers to reclaim it.
56
+
57
+ ## The Four Levers
58
+
59
+ ```
60
+ ┌──────────────────────────────────────────────────────────────────┐
61
+ │ │
62
+ │ 1. AUDIT → See exactly what's eating your context │
63
+ │ 2. APPLY → Disable what you don't use (with backup) │
64
+ │ 3. PROFILE → Different active set per project / cwd │
65
+ │ 4. RESTORE → One command back to any previous state │
66
+ │ │
67
+ └──────────────────────────────────────────────────────────────────┘
68
+ ```
69
+
70
+ ## Quick Start
71
+
72
+ ```bash
73
+ # Install (zero hard dependencies beyond rich, which most setups have)
74
+ pipx install claude-lean
75
+
76
+ # 1. See what's costing you
77
+ claude-lean audit
78
+
79
+ # 2. Apply recommendations interactively (with diff + backup + dry-run safety)
80
+ claude-lean apply
81
+
82
+ # 3. Switch to a focused profile in a specific project
83
+ cd ~/my-python-project
84
+ claude-lean profile use python-ml
85
+
86
+ # 4. Undo anything
87
+ claude-lean restore --latest
88
+ ```
89
+
90
+ ## Real Numbers From a Real Setup
91
+
92
+ A representative audit on a default-everything install:
93
+
94
+ ```
95
+ ───────────────────────── claude-lean audit ─────────────────────────
96
+
97
+ Plugins enabled: 20 · Skills: 262 · Agents: 18
98
+ Estimated system-prompt overhead per turn: 593,122 tokens
99
+
100
+ Top contributors (tokens / turn):
101
+ engineering-advanced-skills 129,302 ✓ keep
102
+ engineering-skills 123,232 ✓ keep
103
+ marketing-skills 111,126 ⚠ disable (no marketing work)
104
+ c-level-skills 68,660 ⚠ disable (no exec work)
105
+ ra-qm-skills 44,325 ⚠ disable (no regulatory work)
106
+
107
+ 17 findings · Estimated savings if applied: 298,283 tokens / turn
108
+ ≈ 2.0× more headroom
109
+ ```
110
+
111
+ With per-project profiles (level 3 above), that 2.0× compounds to **5×+** by loading only the plugins relevant to *that* project's stack.
112
+
113
+ ## How It Works
114
+
115
+ `claude-lean` is a **standalone Python CLI**, not a Claude Code plugin. It runs outside Claude Code and operates on the plain files in `~/.claude/`. Because it never loads into your prompt context, it costs **zero tokens** per Claude conversation.
116
+
117
+ ```
118
+ ┌─────────────────────────────────┐
119
+ │ claude-lean CLI │
120
+ │ (runs in your terminal) │
121
+ └────────────────┬────────────────┘
122
+ │ reads / writes
123
+
124
+ ┌─────────────────────────────────┐
125
+ │ ~/.claude/ │
126
+ │ • CLAUDE.md │
127
+ │ • settings.json │
128
+ │ • plugins/cache/ │
129
+ │ • projects/*/memory/ │
130
+ └─────────────────────────────────┘
131
+ ```
132
+
133
+ See [docs/how-it-works.md](./docs/how-it-works.md) for the full architecture.
134
+
135
+ ## Safety
136
+
137
+ - **Every write creates a backup first** to `~/.claude/.claude-lean-backups/{timestamp}/`
138
+ - **Dry-run is the default for non-TTY usage** — pipes don't accidentally mutate state
139
+ - **`claude-lean restore --latest`** reverts the most recent change in one command
140
+ - **`--list` shows every snapshot** you've ever made
141
+
142
+ See [docs/safety.md](./docs/safety.md) for the full safety model.
143
+
144
+ ## Documentation
145
+
146
+ | Doc | Purpose |
147
+ |---|---|
148
+ | **[Getting Started](./docs/getting-started.md)** | First-time setup, install, the audit→apply loop |
149
+ | **[How It Works](./docs/how-it-works.md)** | Architecture, the four subsystems, data flow |
150
+ | **[Safety](./docs/safety.md)** | Backup, restore, dry-run, what we never touch |
151
+ | **[FAQ](./docs/faq.md)** | Common questions, troubleshooting, limitations |
152
+
153
+ ## Commands
154
+
155
+ | Command | What it does |
156
+ |---|---|
157
+ | `claude-lean audit` | Scan `~/.claude/`, report opportunities (read-only) |
158
+ | `claude-lean audit --json` | Machine-readable output |
159
+ | `claude-lean apply` | Interactive wizard, applies recommendations with diff + backup |
160
+ | `claude-lean apply --dry-run` | Show what would change without writing |
161
+ | `claude-lean apply --yes` | Skip interactive prompt (still respects `--dry-run`) |
162
+ | `claude-lean profile list` | Show installed profiles |
163
+ | `claude-lean profile show <name>` | Print a profile's contents |
164
+ | `claude-lean profile use <name>` | Apply a profile (with backup + diff) |
165
+ | `claude-lean restore --latest` | Revert the most recent change |
166
+ | `claude-lean restore --list` | List all snapshots |
167
+
168
+ ## Status
169
+
170
+ **v0.1.0 — alpha.** The core (`audit`, `apply`, `restore`, `profile`) is working and tested. The following are roadmapped for later versions:
171
+
172
+ - **v0.3** — `claude-lean monitor` (live token-usage dashboard from session logs)
173
+ - **v0.4** — Claude Code hooks integration (auto-switch profile on `cd`)
174
+ - **v1.0** — Profile marketplace + community-contributed profiles
175
+
176
+ ## License
177
+
178
+ MIT — see [LICENSE](./LICENSE).
179
+
180
+ ## Contributing
181
+
182
+ Issues and PRs welcome. Per-project profiles are intentionally easy to contribute — drop a TOML file in `src/claude_lean/profile/stock/`, add a test, ship a PR.
@@ -0,0 +1,148 @@
1
+ <div align="center">
2
+
3
+ # `claude-lean`
4
+
5
+ **Get 5× more from your Claude Code token budget.**
6
+
7
+ *Audit, trim, and switch context profiles per project — without touching Claude Code itself.*
8
+
9
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org)
10
+ [![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
11
+ [![Status](https://img.shields.io/badge/status-alpha-orange)](#status)
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## Why
18
+
19
+ By default, Claude Code loads **every enabled plugin's metadata into your context on every turn**. For a fresh install with the default plugin set, that's often **500,000+ tokens** of agent descriptions, skill metadata, and MCP preambles — *regardless of whether you ever invoke them*.
20
+
21
+ The result: shorter conversations before compaction, slower responses, higher cost, and a tax on multi-agent workflows. `claude-lean` makes that hidden cost visible — and gives you four levers to reclaim it.
22
+
23
+ ## The Four Levers
24
+
25
+ ```
26
+ ┌──────────────────────────────────────────────────────────────────┐
27
+ │ │
28
+ │ 1. AUDIT → See exactly what's eating your context │
29
+ │ 2. APPLY → Disable what you don't use (with backup) │
30
+ │ 3. PROFILE → Different active set per project / cwd │
31
+ │ 4. RESTORE → One command back to any previous state │
32
+ │ │
33
+ └──────────────────────────────────────────────────────────────────┘
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```bash
39
+ # Install (zero hard dependencies beyond rich, which most setups have)
40
+ pipx install claude-lean
41
+
42
+ # 1. See what's costing you
43
+ claude-lean audit
44
+
45
+ # 2. Apply recommendations interactively (with diff + backup + dry-run safety)
46
+ claude-lean apply
47
+
48
+ # 3. Switch to a focused profile in a specific project
49
+ cd ~/my-python-project
50
+ claude-lean profile use python-ml
51
+
52
+ # 4. Undo anything
53
+ claude-lean restore --latest
54
+ ```
55
+
56
+ ## Real Numbers From a Real Setup
57
+
58
+ A representative audit on a default-everything install:
59
+
60
+ ```
61
+ ───────────────────────── claude-lean audit ─────────────────────────
62
+
63
+ Plugins enabled: 20 · Skills: 262 · Agents: 18
64
+ Estimated system-prompt overhead per turn: 593,122 tokens
65
+
66
+ Top contributors (tokens / turn):
67
+ engineering-advanced-skills 129,302 ✓ keep
68
+ engineering-skills 123,232 ✓ keep
69
+ marketing-skills 111,126 ⚠ disable (no marketing work)
70
+ c-level-skills 68,660 ⚠ disable (no exec work)
71
+ ra-qm-skills 44,325 ⚠ disable (no regulatory work)
72
+
73
+ 17 findings · Estimated savings if applied: 298,283 tokens / turn
74
+ ≈ 2.0× more headroom
75
+ ```
76
+
77
+ With per-project profiles (level 3 above), that 2.0× compounds to **5×+** by loading only the plugins relevant to *that* project's stack.
78
+
79
+ ## How It Works
80
+
81
+ `claude-lean` is a **standalone Python CLI**, not a Claude Code plugin. It runs outside Claude Code and operates on the plain files in `~/.claude/`. Because it never loads into your prompt context, it costs **zero tokens** per Claude conversation.
82
+
83
+ ```
84
+ ┌─────────────────────────────────┐
85
+ │ claude-lean CLI │
86
+ │ (runs in your terminal) │
87
+ └────────────────┬────────────────┘
88
+ │ reads / writes
89
+
90
+ ┌─────────────────────────────────┐
91
+ │ ~/.claude/ │
92
+ │ • CLAUDE.md │
93
+ │ • settings.json │
94
+ │ • plugins/cache/ │
95
+ │ • projects/*/memory/ │
96
+ └─────────────────────────────────┘
97
+ ```
98
+
99
+ See [docs/how-it-works.md](./docs/how-it-works.md) for the full architecture.
100
+
101
+ ## Safety
102
+
103
+ - **Every write creates a backup first** to `~/.claude/.claude-lean-backups/{timestamp}/`
104
+ - **Dry-run is the default for non-TTY usage** — pipes don't accidentally mutate state
105
+ - **`claude-lean restore --latest`** reverts the most recent change in one command
106
+ - **`--list` shows every snapshot** you've ever made
107
+
108
+ See [docs/safety.md](./docs/safety.md) for the full safety model.
109
+
110
+ ## Documentation
111
+
112
+ | Doc | Purpose |
113
+ |---|---|
114
+ | **[Getting Started](./docs/getting-started.md)** | First-time setup, install, the audit→apply loop |
115
+ | **[How It Works](./docs/how-it-works.md)** | Architecture, the four subsystems, data flow |
116
+ | **[Safety](./docs/safety.md)** | Backup, restore, dry-run, what we never touch |
117
+ | **[FAQ](./docs/faq.md)** | Common questions, troubleshooting, limitations |
118
+
119
+ ## Commands
120
+
121
+ | Command | What it does |
122
+ |---|---|
123
+ | `claude-lean audit` | Scan `~/.claude/`, report opportunities (read-only) |
124
+ | `claude-lean audit --json` | Machine-readable output |
125
+ | `claude-lean apply` | Interactive wizard, applies recommendations with diff + backup |
126
+ | `claude-lean apply --dry-run` | Show what would change without writing |
127
+ | `claude-lean apply --yes` | Skip interactive prompt (still respects `--dry-run`) |
128
+ | `claude-lean profile list` | Show installed profiles |
129
+ | `claude-lean profile show <name>` | Print a profile's contents |
130
+ | `claude-lean profile use <name>` | Apply a profile (with backup + diff) |
131
+ | `claude-lean restore --latest` | Revert the most recent change |
132
+ | `claude-lean restore --list` | List all snapshots |
133
+
134
+ ## Status
135
+
136
+ **v0.1.0 — alpha.** The core (`audit`, `apply`, `restore`, `profile`) is working and tested. The following are roadmapped for later versions:
137
+
138
+ - **v0.3** — `claude-lean monitor` (live token-usage dashboard from session logs)
139
+ - **v0.4** — Claude Code hooks integration (auto-switch profile on `cd`)
140
+ - **v1.0** — Profile marketplace + community-contributed profiles
141
+
142
+ ## License
143
+
144
+ MIT — see [LICENSE](./LICENSE).
145
+
146
+ ## Contributing
147
+
148
+ Issues and PRs welcome. Per-project profiles are intentionally easy to contribute — drop a TOML file in `src/claude_lean/profile/stock/`, add a test, ship a PR.
@@ -0,0 +1,142 @@
1
+ # FAQ
2
+
3
+ ## General
4
+
5
+ ### Why a separate CLI instead of a Claude Code plugin?
6
+
7
+ Because a plugin's metadata loads into Claude's context every turn — including the metadata of the plugin that's supposed to *save* you tokens. Putting `claude-lean` *outside* Claude Code means it costs zero tokens per conversation. The optimization is purely build-time.
8
+
9
+ ### Is the "5×" claim real?
10
+
11
+ For a default-everything install on the most popular plugin packs, yes. The breakdown:
12
+
13
+ | Lever | Approx. saving |
14
+ |---|---|
15
+ | Disabling 7-10 truly unused plugin packs | ~45% |
16
+ | Rewriting forcing rules in CLAUDE.md | ~10% |
17
+ | Memory hygiene | ~5% |
18
+ | `settings.json` permission allowlist | ~8% |
19
+ | **Subtotal (audit + apply)** | **~2.0-2.5×** |
20
+ | Per-project profiles | ~35% |
21
+ | Hooks (auto-switch on cd, v0.4) | ~25% |
22
+ | **Subtotal (with profiles + hooks)** | **~5.0×** |
23
+
24
+ The first row of numbers (the 2.0-2.5× tier) is what v0.1 ships. The 5× target is end-of-roadmap, with profiles and hooks.
25
+
26
+ If you've already trimmed your setup manually, the savings will obviously be less — `claude-lean` measures, then suggests; it doesn't make magic numbers up.
27
+
28
+ ### Does this work without `tiktoken` installed?
29
+
30
+ Yes. The fallback is a byte-based approximation (1 token ≈ 4 bytes). The *order* of plugins by cost is the same — only the absolute numbers differ. If you want exact counts, `pipx install 'claude-lean[accurate]'`.
31
+
32
+ ### Will Anthropic eventually fix the underlying issues?
33
+
34
+ Probably some of them — and that would be great, the tool would gracefully sunset. The roadmap is built so that even if Anthropic ships lazy plugin loading tomorrow, the per-project profile feature still adds value.
35
+
36
+ ## Setup
37
+
38
+ ### What Python versions are supported?
39
+
40
+ 3.11+. We need `tomllib` (3.11 stdlib) for profile parsing.
41
+
42
+ ### Why `pipx` over `pip`?
43
+
44
+ `pipx` installs CLI tools into isolated environments, which is the right answer for end-user CLIs. `pip install --user` works too but can clash with other Python tools.
45
+
46
+ ### Does it work on Windows?
47
+
48
+ Not tested. macOS and Linux only for v0.1. Windows support is on the roadmap; the path encoding logic just needs to handle backslashes.
49
+
50
+ ### Where does `claude-lean` look for `~/.claude/`?
51
+
52
+ In order:
53
+ 1. `--claude-home <path>` CLI flag
54
+ 2. `$CLAUDE_HOME` environment variable
55
+ 3. `~/.claude` (the default)
56
+
57
+ ## Using It
58
+
59
+ ### What if I disable a plugin and later need it?
60
+
61
+ `claude-lean restore --latest` reverts the most recent `apply`. Or just toggle the plugin back to `true` in `~/.claude/settings.json` — that's all `apply` actually changes.
62
+
63
+ ### Can I add my own anti-pattern rules?
64
+
65
+ Not in v0.1 — rules are hard-coded. v0.2 will support a `~/.claude/claude-lean-rules.py` for user rules. You can fork the repo today and add a rule under `src/claude_lean/audit/rules/`; PRs welcome.
66
+
67
+ ### Can I run this in CI?
68
+
69
+ Yes. `claude-lean audit --json-out audit.json` is non-interactive and produces a stable JSON output. You can fail builds on regression by parsing the result.
70
+
71
+ ### What does "estimated savings" actually mean?
72
+
73
+ The tokens that would no longer load into Claude's system prompt if you applied the recommendation. It's a forward-looking estimate — measured against the static configuration, not against a specific conversation.
74
+
75
+ ## Profiles
76
+
77
+ ### Where do stock profiles live?
78
+
79
+ In the installed package: `src/claude_lean/profile/stock/*.toml`. They're bundled with the wheel.
80
+
81
+ ### Can I make a custom profile?
82
+
83
+ Yes. Copy one of the stock profiles, edit it, save it locally, and pass the path to `profile use` (custom-path support is a v0.2 feature; for v0.1, drop your custom profile into the stock directory and reinstall — clunky but works).
84
+
85
+ ### What about a marketplace?
86
+
87
+ v1.0. Community profiles will live in a separate repo (`claude-lean-profiles`) and be installable via `claude-lean profile install`. Roadmap.
88
+
89
+ ### Will profiles conflict with `apply`?
90
+
91
+ A profile is just a more aggressive `apply` — it's all writes to `settings.json` and `CLAUDE.md`. They both go through the same backup system. Running `apply` after `profile use` is a no-op if the apply recommendations are already covered by the profile.
92
+
93
+ ## Memory
94
+
95
+ ### Why doesn't `claude-lean` auto-fix my memory files?
96
+
97
+ Memory rewriting is risky because memory content is policy + personal context. v0.1 only *reports*. v0.2 will add `apply --rewrite-memories` behind an explicit opt-in flag.
98
+
99
+ ### What's the 200-line cap?
100
+
101
+ Claude Code's harness truncates `MEMORY.md` after 200 lines. Memories referenced beyond that line are silently invisible. The `memory-index-near-cap` rule warns when you're approaching it.
102
+
103
+ ### Why are my memory descriptions flagged as "vague"?
104
+
105
+ Because Claude uses the description as the only signal for whether to *load* the memory body. A description like "notes" doesn't match any topic, so the memory body never gets loaded. Aim for 60+ characters mentioning the topic, constraint, or fact.
106
+
107
+ ## Troubleshooting
108
+
109
+ ### "Claude Code home not found at /Users/you/.claude"
110
+
111
+ Either your install is at a non-default location (use `--claude-home`), or you haven't run `claude` yet to initialize it.
112
+
113
+ ### Audit reports "Agents: 0" but I know I have agents
114
+
115
+ Agents must live under an `agents/` directory inside a plugin. If your agents are at `~/.claude/agents/`, that's the global-agent location and v0.1 doesn't scan it yet (v0.2 will).
116
+
117
+ ### "Estimated savings" looks way too high
118
+
119
+ Without `tiktoken`, the byte-based estimate over-counts on text-heavy content. The relative order is still correct; install the `accurate` extra for exact numbers.
120
+
121
+ ### Rich output is garbled in my terminal
122
+
123
+ `rich` auto-detects terminal capabilities. If output looks weird, try `--json` (machine-readable) or set `TERM=dumb` for plain text.
124
+
125
+ ### Tests fail after `pip install`
126
+
127
+ Make sure you installed with the `dev` extra:
128
+
129
+ ```bash
130
+ pip install -e '.[dev]'
131
+ pytest
132
+ ```
133
+
134
+ ## Privacy
135
+
136
+ ### Does `claude-lean` send any data anywhere?
137
+
138
+ No. Every operation is local. The optional `profile install` from a marketplace (v1.0) is opt-in and shows you what URL it fetches from.
139
+
140
+ ### What's logged?
141
+
142
+ Nothing by default. The `monitor` subcommand (v0.3) will *read* `~/.claude/projects/*/` session logs (which Claude Code already writes), but nothing is sent outside your machine.