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
@@ -1,22 +1,95 @@
1
1
  ---
2
2
  name: superpowers
3
- description: "Activate mandatory agent workflows: brainstorming, TDD, code review, git worktrees, and structured development"
3
+ description: "Law activator and dispatcher route the task to the right Law-aligned specialist across continuous-improvement and four vendored upstream skill libraries (Obra superpowers, addy-agent-skills, ruflo-swarm, oh-my-claudecode)."
4
4
  ---
5
5
 
6
6
  # /superpowers
7
7
 
8
- Activate the Superpowers mandatory workflow framework. Skills trigger automatically based on context this is not optional guidance.
8
+ `/superpowers` is **the dispatcher**, not a peer skill. It does not do work itself; it routes each user task to the correct Law-aligned specialist so the right discipline fires automatically instead of the agent skipping a step.
9
+
10
+ The 7 Laws define *what* discipline must be applied. `/superpowers` decides *which specialist* enforces it for this specific task, across five sources installed from this marketplace.
11
+
12
+ ## Routing surface (five sources)
13
+
14
+ | Source | Where it lives | Examples of what it routes to |
15
+ |---|---|---|
16
+ | `continuous-improvement` (this plugin) | bundled — always present | `gateguard` (Law 1), `tdd-workflow` (Law 3+4), `verification-loop` (Law 4), `wild-risa-balance` (Law 2), `safety-guard` (Law 3), `proceed-with-the-recommendation` (all 7), `ralph` (Law 6), `workspace-surface-audit` (Law 1) |
17
+ | `obra/superpowers` (Jesse Vincent) | vendored at `third-party/superpowers/`, pinned SHA `f2cbfbe` (v5.1.0) | `superpowers:brainstorming`, `:writing-plans`, `:executing-plans`, `:test-driven-development`, `:systematic-debugging`, `:requesting-code-review`, `:receiving-code-review`, `:verification-before-completion`, `:dispatching-parallel-agents`, `:using-git-worktrees`, `:finishing-a-development-branch`, `:subagent-driven-development`, `:writing-skills`, `:using-superpowers` |
18
+ | `addyosmani/agent-skills` | vendored at `third-party/addy-agent-skills/`, pinned SHA `742dca5` (v1.0.0) | `spec-driven-development`, `source-driven-development`, `context-engineering`, `idea-refine`, `incremental-implementation`, `code-review-and-quality`, `code-simplification`, `security-and-hardening`, `debugging-and-error-recovery`, `performance-optimization`, `api-and-interface-design`, `frontend-ui-engineering`, `browser-testing-with-devtools`, `ci-cd-and-automation`, `deprecation-and-migration`, `documentation-and-adrs`, `git-workflow-and-versioning`, `planning-and-task-breakdown`, `shipping-and-launch` |
19
+ | `ruflo-swarm` (ruvnet) | vendored at `third-party/ruflo-swarm/`, pinned SHA `addb5cd` (v0.2.0) | `swarm-init`, `monitor-stream`; `swarm_*` and `agent_*` MCP tools; `/swarm`, `/watch` |
20
+ | `oh-my-claudecode` (Yeachan-Heo) | vendored at `third-party/oh-my-claudecode/`, pinned SHA `aacde3e` (v4.13.6) | 39 skills + 19 agents — `release`, `ultrawork`, `ultraqa`, `team`, `trace`, `visual-verdict`, `debug`, `deep-dive`, `deep-interview`, `autopilot`, `autoresearch`, plus a separate `ralph` (overlaps with our `/ralph` — see "Distinct variants" below) |
21
+
22
+ PM coverage (product-management skills) lives **outside** this marketplace. If you need it, install [`phuryn/pm-skills`](https://github.com/phuryn/pm-skills) separately via Claude Code's host marketplace; the dispatcher names it as a routing target without pre-resolving the namespace. See [docs/THIRD_PARTY.md § Routing in /superpowers](../docs/THIRD_PARTY.md#routing-in-superpowers).
23
+
24
+ ## Distinct variants — never collapse them
25
+
26
+ Two routing targets carry the same short name across sources. Treat them as distinct; do not silently substitute one for the other.
27
+
28
+ | Short name | `obra/superpowers` (Obra) | `continuous-improvement` (CI fork) |
29
+ |---|---|---|
30
+ | `superpowers` (skill) | activator routing into Obra skills | `superpowers` skill in this repo: Law-aligned activator wrapping the dispatcher commitments below |
31
+ | `ralph` | not present in Obra | bundled here; `oh-my-claudecode` ships its own `ralph` — pick deliberately, do not auto-merge |
32
+
33
+ If both Obra `superpowers` and continuous-improvement are loaded, you can call either explicitly: `superpowers:test-driven-development` (Obra) or `tdd-workflow` (CI). Same Law (3+4), different implementation depth.
34
+
35
+ ## Dispatcher commitments (override looser global defaults when `/superpowers` is in scope)
36
+
37
+ When this dispatcher is active for a task, these six rules apply over any looser convention:
38
+
39
+ 1. **Subagent-driven development is the default for non-trivial tasks.** Two-stage spec + quality review per [obra/superpowers § subagent-driven-development](https://github.com/obra/superpowers).
40
+ 2. **Parallel fan-out goes through `superpowers:dispatching-parallel-agents`** (or `/swarm`), not hand-rolled `Task` calls.
41
+ 3. **TDD runs RED → GREEN → REFACTOR.** Code written before its test is **deleted**, not retrofitted. Routes to `tdd-workflow` (CI) or `superpowers:test-driven-development` (Obra) — pick by depth, never both for the same task.
42
+ 4. **Branch isolation is `using-git-worktrees`** by default for any task that touches more than one file.
43
+ 5. **`finishing-a-development-branch` runs before any push.** No bypass via `--no-verify`, `--force`, or direct push to `main`.
44
+ 6. **Obra `superpowers` and `continuous-improvement:superpowers` stay distinct.** Both can be installed; neither shadows the other; the dispatcher names which one is firing.
45
+
46
+ ## Routing rules (which source wins)
47
+
48
+ | User intent | Preferred routing target | Source |
49
+ |---|---|---|
50
+ | New feature, vague requirements | `superpowers:brainstorming` → `:writing-plans` | `obra/superpowers` |
51
+ | Fix this bug | `superpowers:systematic-debugging` → `tdd-workflow` (RED first) → `verification-loop` | Obra → CI → CI |
52
+ | Walk an agent's recommendation list | `proceed-with-the-recommendation` | CI |
53
+ | Write tests for new code | `tdd-workflow` (CI default) or `superpowers:test-driven-development` (Obra, deeper) | CI / Obra |
54
+ | Verify before reporting "done" | `verification-loop` | CI |
55
+ | Refactor, multi-file | `superpowers:using-git-worktrees` → `:writing-plans` → `tdd-workflow` → `:finishing-a-development-branch` | Obra → Obra → CI → Obra |
56
+ | Long autonomous PRD execution | `/ralph` (CI variant) | CI |
57
+ | Parallel sub-agent fan-out | `superpowers:dispatching-parallel-agents` or `/swarm` | Obra / ruflo-swarm |
58
+ | Spec-first, contract-first feature | `spec-driven-development` | addy-agent-skills |
59
+ | Frontend / UI generation | `frontend-design` (external plugin) | external |
60
+ | Diff walk + severity tagging | `code-review` (external plugin) or `superpowers:requesting-code-review` | external / Obra |
61
+ | Library / framework docs lookup | `documentation-lookup` (Context7 MCP) | external |
62
+ | Compliance / security gate | `security-and-hardening` (addy) → `security-review` (host built-in) | addy → host |
63
+ | Release coordination across PRs | `/release-train` | CI |
64
+
65
+ ## Missing-companion detection
66
+
67
+ If `/superpowers` is asked to route to a source that is not installed, it does not silently fall back to the inline placeholder. It must:
68
+
69
+ 1. **Name the missing source** explicitly (e.g. `obra/superpowers` not loaded).
70
+ 2. **Quote the exact install line** for it from the marketplace already added in setup, e.g. `/plugin install superpowers@continuous-improvement`.
71
+ 3. **State the inline-fallback equivalent** that will run if the user declines to install (and which Law that fallback enforces).
72
+ 4. **Stop and ask** before continuing. Do not silently downgrade.
73
+
74
+ This is the same hard-halt discipline used by `proceed-with-the-recommendation` for `needs-approval` items.
9
75
 
10
76
  ## Subcommands
11
77
 
12
78
  ### `/superpowers status`
13
79
 
14
- Show which workflow stages are active:
80
+ Show which routing sources are loaded, which workflow stages are active for the current task, and which sources are **missing**:
15
81
 
16
82
  ```
17
83
  === Superpowers Status ===
18
84
 
19
- Active Skills:
85
+ Sources:
86
+ [x] continuous-improvement (bundled)
87
+ [x] obra/superpowers v5.1.0 (vendored)
88
+ [ ] addyosmani/agent-skills MISSING — /plugin install agent-skills@continuous-improvement
89
+ [x] ruflo-swarm v0.2.0 (vendored)
90
+ [ ] oh-my-claudecode MISSING — /plugin install oh-my-claudecode@continuous-improvement
91
+
92
+ Active for current task:
20
93
  [x] brainstorming (trigger: new feature request)
21
94
  [ ] using-git-worktrees (waiting: design approval)
22
95
  [ ] writing-plans (waiting: worktree ready)
@@ -27,127 +100,81 @@ Active Skills:
27
100
 
28
101
  ### `/superpowers enable <skill>`
29
102
 
30
- Explicitly enable a skill for the current session:
103
+ Explicitly enable a skill for the current session — useful when the dispatcher's intent detection guesses wrong:
31
104
 
32
105
  ```
33
106
  /superpowers enable test-driven-development
107
+ /superpowers enable superpowers:writing-plans # namespaced form for Obra
34
108
  ```
35
109
 
36
110
  ### `/superpowers workflow <type>`
37
111
 
38
112
  Activate a complete workflow preset:
39
113
 
40
- | Preset | Skills Activated |
41
- |--------|------------------|
42
- | `new-feature` | brainstorming → worktrees → plans → TDD → review → finish |
43
- | `bug-fix` | systematic-debugging → verification → TDD → review |
44
- | `refactor` | worktrees → plans → TDD → review → finish |
45
- | `review` | requesting-code-review → receiving-code-review |
114
+ | Preset | Skills activated (in order) |
115
+ |---|---|
116
+ | `new-feature` | `superpowers:brainstorming``:using-git-worktrees``:writing-plans``tdd-workflow``verification-loop` → `:requesting-code-review``:finishing-a-development-branch` |
117
+ | `bug-fix` | `superpowers:systematic-debugging``verification-loop``tdd-workflow` (regression test first) `:requesting-code-review` |
118
+ | `refactor` | `superpowers:using-git-worktrees``:writing-plans``tdd-workflow``:requesting-code-review``:finishing-a-development-branch` |
119
+ | `review` | `superpowers:requesting-code-review``:receiving-code-review` |
120
+ | `release` | `/release-train` → `verification-loop` → `superpowers:finishing-a-development-branch` |
46
121
 
47
122
  Example:
48
123
  ```
49
124
  /superpowers workflow new-feature
50
125
  ```
51
126
 
52
- ## Mandatory Skills
53
-
54
- ### brainstorming
55
- **Triggers:** New feature requests, vague requirements
56
-
57
- 1. Ask clarifying questions
58
- 2. Explore 2-3 alternatives
59
- 3. Present design in sections
60
- 4. Wait for explicit approval
127
+ ## Verification protocol (Law 4)
61
128
 
62
- ### using-git-worktrees
63
- **Triggers:** Design approved, feature branch needed
64
-
65
- Creates isolated workspace:
66
- ```bash
67
- git worktree add -b feature-name ../feature-name
68
- ```
129
+ Every routed skill must verify before reporting completion. The dispatcher refuses to advance to the next stage until the current one shows:
69
130
 
70
- ### writing-plans
71
- **Triggers:** Worktree ready, implementation starting
131
+ 1. Code runs without errors
132
+ 2. Output matches expected result
133
+ 3. Actual result checked — not assumed
134
+ 4. Build passes
135
+ 5. Change explainable in one sentence
72
136
 
73
- Breaks work into bite-sized tasks (2-5 minutes each). Every task includes:
74
- - Exact file paths
75
- - Complete code
76
- - Verification steps
77
-
78
- ### test-driven-development
79
- **Triggers:** Plan approved, coding begins
80
-
81
- ```
82
- RED: Write failing test → Watch it fail
83
- GREEN: Write minimal code → Watch it pass
84
- REFACTOR: Improve while green → Commit
85
- ```
86
-
87
- **Rule:** Code written before tests is deleted.
88
-
89
- ### requesting-code-review
90
- **Triggers:** Task complete, before continuing
91
-
92
- Two-stage review:
93
- 1. Spec compliance — Does it match the plan?
94
- 2. Code quality — Clean, tested, maintainable?
95
-
96
- Severity levels: Critical (blocks), Warning (note), Info (log)
97
-
98
- ### finishing-a-development-branch
99
- **Triggers:** All tasks complete
100
-
101
- Options presented:
102
- - Merge to main
103
- - Create PR
104
- - Keep branch
105
- - Discard (with confirmation)
106
-
107
- ## Skill Activation Rules
108
-
109
- | User Request | Activates |
110
- |--------------|-----------|
111
- | "Create a feature" | brainstorming → writing-plans → executing-plans |
112
- | "Fix this bug" | systematic-debugging → verification → TDD |
113
- | "Review this code" | requesting-code-review |
114
- | "Refactor this" | using-git-worktrees → writing-plans → TDD |
115
-
116
- ## Verification Protocol
117
-
118
- Every skill requires verification before reporting completion:
119
-
120
- 1. **Code runs** without errors
121
- 2. **Output matches** expected result
122
- 3. **Actual result checked** — not assumed
123
- 4. **Build passes**
124
- 5. **Explained** in one sentence
137
+ This is `verification-loop` from `continuous-improvement`. It runs after every workflow stage, not just at the end.
125
138
 
126
139
  ## Integration
127
140
 
128
- Superpowers integrates with:
129
- - **continuous-improvement** — reflection and learning after each stage
130
- - **ralph**autonomous execution of planned stories
131
- - **workspace-surface-audit**verify environment before starting
141
+ `/superpowers` integrates with:
142
+
143
+ - **`/seven-laws`**runs after each stage to capture the reflection block and update instincts (Laws 5 + 7)
144
+ - **`/proceed-with-the-recommendation`**orchestrates a list of recommendations end-to-end, using `/superpowers` per item
145
+ - **`/workspace-surface-audit`** — runs at task start to confirm the right routing surface is actually present (Law 1 pre-flight)
146
+ - **`/ralph`** — autonomous variant; takes a PRD and walks it story-by-story under the same routing table
132
147
 
133
- ## Example Session
148
+ ## Example session
134
149
 
135
150
  ```
136
151
  User: "Build a checkout flow"
137
152
 
138
- [brainstorming activates]
153
+ [/superpowers status]
154
+ Sources: continuous-improvement [x], obra/superpowers [x], others [ ]
155
+ Routing intent: new-feature
156
+
157
+ [brainstorming activates — obra/superpowers]
139
158
  AI: "Clarifying questions: 1) Payment provider? 2) Guest checkout?"
140
159
 
141
160
  User: "Stripe, yes guest checkout"
142
161
 
143
- [writing-plans activates]
162
+ [using-git-worktrees activates — obra/superpowers]
163
+ AI: "Created worktree at ../checkout-feature"
164
+
165
+ [writing-plans activates — obra/superpowers]
144
166
  AI: "Plan created with 6 tasks. Approve?"
145
167
 
146
168
  User: "Approved"
147
169
 
148
- [using-git-worktrees activates]
149
- AI: "Created worktree at ../checkout-feature"
170
+ [tdd-workflow activates — continuous-improvement]
171
+ AI: "Task 1 RED: write failing test for cart validation..."
172
+ AI: "Task 1 GREEN: minimal handler. Verifying with `npm test cart.test.ts`..."
173
+ AI: "Task 1 REFACTOR: extract validator, tests still green. Committing."
174
+
175
+ [verification-loop activates — continuous-improvement]
176
+ AI: "Build [x] Types [x] Lint [x] Tests 42/42 [x] Security scan clean [x]"
150
177
 
151
- [test-driven-development activates]
152
- AI: "Task 1: Write failing test for cart validation..."
178
+ [finishing-a-development-branch activates — obra/superpowers]
179
+ AI: "Options: merge / PR / keep / discard?"
153
180
  ```
@@ -1,77 +1,77 @@
1
- ---
2
- name: workspace-surface-audit
3
- description: "Audit workspace capabilities and recommend continuous-improvement-native skills, hooks, and workflows"
4
- ---
5
-
6
- # /workspace-surface-audit
7
-
8
- Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup. Returns a 5-section report with specific next moves.
9
-
10
- ## Usage
11
-
12
- ```
13
- /workspace-surface-audit
14
- ```
15
-
16
- ## What It Checks
17
-
18
- 1. **Repo surface** — `package.json`, lockfiles, framework config, `.mcp.json`, `.claude/settings*.json`, `AGENTS.md`
19
- 2. **Environment surface** — `.env*` files (key names only, no secrets)
20
- 3. **Connected tools** — installed plugins, MCP servers, LSPs, app integrations
21
- 4. **continuous-improvement surface** — existing skills, commands, hooks, agents
22
-
23
- ## Output Format
24
-
25
- ```
26
- === Workspace Surface Audit ===
27
-
28
- ## Current Surface
29
- - [What is usable right now]
30
-
31
- ## Parity
32
- - [Where continuous-improvement matches or exceeds benchmarks]
33
-
34
- ## Primitive-Only Gaps
35
- - [Tools exist, but continuous-improvement lacks clean operator skills]
36
-
37
- ## Missing Integrations
38
- - [Capabilities not available yet]
39
-
40
- ## Top 3-5 Next Moves
41
- 1. [Concrete continuous-improvement-native addition]
42
- 2. [Ordered by impact]
43
- ```
44
-
45
- ## Rules
46
-
47
- - **Never print secrets** — only provider names, capability names, file paths
48
- - **Prefer continuous-improvement** over generic "install another plugin" advice
49
- - **Organize by workflows**, not API brands
50
- - **Specific recommendations** — concrete enough to implement without another discovery pass
51
-
52
- ## Example Output
53
-
54
- ```
55
- ## Current Surface
56
- - MCP: filesystem, github, playwright
57
- - Plugins: beginner, expert (continuous-improvement)
58
- - Env: STRIPE_API_KEY, FAL_KEY configured
59
- - Framework: Next.js 15, React 19, TypeScript
60
-
61
- ## Parity
62
- - Continuous improvement: covered (native)
63
- - Testing discipline: covered (TDD workflows)
64
-
65
- ## Primitive-Only Gaps
66
- - Stripe connected but no billing-operator skill
67
- - GitHub MCP available but no issue-triage workflow
68
-
69
- ## Missing Integrations
70
- - No Linear connector detected
71
- - No Slack webhook configured
72
-
73
- ## Top 3-5 Next Moves
74
- 1. Create billing-operator skill (Stripe integration)
75
- 2. Create github-ops workflow for issue triage
76
- 3. Add Linear connector skill for project management
77
- ```
1
+ ---
2
+ name: workspace-surface-audit
3
+ description: "Audit workspace capabilities and recommend continuous-improvement-native skills, hooks, and workflows"
4
+ ---
5
+
6
+ # /workspace-surface-audit
7
+
8
+ Audit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup. Returns a 5-section report with specific next moves.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /workspace-surface-audit
14
+ ```
15
+
16
+ ## What It Checks
17
+
18
+ 1. **Repo surface** — `package.json`, lockfiles, framework config, `.mcp.json`, `.claude/settings*.json`, `AGENTS.md`
19
+ 2. **Environment surface** — `.env*` files (key names only, no secrets)
20
+ 3. **Connected tools** — installed plugins, MCP servers, LSPs, app integrations
21
+ 4. **continuous-improvement surface** — existing skills, commands, hooks, agents
22
+
23
+ ## Output Format
24
+
25
+ ```
26
+ === Workspace Surface Audit ===
27
+
28
+ ## Current Surface
29
+ - [What is usable right now]
30
+
31
+ ## Parity
32
+ - [Where continuous-improvement matches or exceeds benchmarks]
33
+
34
+ ## Primitive-Only Gaps
35
+ - [Tools exist, but continuous-improvement lacks clean operator skills]
36
+
37
+ ## Missing Integrations
38
+ - [Capabilities not available yet]
39
+
40
+ ## Top 3-5 Next Moves
41
+ 1. [Concrete continuous-improvement-native addition]
42
+ 2. [Ordered by impact]
43
+ ```
44
+
45
+ ## Rules
46
+
47
+ - **Never print secrets** — only provider names, capability names, file paths
48
+ - **Prefer continuous-improvement** over generic "install another plugin" advice
49
+ - **Organize by workflows**, not API brands
50
+ - **Specific recommendations** — concrete enough to implement without another discovery pass
51
+
52
+ ## Example Output
53
+
54
+ ```
55
+ ## Current Surface
56
+ - MCP: filesystem, github, playwright
57
+ - Plugins: beginner, expert (continuous-improvement)
58
+ - Env: STRIPE_API_KEY, FAL_KEY configured
59
+ - Framework: Next.js 15, React 19, TypeScript
60
+
61
+ ## Parity
62
+ - Continuous improvement: covered (native)
63
+ - Testing discipline: covered (TDD workflows)
64
+
65
+ ## Primitive-Only Gaps
66
+ - Stripe connected but no billing-operator skill
67
+ - GitHub MCP available but no issue-triage workflow
68
+
69
+ ## Missing Integrations
70
+ - No Linear connector detected
71
+ - No Slack webhook configured
72
+
73
+ ## Top 3-5 Next Moves
74
+ 1. Create billing-operator skill (Stripe integration)
75
+ 2. Create github-ops workflow for issue triage
76
+ 3. Add Linear connector skill for project management
77
+ ```
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Runtime PreToolUse gateguard hook.
4
+ *
5
+ * Stdin : JSON { tool_name, tool_input }
6
+ * Stdout : JSON { decision: "allow" | "block", reason?: string }
7
+ * Exit : 0 always (decision is in stdout, fail-open on parse error).
8
+ *
9
+ * Three-stage gate per skills/gateguard.md:
10
+ * - DENY : first mutating tool call per file, with fact-list reason
11
+ * - FORCE : agent presents facts (model-side; out of band)
12
+ * - ALLOW : retry once `_gateguard_facts_presented: true` is set or the
13
+ * per-file marker is recorded in session state
14
+ *
15
+ * Read-only and exploratory tools (Read, Grep, Glob, routine Bash) bypass
16
+ * unconditionally. Destructive Bash gates EVERY call, not just first.
17
+ *
18
+ * V1 honest limitations (see src/lib/gateguard-state.mts header):
19
+ * honor-system flag, state-file deletion, parallel-hook race.
20
+ *
21
+ * MultiEdit handling (V1): gates on edits[0].file_path only. Per-file
22
+ * batching is not implemented — TODO: extend to gate every entry in
23
+ * edits[]. Tracked in issue #106 acceptance criteria item 5.
24
+ */
25
+ import { readFileSync } from "node:fs";
26
+ import { isCapReached, loadState, markFileCleared, resolveSessionDir, saveState, } from "../lib/gateguard-state.mjs";
27
+ const TOOL_ROUTE = {
28
+ Read: "allow",
29
+ Grep: "allow",
30
+ Glob: "allow",
31
+ LS: "allow",
32
+ NotebookRead: "allow",
33
+ Write: "mutating-file",
34
+ Edit: "mutating-file",
35
+ MultiEdit: "mutating-file",
36
+ NotebookEdit: "mutating-file",
37
+ Bash: "allow",
38
+ };
39
+ const DESTRUCTIVE_PATTERNS = [
40
+ "rm -rf",
41
+ "rm -fr",
42
+ "git reset --hard",
43
+ "git push --force",
44
+ "git push -f",
45
+ "--force-with-lease",
46
+ "git branch -D",
47
+ "drop table",
48
+ "drop database",
49
+ "drop schema",
50
+ "truncate ",
51
+ "mkfs",
52
+ "dd if=",
53
+ "format ",
54
+ "rmdir /s",
55
+ "del /f /q",
56
+ "del /q /f",
57
+ "Remove-Item -Recurse",
58
+ "Remove-Item -Force",
59
+ ];
60
+ function isDestructiveBash(command) {
61
+ const lower = command.toLowerCase();
62
+ return DESTRUCTIVE_PATTERNS.some((p) => lower.includes(p.toLowerCase()));
63
+ }
64
+ function classifyTool(toolName, toolInput) {
65
+ const route = TOOL_ROUTE[toolName] ?? "allow";
66
+ if (route !== "allow")
67
+ return route;
68
+ if (toolName === "Bash" && typeof toolInput.command === "string") {
69
+ if (isDestructiveBash(toolInput.command))
70
+ return "destructive-bash";
71
+ }
72
+ return "allow";
73
+ }
74
+ function extractFilePath(toolInput) {
75
+ if (typeof toolInput.file_path === "string")
76
+ return toolInput.file_path;
77
+ // MultiEdit V1: first edit's file_path is the canonical key.
78
+ if (Array.isArray(toolInput.edits) && toolInput.edits.length > 0) {
79
+ const first = toolInput.edits[0];
80
+ if (first && typeof first.file_path === "string")
81
+ return first.file_path;
82
+ }
83
+ if (typeof toolInput.command === "string")
84
+ return toolInput.command;
85
+ return "";
86
+ }
87
+ function buildMutatingFileReason(toolName, filePath) {
88
+ return [
89
+ `Before ${toolName === "Write" ? "creating" : "editing"} ${filePath || "<unknown>"}, present these facts:`,
90
+ "",
91
+ " 1. List ALL files that import/require this file (use Grep)",
92
+ " 2. List the public functions/classes affected by this change",
93
+ " 3. If this file reads/writes data files, show field names, structure, and date format",
94
+ " 4. Quote the user's current instruction verbatim",
95
+ "",
96
+ "After presenting the facts, retry with `_gateguard_facts_presented: true` in tool_input,",
97
+ "or with the same file_path after a previous clearance has been recorded for this session.",
98
+ ].join("\n");
99
+ }
100
+ function buildDestructiveBashReason(command) {
101
+ return [
102
+ `Destructive command requested: ${command}`,
103
+ "",
104
+ " 1. List ALL files/data this command will modify or delete",
105
+ " 2. Write a one-line rollback procedure",
106
+ " 3. Quote the user's current instruction verbatim",
107
+ "",
108
+ "Destructive Bash gates EVERY call — clearance is not cached.",
109
+ ].join("\n");
110
+ }
111
+ function buildCapReachedReason() {
112
+ return [
113
+ "Gateguard session clearance cap reached (50 distinct files).",
114
+ "Start a new Claude Code session to reset the gate. The cap exists to bound",
115
+ "stuck-loop or rogue-agent clearance from compounding within a single session.",
116
+ ].join("\n");
117
+ }
118
+ function emit(decision) {
119
+ process.stdout.write(`${JSON.stringify(decision)}\n`);
120
+ process.exit(0);
121
+ }
122
+ function main() {
123
+ let raw = "";
124
+ try {
125
+ raw = readFileSync(0, "utf8");
126
+ }
127
+ catch {
128
+ emit({ decision: "allow" });
129
+ return;
130
+ }
131
+ let payload;
132
+ try {
133
+ payload = JSON.parse(raw);
134
+ }
135
+ catch {
136
+ emit({ decision: "allow" }); // fail-open
137
+ return;
138
+ }
139
+ const toolName = typeof payload.tool_name === "string" ? payload.tool_name : "";
140
+ const toolInput = payload.tool_input ?? {};
141
+ const gate = classifyTool(toolName, toolInput);
142
+ if (gate === "allow") {
143
+ emit({ decision: "allow" });
144
+ return;
145
+ }
146
+ if (gate === "destructive-bash") {
147
+ const cmd = typeof toolInput.command === "string" ? toolInput.command : "";
148
+ emit({ decision: "block", reason: buildDestructiveBashReason(cmd) });
149
+ return;
150
+ }
151
+ // mutating-file
152
+ const sessionDir = resolveSessionDir();
153
+ const state = loadState(sessionDir);
154
+ const filePath = extractFilePath(toolInput);
155
+ const factsFlagged = toolInput._gateguard_facts_presented === true;
156
+ const alreadyCleared = filePath !== "" && filePath in state.cleared_files;
157
+ if (!factsFlagged && !alreadyCleared) {
158
+ emit({ decision: "block", reason: buildMutatingFileReason(toolName, filePath) });
159
+ return;
160
+ }
161
+ if (factsFlagged && !alreadyCleared) {
162
+ if (isCapReached(state)) {
163
+ emit({ decision: "block", reason: buildCapReachedReason() });
164
+ return;
165
+ }
166
+ if (filePath !== "") {
167
+ saveState(sessionDir, markFileCleared(state, filePath));
168
+ }
169
+ }
170
+ emit({ decision: "allow" });
171
+ }
172
+ main();