continuous-improvement 3.1.0 → 3.8.0
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/.claude-plugin/marketplace.json +78 -0
- package/CHANGELOG.md +191 -0
- package/LICENSE +21 -21
- package/QUICKSTART.md +101 -81
- package/README.md +207 -359
- package/SKILL.md +87 -9
- package/action.yml +33 -33
- package/bin/analyze.sh +161 -153
- package/bin/backfill.mjs +172 -0
- package/bin/check-docs-substrings.mjs +333 -0
- package/bin/check-everything-mirror.mjs +145 -0
- package/bin/check-routing-targets.mjs +151 -0
- package/bin/check-skill-law-tag.mjs +128 -0
- package/bin/check-skill-mirror.mjs +119 -0
- package/bin/check-skill-tiers.mjs +116 -0
- package/bin/check-third-party-shape.mjs +202 -0
- package/bin/generate-plugin-manifests.mjs +169 -0
- package/bin/harvest-friction.mjs +279 -0
- package/bin/hook-stats.mjs +258 -0
- package/bin/install.mjs +417 -516
- package/bin/lint-transcript.mjs +182 -210
- package/bin/mcp-server.mjs +840 -617
- package/bin/observe.mjs +148 -0
- package/bin/pre-commit-block-strays.sh +49 -0
- package/bin/refresh-third-party.mjs +416 -0
- package/bin/unified-cli.mjs +533 -0
- package/commands/continuous-improvement.md +115 -74
- package/commands/dashboard.md +56 -56
- package/commands/discipline.md +51 -37
- package/commands/harvest.md +76 -0
- package/commands/learn-eval.md +117 -0
- package/commands/planning-with-files.md +66 -0
- package/commands/proceed-with-the-recommendation.md +62 -0
- package/commands/ralph.md +103 -0
- package/commands/release-train.md +81 -0
- package/commands/seven-laws.md +16 -0
- package/commands/superpowers.md +153 -0
- package/commands/swarm.md +101 -0
- package/commands/workspace-surface-audit.md +77 -0
- package/hooks/observe.sh +172 -134
- package/hooks/session.sh +106 -106
- package/hooks/three-section-close.mjs +181 -0
- package/instinct-packs/go.json +58 -58
- package/instinct-packs/meta.json +16 -0
- package/instinct-packs/python.json +58 -58
- package/instinct-packs/react.json +58 -58
- package/lib/cli-anything.mjs +401 -0
- package/lib/compound-engineering.mjs +831 -0
- package/lib/observe-event.mjs +128 -0
- package/lib/plugin-metadata.mjs +432 -0
- package/lib/pm-marketplace.mjs +61 -0
- package/lib/pm-skills.mjs +1274 -0
- package/lib/resolve-home-dir.mjs +43 -0
- package/lib/skill-tiers.mjs +137 -0
- package/lib/unified-plugin.mjs +924 -0
- package/llms.txt +68 -43
- package/package.json +28 -19
- package/plugins/beginner.json +17 -6
- package/plugins/continuous-improvement/.claude-plugin/marketplace.json +20 -0
- package/plugins/continuous-improvement/.claude-plugin/plugin.json +26 -0
- package/plugins/continuous-improvement/LICENSE +21 -0
- package/plugins/continuous-improvement/README.md +56 -0
- package/plugins/continuous-improvement/bin/backfill.mjs +172 -0
- package/plugins/continuous-improvement/bin/mcp-server.mjs +886 -0
- package/plugins/continuous-improvement/bin/observe.mjs +148 -0
- package/plugins/continuous-improvement/commands/continuous-improvement.md +115 -0
- package/plugins/continuous-improvement/commands/dashboard.md +56 -0
- package/plugins/continuous-improvement/commands/discipline.md +51 -0
- package/plugins/continuous-improvement/commands/harvest.md +76 -0
- package/plugins/continuous-improvement/commands/learn-eval.md +117 -0
- package/plugins/continuous-improvement/commands/planning-with-files.md +66 -0
- package/plugins/continuous-improvement/commands/proceed-with-the-recommendation.md +62 -0
- package/plugins/continuous-improvement/commands/ralph.md +103 -0
- package/plugins/continuous-improvement/commands/release-train.md +81 -0
- package/plugins/continuous-improvement/commands/seven-laws.md +16 -0
- package/plugins/continuous-improvement/commands/superpowers.md +153 -0
- package/plugins/continuous-improvement/commands/swarm.md +101 -0
- package/plugins/continuous-improvement/commands/workspace-surface-audit.md +77 -0
- package/plugins/continuous-improvement/hooks/hooks.json +60 -0
- package/plugins/continuous-improvement/hooks/observe.sh +172 -0
- package/plugins/continuous-improvement/hooks/session.sh +106 -0
- package/plugins/continuous-improvement/hooks/three-section-close.mjs +181 -0
- package/plugins/continuous-improvement/instinct-packs/go.json +58 -0
- package/plugins/continuous-improvement/instinct-packs/meta.json +16 -0
- package/plugins/continuous-improvement/instinct-packs/python.json +58 -0
- package/plugins/continuous-improvement/instinct-packs/react.json +58 -0
- package/plugins/continuous-improvement/lib/observe-event.mjs +128 -0
- package/plugins/continuous-improvement/lib/plugin-metadata.mjs +432 -0
- package/plugins/continuous-improvement/lib/resolve-home-dir.mjs +43 -0
- package/plugins/continuous-improvement/skills/README.md +34 -0
- package/plugins/continuous-improvement/skills/continuous-improvement/SKILL.md +249 -0
- package/plugins/continuous-improvement/skills/deploy-receipt/SKILL.md +131 -0
- package/plugins/continuous-improvement/skills/gateguard/SKILL.md +155 -0
- package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +108 -0
- package/plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md +454 -0
- package/plugins/continuous-improvement/skills/ralph/SKILL.md +221 -0
- package/plugins/continuous-improvement/skills/safety-guard/SKILL.md +76 -0
- package/plugins/continuous-improvement/skills/strategic-compact/SKILL.md +104 -0
- package/plugins/continuous-improvement/skills/superpowers/SKILL.md +212 -0
- package/plugins/continuous-improvement/skills/tdd-workflow/SKILL.md +411 -0
- package/plugins/continuous-improvement/skills/token-budget-advisor/SKILL.md +136 -0
- package/plugins/continuous-improvement/skills/verification-loop/SKILL.md +192 -0
- package/plugins/continuous-improvement/skills/wild-risa-balance/SKILL.md +191 -0
- package/plugins/continuous-improvement/skills/workspace-surface-audit/SKILL.md +147 -0
- package/plugins/continuous-improvement/templates/planning-with-files/findings.md +8 -0
- package/plugins/continuous-improvement/templates/planning-with-files/progress.md +7 -0
- package/plugins/continuous-improvement/templates/planning-with-files/task_plan.md +23 -0
- package/plugins/expert.json +26 -5
- package/skills/README.md +79 -0
- package/skills/deploy-receipt.md +131 -0
- package/skills/gateguard.md +155 -0
- package/skills/para-memory-files.md +108 -0
- package/skills/proceed-with-the-recommendation.md +454 -0
- package/skills/ralph.md +221 -0
- package/skills/safety-guard.md +76 -0
- package/skills/strategic-compact.md +104 -0
- package/skills/superpowers.md +212 -0
- package/skills/tdd-workflow.md +411 -0
- package/skills/token-budget-advisor.md +136 -0
- package/skills/verification-loop.md +192 -0
- package/skills/wild-risa-balance.md +191 -0
- package/skills/workspace-surface-audit.md +147 -0
- package/templates/planning-with-files/findings.md +8 -0
- package/templates/planning-with-files/progress.md +7 -0
- package/templates/planning-with-files/task_plan.md +23 -0
- package/templates/verify-ladder.example.json +47 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// observe.mts — Mulahazah PreToolUse/PostToolUse observation hook.
|
|
3
|
+
//
|
|
4
|
+
// Reads a Claude Code hook JSON payload from stdin and appends one rich-schema
|
|
5
|
+
// JSONL line to ~/.claude/instincts/<project-hash>/observations.jsonl. Drop-in
|
|
6
|
+
// replacement for the bash observe.sh fallback path: no jq dependency, captures
|
|
7
|
+
// `tool_input.command` for Bash and `Edit.file_path` for Edit/Write/Read so the
|
|
8
|
+
// downstream analysis pass can detect user corrections, error→fix sequences,
|
|
9
|
+
// and tool-argument bigrams the thin schema could not represent.
|
|
10
|
+
//
|
|
11
|
+
// Contract:
|
|
12
|
+
// - Always exits 0. Never blocks the Claude session.
|
|
13
|
+
// - Catches every error to stderr; never throws.
|
|
14
|
+
// - Empty stdin / malformed JSON / missing tool_name → no-op exit 0.
|
|
15
|
+
// - Hook budget: <500ms on Windows (per CONTRIBUTING.md).
|
|
16
|
+
//
|
|
17
|
+
// See docs/plans/2026-05-05-node-observer-rich-schema.md for the full design.
|
|
18
|
+
import { execFileSync } from "node:child_process";
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
20
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
21
|
+
import { homedir } from "node:os";
|
|
22
|
+
import { basename, join } from "node:path";
|
|
23
|
+
import { parseHookPayload, summariseInput, summariseOutput } from "../lib/observe-event.mjs";
|
|
24
|
+
const ROTATION_LINE_THRESHOLD = 10_000;
|
|
25
|
+
const ARCHIVE_RETENTION = 10;
|
|
26
|
+
main();
|
|
27
|
+
function main() {
|
|
28
|
+
try {
|
|
29
|
+
runObserver();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
// Never block the session. Failures land in stderr only.
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
process.stderr.write(`[observe] ${message}\n`);
|
|
35
|
+
}
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
function runObserver() {
|
|
39
|
+
const raw = readStdin();
|
|
40
|
+
const payload = parseHookPayload(raw);
|
|
41
|
+
if (!payload)
|
|
42
|
+
return;
|
|
43
|
+
const projectRoot = resolveProjectRoot();
|
|
44
|
+
const projectHash = createHash("sha256").update(projectRoot).digest("hex").slice(0, 12);
|
|
45
|
+
const projectName = basename(projectRoot.replace(/\.git$/, ""));
|
|
46
|
+
const instinctsDir = join(getHomeDir(), ".claude", "instincts");
|
|
47
|
+
const projectDir = join(instinctsDir, projectHash);
|
|
48
|
+
const obsFile = join(projectDir, "observations.jsonl");
|
|
49
|
+
ensureDir(projectDir);
|
|
50
|
+
rotateIfNeeded(obsFile, projectDir);
|
|
51
|
+
const ts = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
52
|
+
const event = payload.tool_response !== undefined ? "tool_complete" : "tool_start";
|
|
53
|
+
const row = {
|
|
54
|
+
ts,
|
|
55
|
+
event,
|
|
56
|
+
session: payload.session_id,
|
|
57
|
+
tool: payload.tool_name,
|
|
58
|
+
input_summary: summariseInput(payload.tool_name, payload.tool_input),
|
|
59
|
+
output_summary: summariseOutput(payload.tool_response),
|
|
60
|
+
project_id: projectHash,
|
|
61
|
+
project_name: projectName,
|
|
62
|
+
};
|
|
63
|
+
appendFileSync(obsFile, JSON.stringify(row) + "\n", "utf8");
|
|
64
|
+
writeProjectJsonIfNew(projectDir, projectHash, projectName, projectRoot, ts);
|
|
65
|
+
}
|
|
66
|
+
function readStdin() {
|
|
67
|
+
try {
|
|
68
|
+
return readFileSync(0, "utf8");
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function getHomeDir() {
|
|
75
|
+
// CLAUDE_PROJECT_DIR is the project root, not the home dir; HOME wins for
|
|
76
|
+
// home-dir resolution. Fall through to USERPROFILE on Windows then os.homedir.
|
|
77
|
+
return process.env.HOME || process.env.USERPROFILE || homedir();
|
|
78
|
+
}
|
|
79
|
+
function resolveProjectRoot() {
|
|
80
|
+
const fromEnv = process.env.CLAUDE_PROJECT_DIR;
|
|
81
|
+
// The bash version trusts CLAUDE_PROJECT_DIR unconditionally when set;
|
|
82
|
+
// preserve that semantic so test fixtures with synthetic /tmp/... paths
|
|
83
|
+
// and operator workflows that pre-set the env var both keep working.
|
|
84
|
+
if (fromEnv)
|
|
85
|
+
return fromEnv;
|
|
86
|
+
try {
|
|
87
|
+
// execFileSync (not execSync) — no shell, fixed argv array, no injection
|
|
88
|
+
// surface. Inputs are all hard-coded constants.
|
|
89
|
+
const root = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
90
|
+
encoding: "utf8",
|
|
91
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
92
|
+
}).trim();
|
|
93
|
+
if (root)
|
|
94
|
+
return root;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Not in a git repo — fall through.
|
|
98
|
+
}
|
|
99
|
+
return "global";
|
|
100
|
+
}
|
|
101
|
+
function ensureDir(dir) {
|
|
102
|
+
if (!existsSync(dir))
|
|
103
|
+
mkdirSync(dir, { recursive: true });
|
|
104
|
+
}
|
|
105
|
+
function rotateIfNeeded(obsFile, projectDir) {
|
|
106
|
+
if (!existsSync(obsFile))
|
|
107
|
+
return;
|
|
108
|
+
const lineCount = countLines(obsFile);
|
|
109
|
+
if (lineCount < ROTATION_LINE_THRESHOLD)
|
|
110
|
+
return;
|
|
111
|
+
const archiveTs = new Date().toISOString().replace(/[:.]/g, "-").replace(/Z$/, "");
|
|
112
|
+
renameSync(obsFile, join(projectDir, `observations.${archiveTs}.jsonl`));
|
|
113
|
+
pruneArchives(projectDir);
|
|
114
|
+
}
|
|
115
|
+
function countLines(file) {
|
|
116
|
+
const stat = statSync(file);
|
|
117
|
+
if (stat.size === 0)
|
|
118
|
+
return 0;
|
|
119
|
+
// For files capped at 10k lines, readFileSync is faster than streaming.
|
|
120
|
+
return readFileSync(file, "utf8").split("\n").length - 1;
|
|
121
|
+
}
|
|
122
|
+
function pruneArchives(projectDir) {
|
|
123
|
+
const archives = readdirSync(projectDir)
|
|
124
|
+
.filter((name) => /^observations\..+\.jsonl$/.test(name))
|
|
125
|
+
.sort()
|
|
126
|
+
.reverse()
|
|
127
|
+
.map((name) => join(projectDir, name));
|
|
128
|
+
for (const path of archives.slice(ARCHIVE_RETENTION)) {
|
|
129
|
+
try {
|
|
130
|
+
unlinkSync(path);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Pruning failure is non-fatal; rotation already happened.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function writeProjectJsonIfNew(projectDir, projectHash, projectName, projectRoot, ts) {
|
|
138
|
+
const projectJson = join(projectDir, "project.json");
|
|
139
|
+
if (existsSync(projectJson))
|
|
140
|
+
return;
|
|
141
|
+
const body = {
|
|
142
|
+
id: projectHash,
|
|
143
|
+
name: projectName,
|
|
144
|
+
root: projectRoot,
|
|
145
|
+
created_at: ts,
|
|
146
|
+
};
|
|
147
|
+
writeFileSync(projectJson, JSON.stringify(body) + "\n", "utf8");
|
|
148
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: continuous-improvement
|
|
3
|
+
description: "Reflect on the current session, analyze observations for patterns, and show instinct status. Runs on-demand to save tokens."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /continuous-improvement
|
|
7
|
+
|
|
8
|
+
Run this when you want to reflect and learn — not every session. Three steps in order.
|
|
9
|
+
|
|
10
|
+
## Step 1: Reflect
|
|
11
|
+
|
|
12
|
+
Generate a reflection for this session based on what happened:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
## Reflection — [Date]
|
|
16
|
+
- What worked:
|
|
17
|
+
- What failed:
|
|
18
|
+
- What I'd do differently:
|
|
19
|
+
- Rule to add:
|
|
20
|
+
- Iteration — Next best recommendations (ranked, top 3):
|
|
21
|
+
1. <primary — strongest next move>
|
|
22
|
+
2. <alternative — different angle>
|
|
23
|
+
3. <alternative — smaller/larger scope>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If there's a "Rule to add", create an instinct YAML file with 0.6 starting confidence in the project's instinct directory.
|
|
27
|
+
|
|
28
|
+
The "Iteration — Next best recommendations" field is the Law 6 handoff. List the **top 3 ranked** core-development moves — what to build, fix, refactor, or investigate next so the feature/system advances. Item #1 is the strongest; #2 and #3 are alternatives the user can pivot to. NOT git steps (commit, push, PR), NOT verification re-runs, NOT deploy actions — those belong in the end-of-run summary.
|
|
29
|
+
|
|
30
|
+
Format per item: `<verb> <object at path:line> (<why, one clause grounded in current context>)`.
|
|
31
|
+
|
|
32
|
+
Rules: always exactly 3 distinct directions, not padding. If fewer real moves exist, fill remaining slots with `None — goal met from this angle.` If the goal is fully met across all angles, write `1. None — goal met, stop.` and omit #2 and #3.
|
|
33
|
+
|
|
34
|
+
## Step 2: Analyze Observations
|
|
35
|
+
|
|
36
|
+
Check `~/.claude/instincts/` for the current project (detect via git root → SHA-256 first 12 chars).
|
|
37
|
+
|
|
38
|
+
Look at `~/.claude/instincts/<hash>/observations.jsonl`. If 20+ lines exist:
|
|
39
|
+
|
|
40
|
+
1. Read the last 500 lines
|
|
41
|
+
2. Read existing instinct `*.yaml` files (project + global)
|
|
42
|
+
3. Detect patterns:
|
|
43
|
+
- User corrections → "don't do X" instincts
|
|
44
|
+
- Error→fix sequences → "when X fails, try Y"
|
|
45
|
+
- Repeated workflows (3+ times) → "for X, do A→B→C"
|
|
46
|
+
- Tool preferences → "use tool Y for task X"
|
|
47
|
+
4. Create/update instinct YAML files
|
|
48
|
+
5. Be conservative: only create instincts for 3+ observations of the same pattern
|
|
49
|
+
|
|
50
|
+
If fewer than 20 observations, skip analysis and note the count.
|
|
51
|
+
|
|
52
|
+
### Multi-Agent Analysis (500+ observations)
|
|
53
|
+
|
|
54
|
+
When observation backlog is large, parallelize:
|
|
55
|
+
- **Agent 1:** User corrections + error→fix patterns
|
|
56
|
+
- **Agent 2:** Repeated workflows + tool preferences
|
|
57
|
+
- **Agent 3:** Cross-reference existing instincts for updates
|
|
58
|
+
|
|
59
|
+
Merge results and deduplicate before writing YAML files.
|
|
60
|
+
|
|
61
|
+
## Step 3: Show Status
|
|
62
|
+
|
|
63
|
+
Display all instincts for the current project + global:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
=== continuous-improvement ===
|
|
67
|
+
|
|
68
|
+
## Level: [CAPTURE | ANALYZE | SUGGEST | AUTO-APPLY]
|
|
69
|
+
|
|
70
|
+
## Session Reflection
|
|
71
|
+
- What worked: [from this session]
|
|
72
|
+
- What failed: [from this session]
|
|
73
|
+
- What I'd do differently: [from this session]
|
|
74
|
+
- Rule to add: [captured as instinct]
|
|
75
|
+
- Iteration — Next best recommendations (ranked, top 3):
|
|
76
|
+
1. [primary core-development move]
|
|
77
|
+
2. [alternative angle]
|
|
78
|
+
3. [alternative scope]
|
|
79
|
+
|
|
80
|
+
## Learning
|
|
81
|
+
NEW [instinct-id] [domain] [confidence] (from reflection)
|
|
82
|
+
↑ [instinct-id] [domain] [old]→[new] (+N observations)
|
|
83
|
+
|
|
84
|
+
## Instincts — [project-name] ([hash])
|
|
85
|
+
● [0.85] instinct-id domain auto-apply
|
|
86
|
+
◐ [0.60] instinct-id domain suggest
|
|
87
|
+
○ [0.35] instinct-id domain silent
|
|
88
|
+
|
|
89
|
+
## Instincts — global
|
|
90
|
+
● [0.90] instinct-id domain auto-apply
|
|
91
|
+
|
|
92
|
+
## Next
|
|
93
|
+
- Keep working — hooks capture automatically
|
|
94
|
+
- System auto-levels as instincts gain confidence
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If no instincts or observations exist yet, explain this is expected — the system is in CAPTURE level and will create instincts after 20+ observations accumulate.
|
|
98
|
+
|
|
99
|
+
## Subcommands
|
|
100
|
+
|
|
101
|
+
### `/continuous-improvement weekly`
|
|
102
|
+
|
|
103
|
+
Set up a weekly analysis schedule:
|
|
104
|
+
1. Create a cron/loop schedule that runs `/continuous-improvement analyze` every 7 days
|
|
105
|
+
2. Confirm the schedule to the user
|
|
106
|
+
3. Show next scheduled run date
|
|
107
|
+
|
|
108
|
+
### `/continuous-improvement always-on`
|
|
109
|
+
|
|
110
|
+
Toggle always-on mode for the current project:
|
|
111
|
+
1. Find project hash
|
|
112
|
+
2. Create/update `~/.claude/instincts/<hash>/config.yaml` with `always_on: true|false`
|
|
113
|
+
3. Confirm the change
|
|
114
|
+
|
|
115
|
+
**Default is off** — observations accumulate silently, analysis only runs when you ask.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dashboard
|
|
3
|
+
description: Visual dashboard showing instinct health, observation stats, and learning progress
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Instinct Dashboard
|
|
7
|
+
|
|
8
|
+
Generate a visual dashboard for this project's continuous-improvement status.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
|
|
12
|
+
1. **Find project hash:** Run `git rev-parse --show-toplevel 2>/dev/null`, then SHA-256 first 12 chars
|
|
13
|
+
2. **Read observations:** Count lines in `~/.claude/instincts/<hash>/observations.jsonl`
|
|
14
|
+
3. **Read instincts:** Load all `*.yaml` files from project dir + `global/`
|
|
15
|
+
4. **Read instinct packs:** Check if any packs from `instinct-packs/` have been loaded
|
|
16
|
+
|
|
17
|
+
## Display Format
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
21
|
+
║ continuous-improvement Dashboard ║
|
|
22
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
23
|
+
║ ║
|
|
24
|
+
║ Project: <name> Level: <CAPTURE|ANALYZE|...> ║
|
|
25
|
+
║ Sessions: ~<obs/10> Mode: <beginner|expert> ║
|
|
26
|
+
║ ║
|
|
27
|
+
║ ┌─ Observations ────────────────────────────────────────┐ ║
|
|
28
|
+
║ │ Total: <n> Unprocessed: <n> Last: <date> │ ║
|
|
29
|
+
║ └───────────────────────────────────────────────────────┘ ║
|
|
30
|
+
║ ║
|
|
31
|
+
║ ┌─ Instincts ───────────────────────────────────────────┐ ║
|
|
32
|
+
║ │ Total: <n> │ ║
|
|
33
|
+
║ │ ████████░░ Auto-apply (0.7+): <n> │ ║
|
|
34
|
+
║ │ █████░░░░░ Suggest (0.5-0.69): <n> │ ║
|
|
35
|
+
║ │ ██░░░░░░░░ Silent (< 0.5): <n> │ ║
|
|
36
|
+
║ │ Global: <n> Project: <n> │ ║
|
|
37
|
+
║ └───────────────────────────────────────────────────────┘ ║
|
|
38
|
+
║ ║
|
|
39
|
+
║ ┌─ Top Instincts ───────────────────────────────────────┐ ║
|
|
40
|
+
║ │ <list top 5 instincts by confidence with bars> │ ║
|
|
41
|
+
║ └───────────────────────────────────────────────────────┘ ║
|
|
42
|
+
║ ║
|
|
43
|
+
║ ┌─ Health ──────────────────────────────────────────────┐ ║
|
|
44
|
+
║ │ Stale (30+ days): <n> Decaying: <n> │ ║
|
|
45
|
+
║ │ Recently reinforced: <n> │ ║
|
|
46
|
+
║ └───────────────────────────────────────────────────────┘ ║
|
|
47
|
+
║ ║
|
|
48
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## After Display
|
|
52
|
+
|
|
53
|
+
- If stale instincts > 0: suggest reviewing them
|
|
54
|
+
- If unprocessed observations > 20: suggest running analysis
|
|
55
|
+
- If no instincts exist: explain the auto-leveling timeline
|
|
56
|
+
- Show available instinct packs that haven't been loaded yet
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: discipline
|
|
3
|
+
description: Quick reference card for the 7 Laws of AI Agent Discipline
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# The 7 Laws — Quick Reference
|
|
7
|
+
|
|
8
|
+
Print this card and check yourself against each law.
|
|
9
|
+
|
|
10
|
+
## The Laws
|
|
11
|
+
|
|
12
|
+
| # | Law | Check | Red Flag |
|
|
13
|
+
|---|-----|-------|----------|
|
|
14
|
+
| 1 | **Research Before Executing** | Did I search for existing solutions? | "I'll just quickly..." |
|
|
15
|
+
| 2 | **Plan Is Sacred** | Did I state WILL / WILL NOT / VERIFY? | "Let me also add..." |
|
|
16
|
+
| 3 | **One Thing at a Time** | Am I finishing before starting? | "While I'm here..." |
|
|
17
|
+
| 4 | **Verify Before Reporting** | Did I check the ACTUAL output? | "This should work..." |
|
|
18
|
+
| 5 | **Reflect After Sessions** | Did I note what worked/failed? | "I'll remember..." |
|
|
19
|
+
| 6 | **Iterate One Change** | Am I changing one thing at a time? | "And also..." |
|
|
20
|
+
| 7 | **Learn From Every Session** | Did I capture this as an instinct? | "Next time I'll..." |
|
|
21
|
+
|
|
22
|
+
## Operator Stakes
|
|
23
|
+
|
|
24
|
+
The Laws above are the *how*. These five principles are the *why*: code ships from your account, the incident lands on your pager, the bill hits your budget. Each one pairs with the Law that prevents it from going wrong.
|
|
25
|
+
|
|
26
|
+
| # | Principle | Vibe coder | Engineer | Law |
|
|
27
|
+
|---|-----------|------------|----------|-----|
|
|
28
|
+
| 1 | **Ownership** | Ships auth, moves on | Adds rate limits, audit logs, password-reset flow, incident runbook before shipping | 4 |
|
|
29
|
+
| 2 | **Reliability over cleverness** | Accepts a clever regex + heavy lib that breaks on ISO 8601 with millis | Picks the boring tested API, writes tests for leap years and DST | 1 |
|
|
30
|
+
| 3 | **Systems thinking** | Builds in-memory CSV export, works for 100 dev users, OOMs in prod | Asks row count first, picks paginated background job + S3 link | 2 |
|
|
31
|
+
| 4 | **Problem framing** | Builds the websocket chat the ticket asked for | Finds out users wanted faster support replies, not chat | 1 |
|
|
32
|
+
| 5 | **Constraints management** | Calls the $0.02/image model on every upload | Does the math, adds client-side validation + caching + cheaper triage model | 2 |
|
|
33
|
+
|
|
34
|
+
Code is a liability, not an asset. Speed without these five turns into someone else's incident at 3am — except the someone is you.
|
|
35
|
+
|
|
36
|
+
## The Loop
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Research → Plan → Execute (one thing) → Verify → Reflect → Learn → Iterate
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Self-Check
|
|
43
|
+
|
|
44
|
+
Before saying "Done", verify ALL:
|
|
45
|
+
- [ ] Code runs without errors
|
|
46
|
+
- [ ] Output matches expected result
|
|
47
|
+
- [ ] I checked the **actual** result (not assumed)
|
|
48
|
+
- [ ] Build passes
|
|
49
|
+
- [ ] I can explain the change in one sentence
|
|
50
|
+
|
|
51
|
+
If you're skipping a step, that's the step you need most.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harvest
|
|
3
|
+
description: Harvest friction events from observation logs into typed instincts (env_issue, permission_block, wrong_approach, buggy_code) with confidence scoring.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /harvest — Friction Harvest
|
|
7
|
+
|
|
8
|
+
Run the friction-harvest classifier against this project's observation log and append new typed instincts to `instincts.jsonl`. Idempotent on re-run.
|
|
9
|
+
|
|
10
|
+
## What it does
|
|
11
|
+
|
|
12
|
+
Reads `~/.claude/instincts/<project-hash>/observations.jsonl` produced by the Mulahazah hook, classifies failure rows into four typed friction patterns, scores confidence with a recency-weighted decay, and appends new instincts to `<project-hash>/instincts.jsonl` alongside.
|
|
13
|
+
|
|
14
|
+
| Type | What it catches |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `env_issue` | jq missing, command not found, not recognized as cmdlet |
|
|
17
|
+
| `permission_block` | sandbox / harness blocked, Permission denied |
|
|
18
|
+
| `wrong_approach` | file changed since last read (parallel-actor stale) |
|
|
19
|
+
| `buggy_code` | file not read first, old_string ambiguous, file too large |
|
|
20
|
+
|
|
21
|
+
## How to invoke
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
node bin/harvest-friction.mjs
|
|
25
|
+
node bin/harvest-friction.mjs <project-hash>
|
|
26
|
+
node bin/harvest-friction.mjs --list
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`--list` shows new classifications without writing to `instincts.jsonl` — useful for dry-run before committing the harvest output.
|
|
30
|
+
|
|
31
|
+
## Idempotency
|
|
32
|
+
|
|
33
|
+
Each instinct carries a `dedup_key = sha1(type + tool + summary[:120])`. Re-running on the same observations does not duplicate previously-written instincts; `loadExistingDedupKeys()` reads the destination file once at start.
|
|
34
|
+
|
|
35
|
+
## Confidence model
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
confidence = log10(occurrence_count + 1) * recency_factor
|
|
39
|
+
recency_factor = 0.5 + 0.5 * exp(-days_since_last_seen / 14)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
One occurrence today → 0.30. Ten occurrences today → clamped to 1.0. One occurrence 30 days ago → 0.17.
|
|
43
|
+
|
|
44
|
+
## Output shape
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
harvest-friction project=0af156594b39
|
|
48
|
+
observations rows: 9346
|
|
49
|
+
tool_complete rows: 2104
|
|
50
|
+
classified failures: 47
|
|
51
|
+
thin-schema rows: 0
|
|
52
|
+
new instincts: 12
|
|
53
|
+
skipped (existing): 35
|
|
54
|
+
|
|
55
|
+
New instincts:
|
|
56
|
+
[0.92] env_issue on Bash (×8): bash: jq: command not found
|
|
57
|
+
[0.74] permission_block on Bash (×4): harness blocked direct push to main
|
|
58
|
+
...
|
|
59
|
+
|
|
60
|
+
Appended 12 instinct(s) to /Users/.../instincts/0af156594b39/instincts.jsonl
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## When the classifier emits zero instincts
|
|
64
|
+
|
|
65
|
+
If `tool_complete rows: 0`, the bash-fallback hook is active (no jq AND the Node observer is not on PATH) and only emits `tool_start` events. Two remediation paths:
|
|
66
|
+
|
|
67
|
+
- **Install jq** — `winget install jqlang.jq` (Windows), `brew install jq` (macOS), `apt install jq` (Linux).
|
|
68
|
+
- **Wire the Node observer** — ensure `hooks/bin/observe.mjs` is reachable from the active hook script.
|
|
69
|
+
|
|
70
|
+
Both are documented in the WARNING the classifier prints on a thin-schema host.
|
|
71
|
+
|
|
72
|
+
## Pairs with
|
|
73
|
+
|
|
74
|
+
- **`continuous-improvement`** (core SKILL.md, Law 7 — Learn From Every Session) — the harvest pipeline is the concrete mechanism behind Law 7's "capture patterns as instincts" contract.
|
|
75
|
+
- **`workspace-surface-audit`** — Phase 1 Environment Grain confirms whether jq + Node observer are available; if not, the harvest will run inert until that gap closes.
|
|
76
|
+
- **`gateguard`** — observation rows include the Parallel-Actor Gate's HEAD/upstream baselines when divergence-halts fire; the classifier surfaces those as `wrong_approach` instincts.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: learn-eval
|
|
3
|
+
description: "Extract reusable patterns from the session, self-evaluate quality before saving, and determine the right save location (Global vs Project)."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /learn-eval - Extract, Evaluate, then Save
|
|
7
|
+
|
|
8
|
+
Extends `/learn` with a quality gate, save-location decision, and knowledge-placement awareness before writing any skill file.
|
|
9
|
+
|
|
10
|
+
## What to Extract
|
|
11
|
+
|
|
12
|
+
Look for:
|
|
13
|
+
|
|
14
|
+
1. **Error Resolution Patterns** — root cause + fix + reusability
|
|
15
|
+
2. **Debugging Techniques** — non-obvious steps, tool combinations
|
|
16
|
+
3. **Workarounds** — library quirks, API limitations, version-specific fixes
|
|
17
|
+
4. **Project-Specific Patterns** — conventions, architecture decisions, integration patterns
|
|
18
|
+
|
|
19
|
+
## Process
|
|
20
|
+
|
|
21
|
+
1. Review the session for extractable patterns
|
|
22
|
+
2. Identify the most valuable/reusable insight
|
|
23
|
+
|
|
24
|
+
3. **Determine save location:**
|
|
25
|
+
- Ask: "Would this pattern be useful in a different project?"
|
|
26
|
+
- **Global** (`~/.claude/skills/learned/`): Generic patterns usable across 2+ projects (bash compatibility, LLM API behavior, debugging techniques, etc.)
|
|
27
|
+
- **Project** (`.claude/skills/learned/` in current project): Project-specific knowledge (quirks of a particular config file, project-specific architecture decisions, etc.)
|
|
28
|
+
- When in doubt, choose Global (moving Global → Project is easier than the reverse)
|
|
29
|
+
|
|
30
|
+
4. Draft the skill file using this format:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
---
|
|
34
|
+
name: pattern-name
|
|
35
|
+
description: "Under 130 characters"
|
|
36
|
+
user-invocable: false
|
|
37
|
+
origin: auto-extracted
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# [Descriptive Pattern Name]
|
|
41
|
+
|
|
42
|
+
**Extracted:** [Date]
|
|
43
|
+
**Context:** [Brief description of when this applies]
|
|
44
|
+
|
|
45
|
+
## Problem
|
|
46
|
+
[What problem this solves - be specific]
|
|
47
|
+
|
|
48
|
+
## Solution
|
|
49
|
+
[The pattern/technique/workaround - with code examples]
|
|
50
|
+
|
|
51
|
+
## When to Use
|
|
52
|
+
[Trigger conditions]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
5. **Quality gate — Checklist + Holistic verdict**
|
|
56
|
+
|
|
57
|
+
### 5a. Required checklist (verify by actually reading files)
|
|
58
|
+
|
|
59
|
+
Execute **all** of the following before evaluating the draft:
|
|
60
|
+
|
|
61
|
+
- [ ] Grep `~/.claude/skills/` and relevant project `.claude/skills/` files by keyword to check for content overlap
|
|
62
|
+
- [ ] Check MEMORY.md (both project and global) for overlap
|
|
63
|
+
- [ ] Consider whether appending to an existing skill would suffice
|
|
64
|
+
- [ ] Confirm this is a reusable pattern, not a one-off fix
|
|
65
|
+
|
|
66
|
+
### 5b. Holistic verdict
|
|
67
|
+
|
|
68
|
+
Synthesize the checklist results and draft quality, then choose **one** of the following:
|
|
69
|
+
|
|
70
|
+
| Verdict | Meaning | Next Action |
|
|
71
|
+
|---------|---------|-------------|
|
|
72
|
+
| **Save** | Unique, specific, well-scoped | Proceed to Step 6 |
|
|
73
|
+
| **Improve then Save** | Valuable but needs refinement | List improvements → revise → re-evaluate (once) |
|
|
74
|
+
| **Absorb into [X]** | Should be appended to an existing skill | Show target skill and additions → Step 6 |
|
|
75
|
+
| **Drop** | Trivial, redundant, or too abstract | Explain reasoning and stop |
|
|
76
|
+
|
|
77
|
+
**Guideline dimensions** (informing the verdict, not scored):
|
|
78
|
+
|
|
79
|
+
- **Specificity & Actionability**: Contains code examples or commands that are immediately usable
|
|
80
|
+
- **Scope Fit**: Name, trigger conditions, and content are aligned and focused on a single pattern
|
|
81
|
+
- **Uniqueness**: Provides value not covered by existing skills (informed by checklist results)
|
|
82
|
+
- **Reusability**: Realistic trigger scenarios exist in future sessions
|
|
83
|
+
|
|
84
|
+
6. **Verdict-specific confirmation flow**
|
|
85
|
+
|
|
86
|
+
- **Improve then Save**: Present the required improvements + revised draft + updated checklist/verdict after one re-evaluation; if the revised verdict is **Save**, save after user confirmation, otherwise follow the new verdict
|
|
87
|
+
- **Save**: Present save path + checklist results + 1-line verdict rationale + full draft → save after user confirmation
|
|
88
|
+
- **Absorb into [X]**: Present target path + additions (diff format) + checklist results + verdict rationale → append after user confirmation
|
|
89
|
+
- **Drop**: Show checklist results + reasoning only (no confirmation needed)
|
|
90
|
+
|
|
91
|
+
7. Save / Absorb to the determined location
|
|
92
|
+
|
|
93
|
+
## Output Format for Step 5
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
### Checklist
|
|
97
|
+
- [x] skills/ grep: no overlap (or: overlap found → details)
|
|
98
|
+
- [x] MEMORY.md: no overlap (or: overlap found → details)
|
|
99
|
+
- [x] Existing skill append: new file appropriate (or: should append to [X])
|
|
100
|
+
- [x] Reusability: confirmed (or: one-off → Drop)
|
|
101
|
+
|
|
102
|
+
### Verdict: Save / Improve then Save / Absorb into [X] / Drop
|
|
103
|
+
|
|
104
|
+
**Rationale:** (1-2 sentences explaining the verdict)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Design Rationale
|
|
108
|
+
|
|
109
|
+
This version replaces the previous 5-dimension numeric scoring rubric (Specificity, Actionability, Scope Fit, Non-redundancy, Coverage scored 1-5) with a checklist-based holistic verdict system. Modern frontier models (Opus 4.6+) have strong contextual judgment — forcing rich qualitative signals into numeric scores loses nuance and can produce misleading totals. The holistic approach lets the model weigh all factors naturally, producing more accurate save/drop decisions while the explicit checklist ensures no critical check is skipped.
|
|
110
|
+
|
|
111
|
+
## Notes
|
|
112
|
+
|
|
113
|
+
- Don't extract trivial fixes (typos, simple syntax errors)
|
|
114
|
+
- Don't extract one-time issues (specific API outages, etc.)
|
|
115
|
+
- Focus on patterns that will save time in future sessions
|
|
116
|
+
- Keep skills focused — one pattern per skill
|
|
117
|
+
- When the verdict is Absorb, append to the existing skill rather than creating a new file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planning-with-files
|
|
3
|
+
description: Create and maintain task_plan.md, findings.md, and progress.md for persistent file-based planning
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /planning-with-files
|
|
7
|
+
|
|
8
|
+
Use this workflow only when the user explicitly wants persistent, file-based planning. It is opt-in.
|
|
9
|
+
|
|
10
|
+
## Project Root
|
|
11
|
+
|
|
12
|
+
1. Run `git rev-parse --show-toplevel 2>/dev/null`
|
|
13
|
+
2. If that fails, use the current working directory
|
|
14
|
+
3. Create and read planning files in that root only
|
|
15
|
+
|
|
16
|
+
The planning files are:
|
|
17
|
+
- `task_plan.md`
|
|
18
|
+
- `findings.md`
|
|
19
|
+
- `progress.md`
|
|
20
|
+
|
|
21
|
+
## `init`
|
|
22
|
+
|
|
23
|
+
If the files do not exist, create them in the project root.
|
|
24
|
+
|
|
25
|
+
`task_plan.md` must include:
|
|
26
|
+
- `## Goal`
|
|
27
|
+
- `## Status`
|
|
28
|
+
- `## Phases`
|
|
29
|
+
- `## Key Questions`
|
|
30
|
+
- `## Decisions Made`
|
|
31
|
+
- `## Errors Encountered`
|
|
32
|
+
|
|
33
|
+
Default phases:
|
|
34
|
+
- `Research`
|
|
35
|
+
- `Plan`
|
|
36
|
+
- `Execute`
|
|
37
|
+
- `Verify`
|
|
38
|
+
- `Reflect`
|
|
39
|
+
|
|
40
|
+
Never overwrite existing planning files unless the user explicitly asks you to reset or replace them.
|
|
41
|
+
|
|
42
|
+
## `status`
|
|
43
|
+
|
|
44
|
+
Read all three files and summarize:
|
|
45
|
+
- Current status from `task_plan.md`
|
|
46
|
+
- Checked vs unchecked phases
|
|
47
|
+
- Whether `findings.md` has real notes yet
|
|
48
|
+
- Whether `progress.md` has real session or verification entries yet
|
|
49
|
+
|
|
50
|
+
If the files do not exist, say so and offer to initialize them.
|
|
51
|
+
|
|
52
|
+
## `checkpoint`
|
|
53
|
+
|
|
54
|
+
After a meaningful work chunk:
|
|
55
|
+
- Update `progress.md` with what happened, commands run, and verification notes
|
|
56
|
+
- Add new discoveries or sources to `findings.md`
|
|
57
|
+
- Update `task_plan.md` progress, decisions, and errors
|
|
58
|
+
|
|
59
|
+
Do not hide failures. Log them in `## Errors Encountered`.
|
|
60
|
+
|
|
61
|
+
## `recover`
|
|
62
|
+
|
|
63
|
+
When resuming after context loss or a new session:
|
|
64
|
+
- Re-read `task_plan.md`, `findings.md`, and `progress.md` before making major decisions
|
|
65
|
+
- Restate the current goal, phase, open questions, and latest verification state
|
|
66
|
+
- Continue from the recorded plan instead of rebuilding context from memory
|