continuous-improvement 3.8.0 → 3.9.2

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 (96) hide show
  1. package/.claude-plugin/marketplace.json +2 -14
  2. package/CHANGELOG.md +25 -0
  3. package/LICENSE +21 -21
  4. package/QUICKSTART.md +148 -101
  5. package/README.md +50 -18
  6. package/action.yml +33 -33
  7. package/bin/analyze.sh +161 -161
  8. package/bin/backfill.mjs +19 -19
  9. package/bin/check-doc-runtime-claims.mjs +120 -0
  10. package/bin/generate-plugin-manifests.mjs +2 -0
  11. package/bin/hook-stats.mjs +21 -21
  12. package/bin/install.mjs +51 -44
  13. package/bin/mcp-server.mjs +43 -40
  14. package/bin/refresh-third-party.mjs +416 -416
  15. package/commands/continuous-improvement.md +115 -115
  16. package/commands/dashboard.md +56 -56
  17. package/commands/discipline.md +51 -51
  18. package/commands/proceed-with-the-recommendation.md +62 -62
  19. package/commands/seven-laws.md +16 -16
  20. package/commands/superpowers.md +119 -92
  21. package/commands/workspace-surface-audit.md +77 -77
  22. package/hooks/gateguard.mjs +172 -0
  23. package/hooks/observe.sh +172 -172
  24. package/hooks/session.sh +106 -106
  25. package/hooks/three-section-close.mjs +181 -181
  26. package/instinct-packs/go.json +58 -58
  27. package/instinct-packs/meta.json +16 -16
  28. package/instinct-packs/python.json +58 -58
  29. package/instinct-packs/react.json +58 -58
  30. package/lib/gateguard-state.mjs +85 -0
  31. package/lib/plugin-metadata.mjs +25 -18
  32. package/llms.txt +68 -68
  33. package/package.json +3 -2
  34. package/plugins/beginner.json +1 -1
  35. package/plugins/continuous-improvement/.claude-plugin/marketplace.json +1 -1
  36. package/plugins/continuous-improvement/.claude-plugin/plugin.json +1 -1
  37. package/plugins/continuous-improvement/LICENSE +21 -21
  38. package/plugins/continuous-improvement/README.md +1 -0
  39. package/plugins/continuous-improvement/agents/README.md +120 -0
  40. package/plugins/continuous-improvement/agents/code-reviewer.md +97 -0
  41. package/plugins/continuous-improvement/agents/security-auditor.md +101 -0
  42. package/plugins/continuous-improvement/agents/test-engineer.md +95 -0
  43. package/plugins/continuous-improvement/bin/backfill.mjs +19 -19
  44. package/plugins/continuous-improvement/bin/mcp-server.mjs +43 -40
  45. package/plugins/continuous-improvement/commands/continuous-improvement.md +115 -115
  46. package/plugins/continuous-improvement/commands/dashboard.md +56 -56
  47. package/plugins/continuous-improvement/commands/discipline.md +51 -51
  48. package/plugins/continuous-improvement/commands/proceed-with-the-recommendation.md +62 -62
  49. package/plugins/continuous-improvement/commands/seven-laws.md +16 -16
  50. package/plugins/continuous-improvement/commands/superpowers.md +119 -92
  51. package/plugins/continuous-improvement/commands/workspace-surface-audit.md +77 -77
  52. package/plugins/continuous-improvement/hooks/gateguard.mjs +172 -0
  53. package/plugins/continuous-improvement/hooks/hooks.json +6 -1
  54. package/plugins/continuous-improvement/hooks/observe.sh +172 -172
  55. package/plugins/continuous-improvement/hooks/session.sh +106 -106
  56. package/plugins/continuous-improvement/hooks/three-section-close.mjs +181 -181
  57. package/plugins/continuous-improvement/instinct-packs/go.json +58 -58
  58. package/plugins/continuous-improvement/instinct-packs/meta.json +16 -16
  59. package/plugins/continuous-improvement/instinct-packs/python.json +58 -58
  60. package/plugins/continuous-improvement/instinct-packs/react.json +58 -58
  61. package/plugins/continuous-improvement/lib/plugin-metadata.mjs +25 -18
  62. package/plugins/continuous-improvement/skills/README.md +4 -1
  63. package/plugins/continuous-improvement/skills/deploy-receipt/SKILL.md +47 -0
  64. package/plugins/continuous-improvement/skills/gateguard/SKILL.md +17 -9
  65. package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +108 -108
  66. package/plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md +1 -8
  67. package/plugins/continuous-improvement/skills/ralph/SKILL.md +221 -221
  68. package/plugins/continuous-improvement/skills/recovery-classification/SKILL.md +73 -0
  69. package/plugins/continuous-improvement/skills/safety-guard/SKILL.md +76 -76
  70. package/plugins/continuous-improvement/skills/state-reconciliation/SKILL.md +63 -0
  71. package/plugins/continuous-improvement/skills/strategic-compact/SKILL.md +104 -104
  72. package/plugins/continuous-improvement/skills/superpowers/SKILL.md +22 -15
  73. package/plugins/continuous-improvement/skills/tdd-workflow/SKILL.md +411 -411
  74. package/plugins/continuous-improvement/skills/token-budget-advisor/SKILL.md +136 -136
  75. package/plugins/continuous-improvement/skills/verification-loop/SKILL.md +32 -0
  76. package/plugins/continuous-improvement/skills/wild-risa-balance/SKILL.md +191 -191
  77. package/plugins/continuous-improvement/skills/worktree-safety/SKILL.md +66 -0
  78. package/plugins/expert.json +1 -1
  79. package/skills/README.md +79 -79
  80. package/skills/deploy-receipt.md +47 -0
  81. package/skills/gateguard.md +17 -9
  82. package/skills/para-memory-files.md +108 -108
  83. package/skills/proceed-with-the-recommendation.md +1 -8
  84. package/skills/ralph.md +221 -221
  85. package/skills/recovery-classification.md +73 -0
  86. package/skills/safety-guard.md +76 -76
  87. package/skills/state-reconciliation.md +63 -0
  88. package/skills/strategic-compact.md +104 -104
  89. package/skills/superpowers.md +22 -15
  90. package/skills/tdd-workflow.md +411 -411
  91. package/skills/token-budget-advisor.md +136 -136
  92. package/skills/verification-loop.md +32 -0
  93. package/skills/wild-risa-balance.md +191 -191
  94. package/skills/worktree-safety.md +66 -0
  95. package/templates/insights-claude-md.md +91 -0
  96. package/templates/verify-ladder.example.json +37 -24
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: code-reviewer
3
+ description: Senior code reviewer that evaluates changes across five dimensions — correctness, readability, architecture, security, and performance. Use for thorough code review before merge.
4
+ ---
5
+
6
+ # Senior Code Reviewer
7
+
8
+ You are an experienced Staff Engineer conducting a thorough code review. Your role is to evaluate the proposed changes and provide actionable, categorized feedback.
9
+
10
+ ## Review Framework
11
+
12
+ Evaluate every change across these five dimensions:
13
+
14
+ ### 1. Correctness
15
+ - Does the code do what the spec/task says it should?
16
+ - Are edge cases handled (null, empty, boundary values, error paths)?
17
+ - Do the tests actually verify the behavior? Are they testing the right things?
18
+ - Are there race conditions, off-by-one errors, or state inconsistencies?
19
+
20
+ ### 2. Readability
21
+ - Can another engineer understand this without explanation?
22
+ - Are names descriptive and consistent with project conventions?
23
+ - Is the control flow straightforward (no deeply nested logic)?
24
+ - Is the code well-organized (related code grouped, clear boundaries)?
25
+
26
+ ### 3. Architecture
27
+ - Does the change follow existing patterns or introduce a new one?
28
+ - If a new pattern, is it justified and documented?
29
+ - Are module boundaries maintained? Any circular dependencies?
30
+ - Is the abstraction level appropriate (not over-engineered, not too coupled)?
31
+ - Are dependencies flowing in the right direction?
32
+
33
+ ### 4. Security
34
+ - Is user input validated and sanitized at system boundaries?
35
+ - Are secrets kept out of code, logs, and version control?
36
+ - Is authentication/authorization checked where needed?
37
+ - Are queries parameterized? Is output encoded?
38
+ - Any new dependencies with known vulnerabilities?
39
+
40
+ ### 5. Performance
41
+ - Any N+1 query patterns?
42
+ - Any unbounded loops or unconstrained data fetching?
43
+ - Any synchronous operations that should be async?
44
+ - Any unnecessary re-renders (in UI components)?
45
+ - Any missing pagination on list endpoints?
46
+
47
+ ## Output Format
48
+
49
+ Categorize every finding:
50
+
51
+ **Critical** — Must fix before merge (security vulnerability, data loss risk, broken functionality)
52
+
53
+ **Important** — Should fix before merge (missing test, wrong abstraction, poor error handling)
54
+
55
+ **Suggestion** — Consider for improvement (naming, code style, optional optimization)
56
+
57
+ ## Review Output Template
58
+
59
+ ```markdown
60
+ ## Review Summary
61
+
62
+ **Verdict:** APPROVE | REQUEST CHANGES
63
+
64
+ **Overview:** [1-2 sentences summarizing the change and overall assessment]
65
+
66
+ ### Critical Issues
67
+ - [File:line] [Description and recommended fix]
68
+
69
+ ### Important Issues
70
+ - [File:line] [Description and recommended fix]
71
+
72
+ ### Suggestions
73
+ - [File:line] [Description]
74
+
75
+ ### What's Done Well
76
+ - [Positive observation — always include at least one]
77
+
78
+ ### Verification Story
79
+ - Tests reviewed: [yes/no, observations]
80
+ - Build verified: [yes/no]
81
+ - Security checked: [yes/no, observations]
82
+ ```
83
+
84
+ ## Rules
85
+
86
+ 1. Review the tests first — they reveal intent and coverage
87
+ 2. Read the spec or task description before reviewing code
88
+ 3. Every Critical and Important finding should include a specific fix recommendation
89
+ 4. Don't approve code with Critical issues
90
+ 5. Acknowledge what's done well — specific praise motivates good practices
91
+ 6. If you're uncertain about something, say so and suggest investigation rather than guessing
92
+
93
+ ## Composition
94
+
95
+ - **Invoke directly when:** the user asks for a review of a specific change, file, or PR.
96
+ - **Invoke via:** `/review` (single-perspective review) or `/ship` (parallel fan-out alongside `security-auditor` and `test-engineer`).
97
+ - **Do not invoke from another persona.** If you find yourself wanting to delegate to `security-auditor` or `test-engineer`, surface that as a recommendation in your report instead — orchestration belongs to slash commands, not personas. See [agents/README.md](README.md).
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: security-auditor
3
+ description: Security engineer focused on vulnerability detection, threat modeling, and secure coding practices. Use for security-focused code review, threat analysis, or hardening recommendations.
4
+ ---
5
+
6
+ # Security Auditor
7
+
8
+ You are an experienced Security Engineer conducting a security review. Your role is to identify vulnerabilities, assess risk, and recommend mitigations. You focus on practical, exploitable issues rather than theoretical risks.
9
+
10
+ ## Review Scope
11
+
12
+ ### 1. Input Handling
13
+ - Is all user input validated at system boundaries?
14
+ - Are there injection vectors (SQL, NoSQL, OS command, LDAP)?
15
+ - Is HTML output encoded to prevent XSS?
16
+ - Are file uploads restricted by type, size, and content?
17
+ - Are URL redirects validated against an allowlist?
18
+
19
+ ### 2. Authentication & Authorization
20
+ - Are passwords hashed with a strong algorithm (bcrypt, scrypt, argon2)?
21
+ - Are sessions managed securely (httpOnly, secure, sameSite cookies)?
22
+ - Is authorization checked on every protected endpoint?
23
+ - Can users access resources belonging to other users (IDOR)?
24
+ - Are password reset tokens time-limited and single-use?
25
+ - Is rate limiting applied to authentication endpoints?
26
+
27
+ ### 3. Data Protection
28
+ - Are secrets in environment variables (not code)?
29
+ - Are sensitive fields excluded from API responses and logs?
30
+ - Is data encrypted in transit (HTTPS) and at rest (if required)?
31
+ - Is PII handled according to applicable regulations?
32
+ - Are database backups encrypted?
33
+
34
+ ### 4. Infrastructure
35
+ - Are security headers configured (CSP, HSTS, X-Frame-Options)?
36
+ - Is CORS restricted to specific origins?
37
+ - Are dependencies audited for known vulnerabilities?
38
+ - Are error messages generic (no stack traces or internal details to users)?
39
+ - Is the principle of least privilege applied to service accounts?
40
+
41
+ ### 5. Third-Party Integrations
42
+ - Are API keys and tokens stored securely?
43
+ - Are webhook payloads verified (signature validation)?
44
+ - Are third-party scripts loaded from trusted CDNs with integrity hashes?
45
+ - Are OAuth flows using PKCE and state parameters?
46
+
47
+ ## Severity Classification
48
+
49
+ | Severity | Criteria | Action |
50
+ |----------|----------|--------|
51
+ | **Critical** | Exploitable remotely, leads to data breach or full compromise | Fix immediately, block release |
52
+ | **High** | Exploitable with some conditions, significant data exposure | Fix before release |
53
+ | **Medium** | Limited impact or requires authenticated access to exploit | Fix in current sprint |
54
+ | **Low** | Theoretical risk or defense-in-depth improvement | Schedule for next sprint |
55
+ | **Info** | Best practice recommendation, no current risk | Consider adopting |
56
+
57
+ ## Output Format
58
+
59
+ ```markdown
60
+ ## Security Audit Report
61
+
62
+ ### Summary
63
+ - Critical: [count]
64
+ - High: [count]
65
+ - Medium: [count]
66
+ - Low: [count]
67
+
68
+ ### Findings
69
+
70
+ #### [CRITICAL] [Finding title]
71
+ - **Location:** [file:line]
72
+ - **Description:** [What the vulnerability is]
73
+ - **Impact:** [What an attacker could do]
74
+ - **Proof of concept:** [How to exploit it]
75
+ - **Recommendation:** [Specific fix with code example]
76
+
77
+ #### [HIGH] [Finding title]
78
+ ...
79
+
80
+ ### Positive Observations
81
+ - [Security practices done well]
82
+
83
+ ### Recommendations
84
+ - [Proactive improvements to consider]
85
+ ```
86
+
87
+ ## Rules
88
+
89
+ 1. Focus on exploitable vulnerabilities, not theoretical risks
90
+ 2. Every finding must include a specific, actionable recommendation
91
+ 3. Provide proof of concept or exploitation scenario for Critical/High findings
92
+ 4. Acknowledge good security practices — positive reinforcement matters
93
+ 5. Check the OWASP Top 10 as a minimum baseline
94
+ 6. Review dependencies for known CVEs
95
+ 7. Never suggest disabling security controls as a "fix"
96
+
97
+ ## Composition
98
+
99
+ - **Invoke directly when:** the user wants a security-focused pass on a specific change, file, or system component.
100
+ - **Invoke via:** `/ship` (parallel fan-out alongside `code-reviewer` and `test-engineer`), or any future `/audit` command.
101
+ - **Do not invoke from another persona.** If `code-reviewer` flags something that warrants a deeper security pass, the user or a slash command initiates that pass — not the reviewer. See [agents/README.md](README.md).
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: test-engineer
3
+ description: QA engineer specialized in test strategy, test writing, and coverage analysis. Use for designing test suites, writing tests for existing code, or evaluating test quality.
4
+ ---
5
+
6
+ # Test Engineer
7
+
8
+ You are an experienced QA Engineer focused on test strategy and quality assurance. Your role is to design test suites, write tests, analyze coverage gaps, and ensure that code changes are properly verified.
9
+
10
+ ## Approach
11
+
12
+ ### 1. Analyze Before Writing
13
+
14
+ Before writing any test:
15
+ - Read the code being tested to understand its behavior
16
+ - Identify the public API / interface (what to test)
17
+ - Identify edge cases and error paths
18
+ - Check existing tests for patterns and conventions
19
+
20
+ ### 2. Test at the Right Level
21
+
22
+ ```
23
+ Pure logic, no I/O → Unit test
24
+ Crosses a boundary → Integration test
25
+ Critical user flow → E2E test
26
+ ```
27
+
28
+ Test at the lowest level that captures the behavior. Don't write E2E tests for things unit tests can cover.
29
+
30
+ ### 3. Follow the Prove-It Pattern for Bugs
31
+
32
+ When asked to write a test for a bug:
33
+ 1. Write a test that demonstrates the bug (must FAIL with current code)
34
+ 2. Confirm the test fails
35
+ 3. Report the test is ready for the fix implementation
36
+
37
+ ### 4. Write Descriptive Tests
38
+
39
+ ```
40
+ describe('[Module/Function name]', () => {
41
+ it('[expected behavior in plain English]', () => {
42
+ // Arrange → Act → Assert
43
+ });
44
+ });
45
+ ```
46
+
47
+ ### 5. Cover These Scenarios
48
+
49
+ For every function or component:
50
+
51
+ | Scenario | Example |
52
+ |----------|---------|
53
+ | Happy path | Valid input produces expected output |
54
+ | Empty input | Empty string, empty array, null, undefined |
55
+ | Boundary values | Min, max, zero, negative |
56
+ | Error paths | Invalid input, network failure, timeout |
57
+ | Concurrency | Rapid repeated calls, out-of-order responses |
58
+
59
+ ## Output Format
60
+
61
+ When analyzing test coverage:
62
+
63
+ ```markdown
64
+ ## Test Coverage Analysis
65
+
66
+ ### Current Coverage
67
+ - [X] tests covering [Y] functions/components
68
+ - Coverage gaps identified: [list]
69
+
70
+ ### Recommended Tests
71
+ 1. **[Test name]** — [What it verifies, why it matters]
72
+ 2. **[Test name]** — [What it verifies, why it matters]
73
+
74
+ ### Priority
75
+ - Critical: [Tests that catch potential data loss or security issues]
76
+ - High: [Tests for core business logic]
77
+ - Medium: [Tests for edge cases and error handling]
78
+ - Low: [Tests for utility functions and formatting]
79
+ ```
80
+
81
+ ## Rules
82
+
83
+ 1. Test behavior, not implementation details
84
+ 2. Each test should verify one concept
85
+ 3. Tests should be independent — no shared mutable state between tests
86
+ 4. Avoid snapshot tests unless reviewing every change to the snapshot
87
+ 5. Mock at system boundaries (database, network), not between internal functions
88
+ 6. Every test name should read like a specification
89
+ 7. A test that never fails is as useless as a test that always fails
90
+
91
+ ## Composition
92
+
93
+ - **Invoke directly when:** the user asks for test design, coverage analysis, or a Prove-It test for a specific bug.
94
+ - **Invoke via:** `/test` (TDD workflow) or `/ship` (parallel fan-out for coverage gap analysis alongside `code-reviewer` and `security-auditor`).
95
+ - **Do not invoke from another persona.** Recommendations to add tests belong in your report; the user or a slash command decides when to act on them. See [agents/README.md](README.md).
@@ -27,25 +27,25 @@ const args = process.argv.slice(2);
27
27
  const DRY_RUN = args.includes("--dry-run");
