@wazir-dev/cli 1.1.0 → 1.2.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/CHANGELOG.md +73 -4
- package/README.md +6 -6
- package/docs/concepts/architecture.md +1 -1
- package/docs/concepts/roles-and-workflows.md +2 -0
- package/docs/concepts/why-wazir.md +59 -0
- package/docs/decisions/2026-03-19-deferred-items.md +564 -0
- package/docs/decisions/2026-03-19-enhancement-decisions.md +300 -0
- package/docs/readmes/INDEX.md +21 -5
- package/docs/readmes/features/expertise/README.md +2 -2
- package/docs/readmes/features/exports/README.md +2 -2
- package/docs/readmes/features/schemas/README.md +3 -0
- package/docs/readmes/features/skills/README.md +17 -0
- package/docs/readmes/features/skills/clarifier.md +5 -0
- package/docs/readmes/features/skills/claude-cli.md +5 -0
- package/docs/readmes/features/skills/codex-cli.md +5 -0
- package/docs/readmes/features/skills/dispatching-parallel-agents.md +5 -0
- package/docs/readmes/features/skills/executing-plans.md +5 -0
- package/docs/readmes/features/skills/executor.md +5 -0
- package/docs/readmes/features/skills/finishing-a-development-branch.md +5 -0
- package/docs/readmes/features/skills/gemini-cli.md +5 -0
- package/docs/readmes/features/skills/humanize.md +5 -0
- package/docs/readmes/features/skills/init-pipeline.md +5 -0
- package/docs/readmes/features/skills/receiving-code-review.md +5 -0
- package/docs/readmes/features/skills/requesting-code-review.md +5 -0
- package/docs/readmes/features/skills/reviewer.md +5 -0
- package/docs/readmes/features/skills/subagent-driven-development.md +5 -0
- package/docs/readmes/features/skills/using-git-worktrees.md +5 -0
- package/docs/readmes/features/skills/wazir.md +5 -0
- package/docs/readmes/features/skills/writing-skills.md +5 -0
- package/docs/readmes/features/workflows/prepare-next.md +1 -1
- package/docs/reference/configuration-reference.md +47 -6
- package/docs/reference/launch-checklist.md +4 -4
- package/docs/reference/review-loop-pattern.md +117 -8
- package/docs/reference/roles-reference.md +1 -0
- package/docs/reference/skill-tiers.md +147 -0
- package/docs/reference/tooling-cli.md +3 -1
- package/docs/truth-claims.yaml +12 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +97 -1
- package/exports/hosts/claude/.claude/settings.json +9 -0
- package/exports/hosts/claude/CLAUDE.md +1 -1
- package/exports/hosts/claude/export.manifest.json +4 -2
- package/exports/hosts/claude/host-package.json +3 -1
- package/exports/hosts/codex/AGENTS.md +1 -1
- package/exports/hosts/codex/export.manifest.json +4 -2
- package/exports/hosts/codex/host-package.json +3 -1
- package/exports/hosts/cursor/.cursor/hooks.json +4 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +1 -1
- package/exports/hosts/cursor/export.manifest.json +4 -2
- package/exports/hosts/cursor/host-package.json +3 -1
- package/exports/hosts/gemini/GEMINI.md +1 -1
- package/exports/hosts/gemini/export.manifest.json +4 -2
- package/exports/hosts/gemini/host-package.json +3 -1
- package/hooks/context-mode-router +191 -0
- package/hooks/definitions/context_mode_router.yaml +19 -0
- package/hooks/hooks.json +31 -6
- package/hooks/protected-path-write-guard +8 -0
- package/hooks/routing-matrix.json +45 -0
- package/hooks/session-start +62 -1
- package/llms-full.txt +905 -132
- package/package.json +2 -3
- package/schemas/hook.schema.json +2 -1
- package/schemas/phase-report.schema.json +80 -0
- package/schemas/usage.schema.json +25 -1
- package/schemas/wazir-manifest.schema.json +19 -0
- package/skills/brainstorming/SKILL.md +18 -155
- package/skills/clarifier/SKILL.md +122 -98
- package/skills/claude-cli/SKILL.md +320 -0
- package/skills/codex-cli/SKILL.md +260 -0
- package/skills/debugging/SKILL.md +13 -0
- package/skills/design/SKILL.md +13 -0
- package/skills/dispatching-parallel-agents/SKILL.md +13 -0
- package/skills/executing-plans/SKILL.md +13 -0
- package/skills/executor/SKILL.md +72 -19
- package/skills/finishing-a-development-branch/SKILL.md +13 -0
- package/skills/gemini-cli/SKILL.md +260 -0
- package/skills/humanize/SKILL.md +13 -0
- package/skills/init-pipeline/SKILL.md +73 -164
- package/skills/prepare-next/SKILL.md +81 -10
- package/skills/receiving-code-review/SKILL.md +13 -0
- package/skills/requesting-code-review/SKILL.md +13 -0
- package/skills/reviewer/SKILL.md +287 -15
- package/skills/run-audit/SKILL.md +13 -0
- package/skills/scan-project/SKILL.md +13 -0
- package/skills/self-audit/SKILL.md +197 -16
- package/skills/subagent-driven-development/SKILL.md +13 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +2 -0
- package/skills/subagent-driven-development/implementer-prompt.md +8 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +7 -0
- package/skills/tdd/SKILL.md +13 -0
- package/skills/using-git-worktrees/SKILL.md +13 -0
- package/skills/using-skills/SKILL.md +13 -0
- package/skills/verification/SKILL.md +13 -0
- package/skills/wazir/SKILL.md +194 -377
- package/skills/writing-plans/SKILL.md +14 -1
- package/skills/writing-skills/SKILL.md +13 -0
- package/templates/artifacts/implementation-plan.md +3 -0
- package/templates/artifacts/tasks-template.md +133 -0
- package/templates/examples/phase-report.example.json +48 -0
- package/tooling/src/adapters/composition-engine.js +256 -0
- package/tooling/src/adapters/model-router.js +84 -0
- package/tooling/src/capture/command.js +24 -1
- package/tooling/src/capture/run-config.js +3 -1
- package/tooling/src/capture/store.js +24 -0
- package/tooling/src/capture/usage.js +106 -0
- package/tooling/src/checks/ac-matrix.js +256 -0
- package/tooling/src/checks/command-registry.js +12 -0
- package/tooling/src/checks/docs-truth.js +1 -1
- package/tooling/src/checks/skills.js +111 -0
- package/tooling/src/cli.js +9 -0
- package/tooling/src/commands/stats.js +161 -0
- package/tooling/src/commands/validate.js +5 -1
- package/tooling/src/export/compiler.js +33 -37
- package/tooling/src/gating/agent.js +145 -0
- package/tooling/src/guards/phase-prerequisite-guard.js +127 -0
- package/tooling/src/hooks/routing-logic.js +69 -0
- package/tooling/src/init/auto-detect.js +260 -0
- package/tooling/src/init/command.js +95 -135
- package/tooling/src/input/scanner.js +46 -0
- package/tooling/src/reports/command.js +103 -0
- package/tooling/src/reports/phase-report.js +323 -0
- package/tooling/src/state/command.js +160 -0
- package/tooling/src/state/db.js +287 -0
- package/tooling/src/status/command.js +53 -1
- package/wazir.manifest.yaml +26 -14
|
@@ -5,9 +5,22 @@ description: Run the clarification pipeline — research, clarify scope, brainst
|
|
|
5
5
|
|
|
6
6
|
# Clarifier
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Command Routing
|
|
9
|
+
Follow the Canonical Command Matrix in `hooks/routing-matrix.json`.
|
|
10
|
+
- Large commands (test runners, builds, diffs, dependency trees, linting) → context-mode tools
|
|
11
|
+
- Small commands (git status, ls, pwd, wazir CLI) → native Bash
|
|
12
|
+
- If context-mode unavailable, fall back to native Bash with warning
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
## Codebase Exploration
|
|
15
|
+
1. Query `wazir index search-symbols <query>` first
|
|
16
|
+
2. Use `wazir recall file <path> --tier L1` for targeted reads
|
|
17
|
+
3. Fall back to direct file reads ONLY for files identified by index queries
|
|
18
|
+
4. Maximum 10 direct file reads without a justifying index query
|
|
19
|
+
5. If no index exists: `wazir index build && wazir index summarize --tier all`
|
|
20
|
+
|
|
21
|
+
Run the Clarifier phase — everything from reading input to having an approved execution plan.
|
|
22
|
+
|
|
23
|
+
**Pacing rule:** This skill has mandatory user checkpoints between sub-workflows. Do NOT skip checkpoints. Do NOT combine sub-workflows. Complete each fully, present output, and wait for explicit user approval before advancing.
|
|
11
24
|
|
|
12
25
|
Review loops follow the pattern in `docs/reference/review-loop-pattern.md`. All reviewer invocations use explicit `--mode`.
|
|
13
26
|
|
|
@@ -17,8 +30,10 @@ Review loops follow the pattern in `docs/reference/review-loop-pattern.md`. All
|
|
|
17
30
|
|
|
18
31
|
1. Check `.wazir/state/config.json` exists. If not, run `wazir init` first.
|
|
19
32
|
2. Check `.wazir/input/briefing.md` exists. If not, ask the user what they want to build and save it there.
|
|
20
|
-
3.
|
|
21
|
-
4.
|
|
33
|
+
3. Scan `input/` (project-level) and `.wazir/input/` (state-level) for additional input files. Present what's found.
|
|
34
|
+
4. Read config for `default_depth` and `multi_tool` settings.
|
|
35
|
+
5. **Load accepted learnings:** Glob `memory/learnings/accepted/*.md`. For each accepted learning, read scope tags. Inject learnings whose scope matches the current run's intent/stack into context. Limit: top 10 by confidence, most recent first. This is how prior run insights improve future runs.
|
|
36
|
+
6. Create a run directory if one doesn't exist:
|
|
22
37
|
```bash
|
|
23
38
|
mkdir -p .wazir/runs/run-YYYYMMDD-HHMMSS/{sources,tasks,artifacts,reviews,clarified}
|
|
24
39
|
ln -sfn run-YYYYMMDD-HHMMSS .wazir/runs/latest
|
|
@@ -26,30 +41,39 @@ Review loops follow the pattern in `docs/reference/review-loop-pattern.md`. All
|
|
|
26
41
|
|
|
27
42
|
---
|
|
28
43
|
|
|
29
|
-
##
|
|
44
|
+
## Context-Mode Usage
|
|
45
|
+
|
|
46
|
+
Read `context_mode` from `.wazir/state/config.json`:
|
|
47
|
+
|
|
48
|
+
- **If `context_mode.enabled: true`:** Use `fetch_and_index` for URL fetching, `search` for follow-up queries on indexed content. Use `execute` or `execute_file` for large outputs instead of Bash.
|
|
49
|
+
- **If `context_mode.enabled: false`:** Fall back to `WebFetch` for URLs and `Bash` for commands.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Sub-Workflow 1: Research (discover workflow)
|
|
30
54
|
|
|
31
55
|
Delegate to the discover workflow (`workflows/discover.md`):
|
|
32
56
|
|
|
33
|
-
1.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
1. **Keyword extraction:** Read the briefing and extract concepts/terms that are vague, reference external standards, or use unfamiliar terminology.
|
|
58
|
+
- **When to research:** concept references an external standard by name, uses a tool/library not seen in the codebase, or is ambiguous enough that two agents could interpret it differently.
|
|
59
|
+
- **When NOT to research:** concept is fully defined in the input, or it's a well-known programming concept.
|
|
60
|
+
2. **Fetch sources:** For each concept needing research:
|
|
61
|
+
- Use `fetch_and_index` (if context-mode available) or `WebFetch` to fetch the source.
|
|
62
|
+
- Save fetched content to `.wazir/runs/latest/sources/`.
|
|
63
|
+
- Track each fetch in `sources/manifest.json`.
|
|
64
|
+
3. **Error handling:** 404/unreachable → log failure, continue. Research is best-effort.
|
|
65
|
+
4. The **researcher role** produces the research artifact.
|
|
66
|
+
5. The **reviewer role** runs the research-review loop with `--mode research-review`.
|
|
67
|
+
6. Loop runs for `pass_counts[depth]` passes.
|
|
41
68
|
|
|
42
69
|
Save result to `.wazir/runs/latest/clarified/research-brief.md`.
|
|
43
70
|
|
|
44
|
-
### Checkpoint
|
|
45
|
-
|
|
46
|
-
Present the research brief to the user:
|
|
71
|
+
### Checkpoint: Research Review
|
|
47
72
|
|
|
48
73
|
> **Research complete. Here's what I found:**
|
|
49
74
|
>
|
|
50
|
-
> [Summary of
|
|
75
|
+
> [Summary of codebase state, relevant architecture, external context]
|
|
51
76
|
>
|
|
52
|
-
> **Does this match your understanding? Anything to add or correct?**
|
|
53
77
|
> 1. **Looks good, continue** (Recommended)
|
|
54
78
|
> 2. **Missing context** — let me add more information
|
|
55
79
|
> 3. **Wrong direction** — let me clarify the intent
|
|
@@ -58,162 +82,162 @@ Present the research brief to the user:
|
|
|
58
82
|
|
|
59
83
|
---
|
|
60
84
|
|
|
61
|
-
##
|
|
85
|
+
## Sub-Workflow 2: Clarify (clarify workflow)
|
|
86
|
+
|
|
87
|
+
### Input Preservation (before producing clarification)
|
|
88
|
+
|
|
89
|
+
1. Glob `.wazir/input/tasks/*.md`. If files exist:
|
|
90
|
+
- Adopt those specs as the starting point — copy content verbatim into the clarification's item descriptions.
|
|
91
|
+
- Enhance with codebase scan + research findings. **Never remove detail — only add.**
|
|
92
|
+
- Every acceptance criterion from input must appear verbatim.
|
|
93
|
+
- Every API endpoint, color hex code, and UI dimension from input must appear in the relevant item section.
|
|
94
|
+
2. If `.wazir/input/tasks/` is empty or missing, synthesize from `briefing.md` alone.
|
|
95
|
+
|
|
96
|
+
### Clarification Production
|
|
62
97
|
|
|
63
98
|
Read the briefing, research brief, and codebase context. Produce:
|
|
64
99
|
|
|
65
|
-
- **What** we're building — concrete deliverables
|
|
100
|
+
- **What** we're building — concrete deliverables
|
|
66
101
|
- **Why** — the motivation and business value
|
|
67
102
|
- **Constraints** — technical, timeline, dependencies
|
|
68
|
-
- **Assumptions** — what we're taking as given
|
|
103
|
+
- **Assumptions** — what we're taking as given
|
|
69
104
|
- **Scope boundaries** — what's IN and what's explicitly OUT
|
|
70
|
-
- **Unresolved questions** — anything ambiguous
|
|
105
|
+
- **Unresolved questions** — anything ambiguous
|
|
71
106
|
|
|
72
107
|
Save to `.wazir/runs/latest/clarified/clarification.md`.
|
|
73
108
|
|
|
74
|
-
Invoke
|
|
109
|
+
Invoke `wz:reviewer --mode clarification-review`. Resolve findings before presenting to user.
|
|
75
110
|
|
|
76
|
-
### Checkpoint
|
|
77
|
-
|
|
78
|
-
Present the full clarification to the user:
|
|
111
|
+
### Checkpoint: Clarification Review
|
|
79
112
|
|
|
80
113
|
> **Here's the clarified scope:**
|
|
81
114
|
>
|
|
82
|
-
> [Full clarification
|
|
115
|
+
> [Full clarification]
|
|
83
116
|
>
|
|
84
|
-
> **
|
|
85
|
-
> 1. **Approved — continue to spec hardening**
|
|
117
|
+
> 1. **Approved — continue to spec hardening** (Recommended)
|
|
86
118
|
> 2. **Needs changes** — [user provides corrections]
|
|
87
119
|
> 3. **Missing important context** — [user adds information]
|
|
88
120
|
|
|
89
|
-
**Wait for user response
|
|
121
|
+
**Wait for user response.** Route feedback: plan corrections → `user-feedback.md`, new requirements → `briefing.md`.
|
|
90
122
|
|
|
91
123
|
---
|
|
92
124
|
|
|
93
|
-
##
|
|
125
|
+
## Sub-Workflow 3: Spec Harden (specify + spec-challenge workflows)
|
|
94
126
|
|
|
95
127
|
Delegate to the specify workflow (`workflows/specify.md`):
|
|
96
128
|
|
|
97
|
-
1. The **specifier role** produces a measurable spec from
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(`workflows/spec-challenge.md`) with `--mode spec-challenge`.
|
|
101
|
-
3. The specifier resolves findings from each pass.
|
|
102
|
-
4. Loop runs for `pass_counts[depth]` passes.
|
|
129
|
+
1. The **specifier role** produces a measurable spec from clarification + research.
|
|
130
|
+
2. Invoke `wz:reviewer --mode spec-challenge`.
|
|
131
|
+
3. Loop runs for `pass_counts[depth]` passes.
|
|
103
132
|
|
|
104
133
|
Save result to `.wazir/runs/latest/clarified/spec-hardened.md`.
|
|
105
134
|
|
|
106
|
-
###
|
|
135
|
+
### Content-Author Detection
|
|
136
|
+
|
|
137
|
+
After spec hardening, scan the spec for content needs. Auto-enable the `author` workflow if the spec mentions any of:
|
|
138
|
+
- Database seeding, seed data, fixtures, sample records
|
|
139
|
+
- Sample content, placeholder text, demo data
|
|
140
|
+
- Test fixtures, mock API responses, test data files
|
|
141
|
+
- Translations, i18n strings, localization
|
|
142
|
+
- Copy (button labels, error messages, onboarding text)
|
|
143
|
+
- Documentation content, user guides, API docs
|
|
144
|
+
- Email templates, notification text
|
|
107
145
|
|
|
108
|
-
|
|
146
|
+
If detected, set `workflow_policy.author.enabled = true` in the run config and note:
|
|
147
|
+
> **Content needs detected.** The content-author workflow will run after design approval to produce: [list detected content types].
|
|
148
|
+
|
|
149
|
+
### Checkpoint: Hardened Spec Review
|
|
109
150
|
|
|
110
151
|
> **Spec hardened. Changes made:**
|
|
111
152
|
>
|
|
112
|
-
> [List of
|
|
153
|
+
> [List of gaps found and how they were tightened]
|
|
113
154
|
>
|
|
114
|
-
> **Review the hardened spec. Approve or adjust?**
|
|
115
155
|
> 1. **Approved — continue to brainstorming** (Recommended)
|
|
116
156
|
> 2. **Disagree with a change** — [user specifies]
|
|
117
157
|
> 3. **Found more gaps** — [user adds]
|
|
118
158
|
|
|
119
|
-
**Wait for user response
|
|
159
|
+
**Wait for user response.**
|
|
120
160
|
|
|
121
161
|
---
|
|
122
162
|
|
|
123
|
-
##
|
|
163
|
+
## Sub-Workflow 4: Brainstorm (design + design-review workflows)
|
|
124
164
|
|
|
125
|
-
Invoke the `brainstorming` skill (`wz:brainstorming`)
|
|
165
|
+
Invoke the `brainstorming` skill (`wz:brainstorming`):
|
|
126
166
|
|
|
127
|
-
This phase explores design approaches:
|
|
128
167
|
1. Propose 2-3 viable approaches with explicit trade-offs
|
|
129
168
|
2. For each approach: effort estimate, risk assessment, what it enables/prevents
|
|
130
169
|
3. Recommend one approach with rationale
|
|
131
170
|
|
|
132
|
-
|
|
133
|
-
**Agent Teams Structured Dialogue** mode:
|
|
134
|
-
|
|
135
|
-
1. Checks that `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` is enabled (falls back
|
|
136
|
-
to single-agent brainstorming if not)
|
|
137
|
-
2. Creates a team via `TeamCreate` (`wazir-brainstorm-<concept-slug>`)
|
|
138
|
-
3. Spawns three teammates via `Agent` with `team_name`:
|
|
139
|
-
- **Free Thinker** — proposes creative directions via `SendMessage`
|
|
140
|
-
- **Grounder** — challenges each direction with practical concerns via `SendMessage`
|
|
141
|
-
- **Synthesizer** — observes silently, writes the design document on convergence
|
|
142
|
-
4. You (the Arbiter) coordinate the dialogue, signal convergence, and clean up
|
|
143
|
-
with `TeamDelete`
|
|
144
|
-
|
|
145
|
-
See `skills/brainstorming/SKILL.md` "Team Mode: Agent Teams Structured Dialogue"
|
|
146
|
-
for full spawn prompts, convergence criteria, and constraints.
|
|
171
|
+
### Checkpoint: Design Approval
|
|
147
172
|
|
|
148
|
-
### Checkpoint 1B: Design Approval
|
|
149
|
-
|
|
150
|
-
> **Proposed design approaches:**
|
|
151
|
-
>
|
|
152
|
-
> [Approaches with trade-offs, recommendation]
|
|
153
|
-
>
|
|
154
173
|
> **Which approach should we implement?**
|
|
155
|
-
>
|
|
174
|
+
>
|
|
175
|
+
> 1. **Approach A** — [one-line summary] (Recommended)
|
|
156
176
|
> 2. **Approach B** — [one-line summary]
|
|
157
177
|
> 3. **Approach C** — [one-line summary]
|
|
158
178
|
> 4. **Modify an approach** — [user specifies changes]
|
|
159
179
|
|
|
160
|
-
**This is the most important checkpoint.
|
|
180
|
+
**Wait for user response.** This is the most important checkpoint.
|
|
161
181
|
|
|
162
182
|
Save approved design to `.wazir/runs/latest/clarified/design.md`.
|
|
163
183
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
After the user approves the design concept, invoke the design-review loop with `--mode design-review`. The **reviewer role** validates the design against the approved spec using the canonical design-review dimensions:
|
|
167
|
-
|
|
168
|
-
- Spec coverage
|
|
169
|
-
- Design-spec consistency
|
|
170
|
-
- Accessibility
|
|
171
|
-
- Visual consistency
|
|
172
|
-
- Exported-code fidelity
|
|
173
|
-
|
|
174
|
-
See `workflows/design-review.md` and `docs/reference/review-loop-pattern.md`. The designer resolves findings. Proceed to planning only after all design-review passes complete.
|
|
184
|
+
After approval: design-review loop with `--mode design-review` (5 canonical dimensions: spec coverage, design-spec consistency, accessibility, visual consistency, exported-code fidelity).
|
|
175
185
|
|
|
176
186
|
---
|
|
177
187
|
|
|
178
|
-
##
|
|
188
|
+
## Sub-Workflow 5: Plan (plan + plan-review workflows)
|
|
179
189
|
|
|
180
190
|
Delegate to `wz:writing-plans`:
|
|
181
191
|
|
|
182
|
-
1.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
(`workflows/plan-review.md`) with `--mode plan-review`.
|
|
186
|
-
3. The planner resolves findings from each pass.
|
|
187
|
-
4. Loop runs for `pass_counts[depth]` passes.
|
|
192
|
+
1. Planner produces a SINGLE execution plan at `.wazir/runs/latest/clarified/execution-plan.md` in spec-kit format.
|
|
193
|
+
2. **Gap analysis exit gate:** Compare original input against plan. Invoke `wz:reviewer --mode plan-review`.
|
|
194
|
+
3. Loop until clean or cap reached.
|
|
188
195
|
|
|
189
|
-
### Checkpoint
|
|
196
|
+
### Checkpoint: Plan Review
|
|
190
197
|
|
|
191
198
|
> **Implementation plan: [N] tasks**
|
|
192
199
|
>
|
|
193
200
|
> | # | Task | Complexity | Dependencies | Description |
|
|
194
201
|
> |---|------|-----------|--------------|-------------|
|
|
195
|
-
> | 1 | ... | S | none | ... |
|
|
196
|
-
> | 2 | ... | M | task-1 | ... |
|
|
197
202
|
>
|
|
198
|
-
> **Review the plan. Approve or adjust?**
|
|
199
203
|
> 1. **Approved — ready for execution** (Recommended)
|
|
200
|
-
> 2. **Reorder or split tasks**
|
|
201
|
-
> 3. **Missing tasks**
|
|
202
|
-
> 4. **Too granular / too coarse**
|
|
204
|
+
> 2. **Reorder or split tasks**
|
|
205
|
+
> 3. **Missing tasks**
|
|
206
|
+
> 4. **Too granular / too coarse**
|
|
207
|
+
|
|
208
|
+
**Wait for user response.**
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### Scope Coverage Gate (Hard Gate)
|
|
213
|
+
|
|
214
|
+
Before presenting the plan to the user, verify ALL input items are covered:
|
|
215
|
+
|
|
216
|
+
1. Count distinct items/deliverables in the input briefing (`.wazir/input/briefing.md` + any `input/*.md` files)
|
|
217
|
+
2. Count tasks in the execution plan
|
|
218
|
+
3. **If `tasks_in_plan < items_in_input`:** STOP and present:
|
|
219
|
+
|
|
220
|
+
> **Scope reduction detected.** The input contains [N] items but the plan only covers [M].
|
|
221
|
+
>
|
|
222
|
+
> Missing items: [list]
|
|
223
|
+
>
|
|
224
|
+
> 1. **Add missing items to the plan** (Required)
|
|
225
|
+
> 2. **User explicitly approves reduced scope** — only if user confirms
|
|
226
|
+
|
|
227
|
+
**The clarifier MUST NOT autonomously drop items into "future tiers", "deferred", or "out of scope" without explicit user approval. This is a hard rule.**
|
|
203
228
|
|
|
204
|
-
|
|
229
|
+
Invariant: `items_in_plan >= items_in_input` unless user explicitly approves reduction.
|
|
205
230
|
|
|
206
231
|
---
|
|
207
232
|
|
|
208
233
|
## Done
|
|
209
234
|
|
|
210
|
-
When the plan is approved
|
|
235
|
+
When the plan is approved:
|
|
211
236
|
|
|
212
|
-
> **
|
|
237
|
+
> **Clarifier phase complete.**
|
|
213
238
|
>
|
|
214
239
|
> - Spec: `.wazir/runs/latest/clarified/spec-hardened.md`
|
|
215
240
|
> - Design: `.wazir/runs/latest/clarified/design.md`
|
|
216
|
-
> - Tasks: [count] tasks in `.wazir/runs/latest/tasks/`
|
|
217
241
|
> - Plan: `.wazir/runs/latest/clarified/execution-plan.md`
|
|
218
242
|
>
|
|
219
|
-
> **Next:** Run `/
|
|
243
|
+
> **Next:** Run `/executor` to implement the plan.
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wz:claude-cli
|
|
3
|
+
description: How to use Claude Code CLI programmatically for reviews, automation, and non-interactive operations within Wazir pipelines.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Claude Code CLI Integration
|
|
7
|
+
|
|
8
|
+
## Command Routing
|
|
9
|
+
Follow the Canonical Command Matrix in `hooks/routing-matrix.json`.
|
|
10
|
+
- Large commands (test runners, builds, diffs, dependency trees, linting) → context-mode tools
|
|
11
|
+
- Small commands (git status, ls, pwd, wazir CLI) → native Bash
|
|
12
|
+
- If context-mode unavailable, fall back to native Bash with warning
|
|
13
|
+
|
|
14
|
+
## Codebase Exploration
|
|
15
|
+
1. Query `wazir index search-symbols <query>` first
|
|
16
|
+
2. Use `wazir recall file <path> --tier L1` for targeted reads
|
|
17
|
+
3. Fall back to direct file reads ONLY for files identified by index queries
|
|
18
|
+
4. Maximum 10 direct file reads without a justifying index query
|
|
19
|
+
5. If no index exists: `wazir index build && wazir index summarize --tier all`
|
|
20
|
+
|
|
21
|
+
Reference for using the Claude Code CLI (Anthropic's official CLI for Claude) in Wazir pipelines. Claude Code is an agentic coding tool that operates in your terminal with access to tools like file operations, search, and bash execution.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
|
|
25
|
+
### claude (interactive)
|
|
26
|
+
|
|
27
|
+
Launch the interactive TUI for ad-hoc work.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
claude
|
|
31
|
+
claude "Fix the failing test in src/auth.ts"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Print Mode (non-interactive)
|
|
35
|
+
|
|
36
|
+
The `-p` (or `--print`) flag is the primary mode for Wazir automation. It runs Claude Code non-interactively, outputs the result to stdout, and exits.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Basic non-interactive prompt
|
|
40
|
+
claude -p "Explain the architecture of this project"
|
|
41
|
+
|
|
42
|
+
# Pipe data from stdin (avoids command-line length limits)
|
|
43
|
+
git diff main | claude -p "Review this diff for bugs"
|
|
44
|
+
|
|
45
|
+
# Chain with other tools
|
|
46
|
+
claude -p "List all exported functions" --output-format json | jq '.result'
|
|
47
|
+
|
|
48
|
+
# Save output to file
|
|
49
|
+
claude -p "Summarize the test coverage" > summary.md
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Key flags (all work with `-p`):**
|
|
53
|
+
|
|
54
|
+
| Flag | Description |
|
|
55
|
+
|------|-------------|
|
|
56
|
+
| `-p, --print` | Run non-interactively; print response to stdout and exit |
|
|
57
|
+
| `--model <MODEL>` | Select model: `opus`, `sonnet`, `haiku`, or full name (e.g., `claude-opus-4-6`) |
|
|
58
|
+
| `--fallback-model <MODEL>` | Fallback model when the primary is overloaded (print mode) |
|
|
59
|
+
| `--output-format <FORMAT>` | Output format: `text` (default), `json`, `stream-json` |
|
|
60
|
+
| `--json-schema <SCHEMA>` | Enforce structured output conforming to a JSON schema (requires `--output-format json`) |
|
|
61
|
+
| `--allowedTools <TOOLS...>` | Pre-approve specific tools without prompting (space-separated) |
|
|
62
|
+
| `--disallowedTools <TOOLS...>` | Block specific tools from being used |
|
|
63
|
+
| `--max-turns <N>` | Limit agentic turns in a session |
|
|
64
|
+
| `--append-system-prompt <TEXT>` | Add custom instructions while keeping default capabilities (safe choice) |
|
|
65
|
+
| `--system-prompt <TEXT>` | Replace the entire system prompt (removes all defaults; use with caution) |
|
|
66
|
+
| `--dangerously-skip-permissions` | Bypass all permission barriers (CI/CD and dev containers only) |
|
|
67
|
+
| `--verbose` | Enable verbose output for debugging |
|
|
68
|
+
| `--input-format <FORMAT>` | Input format: `text` (default) |
|
|
69
|
+
|
|
70
|
+
### Session Management
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Continue most recent session in current directory
|
|
74
|
+
claude -c
|
|
75
|
+
|
|
76
|
+
# Resume a specific session by ID
|
|
77
|
+
claude -r <SESSION_ID>
|
|
78
|
+
|
|
79
|
+
# Resume from a PR
|
|
80
|
+
claude --from-pr <NUMBER>
|
|
81
|
+
|
|
82
|
+
# Fork a session into a new thread
|
|
83
|
+
claude --fork-session <SESSION_ID>
|
|
84
|
+
|
|
85
|
+
# Set a custom session ID
|
|
86
|
+
claude --session-id <ID>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Subcommands
|
|
90
|
+
|
|
91
|
+
| Subcommand | Description |
|
|
92
|
+
|------------|-------------|
|
|
93
|
+
| `claude mcp add` | Add an MCP server (`--transport http\|stdio`, `-s` for scope, `-e` for env vars) |
|
|
94
|
+
| `claude mcp serve` | Expose Claude Code itself as an MCP server |
|
|
95
|
+
| `claude agents` | List all configured agents |
|
|
96
|
+
| `claude config` | Manage configuration settings |
|
|
97
|
+
| `claude remote-control` | Serve your local environment for external builds |
|
|
98
|
+
|
|
99
|
+
## Model Selection
|
|
100
|
+
|
|
101
|
+
| Model | Best For | Notes |
|
|
102
|
+
|-------|----------|-------|
|
|
103
|
+
| `opus` / `claude-opus-4-6` | Complex reasoning, architecture, multi-step tasks | Most capable, highest cost |
|
|
104
|
+
| `sonnet` / `claude-sonnet-4-6` | Daily coding, balanced performance | Recommended default |
|
|
105
|
+
| `haiku` / `claude-haiku-4-5` | Quick tasks, fast responses, high volume | Lowest cost, fastest |
|
|
106
|
+
|
|
107
|
+
**Select via:**
|
|
108
|
+
- CLI flag: `--model opus` or `--model claude-opus-4-6`
|
|
109
|
+
- Interactive: `/model` slash command
|
|
110
|
+
- Environment variable: `CLAUDE_MODEL`
|
|
111
|
+
- Settings: `.claude/settings.json`
|
|
112
|
+
|
|
113
|
+
**Fallback:** Use `--fallback-model haiku` with `-p` to auto-switch when the primary model is overloaded.
|
|
114
|
+
|
|
115
|
+
## Permission Management
|
|
116
|
+
|
|
117
|
+
### allowedTools
|
|
118
|
+
|
|
119
|
+
Pre-approve tools to avoid interactive permission prompts. Critical for non-interactive automation.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Allow specific tools
|
|
123
|
+
claude -p --allowedTools "Read" "Grep" "Glob" "Bash(npm run test:*)" \
|
|
124
|
+
"Review the test suite"
|
|
125
|
+
|
|
126
|
+
# Allow all tools (equivalent to dangerously-skip-permissions but scoped)
|
|
127
|
+
claude -p --allowedTools "Read" "Write" "Edit" "Bash" "Grep" "Glob" \
|
|
128
|
+
"Fix the bug in auth.ts"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Tool name patterns:**
|
|
132
|
+
- Exact: `"Read"`, `"Write"`, `"Edit"`, `"Bash"`, `"Grep"`, `"Glob"`
|
|
133
|
+
- Scoped: `"Bash(npm run test:*)"` allows only matching bash commands
|
|
134
|
+
- MCP tools: `"mcp__servername__toolname"`
|
|
135
|
+
|
|
136
|
+
### disallowedTools
|
|
137
|
+
|
|
138
|
+
Block specific tools:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
claude -p --disallowedTools "Write" "Edit" "Bash" \
|
|
142
|
+
"Analyze this codebase for security issues"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Project permissions
|
|
146
|
+
|
|
147
|
+
Store permanent permissions in `.claude/settings.json`:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"permissions": {
|
|
152
|
+
"allowedTools": ["Read", "Grep", "Glob"],
|
|
153
|
+
"deny": ["Bash(rm *)"]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Non-Interactive Usage
|
|
159
|
+
|
|
160
|
+
### Piping data
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Pipe a diff for review
|
|
164
|
+
git diff main | claude -p "Review this diff for correctness"
|
|
165
|
+
|
|
166
|
+
# Pipe file content
|
|
167
|
+
cat src/auth.ts | claude -p "Find potential bugs"
|
|
168
|
+
|
|
169
|
+
# Pipe combined context
|
|
170
|
+
{ echo "## Spec"; cat spec.md; echo "## Code"; cat src/main.ts; } | \
|
|
171
|
+
claude -p "Does the code match the spec?"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Structured output
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# JSON output with full metadata (tool calls, token usage)
|
|
178
|
+
claude -p --output-format json "List all API endpoints"
|
|
179
|
+
|
|
180
|
+
# Streaming JSONL (real-time events)
|
|
181
|
+
claude -p --output-format stream-json "Analyze the codebase"
|
|
182
|
+
|
|
183
|
+
# Schema-enforced structured output
|
|
184
|
+
claude -p --output-format json --json-schema '{"type":"object","properties":{"findings":{"type":"array"},"summary":{"type":"string"}}}' \
|
|
185
|
+
"Review this code and return findings"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### System prompt customization
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Append instructions (keeps default Claude Code capabilities)
|
|
192
|
+
claude -p --append-system-prompt "You are a security auditor. Focus only on vulnerabilities." \
|
|
193
|
+
"Review src/auth.ts"
|
|
194
|
+
|
|
195
|
+
# Full override (removes all defaults; use when you need a clean slate)
|
|
196
|
+
claude -p --system-prompt "You are a JSON-only responder. Return only valid JSON." \
|
|
197
|
+
--output-format json "List all functions in this file"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## MCP Server Integration
|
|
201
|
+
|
|
202
|
+
Claude Code supports MCP (Model Context Protocol) servers for extended capabilities.
|
|
203
|
+
|
|
204
|
+
### Adding MCP servers
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# stdio transport
|
|
208
|
+
claude mcp add github -- npx -y @modelcontextprotocol/server-github
|
|
209
|
+
|
|
210
|
+
# HTTP transport
|
|
211
|
+
claude mcp add api --transport http https://api.example.com
|
|
212
|
+
|
|
213
|
+
# With scope (project vs user)
|
|
214
|
+
claude mcp add myserver -s project -- node server.js
|
|
215
|
+
|
|
216
|
+
# With environment variables
|
|
217
|
+
claude mcp add myserver -e API_KEY=xxx -- node server.js
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Using MCP tools in automation
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Allow specific MCP tools in print mode
|
|
224
|
+
claude -p --allowedTools "mcp__github__create_pull_request" "mcp__github__list_issues" \
|
|
225
|
+
"Create a PR for the current changes"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Claude Code as MCP server
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Expose Claude Code as an MCP server for other tools
|
|
232
|
+
claude mcp serve
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Tool Search (lazy loading):** Since early 2026, Claude Code uses Tool Search for MCP tools by default, loading tool schemas on demand rather than all at once. This reduces context usage by ~95%.
|
|
236
|
+
|
|
237
|
+
## Built-in Slash Commands
|
|
238
|
+
|
|
239
|
+
| Command | Description |
|
|
240
|
+
|---------|-------------|
|
|
241
|
+
| `/model` | Switch model |
|
|
242
|
+
| `/cost` | Show token usage and cost |
|
|
243
|
+
| `/clear` | Clear conversation context |
|
|
244
|
+
| `/compact` | Compress conversation to save tokens |
|
|
245
|
+
| `/help` | Display available commands |
|
|
246
|
+
| `/review` | Review current changes |
|
|
247
|
+
| `/debug` | Debug a failing test or error |
|
|
248
|
+
| `/effort` | Set reasoning effort level |
|
|
249
|
+
|
|
250
|
+
## Wazir Integration Patterns
|
|
251
|
+
|
|
252
|
+
### Secondary Review (used by wz:reviewer)
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
CLAUDE_MODEL=$(jq -r '.multi_tool.claude.model // empty' .wazir/state/config.json 2>/dev/null)
|
|
256
|
+
CLAUDE_MODEL=${CLAUDE_MODEL:-sonnet}
|
|
257
|
+
|
|
258
|
+
# Review uncommitted changes
|
|
259
|
+
git diff | claude -p --model "$CLAUDE_MODEL" \
|
|
260
|
+
--allowedTools "Read" "Grep" "Glob" \
|
|
261
|
+
"Review this diff against these acceptance criteria: <criteria>" \
|
|
262
|
+
2>&1 | tee .wazir/runs/latest/reviews/claude-review.md
|
|
263
|
+
|
|
264
|
+
# Review a spec or design artifact
|
|
265
|
+
cat artifact.md | claude -p --model "$CLAUDE_MODEL" \
|
|
266
|
+
"Review this spec against these criteria: <criteria>" \
|
|
267
|
+
2>&1 | tee .wazir/runs/latest/reviews/claude-review.md
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Structured Review Output
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
claude -p --model "$CLAUDE_MODEL" --output-format json \
|
|
274
|
+
--json-schema '{"type":"object","properties":{"findings":{"type":"array","items":{"type":"object","properties":{"severity":{"type":"string"},"description":{"type":"string"},"location":{"type":"string"}}}},"summary":{"type":"string"}}}' \
|
|
275
|
+
"Review the changes in src/auth/" \
|
|
276
|
+
> .wazir/runs/latest/reviews/claude-review.json
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Parallel Execution as External Validator
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
# Run Claude review in background
|
|
283
|
+
git diff main | claude -p --model haiku \
|
|
284
|
+
--allowedTools "Read" "Grep" \
|
|
285
|
+
"Quick security scan of this diff" \
|
|
286
|
+
> .wazir/runs/latest/reviews/claude-security.md 2>&1 &
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Multi-Turn Programmatic Sessions
|
|
290
|
+
|
|
291
|
+
For complex automation requiring multiple turns:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Limit turns to prevent runaway sessions
|
|
295
|
+
claude -p --max-turns 5 --allowedTools "Read" "Grep" "Bash(npm test)" \
|
|
296
|
+
"Run the tests, analyze any failures, and suggest fixes"
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Error Handling
|
|
300
|
+
|
|
301
|
+
| Error | Handling |
|
|
302
|
+
|-------|----------|
|
|
303
|
+
| **Non-zero exit** (auth/rate-limit/transport) | Log full stderr, mark pass as `claude-unavailable`, use self-review only. Next pass re-attempts. |
|
|
304
|
+
| **Timeout** | Wrap with `timeout 120 claude -p ...`. Treat timeout as `claude-unavailable`. |
|
|
305
|
+
| **Model overloaded** | `--fallback-model haiku` auto-switches. Without it, retry after backoff. |
|
|
306
|
+
| **Permission denied** | Add required tools to `--allowedTools` or use `--dangerously-skip-permissions` in CI. |
|
|
307
|
+
| **Max turns reached** | Increase `--max-turns` or break the task into smaller prompts. |
|
|
308
|
+
|
|
309
|
+
## Configuration
|
|
310
|
+
|
|
311
|
+
Claude Code reads configuration from (highest to lowest precedence):
|
|
312
|
+
1. CLI flags (`--model`, `--allowedTools`, etc.)
|
|
313
|
+
2. Environment variables (`CLAUDE_MODEL`, `ANTHROPIC_API_KEY`)
|
|
314
|
+
3. `.claude/settings.json` (project-level)
|
|
315
|
+
4. `~/.claude/settings.json` (user-level)
|
|
316
|
+
5. `.claude/rules/` directory (modular rule files)
|
|
317
|
+
6. `CLAUDE.md` (project instructions)
|
|
318
|
+
7. Auto Memory (persisted learnings)
|
|
319
|
+
|
|
320
|
+
Key config fields in `settings.json`: `model`, `maxTokens`, `permissions.allowedTools`, `permissions.deny`, `env`.
|