claude-smart 0.1.3 → 0.1.4
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.
- package/README.md +41 -43
- package/bin/claude-smart.js +3 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
claude-smart
|
|
7
7
|
</h1>
|
|
8
8
|
|
|
9
|
-
<h4 align="center">
|
|
9
|
+
<h4 align="center">The <a href="https://claude.com/claude-code" target="_blank">Claude Code</a> plugin that makes Claude Code self-improve as you use it — not by remembering past sessions, but by turning your corrections into rules it actually follows next time.</h4>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
12
|
<a href="LICENSE">
|
|
13
13
|
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
|
|
14
14
|
</a>
|
|
15
|
-
<a href="pyproject.toml">
|
|
16
|
-
<img src="https://img.shields.io/badge/version-0.1.
|
|
15
|
+
<a href="plugin/pyproject.toml">
|
|
16
|
+
<img src="https://img.shields.io/badge/version-0.1.4-green.svg" alt="Version">
|
|
17
17
|
</a>
|
|
18
|
-
<a href="pyproject.toml">
|
|
18
|
+
<a href="plugin/pyproject.toml">
|
|
19
19
|
<img src="https://img.shields.io/badge/python-%3E%3D3.12-brightgreen.svg" alt="Python">
|
|
20
20
|
</a>
|
|
21
21
|
<a href="#quick-start">
|
|
@@ -34,14 +34,18 @@
|
|
|
34
34
|
</p>
|
|
35
35
|
|
|
36
36
|
<p align="center">
|
|
37
|
-
claude-smart turns
|
|
37
|
+
Every time you correct Claude Code, claude-smart turns that moment into a durable rule it follows from then on. No more re-explaining your stack, your conventions, or the same gotcha you flagged last week — Claude Code steadily adapts to how <i>your</i> codebase actually wants to be written, session after session.
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<b>Head-to-head vs <code>claude-mem</code></b> (LLM-judged on how well each system's reinjected context matches the expected rule): claude-smart is <b>~2.7× more accurate overall</b>, <b>stops Claude from repeating mistakes you've already corrected</b> where claude-mem only recalls that they happened, and is <b>3× better at turning past events into future-facing rules</b> — see <a href="benchmarks/memory_comparison/EXPERIMENT.md">EXPERIMENT.md</a> for details.
|
|
38
42
|
</p>
|
|
39
43
|
|
|
40
44
|
---
|
|
41
45
|
|
|
42
46
|
## Why Learning, Not Memory
|
|
43
47
|
|
|
44
|
-
Plain memory solutions re-inject transcripts or summaries from prior sessions
|
|
48
|
+
Plain memory solutions re-inject transcripts or summaries from prior sessions — useful for continuity, but purely informative. claude-smart extracts *rules* from those sessions instead. Four ways that changes what Claude Code can do for you:
|
|
45
49
|
|
|
46
50
|
- **Actionable, not just informative.** Memory logs *what happened*; learning produces *rules to follow* that change the next decision.
|
|
47
51
|
> *e.g.* you told Claude to stop running `npm test` without `--run` because it hangs on watch mode. **Memory** recalls "user was annoyed about npm test hanging". **Learning** writes the rule *"always pass `--run` to `npm test` in this repo — default watch mode blocks CI"* and applies it next session.
|
|
@@ -79,8 +83,10 @@ Developing the plugin itself? See [DEVELOPER.md](./DEVELOPER.md#developing-local
|
|
|
79
83
|
|
|
80
84
|
- 🧠 **Learn, don't just remember** — Corrections become structured, deduplicated rules, not transcript replays.
|
|
81
85
|
- ⚡ **Fully automatic learning** — Every user turn, tool call, and assistant response is captured via lifecycle hooks and extracted into rules without you running anything.
|
|
86
|
+
- 📈 **Compounds with every session** — Rules auto-merge, supersede, and archive as your project evolves — the playbook sharpens with use instead of bloating.
|
|
87
|
+
> *e.g.* you correct the same `npm test --run` gotcha twice → **claude-smart** consolidates them into one stronger rule. Later you switch the policy to `pnpm test` → the old rule is archived and the new one supersedes it, no manual cleanup.
|
|
82
88
|
- 🎯 **Two-tier scope** — Per-session profiles for the current conversation; cross-session playbooks for the whole project.
|
|
83
|
-
- 🔌 **
|
|
89
|
+
- 🔌 **No external API call** — semantic search runs on an in-process ONNX embedder (all-MiniLM-L6-v2), and all data (profiles, playbooks, interaction buffers) is stored locally on your machine (`~/.reflexio/` and `~/.claude-smart/`).
|
|
84
90
|
- 🔎 **Hybrid search** — Playbooks and profiles are indexed with vector + BM25 search for fast, robust retrieval.
|
|
85
91
|
- 🧪 **Offline resilience** — If the reflexio backend is down, hooks buffer to disk; the next successful publish drains them.
|
|
86
92
|
- 🧰 **Manual correction tag** — `/claude-smart:tag` flags the last turn as a correction so the extractor weights it heavily.
|
|
@@ -99,52 +105,44 @@ Developing the plugin itself? See [DEVELOPER.md](./DEVELOPER.md#developing-local
|
|
|
99
105
|
|
|
100
106
|
## Dashboard
|
|
101
107
|
|
|
102
|
-
A Next.js web UI lives in [`dashboard/`](dashboard/) for browsing session buffers, inspecting user profiles, and editing project playbooks. It auto-starts alongside the backend — just open **http://localhost:3001**.
|
|
108
|
+
A Next.js web UI lives in [`plugin/dashboard/`](plugin/dashboard/) for browsing session buffers, inspecting user profiles, and editing project playbooks. It auto-starts alongside the backend — just open **http://localhost:3001**.
|
|
103
109
|
|
|
104
110
|
---
|
|
105
111
|
|
|
106
112
|
## How It Works
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
As you work, claude-smart builds two things and hands them back to Claude at the start of every new session:
|
|
109
115
|
|
|
110
|
-
|
|
111
|
-
- `SessionStart` — fetches the project playbook from reflexio and injects it as `additionalContext`.
|
|
112
|
-
- `UserPromptSubmit` — buffers each user turn, heuristically flags corrections.
|
|
113
|
-
- `PostToolUse` — records tool invocations for later extraction.
|
|
114
|
-
- `Stop` — finalizes the assistant turn from the transcript, publishes to reflexio.
|
|
115
|
-
- `SessionEnd` — flushes the remaining buffer with `force_extraction=True`.
|
|
116
|
-
2. **Local state buffer** — JSONL per session at `~/.claude-smart/sessions/{session_id}.jsonl`. Offline-safe.
|
|
117
|
-
3. **Reflexio backend** (submodule at `reflexio/`) — SQLite storage, hybrid search, profile/playbook extraction, dedup, status lifecycle (`CURRENT` → `ARCHIVED`). Runs on `localhost:8081`.
|
|
118
|
-
4. **Claude Code LLM provider** — a LiteLLM custom provider registered inside reflexio. Every generation call (extraction, update, dedup, evaluation) subprocesses `claude -p --output-format json`, so no OpenAI/Anthropic key is needed for the learning loop.
|
|
116
|
+
### Your user profile — *who you are, this session*
|
|
119
117
|
|
|
120
|
-
|
|
118
|
+
A quick sketch of how you want to work right now — your stack, your role, small preferences you've dropped into the conversation. Scoped to the current session, so it doesn't follow you into unrelated projects.
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
└─ Stop ─────┘ │
|
|
127
|
-
▼
|
|
128
|
-
┌─────────────────────────┐
|
|
129
|
-
│ reflexio extractors │
|
|
130
|
-
│ (run via claude -p) │
|
|
131
|
-
│ → profiles + playbooks │
|
|
132
|
-
└────────────┬────────────┘
|
|
133
|
-
│
|
|
134
|
-
▼
|
|
135
|
-
Next session → SessionStart → search_user_playbooks(agent_version=project_id)
|
|
136
|
-
→ additionalContext injected into Claude's system prompt
|
|
137
|
-
```
|
|
120
|
+
> *Examples:*
|
|
121
|
+
> - *Uses pnpm, not npm.*
|
|
122
|
+
> - *Prefers terse answers, no trailing summaries.*
|
|
123
|
+
> - *Backend engineer — explain frontend code with backend analogues.*
|
|
138
124
|
|
|
139
|
-
|
|
125
|
+
### The project playbook — *durable rules, every session*
|
|
140
126
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
127
|
+
A growing list of **rules for this project**, pulled from every session you've ever run in it. Each rule says when it applies and why it exists.
|
|
128
|
+
|
|
129
|
+
> *Examples:*
|
|
130
|
+
> - *Always pass `--run` to `npm test` — default watch mode hangs CI.*
|
|
131
|
+
> - *Use a real Postgres for integration tests, not mocks — mocks once hid a broken migration.*
|
|
132
|
+
> - *Prefer ESM-native test runners in this monorepo.*
|
|
133
|
+
|
|
134
|
+
Rules clean themselves up: correct the same thing twice and they merge; change your mind later and the old one is archived.
|
|
135
|
+
|
|
136
|
+
### How it runs
|
|
137
|
+
|
|
138
|
+
1. You have a normal Claude Code session.
|
|
139
|
+
2. claude-smart quietly watches your turns, tool calls, and Claude's replies — flagging corrections automatically (or anything you `/tag`).
|
|
140
|
+
3. When the session ends (or you run `/learn`), it turns what happened into profile entries and playbook rules.
|
|
141
|
+
4. Next session, both get injected into Claude's system prompt. Run `/show` any time to see what Claude is being told.
|
|
142
|
+
|
|
143
|
+
No chat, no prompts to rewrite, no config files to groom. Everything runs on your machine.
|
|
146
144
|
|
|
147
|
-
|
|
145
|
+
See [ARCHITECTURE.md](./ARCHITECTURE.md) for the hooks, data flow, and reflexio details.
|
|
148
146
|
|
|
149
147
|
---
|
|
150
148
|
|
|
@@ -192,7 +190,7 @@ If you still want to use a cloud embedding provider (OpenAI, Gemini, etc.), omit
|
|
|
192
190
|
Extraction is async by default. Run `/learn` to force it, wait ~20–30s, then run `/show` — no new session needed. `/show` shows whether the rule was actually extracted.
|
|
193
191
|
|
|
194
192
|
**Reflexio refuses to boot with "no embedding-capable provider".**
|
|
195
|
-
Check that `CLAUDE_SMART_USE_LOCAL_EMBEDDING=1` is in `~/.reflexio/.env` *and* that `chromadb` is installed in the venv (`uv run python -c "import chromadb"` should print nothing). If you'd rather use a cloud embedder instead, drop the env flag and set `OPENAI_API_KEY` or `GEMINI_API_KEY` in the same file.
|
|
193
|
+
Check that `CLAUDE_SMART_USE_LOCAL_EMBEDDING=1` is in `~/.reflexio/.env` *and* that `chromadb` is installed in the venv (`uv run --project plugin python -c "import chromadb"` should print nothing). If you'd rather use a cloud embedder instead, drop the env flag and set `OPENAI_API_KEY` or `GEMINI_API_KEY` in the same file.
|
|
196
194
|
|
|
197
195
|
**`claude-smart` doesn't see my interactions.**
|
|
198
196
|
Check `~/.claude-smart/sessions/`. If your current session's JSONL has no `User`/`Assistant` rows, the plugin isn't receiving hook events — verify `.claude/settings.local.json` has the right path and that `enabledPlugins` is `true`.
|
package/bin/claude-smart.js
CHANGED
|
@@ -110,10 +110,9 @@ function runInstall(args) {
|
|
|
110
110
|
process.stdout.write(
|
|
111
111
|
[
|
|
112
112
|
"",
|
|
113
|
-
"claude-smart installed.
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
" 2. Restart Claude Code in your project.",
|
|
113
|
+
"claude-smart installed. Restart Claude Code in your project.",
|
|
114
|
+
"The reflexio backend and dashboard auto-start on session start.",
|
|
115
|
+
"Opt out with CLAUDE_SMART_BACKEND_AUTOSTART=0 or CLAUDE_SMART_DASHBOARD_AUTOSTART=0.",
|
|
117
116
|
"",
|
|
118
117
|
].join("\n"),
|
|
119
118
|
);
|