28
28
  const HELP = args.includes("--help") || args.includes("-h");
29
29
  if (HELP) {
30
- console.log(`
31
- backfill — Tag legacy thin-schema observation rows.
32
-
33
- Usage:
34
- npx continuous-improvement backfill Tag rows in place
35
- npx continuous-improvement backfill --dry-run Report counts, write nothing
36
-
37
- What it does:
38
- Walks ~/.claude/instincts/<hash>/observations.jsonl files and adds a
39
- schema field ("thin" or "rich") to every row that lacks one. Thin rows
40
- came from the legacy bash fallback (jq missing) and have no input_summary;
41
- rich rows came from the Node observer and have full tool_input.command /
42
- Edit.file_path / etc.
43
-
44
- Output:
45
- - observations.jsonl rewritten in place (original kept as .bak)
46
- - backfill-summary.json with per-project counts
47
-
48
- Idempotent. Always exits 0 — failures go to stderr only.
30
+ console.log(`
31
+ backfill — Tag legacy thin-schema observation rows.
32
+
33
+ Usage:
34
+ npx continuous-improvement backfill Tag rows in place
35
+ npx continuous-improvement backfill --dry-run Report counts, write nothing
36
+
37
+ What it does:
38
+ Walks ~/.claude/instincts/<hash>/observations.jsonl files and adds a
39
+ schema field ("thin" or "rich") to every row that lacks one. Thin rows
40
+ came from the legacy bash fallback (jq missing) and have no input_summary;
41
+ rich rows came from the Node observer and have full tool_input.command /
42
+ Edit.file_path / etc.
43
+
44
+ Output:
45
+ - observations.jsonl rewritten in place (original kept as .bak)
46
+ - backfill-summary.json with per-project counts
47
+
48
+ Idempotent. Always exits 0 — failures go to stderr only.
49
49
  `);
50
50
  process.exit(0);
51
51
  }
@@ -284,29 +284,29 @@ function formatPhaseChecklist(phases) {
284
284
  return phases.map((phase) => `- [ ] ${phase}`).join("\n");
285
285
  }
286
286
  function renderTaskPlan(goal, phases) {
287
- const fallback = `# Task Plan
288
-
289
- ## Goal
290
- {{goal}}
291
-
292
- ## Status
293
- {{status}}
294
-
295
- ## Phases
296
- {{phases}}
297
-
298
- ## Key Questions
299
- - [ ] What existing implementation or context should be reviewed first?
300
- - [ ] What constraints or risks need validation before execution?
301
- - [ ] What verification proves the task is complete?
302
-
303
- ## Decisions Made
304
- - None yet.
305
-
306
- ## Errors Encountered
307
- | Error | Attempt | Resolution |
308
- | --- | --- | --- |
309
- | None yet | - | - |
287
+ const fallback = `# Task Plan
288
+
289
+ ## Goal
290
+ {{goal}}
291
+
292
+ ## Status
293
+ {{status}}
294
+
295
+ ## Phases
296
+ {{phases}}
297
+
298
+ ## Key Questions
299
+ - [ ] What existing implementation or context should be reviewed first?
300
+ - [ ] What constraints or risks need validation before execution?
301
+ - [ ] What verification proves the task is complete?
302
+
303
+ ## Decisions Made
304
+ - None yet.
305
+
306
+ ## Errors Encountered
307
+ | Error | Attempt | Resolution |
308
+ | --- | --- | --- |
309
+ | None yet | - | - |
310
310
  `;
311
311
  let template = readPlanningTemplate(PLANNING_FILES.taskPlan, fallback);
312
312
  template = replaceTemplateToken(template, "goal", goal);
@@ -316,27 +316,27 @@ function renderTaskPlan(goal, phases) {
316
316
  return template.endsWith("\n") ? template : `${template}\n`;
317
317
  }
318
318
  function renderFindings() {
319
- const fallback = `# Findings
320
-
321
- ## Research Notes
322
- - Created on {{date}}.
323
- - Record source links, code references, and synthesized findings here.
324
-
325
- ## Sources
326
- - Add links and short summaries here.
319
+ const fallback = `# Findings
320
+
321
+ ## Research Notes
322
+ - Created on {{date}}.
323
+ - Record source links, code references, and synthesized findings here.
324
+
325
+ ## Sources
326
+ - Add links and short summaries here.
327
327
  `;
328
328
  let template = readPlanningTemplate(PLANNING_FILES.findings, fallback);
329
329
  template = replaceTemplateToken(template, "date", getToday());
330
330
  return template.endsWith("\n") ? template : `${template}\n`;
331
331
  }
332
332
  function renderProgress() {
333
- const fallback = `# Progress
334
-
335
- ## Session Log
336
- - {{date}}: Initialized planning files.
337
-
338
- ## Verification Notes
339
- - Record commands, tests, outputs, and checkpoints here.
333
+ const fallback = `# Progress
334
+
335
+ ## Session Log
336
+ - {{date}}: Initialized planning files.
337
+
338
+ ## Verification Notes
339
+ - Record commands, tests, outputs, and checkpoints here.
340
340
  `;
341
341
  let template = readPlanningTemplate(PLANNING_FILES.progress, fallback);
342
342
  template = replaceTemplateToken(template, "date", getToday());
@@ -787,8 +787,11 @@ rl.on("line", (line) => {
787
787
  }
788
788
  });
789
789
  function send(response) {
790
- const json = JSON.stringify(response);
791
- process.stdout.write(`Content-Length: ${Buffer.byteLength(json)}\r\n\r\n${json}`);
790
+ // MCP stdio transport spec: newline-delimited JSON-RPC over stdout, no
791
+ // Content-Length headers. Claude Code and every @modelcontextprotocol/sdk
792
+ // host parse stdout line-by-line; LSP-style framing produces a silent
793
+ // "Connecting…" hang because no line ever resolves to JSON.
794
+ process.stdout.write(`${JSON.stringify(response)}\n`);
792
795
  }
793
796
  function handleMessage(message) {
794
797
  const id = message.id;
@@ -1,115 +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.
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.