mustard-claude 3.1.7 → 3.1.10

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 (31) hide show
  1. package/package.json +1 -1
  2. package/templates/commands/mustard/complete/SKILL.md +3 -0
  3. package/templates/commands/mustard/feature/SKILL.md +61 -1
  4. package/templates/commands/mustard/metrics/SKILL.md +33 -0
  5. package/templates/commands/mustard/resume/SKILL.md +6 -2
  6. package/templates/commands/mustard/review/SKILL.md +113 -102
  7. package/templates/hooks/__tests__/integration.test.js +316 -0
  8. package/templates/hooks/context-budget.js +142 -14
  9. package/templates/hooks/pre-compact.js +34 -0
  10. package/templates/hooks/rtk-rewrite.js +4 -3
  11. package/templates/hooks/session-knowledge-inc.js +6 -0
  12. package/templates/hooks/spec-hygiene.js +113 -0
  13. package/templates/scripts/_metrics-write.js +27 -0
  14. package/templates/scripts/analyze-validation.js +98 -0
  15. package/templates/scripts/metrics-report.js +70 -0
  16. package/templates/settings.json +11 -0
  17. package/templates/.claude/commands/guards.md +0 -76
  18. package/templates/.claude/commands/notes.md +0 -22
  19. package/templates/.claude/commands/patterns.md +0 -173
  20. package/templates/.claude/commands/recipes.md +0 -91
  21. package/templates/.claude/commands/stack.md +0 -86
  22. package/templates/.claude/skills/templates-command-authoring/SKILL.md +0 -88
  23. package/templates/.claude/skills/templates-command-authoring/references/examples.md +0 -83
  24. package/templates/.claude/skills/templates-hook-protocol/SKILL.md +0 -73
  25. package/templates/.claude/skills/templates-hook-protocol/references/examples.md +0 -74
  26. package/templates/.claude/skills/templates-settings-wiring/SKILL.md +0 -75
  27. package/templates/.claude/skills/templates-settings-wiring/references/examples.md +0 -59
  28. package/templates/.claude/skills/templates-skill-authoring/SKILL.md +0 -97
  29. package/templates/.claude/skills/templates-skill-authoring/references/examples.md +0 -69
  30. package/templates/.claude/skills/templates-sync-detect/SKILL.md +0 -62
  31. package/templates/.claude/skills/templates-sync-detect/references/examples.md +0 -55
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mustard-claude",
3
- "version": "3.1.7",
3
+ "version": "3.1.10",
4
4
  "description": "Framework-agnostic CLI for Claude Code project setup",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,6 +32,8 @@ node .claude/scripts/verify-pipeline.js "$PROJECT_DIR"
32
32
 
33
33
  If ANY gate fails: do NOT mark complete → report what failed + suggest fix. If review wasn't run → run it now before completing.
34
34
 
35
+ Re-reviews always dispatch with `model: "sonnet"` (see `review/SKILL.md § Model Selection`).
36
+
35
37
  #### Surface Accumulated Concerns
36
38
 
37
39
  Before finalizing, scan the active spec for any `## Concerns` section written during EXECUTE:
@@ -54,6 +56,7 @@ See `.claude/pipeline-config.md` Escalation Statuses for concern classification
54
56
  - Mark all remaining `[ ]` as `[x]`
55
57
  4. **Entity Registry — update if needed:**
56
58
  - `node .claude/scripts/sync-registry.js`
59
+ - **Schema-aware refresh (conditional):** If the spec's `## Files` section touched any file matching `*.schema.ts`, `*.entity.ts`, `*.prisma`, `*DbContext*.cs`, or `schema.rs`, run `rtk node .claude/scripts/sync-registry.js` to refresh `entity-registry.json`. If sync-registry fails (non-zero exit or script missing), log a warning and continue with close — this step is non-blocking.
57
60
  5. **Move spec** from `.claude/spec/active/` to `.claude/spec/completed/`
58
61
  6. **Pipeline State — cleanup:**
59
62
  - Extract `spec-name` from the spec directory (e.g. `2026-02-26-linked-services-card`)
