claude-smart 0.1.4 → 0.1.6
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 +54 -65
- package/bin/claude-smart.js +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
|
|
14
14
|
</a>
|
|
15
15
|
<a href="plugin/pyproject.toml">
|
|
16
|
-
<img src="https://img.shields.io/badge/version-0.1.
|
|
16
|
+
<img src="https://img.shields.io/badge/version-0.1.6-green.svg" alt="Version">
|
|
17
17
|
</a>
|
|
18
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
|
+
<a href="package.json">
|
|
22
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node">
|
|
23
|
+
</a>
|
|
21
24
|
<a href="#quick-start">
|
|
22
25
|
<img src="https://img.shields.io/badge/llm-claude%20code%20cli-purple.svg" alt="LLM">
|
|
23
26
|
</a>
|
|
@@ -34,27 +37,45 @@
|
|
|
34
37
|
</p>
|
|
35
38
|
|
|
36
39
|
<p align="center">
|
|
37
|
-
|
|
40
|
+
It learns both corrections and successful execution patterns—so Claude Code avoids repeating mistakes and reuses what works. Instead of repeatedly explaining your stack, conventions, preferences, or the same gotchas, Claude Code steadily adapts to <i>how you like</i> to work—across projects, codebases, and sessions.
|
|
38
41
|
</p>
|
|
39
42
|
|
|
40
43
|
<p align="center">
|
|
41
|
-
<b>Head-to-head vs <code>claude-mem</code></b
|
|
44
|
+
<b>Head-to-head vs <code>claude-mem</code></b>, evaluated by an LLM on how well each system’s reinjected context matched the expected rule: claude-smart achieved <b>~2.7× higher overall accuracy</b>, is better at <b>preventing Claude Code from repeating mistakes you have already corrected</b> rather than merely recalling that those mistakes happened, and is <b>3× better at converting past events into future-facing rules</b> — see <a href="benchmarks/memory_comparison/EXPERIMENT.md">EXPERIMENT.md</a> for details.
|
|
42
45
|
</p>
|
|
43
|
-
|
|
44
46
|
---
|
|
45
47
|
|
|
46
48
|
## Why Learning, Not Memory
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
Most memory solutions re-inject transcripts or summaries from prior sessions, but it is still mostly informative—Claude remembers what happened, without necessarily changing what it does next.
|
|
51
|
+
|
|
52
|
+
`claude-smart` focuses on learning instead.
|
|
53
|
+
|
|
54
|
+
Four ways this changes what Claude Code can do for you:
|
|
55
|
+
|
|
56
|
+
- **Actionable, not just informative:** Produces rules Claude can follow next time; memory only records what happened;
|
|
57
|
+
|
|
58
|
+
> *Example:* you tell Claude to stop running `npm test` without `--run` because watch mode hangs.
|
|
59
|
+
> **Memory:** “user was annoyed about npm test hanging”
|
|
60
|
+
> **Learning:** “always pass `--run` to `npm test` in this repo — default watch mode blocks CI”
|
|
61
|
+
|
|
62
|
+
- **Optimized paths, not just past events:** Preserves successful execution paths so Claude can reuse what already works.
|
|
63
|
+
> *Example:* Claude spends several iterations trying to start the local dev environment before discovering that this repo requires `pnpm dev:all` instead of the usual `npm run dev`.
|
|
64
|
+
> **Memory:** “user mentioned that `npm run dev` did not work”
|
|
65
|
+
> **Learning:** “for this repo, always use `pnpm dev:all` to start the full local stack — `npm run dev` only starts the frontend and causes missing service errors”
|
|
66
|
+
|
|
67
|
+
Instead of re-exploring the same setup problem next time, Claude starts from the proven path—reducing planning steps, latency, and token usage.
|
|
68
|
+
|
|
69
|
+
- **Project-wide, not session-siloed:** Session memory disappears with the conversation. The project playbook persists and improves across every session in that repo.
|
|
70
|
+
|
|
71
|
+
- **Compact:** Distilled, deduplicated rules stay in dozens of tokens—not thousands—even as the project grows.
|
|
49
72
|
|
|
50
|
-
-
|
|
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.
|
|
52
|
-
- **Preferences, not events.** Memory records literal facts; learning abstracts the *why* into rules that generalize.
|
|
53
|
-
> *e.g.* you reject Jest in favor of Vitest once. **Memory** stores that single choice. **Learning** derives *"prefer ESM-native test runners for this TypeScript monorepo"* — which also covers the next framework decision (e.g. picking `tsx` over `ts-node`) without waiting for the same correction to repeat.
|
|
54
|
-
- **Carries across sessions and workspaces.** Playbooks are keyed to the project and surface in every future session against that repo.
|
|
55
|
-
- **Compact.** Distilled, deduplicated rules stay in dozens of tokens — not thousands — even as the project grows.
|
|
73
|
+
claude-smart turns corrections and successful execution patterns into two artifacts:
|
|
56
74
|
|
|
57
|
-
|
|
75
|
+
- **User Profile** → your preferences and working style across sessions
|
|
76
|
+
- **Project Playbook** → durable rules and optimized execution paths for how Claude should behave
|
|
77
|
+
|
|
78
|
+
Both are automatically reinjected at the start of every session, so Claude Code gets better the more you use it.
|
|
58
79
|
|
|
59
80
|
---
|
|
60
81
|
|
|
@@ -93,74 +114,47 @@ Developing the plugin itself? See [DEVELOPER.md](./DEVELOPER.md#developing-local
|
|
|
93
114
|
|
|
94
115
|
---
|
|
95
116
|
|
|
96
|
-
## Slash Commands
|
|
97
|
-
|
|
98
|
-
| Command | What it does |
|
|
99
|
-
| --- | --- |
|
|
100
|
-
| `/show` | Print the current project playbook plus the current session's user profiles (same markdown that `SessionStart` injects). Use it to audit what rules and preferences Claude is being told to follow. |
|
|
101
|
-
| `/learn` | Force reflexio to run extraction *now* on the current session's unpublished interactions. Without this, extraction runs at the end of the session or on reflexio's batch interval. |
|
|
102
|
-
| `/tag [note]` | Tag the most recent turn as a correction, for cases the automatic heuristic missed. The note becomes the correction description the extractor sees. |
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
117
|
## Dashboard
|
|
107
118
|
|
|
108
119
|
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**.
|
|
109
120
|
|
|
121
|
+
<p align="center">
|
|
122
|
+
<img src="assets/profile_dashboard.png" alt="Profile dashboard" width="49%">
|
|
123
|
+
<img src="assets/playbook_dashboard.png" alt="Playbook dashboard" width="49%">
|
|
124
|
+
</p>
|
|
125
|
+
|
|
110
126
|
---
|
|
111
127
|
|
|
112
128
|
## How It Works
|
|
113
129
|
|
|
114
|
-
|
|
130
|
+
claude-smart builds two artifacts as you work and injects them into Claude at the start of every new session:
|
|
115
131
|
|
|
116
|
-
|
|
132
|
+
- **User profile** — session-scoped preferences (stack, role, small quirks). *e.g.* "uses pnpm, not npm"; "prefers terse answers"; "backend engineer — explain frontend with backend analogues."
|
|
133
|
+
- **Project playbook** — durable, generalized rules accumulated across every session in the repo. Each says when it applies and why. *e.g.* "always pass `--run` to `npm test` — watch mode hangs CI"; "use real Postgres for integration tests — mocks once hid a broken migration."
|
|
117
134
|
|
|
118
|
-
|
|
135
|
+
Rules clean themselves up: correct the same thing twice and they merge; change your mind and the old one is archived.
|
|
119
136
|
|
|
120
|
-
|
|
121
|
-
> - *Uses pnpm, not npm.*
|
|
122
|
-
> - *Prefers terse answers, no trailing summaries.*
|
|
123
|
-
> - *Backend engineer — explain frontend code with backend analogues.*
|
|
137
|
+
Under the hood: hooks watch your turns, tool calls, and Claude's replies, auto-flagging corrections (or anything you `/tag`). At session end (or on `/learn`), [reflexio](https://github.com/ReflexioAI/reflexio) — the self-improving engine that powers claude-smart — extracts profile entries and playbook rules. Next session, both get injected into the system prompt — run `/show` to see what Claude is being told. Everything runs on your machine.
|
|
124
138
|
|
|
125
|
-
|
|
139
|
+
See [ARCHITECTURE.md](./ARCHITECTURE.md) for hooks, data flow, and reflexio details.
|
|
126
140
|
|
|
127
|
-
|
|
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.
|
|
141
|
+
---
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
## Slash Commands
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
| Command | What it does |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `/show` | Print the current project playbook plus the current session's user profiles (same markdown that `SessionStart` injects). Use it to audit what rules and preferences Claude is being told to follow. |
|
|
148
|
+
| `/learn` | Force reflexio to run extraction *now* on the current session's unpublished interactions. Without this, extraction runs at the end of the session or on reflexio's batch interval. |
|
|
149
|
+
| `/tag [note]` | Tag the most recent turn as a correction, for cases the automatic heuristic missed. The note becomes the correction description the extractor sees. |
|
|
150
|
+
| `/restart` | Restart the reflexio backend and dashboard to pick up new changes (e.g. after upgrading the plugin or editing local reflexio code). |
|
|
151
|
+
| `/clear-all` | **Destructive.** Delete *all* reflexio interactions, profiles, and user playbooks. Use when you want to wipe learned state and start fresh. |
|
|
146
152
|
|
|
147
153
|
---
|
|
148
154
|
|
|
149
155
|
## Configuration
|
|
150
156
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
| Variable | Default | Purpose |
|
|
154
|
-
| --- | --- | --- |
|
|
155
|
-
| `CLAUDE_SMART_USE_LOCAL_CLI` | `0` (installer sets `1`) | Route generation through the local `claude` CLI. Written to `~/.reflexio/.env` by `claude-smart install`. |
|
|
156
|
-
| `CLAUDE_SMART_USE_LOCAL_EMBEDDING` | `0` (installer sets `1`) | Use the in-process ONNX embedder (requires `chromadb`). Written to `~/.reflexio/.env` by `claude-smart install`. |
|
|
157
|
-
| `CLAUDE_SMART_CLI_PATH` | `shutil.which("claude")` | Override the path to the `claude` binary. |
|
|
158
|
-
| `CLAUDE_SMART_CLI_TIMEOUT` | `120` | Per-call subprocess timeout (seconds). Raise for slow prompts. |
|
|
159
|
-
| `CLAUDE_SMART_STATE_DIR` | `~/.claude-smart/sessions/` | Where the per-session JSONL buffer lives. |
|
|
160
|
-
| `CLAUDE_SMART_BACKEND_AUTOSTART` | `1` | Set to `0` to stop the SessionStart hook from spawning the reflexio backend on `localhost:8081`. |
|
|
161
|
-
| `CLAUDE_SMART_DASHBOARD_AUTOSTART` | `1` | Set to `0` to stop the SessionStart hook from spawning the Next.js dashboard on `localhost:3001`. |
|
|
162
|
-
| `CLAUDE_SMART_BACKEND_STOP_ON_END` | `0` | Set to `1` to tear down the backend at `SessionEnd` instead of leaving it long-lived. |
|
|
163
|
-
| `REFLEXIO_URL` | `http://localhost:8081/` | Point the plugin at a non-local reflexio backend. |
|
|
157
|
+
Advanced users can tune claude-smart via environment variables — see [DEVELOPER.md](./DEVELOPER.md#environment-variables) for the full list.
|
|
164
158
|
|
|
165
159
|
### Where data lives
|
|
166
160
|
|
|
@@ -171,11 +165,6 @@ See [ARCHITECTURE.md](./ARCHITECTURE.md) for the hooks, data flow, and reflexio
|
|
|
171
165
|
| `~/.claude-smart/sessions/{session_id}.jsonl` | Per-session buffer. User turns, assistant turns, tool invocations, `{"published_up_to": N}` watermarks. Safe to inspect and safe to delete — everything past the latest watermark has already been written to reflexio's DB. |
|
|
172
166
|
| `~/.cache/chroma/onnx_models/all-MiniLM-L6-v2/` | Cached ONNX weights (~86 MB, downloaded once). Delete to force a re-download. |
|
|
173
167
|
|
|
174
|
-
### Scope: profile vs. playbook
|
|
175
|
-
|
|
176
|
-
- **Profile** (`user_id = session_id`) — session-scoped preferences. Does not persist across sessions, but *is* reinjected if you resume the same session (`/resume`, `/clear`, `/compact`).
|
|
177
|
-
- **Playbook** (`agent_version = project_id`) — cross-session. Every session in the same project — identified by git-toplevel basename — sees the accumulated playbook.
|
|
178
|
-
|
|
179
168
|
### Embeddings
|
|
180
169
|
|
|
181
170
|
claude-smart uses an in-process ONNX embedder (Chroma's `all-MiniLM-L6-v2`, 384-dim, zero-padded to reflexio's 512-dim schema). The model weights are downloaded on first use (~80 MB, cached under `~/.cache/chroma/onnx_models/`) — after that, no network calls for embedding. Runtime cost is a few milliseconds per short document on CPU.
|
package/bin/claude-smart.js
CHANGED
|
@@ -58,6 +58,9 @@ function printHelp() {
|
|
|
58
58
|
" 3. Appends CLAUDE_SMART_USE_LOCAL_CLI=1 and CLAUDE_SMART_USE_LOCAL_EMBEDDING=1",
|
|
59
59
|
" to ~/.reflexio/.env (idempotent).",
|
|
60
60
|
"",
|
|
61
|
+
"Update:",
|
|
62
|
+
" npx claude-smart update Update to the latest version",
|
|
63
|
+
"",
|
|
61
64
|
].join("\n"),
|
|
62
65
|
);
|
|
63
66
|
}
|
|
@@ -73,6 +76,26 @@ function parseSource(args) {
|
|
|
73
76
|
return value;
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
function runUpdate() {
|
|
80
|
+
if (!hasClaudeCli()) {
|
|
81
|
+
process.stderr.write(
|
|
82
|
+
"error: 'claude' CLI not found on PATH. " +
|
|
83
|
+
"Install Claude Code first: https://claude.com/claude-code\n",
|
|
84
|
+
);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
execFileSync("claude", ["plugin", "update", PLUGIN_SPEC], { stdio: "inherit" });
|
|
90
|
+
} catch (err) {
|
|
91
|
+
const code = typeof err.status === "number" ? err.status : 1;
|
|
92
|
+
process.stderr.write(`error: \`claude plugin update ${PLUGIN_SPEC}\` failed (exit ${code})\n`);
|
|
93
|
+
process.exit(code);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
process.stdout.write("\nclaude-smart updated. Restart Claude Code to apply.\n");
|
|
97
|
+
}
|
|
98
|
+
|
|
76
99
|
function runInstall(args) {
|
|
77
100
|
if (!hasClaudeCli()) {
|
|
78
101
|
process.stderr.write(
|
|
@@ -132,6 +155,11 @@ function main() {
|
|
|
132
155
|
return;
|
|
133
156
|
}
|
|
134
157
|
|
|
158
|
+
if (cmd === "update") {
|
|
159
|
+
runUpdate();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
135
163
|
process.stderr.write(
|
|
136
164
|
`claude-smart: unknown command '${cmd}'. Try 'npx claude-smart --help'.\n`,
|
|
137
165
|
);
|