@@ -104,6 +104,12 @@ After ANALYZE completes, if the analysis required heavy exploration (>8 file rea
104
104
  - Suggest to user: _"Analysis complete. Context is heavy — consider `/compact` before we proceed to implementation, then `/resume`."_
105
105
  - This is advisory only — proceed immediately if user declines or ignores.
106
106
 
107
+ ### End of ANALYZE — Validation
108
+
109
+ Run: `rtk node .claude/scripts/analyze-validation.js --spec .claude/spec/active/{specName}/spec.md`
110
+ If output `ok: false`, append each `issues[]` entry to the spec under `## Concerns` (non-blocking).
111
+ Continue to PLAN regardless.
112
+
107
113
  ### PLAN Phase
108
114
 
109
115
  #### Full Scope
@@ -161,6 +167,58 @@ Rules:
161
167
  - Be specific: prefer exact files over broad directories when the change is known
162
168
  - Out-of-boundary edits during EXECUTE will surface a `[BOUNDARY WARNING]` from guard-verify — treat as a signal to re-evaluate, not an error to suppress
163
169
 
170
+ ### Pre-EXECUTE Existence Gate (Full scope only)
171
+
172
+ **Skip conditions**: Light scope OR `## Files` section lists more than 8 files (cost-benefit inverts — Haiku 10-tool-use cap will not cover).
173
+
174
+ Before dispatching implementation agents, run 1 Haiku explorer to verify the work is still needed.
175
+
176
+ **Pre-check (free, zero LLM tokens)**: Before dispatching Haiku, run:
177
+
178
+ ```bash
179
+ rtk git diff --stat HEAD -- <files listed in `## Files` of spec>
180
+ ```
181
+
182
+ Skip rules based on pre-check output:
183
+ - **Empty output** (no changes) → skip gate entirely, proceed to EXECUTE normally (nothing to verify)
184
+ - **<10 total insertions/deletions** → skip gate entirely, proceed to EXECUTE normally (trivial changes, verification not worth the overhead)
185
+ - **≥10 insertions/deletions** → proceed with Haiku dispatch below
186
+
187
+ **Dispatch:**
188
+
189
+ ```javascript
190
+ Task({
191
+ subagent_type: "Explore",
192
+ model: "haiku",
193
+ description: "Pre-EXECUTE existence check",
194
+ prompt: `# EXISTENCE CHECK
195
+ Read .claude/spec/active/{specName}/spec.md sections: "## Files" and "## Checklist".
196
+
197
+ For EACH checklist task (task-level, NOT file-level):
198
+ 1. Extract 1-3 concrete identifiers from the task text — function names, component names, file path fragments, string literals.
199
+ Example: task "Add LogoutButton component with handleLogout handler" → identifiers: ["LogoutButton", "handleLogout"].
200
+ 2. Identify target files for the task from "## Files" (match by extension, name hint, or task context).
201
+ 3. Grep each target file for the identifiers.
202
+ 4. Verdict for this task:
203
+ - ALL target files contain a MAJORITY of identifiers → all_present=yes
204
+ - SOME do, SOME do not → all_present=partial
205
+ - NONE do → all_present=no
206
+
207
+ Return a markdown table:
208
+ | task | target_files | all_present | evidence |
209
+ |------|--------------|-------------|----------|
210
+ | <task text> | <comma-sep files> | yes/partial/no | <identifier:line or "none"> |
211
+
212
+ Return ≤20 lines total. Self-cap: ≤10 tool uses (the tool-use budget is the true limit, not the task count).`
213
+ })
214
+ ```
215
+
216
+ **Decision after return (orchestrator inspects the returned table):**
217
+
218
+ - **All tasks `all_present=no`** → Gate is transparent. Proceed to EXECUTE normally.
219
+ - **Mixed** (any combination that is NOT all-no AND NOT all-yes — includes all-partial, yes+no, partial+no, yes+partial, yes+partial+no) → Edit the spec: mark `[x]` on tasks where `all_present=yes`. Leave `[ ]` on `partial` and `no` (both require re-dispatch). Re-dispatch EXECUTE only for tasks still `[ ]`. Keep the original scope (Light/Full). Do NOT invent a new "PARTIAL" state.
220
+ - **All tasks `all_present=yes`** → **MANDATORY user surface** via `AskUserQuestion`: _"Pre-EXECUTE Existence Gate detected all N tasks already implemented. Evidence: {inline table}. Choose: (a) Close as already-implemented, (b) Force EXECUTE anyway (the gate may be wrong), (c) Abort pipeline."_ Never silently skip EXECUTE.
221
+
164
222
  ### EXECUTE Phase (Light scope — same session)
165
223
 
166
224
  When user chooses "Approve and implement now":
@@ -188,7 +246,9 @@ After each agent returns, check the return value for an escalation status before
188
246
 
189
247
  If two or more agents in the same wave return `CONCERN`, surface all concerns together before starting the next wave. See `.claude/pipeline-config.md` Escalation Statuses and Diagnostic Failure Routing for the full status table.
190
248
 
191
- 9. **REVIEW** — dispatch review agent for each affected subproject (reads guards + relevant skills, runs 7-category checklist: SOLID, Design System, Patterns, i18n, Integration, Build, Elegance). REJECTED → fix + re-review (max 2 loops)
249
+ 9. **REVIEW** — dispatch review agent for each affected subproject (reads guards + relevant skills, runs 7-category checklist: SOLID, Design System, Patterns, i18n, Integration, Build, Elegance). REJECTED → fix + re-review (max 2 loops).
250
+
251
+ Re-reviews always dispatch with `model: "sonnet"` (see `review/SKILL.md § Model Selection`).
192
252
  10. All passed + APPROVED → CLOSE flow inline (sync registry, move spec, cleanup state)
193
253
  11. Failed → max 2 retries, then STOP + report
194
254
 
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: mustard:metrics
3
+ description: Show enforcement metrics report — hook hit rates, budget distributions, gate activity. Metrics are recorded automatically; just run this to see them.
4
+ ---
5
+
6
+ # /mustard:metrics - Show Metrics Report
7
+
8
+ ## Trigger
9
+ `/mustard:metrics [--since <ISO date>] [--event <type>]`
10
+
11
+ ## What it does
12
+ Runs `.claude/scripts/metrics-report.js` and shows the aggregated report.
13
+
14
+ Metrics are recorded **automatically** by enforcement hooks on every Task dispatch — no activation needed. Just run this command whenever you want to see the current state.
15
+
16
+ ## Action
17
+ 1. Run `rtk node .claude/scripts/metrics-report.js $ARGS` (pass through any flags)
18
+ 2. Display output verbatim
19
+
20
+ ## Optional flags
21
+ - `--since <ISO date>` — filter events after this date
22
+ - `--event <type>` — filter to one event type (e.g. `budget-check`)
23
+
24
+ ## Examples
25
+ - `/mustard:metrics` — full report since beginning
26
+ - `/mustard:metrics --since 2026-04-09` — only recent events
27
+ - `/mustard:metrics --event budget-check` — only budget-check events
28
+
29
+ ## Notes
30
+ - Metrics live in `.claude/.metrics/*.jsonl` (gitignored, runtime state)
31
+ - Logs auto-rotate at 10MB
32
+ - To reset: delete files in `.claude/.metrics/` manually
33
+ - Advanced: override mode via `CONTEXT_BUDGET_MODE` env var (`strict`|`warn`|`observe`). Default is `strict`.
@@ -69,8 +69,8 @@ Before the normal detect-and-confirm flow, scan the newest pipeline state for a
69
69
  ## Context
70
70
  - Branch: {from git}
71
71
  - Files changed: {run `node .claude/scripts/diff-context.js`}
72
- - Last agent: {from `.claude/.agent-memory/_index.json` last entry}
73
- - Last action: {summary from last agent memory entry}
72
+ - Last agent: {Read `.claude/.agent-memory/_index.json` and pick the last entry's `agent_type`. If the file or `.agent-memory/` directory is missing, print literal `(none)` — do NOT probe with `ls`/`grep`, it surfaces noisy exit codes}
73
+ - Last action: {from the same last entry's `summary` field. If missing, print literal `(no prior memory)`}
74
74
  - Decisions: {decisions[] from pipeline state, if any}
75
75
 
76
76
  ## Next Action
@@ -97,6 +97,10 @@ Run `node .claude/scripts/diff-context.js` to capture the current git state. Inc
97
97
  **CRITICAL: Main context IS the Pipeline Runner. NEVER delegate to intermediate Task agent.**
98
98
 
99
99
  12. **Match recipe by name only:** Grep `{subproject}/.claude/commands/recipes.md` for recipe title matching the task type — do NOT read the full recipes file. Extract only: recipe number, pattern refs, reference modules
100
+ 12b. **Pre-EXECUTE Existence Gate**: Same gate as `feature/SKILL.md § Pre-EXECUTE Existence Gate`. Invoke identically (Full scope only, `## Files` ≤ 8). On retry/resume, the gate naturally handles idempotence: tasks already `[x]` from a prior run are treated as Mixed — the Haiku confirms they stay done and the orchestrator only re-dispatches what remains `[ ]`.
101
+
102
+ **Pre-check (same as `feature/SKILL.md § Pre-EXECUTE Existence Gate`):** Before dispatching Haiku, run `rtk git diff --stat HEAD -- <files listed in spec's ## Files>`. Skip gate entirely if output is empty (no changes) or total insertions/deletions <10. Only proceed with Haiku dispatch if ≥10 lines changed.
103
+
100
104
  13. **Plan waves:** `Depends on: none` → Wave 1; dependencies → later. DB+Backend parallel. Frontend after Backend UNLESS all parallel override conditions met (see `.claude/pipeline-config.md` Parallel Rules). Review agents: ALWAYS dispatch in single parallel message. Skip completed tasks.
101
105
  14. **Build agent prompts using template** (`.claude/commands/mustard/templates/agent-prompt/SKILL.md`):
102
106
  - Read template once, then fill placeholders per agent using `.claude/pipeline-config.md` data:
@@ -1,102 +1,113 @@
1
- # /review - Pull Request Review
2
-
3
- > Review a PR using Claude's native code-review skill. Auto-detects current branch PR or accepts PR number/URL.
4
-
5
- ## Trigger
6
-
7
- `/review [pr-number-or-url]`
8
-
9
- ## Configuration
10
-
11
- Reads `mustard.json` from the **project root** for `git.provider`.
12
-
13
- | Provider | CLI | PR detection |
14
- |----------|-----|--------------|
15
- | `github` | `gh` | `gh pr view --json number,url` |
16
- | `gitlab` | `glab` | `glab mr view` |
17
-
18
- ## Behavior
19
-
20
- - **ZERO confirmations** — detect PR, invoke review, done.
21
- - **ZERO questions** — auto-detect if no argument provided.
22
-
23
- ---
24
-
25
- ## Step 1 — Resolve PR
26
-
27
- ### If argument provided
28
-
29
- - Numeric → treat as PR number
30
- - URL → use directly
31
-
32
- ### If no argument
33
-
34
- ```bash
35
- gh pr view --json number,url,title,headRefName 2>/dev/null
36
- ```
37
-
38
- If no PR found for current branch → error:
39
- > No open PR found for current branch. Run `/git merge` first to create one.
40
-
41
- ---
42
-
43
- ## Step 2 — Invoke Code Review
44
-
45
- Use the Skill tool to invoke Claude's native code-review:
46
-
47
- ```
48
- Skill({
49
- skill: "code-review",
50
- args: "<pr-number-or-url>"
51
- })
52
- ```
53
-
54
- If the native `code-review` skill is not available, fall back to local review:
55
-
56
- ```
57
- Task({
58
- subagent_type: "general-purpose",
59
- model: "opus",
60
- description: "Review: PR <number>",
61
- prompt: "Review the changes in the current branch against $PARENT. Checklist: SOLID, Security, Performance, Patterns, Integration."
62
- })
63
- ```
64
-
65
- ---
66
-
67
- ## Step 3 — Report
68
-
69
- Present the review results as returned by the skill/agent.
70
-
71
- ---
72
-
73
- ## Provider Support
74
-
75
- | Provider | Auto-detect | Manual URL |
76
- |----------|-------------|------------|
77
- | GitHub | `gh pr view` | yes |
78
- | GitLab | `glab mr view` | yes |
79
- | Bitbucket | no | yes |
80
-
81
- ---
82
-
83
- ## Rules
84
-
85
- - NEVER ask for confirmation before invoking the review
86
- - NEVER attempt both Skill and Task — try Skill first, fall back only if unavailable
87
- - ALWAYS use the PR number or URL directly do NOT pass branch names to the skill
88
- - If provider CLI is missing, instruct the user to install it; do NOT improvise
89
-
90
- ## Examples
91
-
92
- ```bash
93
- /review # Auto-detect PR for current branch
94
- /review 42 # Review PR #42
95
- /review https://github.com/org/repo/pull/42
96
- ```
97
-
98
- ## Performance Budget
99
-
100
- - **Max Bash calls**: 1 (PR detection)
101
- - **Max Skill/Task calls**: 1
102
- - **Max API calls total**: ≤ 4
1
+ # /review - Pull Request Review
2
+
3
+ > Review a PR using Claude's native code-review skill. Auto-detects current branch PR or accepts PR number/URL.
4
+
5
+ ## Trigger
6
+
7
+ `/review [pr-number-or-url]`
8
+
9
+ ## Configuration
10
+
11
+ Reads `mustard.json` from the **project root** for `git.provider`.
12
+
13
+ | Provider | CLI | PR detection |
14
+ |----------|-----|--------------|
15
+ | `github` | `gh` | `gh pr view --json number,url` |
16
+ | `gitlab` | `glab` | `glab mr view` |
17
+
18
+ ## Behavior
19
+
20
+ - **ZERO confirmations** — detect PR, invoke review, done.
21
+ - **ZERO questions** — auto-detect if no argument provided.
22
+
23
+ ---
24
+
25
+ ## Step 1 — Resolve PR
26
+
27
+ ### If argument provided
28
+
29
+ - Numeric → treat as PR number
30
+ - URL → use directly
31
+
32
+ ### If no argument
33
+
34
+ ```bash
35
+ gh pr view --json number,url,title,headRefName 2>/dev/null
36
+ ```
37
+
38
+ If no PR found for current branch → error:
39
+ > No open PR found for current branch. Run `/git merge` first to create one.
40
+
41
+ ---
42
+
43
+ ## Step 2 — Invoke Code Review
44
+
45
+ Use the Skill tool to invoke Claude's native code-review:
46
+
47
+ ```
48
+ Skill({
49
+ skill: "code-review",
50
+ args: "<pr-number-or-url>"
51
+ })
52
+ ```
53
+
54
+ If the native `code-review` skill is not available, fall back to local review:
55
+
56
+ ```
57
+ Task({
58
+ subagent_type: "general-purpose",
59
+ model: "opus",
60
+ description: "Review: PR <number>",
61
+ prompt: "Review the changes in the current branch against $PARENT. Checklist: SOLID, Security, Performance, Patterns, Integration."
62
+ })
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Step 3 — Report
68
+
69
+ Present the review results as returned by the skill/agent.
70
+
71
+ ---
72
+
73
+ ## Provider Support
74
+
75
+ | Provider | Auto-detect | Manual URL |
76
+ |----------|-------------|------------|
77
+ | GitHub | `gh pr view` | yes |
78
+ | GitLab | `glab mr view` | yes |
79
+ | Bitbucket | no | yes |
80
+
81
+ ---
82
+
83
+ ## Model Selection
84
+
85
+ **Initial reviews**: use default model per `pipeline-config.md § Models` (sonnet for most; opus for Full + new patterns; etc.).
86
+
87
+ **Re-reviews**: always dispatch with `model: "sonnet"`, regardless of the initial review's model.
88
+
89
+ **Rationale**:
90
+ - Re-reviews verify a targeted fix to already-reviewed code. Sonnet is capable enough even in complex codebases (see `pipeline-config.md` where Sonnet is default for audit, bugfix, and ≤5-file features).
91
+ - For Full + new-pattern features (initial review in Opus), this saves ~$5/re-review without introducing Haiku quality risk.
92
+ - Simpler than heuristic decision table: one rule, zero edge cases.
93
+
94
+ ## Rules
95
+
96
+ - NEVER ask for confirmation before invoking the review
97
+ - NEVER attempt both Skill and Task — try Skill first, fall back only if unavailable
98
+ - ALWAYS use the PR number or URL directly — do NOT pass branch names to the skill
99
+ - If provider CLI is missing, instruct the user to install it; do NOT improvise
100
+
101
+ ## Examples
102
+
103
+ ```bash
104
+ /review # Auto-detect PR for current branch
105
+ /review 42 # Review PR #42
106
+ /review https://github.com/org/repo/pull/42
107
+ ```
108
+
109
+ ## Performance Budget
110
+
111
+ - **Max Bash calls**: 1 (PR detection)
112
+ - **Max Skill/Task calls**: 1
113
+ - **Max API calls total**: ≤ 4