@sniper.ai/core 2.0.0 → 3.1.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/README.md +87 -98
- package/agents/analyst.md +29 -0
- package/agents/architect.md +38 -0
- package/agents/backend-dev.md +43 -0
- package/agents/code-reviewer.md +72 -0
- package/agents/doc-writer.md +60 -0
- package/agents/frontend-dev.md +43 -0
- package/agents/fullstack-dev.md +44 -0
- package/agents/gate-reviewer.md +72 -0
- package/agents/lead-orchestrator.md +51 -0
- package/agents/product-manager.md +40 -0
- package/agents/qa-engineer.md +37 -0
- package/agents/retro-analyst.md +104 -0
- package/checklists/discover.yaml +23 -0
- package/checklists/implement.yaml +28 -0
- package/checklists/ingest-document.yaml +18 -0
- package/checklists/ingest-extract.yaml +13 -0
- package/checklists/ingest-scan.yaml +18 -0
- package/checklists/multi-faceted-review.yaml +57 -0
- package/checklists/plan.yaml +36 -0
- package/checklists/refactor-analyze.yaml +19 -0
- package/checklists/review.yaml +29 -0
- package/claude-md.template +42 -0
- package/config.template.yaml +156 -0
- package/hooks/settings-hooks.json +40 -0
- package/hooks/signal-hooks.json +16 -0
- package/package.json +23 -5
- package/personas/cognitive/devils-advocate.md +24 -0
- package/personas/cognitive/performance-focused.md +23 -0
- package/personas/cognitive/security-first.md +24 -0
- package/protocols/explore.yaml +21 -0
- package/protocols/feature.yaml +47 -0
- package/protocols/full.yaml +65 -0
- package/protocols/hotfix.yaml +19 -0
- package/protocols/ingest.yaml +42 -0
- package/protocols/patch.yaml +30 -0
- package/protocols/refactor.yaml +43 -0
- package/schemas/checkpoint.schema.yaml +133 -0
- package/schemas/cost.schema.yaml +97 -0
- package/schemas/dependency-graph.schema.yaml +37 -0
- package/schemas/gate-result.schema.yaml +101 -0
- package/schemas/knowledge-manifest.schema.yaml +39 -0
- package/schemas/live-status.schema.yaml +122 -0
- package/schemas/protocol-meta.schema.yaml +58 -0
- package/schemas/protocol.schema.yaml +100 -0
- package/schemas/retro.schema.yaml +95 -0
- package/schemas/revert-plan.schema.yaml +40 -0
- package/schemas/signal.schema.yaml +39 -0
- package/schemas/velocity.schema.yaml +52 -0
- package/schemas/workspace-lock.schema.yaml +34 -0
- package/schemas/workspace.schema.yaml +82 -0
- package/skills/sniper-flow/SKILL.md +196 -0
- package/skills/sniper-init/SKILL.md +102 -0
- package/skills/sniper-review/SKILL.md +49 -0
- package/skills/sniper-status/SKILL.md +79 -0
- package/templates/architecture.md +23 -0
- package/templates/checkpoint.yaml +27 -0
- package/templates/codebase-overview.md +19 -0
- package/templates/cost.yaml +23 -0
- package/templates/custom-protocol.yaml +98 -0
- package/templates/knowledge-manifest.yaml +32 -0
- package/templates/live-status.yaml +26 -0
- package/templates/multi-faceted-review-report.md +28 -0
- package/templates/registry.md +4 -0
- package/templates/review-report.md +25 -0
- package/templates/signal-record.yaml +37 -0
- package/templates/spec.md +28 -0
- package/templates/story.md +19 -0
- package/templates/velocity.yaml +9 -0
- package/templates/workspace-config.yaml +44 -0
- package/framework/checklists/code-review.md +0 -33
- package/framework/checklists/debug-review.md +0 -34
- package/framework/checklists/discover-review.md +0 -33
- package/framework/checklists/doc-review.md +0 -39
- package/framework/checklists/feature-review.md +0 -42
- package/framework/checklists/ingest-review.md +0 -42
- package/framework/checklists/memory-review.md +0 -30
- package/framework/checklists/perf-review.md +0 -33
- package/framework/checklists/plan-review.md +0 -52
- package/framework/checklists/refactor-review.md +0 -33
- package/framework/checklists/security-review.md +0 -34
- package/framework/checklists/sprint-review.md +0 -41
- package/framework/checklists/story-review.md +0 -30
- package/framework/checklists/test-review.md +0 -32
- package/framework/checklists/workspace-review.md +0 -34
- package/framework/claude-md.template +0 -37
- package/framework/commands/sniper-audit.md +0 -1549
- package/framework/commands/sniper-compose.md +0 -323
- package/framework/commands/sniper-debug.md +0 -337
- package/framework/commands/sniper-discover.md +0 -423
- package/framework/commands/sniper-doc.md +0 -441
- package/framework/commands/sniper-feature.md +0 -515
- package/framework/commands/sniper-ingest.md +0 -506
- package/framework/commands/sniper-init.md +0 -388
- package/framework/commands/sniper-memory.md +0 -219
- package/framework/commands/sniper-plan.md +0 -630
- package/framework/commands/sniper-review.md +0 -369
- package/framework/commands/sniper-solve.md +0 -408
- package/framework/commands/sniper-sprint.md +0 -716
- package/framework/commands/sniper-status.md +0 -481
- package/framework/commands/sniper-workspace-feature.md +0 -267
- package/framework/commands/sniper-workspace-init.md +0 -252
- package/framework/commands/sniper-workspace-status.md +0 -112
- package/framework/commands/sniper-workspace-validate.md +0 -138
- package/framework/config.template.yaml +0 -196
- package/framework/personas/cognitive/devils-advocate.md +0 -30
- package/framework/personas/cognitive/mentor-explainer.md +0 -29
- package/framework/personas/cognitive/performance-focused.md +0 -30
- package/framework/personas/cognitive/security-first.md +0 -29
- package/framework/personas/cognitive/systems-thinker.md +0 -29
- package/framework/personas/cognitive/user-empathetic.md +0 -29
- package/framework/personas/domain/.gitkeep +0 -0
- package/framework/personas/process/analyst.md +0 -29
- package/framework/personas/process/architect.md +0 -30
- package/framework/personas/process/architecture-cartographer.md +0 -25
- package/framework/personas/process/code-archaeologist.md +0 -22
- package/framework/personas/process/code-investigator.md +0 -29
- package/framework/personas/process/code-reviewer.md +0 -26
- package/framework/personas/process/contract-designer.md +0 -31
- package/framework/personas/process/convention-miner.md +0 -27
- package/framework/personas/process/coverage-analyst.md +0 -24
- package/framework/personas/process/developer.md +0 -32
- package/framework/personas/process/doc-analyst.md +0 -63
- package/framework/personas/process/doc-reviewer.md +0 -62
- package/framework/personas/process/doc-writer.md +0 -42
- package/framework/personas/process/flake-hunter.md +0 -30
- package/framework/personas/process/impact-analyst.md +0 -23
- package/framework/personas/process/integration-validator.md +0 -29
- package/framework/personas/process/log-analyst.md +0 -22
- package/framework/personas/process/migration-architect.md +0 -24
- package/framework/personas/process/perf-profiler.md +0 -27
- package/framework/personas/process/product-manager.md +0 -32
- package/framework/personas/process/qa-engineer.md +0 -31
- package/framework/personas/process/release-manager.md +0 -23
- package/framework/personas/process/retro-analyst.md +0 -30
- package/framework/personas/process/scrum-master.md +0 -31
- package/framework/personas/process/threat-modeler.md +0 -30
- package/framework/personas/process/triage-lead.md +0 -23
- package/framework/personas/process/ux-designer.md +0 -31
- package/framework/personas/process/vuln-scanner.md +0 -27
- package/framework/personas/process/workspace-orchestrator.md +0 -30
- package/framework/personas/technical/ai-ml.md +0 -33
- package/framework/personas/technical/api-design.md +0 -32
- package/framework/personas/technical/backend.md +0 -32
- package/framework/personas/technical/database.md +0 -32
- package/framework/personas/technical/frontend.md +0 -33
- package/framework/personas/technical/infrastructure.md +0 -32
- package/framework/personas/technical/security.md +0 -34
- package/framework/settings.template.json +0 -6
- package/framework/spawn-prompts/_template.md +0 -25
- package/framework/teams/debug.yaml +0 -56
- package/framework/teams/discover.yaml +0 -57
- package/framework/teams/doc.yaml +0 -76
- package/framework/teams/feature-plan.yaml +0 -61
- package/framework/teams/ingest.yaml +0 -85
- package/framework/teams/perf.yaml +0 -33
- package/framework/teams/plan.yaml +0 -86
- package/framework/teams/refactor.yaml +0 -34
- package/framework/teams/retro.yaml +0 -30
- package/framework/teams/review-pr.yaml +0 -73
- package/framework/teams/review-release.yaml +0 -70
- package/framework/teams/security.yaml +0 -59
- package/framework/teams/solve.yaml +0 -48
- package/framework/teams/sprint.yaml +0 -68
- package/framework/teams/test.yaml +0 -59
- package/framework/teams/workspace-feature.yaml +0 -69
- package/framework/teams/workspace-validation.yaml +0 -27
- package/framework/templates/arch-delta.md +0 -74
- package/framework/templates/architecture.md +0 -95
- package/framework/templates/brief.md +0 -73
- package/framework/templates/bug-report.md +0 -55
- package/framework/templates/contract-validation-report.md +0 -68
- package/framework/templates/contract.yaml +0 -60
- package/framework/templates/conventions.md +0 -59
- package/framework/templates/coverage-report.md +0 -67
- package/framework/templates/doc-api.md +0 -53
- package/framework/templates/doc-guide.md +0 -35
- package/framework/templates/doc-readme.md +0 -49
- package/framework/templates/epic.md +0 -47
- package/framework/templates/feature-brief.md +0 -54
- package/framework/templates/feature-spec.md +0 -53
- package/framework/templates/flaky-report.md +0 -64
- package/framework/templates/investigation.md +0 -49
- package/framework/templates/memory-anti-pattern.yaml +0 -16
- package/framework/templates/memory-convention.yaml +0 -17
- package/framework/templates/memory-decision.yaml +0 -16
- package/framework/templates/migration-plan.md +0 -47
- package/framework/templates/optimization-plan.md +0 -59
- package/framework/templates/performance-profile.md +0 -64
- package/framework/templates/personas.md +0 -118
- package/framework/templates/postmortem.md +0 -69
- package/framework/templates/pr-review.md +0 -50
- package/framework/templates/prd.md +0 -92
- package/framework/templates/refactor-scope.md +0 -52
- package/framework/templates/release-readiness.md +0 -66
- package/framework/templates/retro.yaml +0 -44
- package/framework/templates/risks.md +0 -64
- package/framework/templates/security.md +0 -111
- package/framework/templates/sprint-review.md +0 -32
- package/framework/templates/story.md +0 -53
- package/framework/templates/threat-model.md +0 -71
- package/framework/templates/ux-spec.md +0 -71
- package/framework/templates/vulnerability-report.md +0 -56
- package/framework/templates/workspace-brief.md +0 -52
- package/framework/templates/workspace-plan.md +0 -50
- package/framework/workflows/discover-only.md +0 -39
- package/framework/workflows/full-lifecycle.md +0 -56
- package/framework/workflows/quick-feature.md +0 -44
- package/framework/workflows/sprint-cycle.md +0 -47
- package/framework/workflows/workspace-feature.md +0 -71
|
@@ -1,1549 +0,0 @@
|
|
|
1
|
-
# /sniper-audit -- Audit: Refactoring, Review & QA
|
|
2
|
-
|
|
3
|
-
You are executing the `/sniper-audit` command. This is an umbrella command that dispatches to target-specific audit modes. Each mode spawns specialized agent teams for structured analysis. Follow every step below precisely.
|
|
4
|
-
|
|
5
|
-
**Arguments:** $ARGUMENTS
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Step 0: Pre-Flight Checks (All Targets)
|
|
10
|
-
|
|
11
|
-
### 0a. Verify SNIPER Is Initialized
|
|
12
|
-
|
|
13
|
-
1. Read `.sniper/config.yaml`.
|
|
14
|
-
2. If the file does not exist or `project.name` is empty:
|
|
15
|
-
- **STOP.** Print: "SNIPER is not initialized. Run `/sniper-init` first."
|
|
16
|
-
|
|
17
|
-
### 0b. Config Migration Check
|
|
18
|
-
|
|
19
|
-
1. Read `schema_version` from `.sniper/config.yaml`.
|
|
20
|
-
2. If `schema_version` is absent or less than 2, run the v1→v2 migration. Write the updated config before proceeding.
|
|
21
|
-
|
|
22
|
-
### 0c. Parse Shared Arguments
|
|
23
|
-
|
|
24
|
-
1. **`--target {name}`** (required): Select the audit mode. Valid targets listed below.
|
|
25
|
-
2. **`--dry-run`:** Run scoping/analysis only without proceeding to implementation or full review.
|
|
26
|
-
3. **`--scope "dir1/ dir2/"`:** Limit analysis to specific directories.
|
|
27
|
-
|
|
28
|
-
### 0d. Target Dispatch
|
|
29
|
-
|
|
30
|
-
If `--target` is missing, print the target table and ask the user to specify one:
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
============================================
|
|
34
|
-
SNIPER Audit Targets
|
|
35
|
-
============================================
|
|
36
|
-
|
|
37
|
-
Target Description Status
|
|
38
|
-
────── ─────────── ──────
|
|
39
|
-
refactor Large-scale code changes Available
|
|
40
|
-
review PR review / release readiness Available
|
|
41
|
-
tests Test & coverage analysis Available
|
|
42
|
-
security Security audit Available
|
|
43
|
-
performance Performance analysis Available
|
|
44
|
-
|
|
45
|
-
Usage:
|
|
46
|
-
/sniper-audit --target refactor "Migrate from Express to Fastify"
|
|
47
|
-
/sniper-audit --target review --pr 42
|
|
48
|
-
/sniper-audit --target review --release v2.5.0
|
|
49
|
-
|
|
50
|
-
============================================
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Then STOP.
|
|
54
|
-
|
|
55
|
-
### 0e. Dispatch to Target
|
|
56
|
-
|
|
57
|
-
Based on `--target`:
|
|
58
|
-
- `refactor` → Jump to **Section A: Refactoring**
|
|
59
|
-
- `review` → Jump to **Section B: Review & QA**
|
|
60
|
-
- `tests` → Jump to **Section C: Test & Coverage**
|
|
61
|
-
- `security` → Jump to **Section D: Security**
|
|
62
|
-
- `performance` → Jump to **Section E: Performance**
|
|
63
|
-
- Anything else → STOP. Print: "Unknown target '{name}'. Run `/sniper-audit` to see available targets."
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
68
|
-
# Section A: Refactoring (`--target refactor`)
|
|
69
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
70
|
-
|
|
71
|
-
## A0. Parse Refactor Arguments
|
|
72
|
-
|
|
73
|
-
1. **Refactor description** (positional): What is being refactored (e.g., "Migrate from Express to Fastify").
|
|
74
|
-
2. **`--list`:** List all refactors with status. Print and STOP.
|
|
75
|
-
3. **`--resume REF-{NNN}`:** Resume an in-progress refactor.
|
|
76
|
-
|
|
77
|
-
### A0a. Handle `--list`
|
|
78
|
-
|
|
79
|
-
If `--list` was passed:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
============================================
|
|
83
|
-
SNIPER Refactors
|
|
84
|
-
============================================
|
|
85
|
-
|
|
86
|
-
Active Refactors:
|
|
87
|
-
REF-{NNN} {title} {status} ({stories_complete}/{stories_total} stories)
|
|
88
|
-
...
|
|
89
|
-
|
|
90
|
-
Completed Refactors:
|
|
91
|
-
REF-{NNN} {title} complete {date} ({stories_total} stories)
|
|
92
|
-
...
|
|
93
|
-
|
|
94
|
-
Total: {active} active, {completed} completed
|
|
95
|
-
|
|
96
|
-
============================================
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Then STOP.
|
|
100
|
-
|
|
101
|
-
### A0b. Handle `--resume`
|
|
102
|
-
|
|
103
|
-
If `--resume REF-{NNN}` was passed:
|
|
104
|
-
|
|
105
|
-
1. Find the refactor in `state.refactors[]` by ID.
|
|
106
|
-
2. If not found, STOP: "Refactor REF-{NNN} not found."
|
|
107
|
-
3. Jump to the corresponding phase:
|
|
108
|
-
- `scoping` → Step A1 (re-run impact analysis)
|
|
109
|
-
- `planning` → Step A3 (run migration planning)
|
|
110
|
-
- `in-progress` → Step A7 (resume sprint)
|
|
111
|
-
|
|
112
|
-
### A0c. Verify Refactor Description
|
|
113
|
-
|
|
114
|
-
If no `--list` or `--resume` flag, a refactor description is required. If not provided, ask the user to describe the refactoring.
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## A1. Assign Refactor ID and Scope
|
|
119
|
-
|
|
120
|
-
### A1a. Assign Refactor ID
|
|
121
|
-
|
|
122
|
-
1. Read `state.refactor_counter` from config (default: 1).
|
|
123
|
-
2. Assign: `REF-{NNN}` where NNN is zero-padded to 3 digits.
|
|
124
|
-
3. Increment `refactor_counter` and write back to config.
|
|
125
|
-
|
|
126
|
-
### A1b. Record Refactor in State
|
|
127
|
-
|
|
128
|
-
Add to `state.refactors[]`:
|
|
129
|
-
|
|
130
|
-
```yaml
|
|
131
|
-
- id: "REF-{NNN}"
|
|
132
|
-
title: "{refactor description, truncated to 80 chars}"
|
|
133
|
-
status: scoping
|
|
134
|
-
created_at: "{current ISO timestamp}"
|
|
135
|
-
completed_at: null
|
|
136
|
-
scope_dirs: ["{from --scope, or empty for full codebase}"]
|
|
137
|
-
stories_total: 0
|
|
138
|
-
stories_complete: 0
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### A1c. Create Refactor Directory
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
docs/refactors/REF-{NNN}/
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## A2. Impact Analysis (Single Agent — You Do This Directly)
|
|
150
|
-
|
|
151
|
-
### A2a. Read Context
|
|
152
|
-
|
|
153
|
-
1. `docs/architecture.md` (if exists) — identify affected components
|
|
154
|
-
2. `docs/conventions.md` (if exists) — understand current patterns
|
|
155
|
-
3. Source code in the affected scope (`--scope` dirs, or scan full codebase)
|
|
156
|
-
4. Refactor description
|
|
157
|
-
|
|
158
|
-
### A2b. Compose Impact Analyst Persona
|
|
159
|
-
|
|
160
|
-
Read persona layers:
|
|
161
|
-
1. `.sniper/personas/process/impact-analyst.md`
|
|
162
|
-
2. `.sniper/personas/cognitive/devils-advocate.md`
|
|
163
|
-
|
|
164
|
-
Apply these perspectives as you produce the analysis.
|
|
165
|
-
|
|
166
|
-
### A2c. Produce Scope Document
|
|
167
|
-
|
|
168
|
-
Read the template at `.sniper/templates/refactor-scope.md`.
|
|
169
|
-
|
|
170
|
-
Write `docs/refactors/REF-{NNN}/scope.md` following the template:
|
|
171
|
-
- **Summary** — what is being changed and why
|
|
172
|
-
- **Blast Radius** — complete list of affected files, modules, and components
|
|
173
|
-
- **Pattern Inventory** — count of each pattern instance that needs migration (e.g., "47 Express route handlers across 12 files")
|
|
174
|
-
- **Risks** — what could go wrong, breaking change potential
|
|
175
|
-
- **Compatibility Concerns** — API consumers, downstream dependencies, database migrations
|
|
176
|
-
- **Estimated Effort** — S/M/L/XL based on file count and complexity
|
|
177
|
-
|
|
178
|
-
### A2d. Present Scope
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
============================================
|
|
182
|
-
Impact Analysis: REF-{NNN}
|
|
183
|
-
============================================
|
|
184
|
-
|
|
185
|
-
Refactor: {title}
|
|
186
|
-
Blast Radius: {file count} files, {instance count} instances
|
|
187
|
-
Effort: {S/M/L/XL}
|
|
188
|
-
Risk: {key risk summary}
|
|
189
|
-
|
|
190
|
-
Full scope: docs/refactors/REF-{NNN}/scope.md
|
|
191
|
-
|
|
192
|
-
Options:
|
|
193
|
-
yes — Continue to migration planning
|
|
194
|
-
edit — Edit the scope, then say "continue"
|
|
195
|
-
cancel — Pause (resume later with --resume)
|
|
196
|
-
|
|
197
|
-
============================================
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Wait for user response.
|
|
201
|
-
- **yes** → proceed to Step A3
|
|
202
|
-
- **edit** → wait for "continue", then proceed
|
|
203
|
-
- **cancel** → STOP. Refactor stays in `scoping` status.
|
|
204
|
-
|
|
205
|
-
If `--dry-run` was passed, STOP here after presenting the scope.
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## A3. Transition to Planning
|
|
210
|
-
|
|
211
|
-
Update `state.refactors[]` for this refactor: `status: planning`
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## A4. Migration Planning (Single Agent — You Do This Directly)
|
|
216
|
-
|
|
217
|
-
### A4a. Read Context
|
|
218
|
-
|
|
219
|
-
1. `docs/refactors/REF-{NNN}/scope.md` — the impact analysis
|
|
220
|
-
2. `docs/architecture.md` (if exists)
|
|
221
|
-
3. `docs/conventions.md` (if exists)
|
|
222
|
-
4. Target framework/pattern documentation (if the user provided links)
|
|
223
|
-
|
|
224
|
-
### A4b. Compose Migration Architect Persona
|
|
225
|
-
|
|
226
|
-
Read persona layers:
|
|
227
|
-
1. `.sniper/personas/process/migration-architect.md`
|
|
228
|
-
2. `.sniper/personas/technical/backend.md`
|
|
229
|
-
3. `.sniper/personas/cognitive/systems-thinker.md`
|
|
230
|
-
|
|
231
|
-
Apply these perspectives as you produce the plan.
|
|
232
|
-
|
|
233
|
-
### A4c. Produce Migration Plan
|
|
234
|
-
|
|
235
|
-
Read the template at `.sniper/templates/migration-plan.md`.
|
|
236
|
-
|
|
237
|
-
Write `docs/refactors/REF-{NNN}/plan.md` following the template:
|
|
238
|
-
- **Strategy** — big-bang vs incremental vs strangler fig, with rationale
|
|
239
|
-
- **Steps** — ordered phases for the migration (following dependency order)
|
|
240
|
-
- **Coexistence** — how old and new patterns coexist during migration
|
|
241
|
-
- **Compatibility** — adapter patterns needed during transition
|
|
242
|
-
- **Verification** — how to verify each step (tests, canary, etc.)
|
|
243
|
-
- **Rollback** — how to undo if something goes wrong
|
|
244
|
-
|
|
245
|
-
### A4d. Present Plan
|
|
246
|
-
|
|
247
|
-
```
|
|
248
|
-
============================================
|
|
249
|
-
Migration Plan: REF-{NNN}
|
|
250
|
-
============================================
|
|
251
|
-
|
|
252
|
-
Strategy: {strategy name}
|
|
253
|
-
Steps: {step count} migration phases
|
|
254
|
-
Coexistence: {brief description}
|
|
255
|
-
|
|
256
|
-
Full plan: docs/refactors/REF-{NNN}/plan.md
|
|
257
|
-
|
|
258
|
-
Options:
|
|
259
|
-
yes — Generate stories
|
|
260
|
-
edit — Edit the plan, then say "continue"
|
|
261
|
-
cancel — Pause
|
|
262
|
-
|
|
263
|
-
============================================
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
Wait for user response.
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## A5. Story Generation (Scoped Solve)
|
|
271
|
-
|
|
272
|
-
### A5a. Generate Stories
|
|
273
|
-
|
|
274
|
-
1. Read the migration plan at `docs/refactors/REF-{NNN}/plan.md`
|
|
275
|
-
2. Generate 3-12 stories under `docs/refactors/REF-{NNN}/stories/`
|
|
276
|
-
3. Stories follow the migration order from the plan
|
|
277
|
-
4. Each story handles one logical migration step
|
|
278
|
-
5. Name stories: `S01-{slug}.md`, `S02-{slug}.md`, etc.
|
|
279
|
-
|
|
280
|
-
Use the story template from `.sniper/templates/story.md`.
|
|
281
|
-
|
|
282
|
-
### A5b. Update State
|
|
283
|
-
|
|
284
|
-
Update `state.refactors[]`: `stories_total: {count}`
|
|
285
|
-
|
|
286
|
-
### A5c. Present Stories
|
|
287
|
-
|
|
288
|
-
```
|
|
289
|
-
============================================
|
|
290
|
-
Refactor Stories: REF-{NNN}
|
|
291
|
-
============================================
|
|
292
|
-
|
|
293
|
-
{count} stories generated:
|
|
294
|
-
S01 {title}
|
|
295
|
-
S02 {title}
|
|
296
|
-
...
|
|
297
|
-
|
|
298
|
-
Stories: docs/refactors/REF-{NNN}/stories/
|
|
299
|
-
|
|
300
|
-
Options:
|
|
301
|
-
yes — Start refactoring sprint
|
|
302
|
-
edit — Edit stories, then say "continue"
|
|
303
|
-
cancel — Pause
|
|
304
|
-
|
|
305
|
-
============================================
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
Wait for user response.
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
## A6. Review Gate
|
|
313
|
-
|
|
314
|
-
Run `/sniper-review` against the refactor artifacts using the refactor review checklist at `.sniper/checklists/refactor-review.md`. Verify:
|
|
315
|
-
- Impact analysis is complete and thorough
|
|
316
|
-
- Migration plan follows dependency order
|
|
317
|
-
- Stories cover all instances from the pattern inventory
|
|
318
|
-
- Overall consistency between scope, plan, and stories
|
|
319
|
-
|
|
320
|
-
---
|
|
321
|
-
|
|
322
|
-
## A7. Sprint Execution
|
|
323
|
-
|
|
324
|
-
### A7a. Transition to In-Progress
|
|
325
|
-
|
|
326
|
-
Update `state.refactors[]` for this refactor: `status: in-progress`
|
|
327
|
-
|
|
328
|
-
### A7b. Run Sprint
|
|
329
|
-
|
|
330
|
-
Execute the sprint using the standard sprint infrastructure (same as `/sniper-sprint`) with these adjustments:
|
|
331
|
-
|
|
332
|
-
1. **Story source:** Read stories from `docs/refactors/REF-{NNN}/stories/` instead of `docs/stories/`.
|
|
333
|
-
2. **State tracking:** Does NOT increment `state.current_sprint`. Updates `state.refactors[].stories_complete`.
|
|
334
|
-
3. **Team naming:** Team is named `sniper-refactor-sprint-REF-{NNN}`.
|
|
335
|
-
4. **Architecture context:** Include migration plan (`docs/refactors/REF-{NNN}/plan.md`) in spawn prompts.
|
|
336
|
-
5. **phase_log:** Append to `state.phase_log` with `context: "refactor-sprint-REF-{NNN}"`.
|
|
337
|
-
|
|
338
|
-
### A7c. On Completion
|
|
339
|
-
|
|
340
|
-
If all stories complete:
|
|
341
|
-
1. Optionally update `docs/conventions.md` to reflect new patterns (ask user)
|
|
342
|
-
2. Update `state.refactors[]`: `status: complete`, `completed_at: "{timestamp}"`
|
|
343
|
-
|
|
344
|
-
---
|
|
345
|
-
|
|
346
|
-
## A8. Present Final Results
|
|
347
|
-
|
|
348
|
-
```
|
|
349
|
-
============================================
|
|
350
|
-
Refactor Complete: REF-{NNN}
|
|
351
|
-
============================================
|
|
352
|
-
|
|
353
|
-
{title}
|
|
354
|
-
|
|
355
|
-
Scope: {file count} files, {instance count} instances
|
|
356
|
-
Stories: {complete}/{total}
|
|
357
|
-
Duration: {time from creation to completion}
|
|
358
|
-
|
|
359
|
-
Artifacts:
|
|
360
|
-
Scope: docs/refactors/REF-{NNN}/scope.md
|
|
361
|
-
Plan: docs/refactors/REF-{NNN}/plan.md
|
|
362
|
-
Stories: docs/refactors/REF-{NNN}/stories/
|
|
363
|
-
|
|
364
|
-
============================================
|
|
365
|
-
Next Steps
|
|
366
|
-
============================================
|
|
367
|
-
|
|
368
|
-
1. Review the migrated code and run full test suite
|
|
369
|
-
2. Update docs/conventions.md if not already done
|
|
370
|
-
3. Run /sniper-status to see overall project state
|
|
371
|
-
|
|
372
|
-
============================================
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
---
|
|
376
|
-
|
|
377
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
378
|
-
# Section B: Review & QA (`--target review`)
|
|
379
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
380
|
-
|
|
381
|
-
## B0. Parse Review Arguments
|
|
382
|
-
|
|
383
|
-
1. **`--pr {number}`:** Review a specific pull request.
|
|
384
|
-
2. **`--release {tag}`:** Run release readiness assessment.
|
|
385
|
-
3. **`--focus {area}`:** Deep-dive on one area only (e.g., `security`, `tests`, `code`). Valid with `--pr` only.
|
|
386
|
-
4. **`--since {tag}`:** Compare against a specific previous release. Valid with `--release` only.
|
|
387
|
-
|
|
388
|
-
If neither `--pr` nor `--release` is provided, print:
|
|
389
|
-
|
|
390
|
-
```
|
|
391
|
-
============================================
|
|
392
|
-
/sniper-audit --target review
|
|
393
|
-
============================================
|
|
394
|
-
|
|
395
|
-
Specify a review sub-mode:
|
|
396
|
-
|
|
397
|
-
--pr {number} Review a pull request
|
|
398
|
-
--release {tag} Assess release readiness
|
|
399
|
-
|
|
400
|
-
Examples:
|
|
401
|
-
/sniper-audit --target review --pr 42
|
|
402
|
-
/sniper-audit --target review --release v2.5.0
|
|
403
|
-
/sniper-audit --target review --release v2.5.0 --since v2.4.0
|
|
404
|
-
|
|
405
|
-
============================================
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
Then STOP.
|
|
409
|
-
|
|
410
|
-
Dispatch:
|
|
411
|
-
- `--pr` → Jump to **B1: PR Review**
|
|
412
|
-
- `--release` → Jump to **B5: Release Readiness**
|
|
413
|
-
|
|
414
|
-
---
|
|
415
|
-
|
|
416
|
-
## B1. PR Review Mode
|
|
417
|
-
|
|
418
|
-
### B1a. Retrieve PR Diff
|
|
419
|
-
|
|
420
|
-
1. Try: `gh pr diff {number}` to get the diff.
|
|
421
|
-
2. If `gh` is not available, fall back to `git diff main...HEAD` for the current branch.
|
|
422
|
-
3. If neither works, STOP: "Cannot retrieve PR diff. Ensure `gh` CLI is installed or check out the PR branch locally."
|
|
423
|
-
|
|
424
|
-
### B1b. Read Context
|
|
425
|
-
|
|
426
|
-
1. `docs/architecture.md` (if exists)
|
|
427
|
-
2. `docs/conventions.md` (if exists)
|
|
428
|
-
3. The PR diff
|
|
429
|
-
|
|
430
|
-
### B1c. Create Output Directory
|
|
431
|
-
|
|
432
|
-
Create `docs/reviews/` if it doesn't exist.
|
|
433
|
-
|
|
434
|
-
### B1d. Handle `--dry-run`
|
|
435
|
-
|
|
436
|
-
If `--dry-run` was passed, run only the code-reviewer (single perspective preview). Skip to B1f with a single-agent review instead of a team.
|
|
437
|
-
|
|
438
|
-
### B1e. Handle `--focus`
|
|
439
|
-
|
|
440
|
-
If `--focus {area}` was passed, run only the corresponding single reviewer:
|
|
441
|
-
- `--focus code` → code-reviewer only
|
|
442
|
-
- `--focus security` → security-reviewer only
|
|
443
|
-
- `--focus tests` → test-reviewer only
|
|
444
|
-
|
|
445
|
-
Skip to B1f with a single-agent review.
|
|
446
|
-
|
|
447
|
-
### B1f. Spawn PR Review Team (3 Agents)
|
|
448
|
-
|
|
449
|
-
Read `.sniper/teams/review-pr.yaml`. Replace `{pr_number}` with the actual PR number.
|
|
450
|
-
|
|
451
|
-
**code-reviewer:**
|
|
452
|
-
1. Read persona layers: `process/code-reviewer.md`, `cognitive/devils-advocate.md`
|
|
453
|
-
2. Include: PR diff, architecture doc, conventions doc
|
|
454
|
-
3. Task: produce code quality section of `docs/reviews/PR-{NNN}-review.md`
|
|
455
|
-
4. Instructions: review for logic errors, naming clarity, pattern adherence, error handling, complexity, DRY violations, architecture compliance
|
|
456
|
-
|
|
457
|
-
**security-reviewer:**
|
|
458
|
-
1. Read persona layers: `process/code-reviewer.md`, `cognitive/security-first.md`
|
|
459
|
-
2. Include: PR diff
|
|
460
|
-
3. Task: produce security section of `docs/reviews/PR-{NNN}-review.md`
|
|
461
|
-
4. Instructions: review for OWASP top 10, input validation, authentication, authorization, secrets handling, SQL injection, XSS, CSRF
|
|
462
|
-
|
|
463
|
-
**test-reviewer:**
|
|
464
|
-
1. Read persona layers: `process/qa-engineer.md`, `cognitive/systems-thinker.md`
|
|
465
|
-
2. Include: PR diff, conventions doc
|
|
466
|
-
3. Task: produce test coverage section of `docs/reviews/PR-{NNN}-review.md`
|
|
467
|
-
4. Instructions: review for missing tests, edge cases, test naming, mock patterns, assertion quality
|
|
468
|
-
|
|
469
|
-
### B1g. Create Team, Tasks, and Spawn
|
|
470
|
-
|
|
471
|
-
```
|
|
472
|
-
TeamCreate:
|
|
473
|
-
team_name: "sniper-review-pr-{pr_number}"
|
|
474
|
-
description: "PR review for #{pr_number}"
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
Create three tasks (parallel, no dependencies):
|
|
478
|
-
1. "Code Quality Review" — assigned to code-reviewer
|
|
479
|
-
2. "Security Review" — assigned to security-reviewer
|
|
480
|
-
3. "Test Coverage Review" — assigned to test-reviewer
|
|
481
|
-
|
|
482
|
-
Spawn all agents. Enter delegate mode.
|
|
483
|
-
|
|
484
|
-
### B1h. Compile Review Report
|
|
485
|
-
|
|
486
|
-
When all reviewers complete:
|
|
487
|
-
|
|
488
|
-
1. Read all agents' findings
|
|
489
|
-
2. Read the template at `.sniper/templates/pr-review.md`
|
|
490
|
-
3. Compile into `docs/reviews/PR-{NNN}-review.md` following the template
|
|
491
|
-
4. Determine recommendation:
|
|
492
|
-
- If any **critical** findings → `request-changes`
|
|
493
|
-
- If any **warning** findings but no criticals → `comment`
|
|
494
|
-
- If only **suggestion** findings → `approve`
|
|
495
|
-
5. Shut down the review team
|
|
496
|
-
|
|
497
|
-
### B1i. Record Review in State
|
|
498
|
-
|
|
499
|
-
Add to `state.reviews[]`:
|
|
500
|
-
|
|
501
|
-
```yaml
|
|
502
|
-
- id: "PR-{NNN}"
|
|
503
|
-
type: pr
|
|
504
|
-
target: "{pr_number}"
|
|
505
|
-
recommendation: "{approve | request-changes | comment}"
|
|
506
|
-
created_at: "{current ISO timestamp}"
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
### B1j. Present Review
|
|
510
|
-
|
|
511
|
-
```
|
|
512
|
-
============================================
|
|
513
|
-
PR Review: #{pr_number}
|
|
514
|
-
============================================
|
|
515
|
-
|
|
516
|
-
Recommendation: {APPROVE / REQUEST CHANGES / COMMENT}
|
|
517
|
-
|
|
518
|
-
Findings:
|
|
519
|
-
Critical: {count}
|
|
520
|
-
Warning: {count}
|
|
521
|
-
Suggestion: {count}
|
|
522
|
-
|
|
523
|
-
Full review: docs/reviews/PR-{NNN}-review.md
|
|
524
|
-
|
|
525
|
-
============================================
|
|
526
|
-
Note: This review is local only.
|
|
527
|
-
To post comments to GitHub, review the
|
|
528
|
-
report and manually copy relevant findings.
|
|
529
|
-
============================================
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
---
|
|
533
|
-
|
|
534
|
-
## B5. Release Readiness Mode
|
|
535
|
-
|
|
536
|
-
### B5a. Determine Comparison Range
|
|
537
|
-
|
|
538
|
-
1. If `--since {tag}` was provided, use that as the base.
|
|
539
|
-
2. Otherwise, find the most recent release tag: `git describe --tags --abbrev=0`
|
|
540
|
-
3. If no tags found, use the initial commit.
|
|
541
|
-
|
|
542
|
-
### B5b. Read Context
|
|
543
|
-
|
|
544
|
-
1. `git log {base}..HEAD` — all commits since previous release
|
|
545
|
-
2. `git diff {base}..HEAD` — all file changes
|
|
546
|
-
3. `docs/architecture.md` (if exists)
|
|
547
|
-
4. `README.md` (if exists)
|
|
548
|
-
|
|
549
|
-
### B5c. Create Output Directory
|
|
550
|
-
|
|
551
|
-
Create `docs/releases/` if it doesn't exist.
|
|
552
|
-
|
|
553
|
-
### B5d. Handle `--dry-run`
|
|
554
|
-
|
|
555
|
-
If `--dry-run` was passed, run only the release-manager (changelog only, no breaking change analysis or migration guide). Skip to B5f with a single-agent review.
|
|
556
|
-
|
|
557
|
-
### B5e. Spawn Release Readiness Team (3 Agents)
|
|
558
|
-
|
|
559
|
-
Read `.sniper/teams/review-release.yaml`. Replace `{version}` with the target version tag.
|
|
560
|
-
|
|
561
|
-
**release-manager:**
|
|
562
|
-
1. Read persona layers: `process/release-manager.md`, `cognitive/systems-thinker.md`
|
|
563
|
-
2. Include: git log, package.json
|
|
564
|
-
3. Task: produce changelog and version recommendation sections of readiness report
|
|
565
|
-
4. Instructions: categorize all changes, determine semver bump, produce user-facing changelog
|
|
566
|
-
|
|
567
|
-
**breaking-change-analyst:**
|
|
568
|
-
1. Read persona layers: `process/code-reviewer.md`, `cognitive/devils-advocate.md`
|
|
569
|
-
2. Include: git diff, architecture doc
|
|
570
|
-
3. Task: produce breaking changes and migration sections of readiness report
|
|
571
|
-
4. Instructions: analyze for API changes, schema changes, config changes, behavior changes. For each breaking change, write a migration step. Err on the side of flagging.
|
|
572
|
-
|
|
573
|
-
**doc-reviewer:**
|
|
574
|
-
1. Read persona layers: `process/doc-writer.md`, `cognitive/user-empathetic.md`
|
|
575
|
-
2. Include: git log, docs/, README.md
|
|
576
|
-
3. Task: produce documentation status section of readiness report
|
|
577
|
-
4. Instructions: check if documentation matches changes. Flag outdated or missing docs.
|
|
578
|
-
|
|
579
|
-
### B5f. Create Team, Tasks, and Spawn
|
|
580
|
-
|
|
581
|
-
```
|
|
582
|
-
TeamCreate:
|
|
583
|
-
team_name: "sniper-review-release-{version}"
|
|
584
|
-
description: "Release readiness assessment for {version}"
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
Create three tasks (parallel, no dependencies):
|
|
588
|
-
1. "Changelog & Version Recommendation" — assigned to release-manager
|
|
589
|
-
2. "Breaking Change Analysis" — assigned to breaking-change-analyst
|
|
590
|
-
3. "Documentation Status" — assigned to doc-reviewer
|
|
591
|
-
|
|
592
|
-
Spawn all agents. Enter delegate mode.
|
|
593
|
-
|
|
594
|
-
### B5g. Compile Readiness Report
|
|
595
|
-
|
|
596
|
-
When all reviewers complete:
|
|
597
|
-
|
|
598
|
-
1. Read all agents' findings
|
|
599
|
-
2. Read the template at `.sniper/templates/release-readiness.md`
|
|
600
|
-
3. Compile into `docs/releases/{version}-readiness.md` following the template
|
|
601
|
-
4. Determine recommendation:
|
|
602
|
-
- If any undocumented breaking changes → `not-ready`
|
|
603
|
-
- If all breaking changes have migration guides and docs are updated → `ready`
|
|
604
|
-
5. Shut down the release team
|
|
605
|
-
|
|
606
|
-
### B5h. Record Review in State
|
|
607
|
-
|
|
608
|
-
Add to `state.reviews[]`:
|
|
609
|
-
|
|
610
|
-
```yaml
|
|
611
|
-
- id: "REL-{version}"
|
|
612
|
-
type: release
|
|
613
|
-
target: "{version}"
|
|
614
|
-
recommendation: "{ready | not-ready}"
|
|
615
|
-
created_at: "{current ISO timestamp}"
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
### B5i. Present Readiness Report
|
|
619
|
-
|
|
620
|
-
```
|
|
621
|
-
============================================
|
|
622
|
-
Release Readiness: {version}
|
|
623
|
-
============================================
|
|
624
|
-
|
|
625
|
-
Recommendation: {READY / NOT READY}
|
|
626
|
-
Version Bump: {major / minor / patch}
|
|
627
|
-
|
|
628
|
-
Changes:
|
|
629
|
-
Features: {count}
|
|
630
|
-
Bug Fixes: {count}
|
|
631
|
-
Breaking: {count}
|
|
632
|
-
Internal: {count}
|
|
633
|
-
|
|
634
|
-
Documentation:
|
|
635
|
-
Up to date: {count}
|
|
636
|
-
Needs update: {count}
|
|
637
|
-
|
|
638
|
-
Full report: docs/releases/{version}-readiness.md
|
|
639
|
-
|
|
640
|
-
============================================
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
---
|
|
644
|
-
|
|
645
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
646
|
-
# Section C: Test & Coverage (`--target tests`)
|
|
647
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
648
|
-
|
|
649
|
-
## C0. Parse Tests Arguments
|
|
650
|
-
|
|
651
|
-
1. **`--list`:** List all test audits with status. Print and STOP.
|
|
652
|
-
2. **`--resume TST-{NNN}`:** Resume an in-progress test audit.
|
|
653
|
-
3. **`--focus {area}`:** `coverage` (coverage-analyst only) or `flaky` (flake-hunter only).
|
|
654
|
-
|
|
655
|
-
### C0a. Handle `--list`
|
|
656
|
-
|
|
657
|
-
If `--list` was passed:
|
|
658
|
-
|
|
659
|
-
```
|
|
660
|
-
============================================
|
|
661
|
-
SNIPER Test Audits
|
|
662
|
-
============================================
|
|
663
|
-
|
|
664
|
-
Active Test Audits:
|
|
665
|
-
TST-{NNN} {title} {status} ({stories_complete}/{stories_total} stories)
|
|
666
|
-
...
|
|
667
|
-
|
|
668
|
-
Completed Test Audits:
|
|
669
|
-
TST-{NNN} {title} complete {date} ({stories_total} stories)
|
|
670
|
-
...
|
|
671
|
-
|
|
672
|
-
Total: {active} active, {completed} completed
|
|
673
|
-
|
|
674
|
-
============================================
|
|
675
|
-
```
|
|
676
|
-
|
|
677
|
-
Then STOP.
|
|
678
|
-
|
|
679
|
-
### C0b. Handle `--resume`
|
|
680
|
-
|
|
681
|
-
If `--resume TST-{NNN}` was passed:
|
|
682
|
-
|
|
683
|
-
1. Find the test audit in `state.test_audits[]` by ID.
|
|
684
|
-
2. If not found, STOP: "Test audit TST-{NNN} not found."
|
|
685
|
-
3. Jump to the corresponding phase:
|
|
686
|
-
- `analyzing` → Step C1 (re-run analysis)
|
|
687
|
-
- `planning` → Step C4 (generate stories)
|
|
688
|
-
- `in-progress` → Step C6 (resume sprint)
|
|
689
|
-
|
|
690
|
-
---
|
|
691
|
-
|
|
692
|
-
## C1. Assign Test Audit ID
|
|
693
|
-
|
|
694
|
-
### C1a. Assign ID
|
|
695
|
-
|
|
696
|
-
1. Read `state.test_audit_counter` from config (default: 1).
|
|
697
|
-
2. Assign: `TST-{NNN}` where NNN is zero-padded to 3 digits.
|
|
698
|
-
3. Increment `test_audit_counter` and write back to config.
|
|
699
|
-
|
|
700
|
-
### C1b. Record Test Audit in State
|
|
701
|
-
|
|
702
|
-
Add to `state.test_audits[]`:
|
|
703
|
-
|
|
704
|
-
```yaml
|
|
705
|
-
- id: "TST-{NNN}"
|
|
706
|
-
title: "{description or 'Full test suite analysis'}"
|
|
707
|
-
status: analyzing
|
|
708
|
-
created_at: "{current ISO timestamp}"
|
|
709
|
-
completed_at: null
|
|
710
|
-
scope_dirs: ["{from --scope, or empty for full codebase}"]
|
|
711
|
-
focus: "{null | coverage | flaky}"
|
|
712
|
-
stories_total: 0
|
|
713
|
-
stories_complete: 0
|
|
714
|
-
```
|
|
715
|
-
|
|
716
|
-
### C1c. Create Audit Directory
|
|
717
|
-
|
|
718
|
-
```
|
|
719
|
-
docs/audits/TST-{NNN}/
|
|
720
|
-
```
|
|
721
|
-
|
|
722
|
-
---
|
|
723
|
-
|
|
724
|
-
## C2. Analysis Phase (Team Spawn)
|
|
725
|
-
|
|
726
|
-
### C2a. Determine Agents to Spawn
|
|
727
|
-
|
|
728
|
-
- If `--focus coverage`: spawn only `coverage-analyst`
|
|
729
|
-
- If `--focus flaky`: spawn only `flake-hunter`
|
|
730
|
-
- Otherwise: spawn both in parallel
|
|
731
|
-
|
|
732
|
-
### C2b. Read Context
|
|
733
|
-
|
|
734
|
-
1. `docs/architecture.md` (if exists) — to map coverage to architectural components
|
|
735
|
-
2. `docs/conventions.md` (if exists) — to understand testing patterns
|
|
736
|
-
3. Source code in the scoped directories (`--scope` dirs, or scan full codebase)
|
|
737
|
-
|
|
738
|
-
### C2c. Spawn Coverage Analyst
|
|
739
|
-
|
|
740
|
-
Read persona layers:
|
|
741
|
-
1. `.sniper/personas/process/coverage-analyst.md`
|
|
742
|
-
2. `.sniper/personas/cognitive/systems-thinker.md`
|
|
743
|
-
|
|
744
|
-
**Instructions:**
|
|
745
|
-
1. Run `{test_runner} --coverage` (from `stack.test_runner` in config) to get coverage data. Common mappings:
|
|
746
|
-
- `vitest` → `npx vitest run --coverage`
|
|
747
|
-
- `jest` → `npx jest --coverage`
|
|
748
|
-
- `pytest` → `pytest --cov --cov-report=json`
|
|
749
|
-
- `go` → `go test -coverprofile=coverage.out ./...`
|
|
750
|
-
2. If coverage tooling fails, fall back to static analysis: scan for source files without corresponding test files.
|
|
751
|
-
3. Read `.sniper/templates/coverage-report.md`.
|
|
752
|
-
4. Produce `docs/audits/TST-{NNN}/coverage-report.md` following the template.
|
|
753
|
-
|
|
754
|
-
### C2d. Spawn Flake Hunter
|
|
755
|
-
|
|
756
|
-
Read persona layers:
|
|
757
|
-
1. `.sniper/personas/process/flake-hunter.md`
|
|
758
|
-
2. `.sniper/personas/cognitive/devils-advocate.md`
|
|
759
|
-
|
|
760
|
-
**Instructions:**
|
|
761
|
-
1. Run the test suite twice to identify inconsistent results.
|
|
762
|
-
2. If dual-run is too slow, fall back to static analysis: scan for common flake patterns (setTimeout in tests, shared mutable state, missing cleanup, hardcoded ports, Date.now() in assertions).
|
|
763
|
-
3. If CI logs are available (`.github/workflows/`), cross-reference with historically failing tests.
|
|
764
|
-
4. Read `.sniper/templates/flaky-report.md`.
|
|
765
|
-
5. Produce `docs/audits/TST-{NNN}/flaky-report.md` following the template.
|
|
766
|
-
|
|
767
|
-
### C2e. Create Team, Tasks, and Spawn
|
|
768
|
-
|
|
769
|
-
```
|
|
770
|
-
TeamCreate:
|
|
771
|
-
team_name: "sniper-test-audit-TST-{NNN}"
|
|
772
|
-
description: "Test & coverage audit TST-{NNN}"
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
Create tasks (parallel, no dependencies):
|
|
776
|
-
1. "Coverage Analysis" — assigned to coverage-analyst (if not `--focus flaky`)
|
|
777
|
-
2. "Flaky Test Investigation" — assigned to flake-hunter (if not `--focus coverage`)
|
|
778
|
-
|
|
779
|
-
Spawn agents. Enter delegate mode.
|
|
780
|
-
|
|
781
|
-
### C2f. Present Analysis
|
|
782
|
-
|
|
783
|
-
When agents complete:
|
|
784
|
-
|
|
785
|
-
```
|
|
786
|
-
============================================
|
|
787
|
-
Test Analysis: TST-{NNN}
|
|
788
|
-
============================================
|
|
789
|
-
|
|
790
|
-
Coverage:
|
|
791
|
-
Lines: {pct}% | Branches: {pct}%
|
|
792
|
-
Critical gaps: {count}
|
|
793
|
-
Integration boundaries without tests: {count}
|
|
794
|
-
|
|
795
|
-
Flaky Tests:
|
|
796
|
-
Identified: {count}
|
|
797
|
-
Systemic issues: {count}
|
|
798
|
-
Quick wins: {count}
|
|
799
|
-
|
|
800
|
-
Reports:
|
|
801
|
-
docs/audits/TST-{NNN}/coverage-report.md
|
|
802
|
-
docs/audits/TST-{NNN}/flaky-report.md
|
|
803
|
-
|
|
804
|
-
Options:
|
|
805
|
-
yes — Generate improvement stories
|
|
806
|
-
edit — Edit the reports, then say "continue"
|
|
807
|
-
cancel — Pause (resume later with --resume)
|
|
808
|
-
|
|
809
|
-
============================================
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
Wait for user response.
|
|
813
|
-
- **yes** → proceed to Step C3
|
|
814
|
-
- **edit** → wait for "continue", then proceed
|
|
815
|
-
- **cancel** → STOP. Audit stays in `analyzing` status.
|
|
816
|
-
|
|
817
|
-
If `--dry-run` was passed, STOP here after presenting the analysis.
|
|
818
|
-
|
|
819
|
-
---
|
|
820
|
-
|
|
821
|
-
## C3. Transition to Planning
|
|
822
|
-
|
|
823
|
-
Update `state.test_audits[]` for this audit: `status: planning`
|
|
824
|
-
|
|
825
|
-
Shut down the analysis team.
|
|
826
|
-
|
|
827
|
-
---
|
|
828
|
-
|
|
829
|
-
## C4. Story Generation (Lead Generates Directly)
|
|
830
|
-
|
|
831
|
-
### C4a. Read Context
|
|
832
|
-
|
|
833
|
-
1. `docs/audits/TST-{NNN}/coverage-report.md` (if exists)
|
|
834
|
-
2. `docs/audits/TST-{NNN}/flaky-report.md` (if exists)
|
|
835
|
-
|
|
836
|
-
### C4b. Generate Stories
|
|
837
|
-
|
|
838
|
-
1. Generate 3-15 stories under `docs/audits/TST-{NNN}/stories/`
|
|
839
|
-
2. Prioritize: critical gap fixes and quick-win flake fixes first
|
|
840
|
-
3. Each story handles one logical improvement
|
|
841
|
-
4. Name stories: `S01-{slug}.md`, `S02-{slug}.md`, etc.
|
|
842
|
-
5. Use the story template from `.sniper/templates/story.md`
|
|
843
|
-
|
|
844
|
-
### C4c. Update State
|
|
845
|
-
|
|
846
|
-
Update `state.test_audits[]`: `stories_total: {count}`
|
|
847
|
-
|
|
848
|
-
### C4d. Present Stories
|
|
849
|
-
|
|
850
|
-
```
|
|
851
|
-
============================================
|
|
852
|
-
Test Improvement Stories: TST-{NNN}
|
|
853
|
-
============================================
|
|
854
|
-
|
|
855
|
-
{count} stories generated:
|
|
856
|
-
S01 {title}
|
|
857
|
-
S02 {title}
|
|
858
|
-
...
|
|
859
|
-
|
|
860
|
-
Stories: docs/audits/TST-{NNN}/stories/
|
|
861
|
-
|
|
862
|
-
Options:
|
|
863
|
-
yes — Start test improvement sprint
|
|
864
|
-
edit — Edit stories, then say "continue"
|
|
865
|
-
cancel — Pause
|
|
866
|
-
|
|
867
|
-
============================================
|
|
868
|
-
```
|
|
869
|
-
|
|
870
|
-
Wait for user response.
|
|
871
|
-
|
|
872
|
-
---
|
|
873
|
-
|
|
874
|
-
## C5. Review Gate
|
|
875
|
-
|
|
876
|
-
Run `/sniper-review` against the test audit artifacts using the checklist at `.sniper/checklists/test-review.md`.
|
|
877
|
-
|
|
878
|
-
---
|
|
879
|
-
|
|
880
|
-
## C6. Sprint Execution
|
|
881
|
-
|
|
882
|
-
### C6a. Transition to In-Progress
|
|
883
|
-
|
|
884
|
-
Update `state.test_audits[]` for this audit: `status: in-progress`
|
|
885
|
-
|
|
886
|
-
### C6b. Run Sprint
|
|
887
|
-
|
|
888
|
-
Execute the sprint using the standard sprint infrastructure with these adjustments:
|
|
889
|
-
|
|
890
|
-
1. **Story source:** Read stories from `docs/audits/TST-{NNN}/stories/`
|
|
891
|
-
2. **State tracking:** Does NOT increment `state.current_sprint`. Updates `state.test_audits[].stories_complete`.
|
|
892
|
-
3. **Team naming:** Team is named `sniper-test-sprint-TST-{NNN}`.
|
|
893
|
-
4. **Context:** Include coverage-report.md and flaky-report.md in spawn prompts.
|
|
894
|
-
5. **phase_log:** Append to `state.phase_log` with `context: "test-sprint-TST-{NNN}"`.
|
|
895
|
-
|
|
896
|
-
### C6c. On Completion
|
|
897
|
-
|
|
898
|
-
If all stories complete:
|
|
899
|
-
1. Update `state.test_audits[]`: `status: complete`, `completed_at: "{timestamp}"`
|
|
900
|
-
|
|
901
|
-
---
|
|
902
|
-
|
|
903
|
-
## C7. Present Final Results
|
|
904
|
-
|
|
905
|
-
```
|
|
906
|
-
============================================
|
|
907
|
-
Test Audit Complete: TST-{NNN}
|
|
908
|
-
============================================
|
|
909
|
-
|
|
910
|
-
{title}
|
|
911
|
-
|
|
912
|
-
Coverage Gaps Fixed: {count}
|
|
913
|
-
Flaky Tests Fixed: {count}
|
|
914
|
-
Stories: {complete}/{total}
|
|
915
|
-
|
|
916
|
-
Artifacts:
|
|
917
|
-
Coverage: docs/audits/TST-{NNN}/coverage-report.md
|
|
918
|
-
Flaky: docs/audits/TST-{NNN}/flaky-report.md
|
|
919
|
-
Stories: docs/audits/TST-{NNN}/stories/
|
|
920
|
-
|
|
921
|
-
============================================
|
|
922
|
-
Next Steps
|
|
923
|
-
============================================
|
|
924
|
-
|
|
925
|
-
1. Run the full test suite to verify improvements
|
|
926
|
-
2. Check coverage numbers against the original baseline
|
|
927
|
-
3. Run /sniper-status to see overall project state
|
|
928
|
-
|
|
929
|
-
============================================
|
|
930
|
-
```
|
|
931
|
-
|
|
932
|
-
---
|
|
933
|
-
|
|
934
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
935
|
-
# Section D: Security (`--target security`)
|
|
936
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
937
|
-
|
|
938
|
-
## D0. Parse Security Arguments
|
|
939
|
-
|
|
940
|
-
1. **`--list`:** List all security audits with status. Print and STOP.
|
|
941
|
-
2. **`--resume SEC-{NNN}`:** Resume an in-progress security audit.
|
|
942
|
-
3. **`--focus {area}`:** `threats` (threat-modeler only) or `vulns` (vuln-scanner only).
|
|
943
|
-
|
|
944
|
-
### D0a. Handle `--list`
|
|
945
|
-
|
|
946
|
-
If `--list` was passed:
|
|
947
|
-
|
|
948
|
-
```
|
|
949
|
-
============================================
|
|
950
|
-
SNIPER Security Audits
|
|
951
|
-
============================================
|
|
952
|
-
|
|
953
|
-
Active Security Audits:
|
|
954
|
-
SEC-{NNN} {title} {status} ({stories_complete}/{stories_total} stories)
|
|
955
|
-
...
|
|
956
|
-
|
|
957
|
-
Completed Security Audits:
|
|
958
|
-
SEC-{NNN} {title} complete {date} ({stories_total} stories, {critical} critical fixed)
|
|
959
|
-
...
|
|
960
|
-
|
|
961
|
-
Total: {active} active, {completed} completed
|
|
962
|
-
|
|
963
|
-
============================================
|
|
964
|
-
```
|
|
965
|
-
|
|
966
|
-
Then STOP.
|
|
967
|
-
|
|
968
|
-
### D0b. Handle `--resume`
|
|
969
|
-
|
|
970
|
-
If `--resume SEC-{NNN}` was passed:
|
|
971
|
-
|
|
972
|
-
1. Find the security audit in `state.security_audits[]` by ID.
|
|
973
|
-
2. If not found, STOP: "Security audit SEC-{NNN} not found."
|
|
974
|
-
3. Jump to the corresponding phase:
|
|
975
|
-
- `analyzing` → Step D1 (re-run analysis)
|
|
976
|
-
- `planning` → Step D4 (generate stories)
|
|
977
|
-
- `in-progress` → Step D6 (resume sprint)
|
|
978
|
-
|
|
979
|
-
---
|
|
980
|
-
|
|
981
|
-
## D1. Assign Security Audit ID
|
|
982
|
-
|
|
983
|
-
### D1a. Assign ID
|
|
984
|
-
|
|
985
|
-
1. Read `state.security_audit_counter` from config (default: 1).
|
|
986
|
-
2. Assign: `SEC-{NNN}` where NNN is zero-padded to 3 digits.
|
|
987
|
-
3. Increment `security_audit_counter` and write back to config.
|
|
988
|
-
|
|
989
|
-
### D1b. Record Security Audit in State
|
|
990
|
-
|
|
991
|
-
Add to `state.security_audits[]`:
|
|
992
|
-
|
|
993
|
-
```yaml
|
|
994
|
-
- id: "SEC-{NNN}"
|
|
995
|
-
title: "{description or 'Full security audit'}"
|
|
996
|
-
status: analyzing
|
|
997
|
-
created_at: "{current ISO timestamp}"
|
|
998
|
-
completed_at: null
|
|
999
|
-
scope_dirs: ["{from --scope, or empty for full codebase}"]
|
|
1000
|
-
focus: "{null | threats | vulns}"
|
|
1001
|
-
findings_critical: 0
|
|
1002
|
-
findings_high: 0
|
|
1003
|
-
findings_medium: 0
|
|
1004
|
-
findings_low: 0
|
|
1005
|
-
stories_total: 0
|
|
1006
|
-
stories_complete: 0
|
|
1007
|
-
```
|
|
1008
|
-
|
|
1009
|
-
### D1c. Create Audit Directory
|
|
1010
|
-
|
|
1011
|
-
```
|
|
1012
|
-
docs/audits/SEC-{NNN}/
|
|
1013
|
-
```
|
|
1014
|
-
|
|
1015
|
-
---
|
|
1016
|
-
|
|
1017
|
-
## D2. Analysis Phase (Team Spawn)
|
|
1018
|
-
|
|
1019
|
-
### D2a. Determine Agents to Spawn
|
|
1020
|
-
|
|
1021
|
-
- If `--focus threats`: spawn only `threat-modeler`
|
|
1022
|
-
- If `--focus vulns`: spawn only `vuln-scanner`
|
|
1023
|
-
- Otherwise: spawn both in parallel
|
|
1024
|
-
|
|
1025
|
-
### D2b. Read Context
|
|
1026
|
-
|
|
1027
|
-
1. `docs/architecture.md` (if exists) — component structure and data flows
|
|
1028
|
-
2. `docs/conventions.md` (if exists) — auth/authz patterns
|
|
1029
|
-
3. Source code in the scoped directories
|
|
1030
|
-
4. `package.json` / dependency manifests
|
|
1031
|
-
|
|
1032
|
-
### D2c. Spawn Threat Modeler
|
|
1033
|
-
|
|
1034
|
-
Read persona layers:
|
|
1035
|
-
1. `.sniper/personas/process/threat-modeler.md`
|
|
1036
|
-
2. `.sniper/personas/technical/security.md`
|
|
1037
|
-
3. `.sniper/personas/cognitive/systems-thinker.md`
|
|
1038
|
-
|
|
1039
|
-
**Instructions:**
|
|
1040
|
-
1. Map all entry points (API endpoints, webhooks, file uploads, admin panels, WebSocket connections) with authentication requirements.
|
|
1041
|
-
2. Identify trust boundaries (authenticated/unauthenticated, internal/external, user/admin).
|
|
1042
|
-
3. Classify sensitive data (PII, credentials, tokens, financial data) and trace data flows.
|
|
1043
|
-
4. Apply STRIDE methodology to identify threats.
|
|
1044
|
-
5. Assess dependency risk from manifests.
|
|
1045
|
-
6. Read `.sniper/templates/threat-model.md`.
|
|
1046
|
-
7. Produce `docs/audits/SEC-{NNN}/threat-model.md` following the template.
|
|
1047
|
-
|
|
1048
|
-
### D2d. Spawn Vulnerability Scanner
|
|
1049
|
-
|
|
1050
|
-
Read persona layers:
|
|
1051
|
-
1. `.sniper/personas/process/vuln-scanner.md`
|
|
1052
|
-
2. `.sniper/personas/technical/security.md`
|
|
1053
|
-
3. `.sniper/personas/cognitive/devils-advocate.md`
|
|
1054
|
-
|
|
1055
|
-
**Instructions:**
|
|
1056
|
-
1. Search for common vulnerability patterns: SQL concatenation, unsanitized user input, missing auth checks, hardcoded secrets, insecure crypto, CORS misconfig.
|
|
1057
|
-
2. Trace data flow from user input to database/response.
|
|
1058
|
-
3. Check auth/authz middleware coverage on all routes.
|
|
1059
|
-
4. Review error handling for information leakage.
|
|
1060
|
-
5. Check dependency manifests for known vulnerable versions.
|
|
1061
|
-
6. Read `.sniper/templates/vulnerability-report.md`.
|
|
1062
|
-
7. Produce `docs/audits/SEC-{NNN}/vulnerability-report.md` following the template.
|
|
1063
|
-
|
|
1064
|
-
### D2e. Create Team, Tasks, and Spawn
|
|
1065
|
-
|
|
1066
|
-
```
|
|
1067
|
-
TeamCreate:
|
|
1068
|
-
team_name: "sniper-security-audit-SEC-{NNN}"
|
|
1069
|
-
description: "Security audit SEC-{NNN}"
|
|
1070
|
-
```
|
|
1071
|
-
|
|
1072
|
-
Create tasks (parallel, no dependencies):
|
|
1073
|
-
1. "Threat Modeling" — assigned to threat-modeler (if not `--focus vulns`)
|
|
1074
|
-
2. "Vulnerability Scanning" — assigned to vuln-scanner (if not `--focus threats`)
|
|
1075
|
-
|
|
1076
|
-
Spawn agents. Enter delegate mode.
|
|
1077
|
-
|
|
1078
|
-
### D2f. Present Analysis
|
|
1079
|
-
|
|
1080
|
-
When agents complete:
|
|
1081
|
-
|
|
1082
|
-
```
|
|
1083
|
-
============================================
|
|
1084
|
-
Security Analysis: SEC-{NNN}
|
|
1085
|
-
============================================
|
|
1086
|
-
|
|
1087
|
-
Threat Model:
|
|
1088
|
-
Entry points mapped: {count}
|
|
1089
|
-
Trust boundaries: {count}
|
|
1090
|
-
Priority threats: {count}
|
|
1091
|
-
|
|
1092
|
-
Vulnerabilities:
|
|
1093
|
-
Critical: {count} | High: {count}
|
|
1094
|
-
Medium: {count} | Low: {count}
|
|
1095
|
-
Patterns of concern: {count}
|
|
1096
|
-
|
|
1097
|
-
Reports:
|
|
1098
|
-
docs/audits/SEC-{NNN}/threat-model.md
|
|
1099
|
-
docs/audits/SEC-{NNN}/vulnerability-report.md
|
|
1100
|
-
|
|
1101
|
-
Options:
|
|
1102
|
-
yes — Generate remediation stories
|
|
1103
|
-
edit — Edit the reports, then say "continue"
|
|
1104
|
-
cancel — Pause (resume later with --resume)
|
|
1105
|
-
|
|
1106
|
-
============================================
|
|
1107
|
-
```
|
|
1108
|
-
|
|
1109
|
-
Wait for user response.
|
|
1110
|
-
|
|
1111
|
-
If `--dry-run` was passed, STOP here after presenting the analysis.
|
|
1112
|
-
|
|
1113
|
-
---
|
|
1114
|
-
|
|
1115
|
-
## D3. Transition to Planning
|
|
1116
|
-
|
|
1117
|
-
Update `state.security_audits[]` for this audit: `status: planning`
|
|
1118
|
-
|
|
1119
|
-
Update finding counts: `findings_critical`, `findings_high`, `findings_medium`, `findings_low` from the vulnerability report.
|
|
1120
|
-
|
|
1121
|
-
Shut down the analysis team.
|
|
1122
|
-
|
|
1123
|
-
---
|
|
1124
|
-
|
|
1125
|
-
## D4. Story Generation (Lead Generates Directly)
|
|
1126
|
-
|
|
1127
|
-
### D4a. Read Context
|
|
1128
|
-
|
|
1129
|
-
1. `docs/audits/SEC-{NNN}/threat-model.md` (if exists)
|
|
1130
|
-
2. `docs/audits/SEC-{NNN}/vulnerability-report.md` (if exists)
|
|
1131
|
-
|
|
1132
|
-
### D4b. Generate Stories
|
|
1133
|
-
|
|
1134
|
-
1. Generate 3-15 stories under `docs/audits/SEC-{NNN}/stories/`
|
|
1135
|
-
2. Prioritize by severity: critical findings first, then high, medium, low
|
|
1136
|
-
3. Systemic fixes (middleware, validation layers) before individual fixes
|
|
1137
|
-
4. Each story handles one remediation
|
|
1138
|
-
5. Name stories: `S01-{slug}.md`, `S02-{slug}.md`, etc.
|
|
1139
|
-
6. Use the story template from `.sniper/templates/story.md`
|
|
1140
|
-
|
|
1141
|
-
### D4c. Update State
|
|
1142
|
-
|
|
1143
|
-
Update `state.security_audits[]`: `stories_total: {count}`
|
|
1144
|
-
|
|
1145
|
-
### D4d. Present Stories
|
|
1146
|
-
|
|
1147
|
-
```
|
|
1148
|
-
============================================
|
|
1149
|
-
Remediation Stories: SEC-{NNN}
|
|
1150
|
-
============================================
|
|
1151
|
-
|
|
1152
|
-
{count} stories generated:
|
|
1153
|
-
S01 {title} ({severity})
|
|
1154
|
-
S02 {title} ({severity})
|
|
1155
|
-
...
|
|
1156
|
-
|
|
1157
|
-
Stories: docs/audits/SEC-{NNN}/stories/
|
|
1158
|
-
|
|
1159
|
-
Options:
|
|
1160
|
-
yes — Start remediation sprint
|
|
1161
|
-
edit — Edit stories, then say "continue"
|
|
1162
|
-
cancel — Pause
|
|
1163
|
-
|
|
1164
|
-
============================================
|
|
1165
|
-
```
|
|
1166
|
-
|
|
1167
|
-
Wait for user response.
|
|
1168
|
-
|
|
1169
|
-
---
|
|
1170
|
-
|
|
1171
|
-
## D5. Review Gate
|
|
1172
|
-
|
|
1173
|
-
Run `/sniper-review` against the security audit artifacts using the checklist at `.sniper/checklists/security-review.md`.
|
|
1174
|
-
|
|
1175
|
-
---
|
|
1176
|
-
|
|
1177
|
-
## D6. Sprint Execution
|
|
1178
|
-
|
|
1179
|
-
### D6a. Transition to In-Progress
|
|
1180
|
-
|
|
1181
|
-
Update `state.security_audits[]` for this audit: `status: in-progress`
|
|
1182
|
-
|
|
1183
|
-
### D6b. Run Sprint
|
|
1184
|
-
|
|
1185
|
-
Execute the sprint using the standard sprint infrastructure with these adjustments:
|
|
1186
|
-
|
|
1187
|
-
1. **Story source:** Read stories from `docs/audits/SEC-{NNN}/stories/`
|
|
1188
|
-
2. **State tracking:** Does NOT increment `state.current_sprint`. Updates `state.security_audits[].stories_complete`.
|
|
1189
|
-
3. **Team naming:** Team is named `sniper-security-sprint-SEC-{NNN}`.
|
|
1190
|
-
4. **Context:** Include threat-model.md and vulnerability-report.md in spawn prompts.
|
|
1191
|
-
5. **phase_log:** Append to `state.phase_log` with `context: "security-sprint-SEC-{NNN}"`.
|
|
1192
|
-
|
|
1193
|
-
### D6c. On Completion
|
|
1194
|
-
|
|
1195
|
-
If all stories complete:
|
|
1196
|
-
1. Update `state.security_audits[]`: `status: complete`, `completed_at: "{timestamp}"`
|
|
1197
|
-
|
|
1198
|
-
---
|
|
1199
|
-
|
|
1200
|
-
## D7. Present Final Results
|
|
1201
|
-
|
|
1202
|
-
```
|
|
1203
|
-
============================================
|
|
1204
|
-
Security Audit Complete: SEC-{NNN}
|
|
1205
|
-
============================================
|
|
1206
|
-
|
|
1207
|
-
{title}
|
|
1208
|
-
|
|
1209
|
-
Findings Remediated:
|
|
1210
|
-
Critical: {count} | High: {count}
|
|
1211
|
-
Medium: {count} | Low: {count}
|
|
1212
|
-
Stories: {complete}/{total}
|
|
1213
|
-
|
|
1214
|
-
Artifacts:
|
|
1215
|
-
Threat Model: docs/audits/SEC-{NNN}/threat-model.md
|
|
1216
|
-
Vulnerabilities: docs/audits/SEC-{NNN}/vulnerability-report.md
|
|
1217
|
-
Stories: docs/audits/SEC-{NNN}/stories/
|
|
1218
|
-
|
|
1219
|
-
============================================
|
|
1220
|
-
Next Steps
|
|
1221
|
-
============================================
|
|
1222
|
-
|
|
1223
|
-
1. Run the full test suite to verify remediations
|
|
1224
|
-
2. Re-run /sniper-audit --target security to verify no regressions
|
|
1225
|
-
3. Run /sniper-status to see overall project state
|
|
1226
|
-
|
|
1227
|
-
============================================
|
|
1228
|
-
```
|
|
1229
|
-
|
|
1230
|
-
---
|
|
1231
|
-
|
|
1232
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1233
|
-
# Section E: Performance (`--target performance`)
|
|
1234
|
-
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1235
|
-
|
|
1236
|
-
## E0. Parse Performance Arguments
|
|
1237
|
-
|
|
1238
|
-
1. **Performance description** (positional): Specific concern to investigate (e.g., "Checkout API is slow"). Optional — if omitted, runs a general performance audit.
|
|
1239
|
-
2. **`--list`:** List all performance audits with status. Print and STOP.
|
|
1240
|
-
3. **`--resume PERF-{NNN}`:** Resume an in-progress performance audit.
|
|
1241
|
-
4. **`--focus {area}`:** `profile` (profiling only) or `benchmarks` (benchmark gap analysis only).
|
|
1242
|
-
|
|
1243
|
-
### E0a. Handle `--list`
|
|
1244
|
-
|
|
1245
|
-
If `--list` was passed:
|
|
1246
|
-
|
|
1247
|
-
```
|
|
1248
|
-
============================================
|
|
1249
|
-
SNIPER Performance Audits
|
|
1250
|
-
============================================
|
|
1251
|
-
|
|
1252
|
-
Active Performance Audits:
|
|
1253
|
-
PERF-{NNN} {title} {status} ({stories_complete}/{stories_total} stories)
|
|
1254
|
-
...
|
|
1255
|
-
|
|
1256
|
-
Completed Performance Audits:
|
|
1257
|
-
PERF-{NNN} {title} complete {date} ({stories_total} stories)
|
|
1258
|
-
...
|
|
1259
|
-
|
|
1260
|
-
Total: {active} active, {completed} completed
|
|
1261
|
-
|
|
1262
|
-
============================================
|
|
1263
|
-
```
|
|
1264
|
-
|
|
1265
|
-
Then STOP.
|
|
1266
|
-
|
|
1267
|
-
### E0b. Handle `--resume`
|
|
1268
|
-
|
|
1269
|
-
If `--resume PERF-{NNN}` was passed:
|
|
1270
|
-
|
|
1271
|
-
1. Find the performance audit in `state.perf_audits[]` by ID.
|
|
1272
|
-
2. If not found, STOP: "Performance audit PERF-{NNN} not found."
|
|
1273
|
-
3. Jump to the corresponding phase:
|
|
1274
|
-
- `analyzing` → Step E1 (re-run profiling)
|
|
1275
|
-
- `planning` → Step E4 (optimization planning)
|
|
1276
|
-
- `in-progress` → Step E7 (resume sprint)
|
|
1277
|
-
|
|
1278
|
-
---
|
|
1279
|
-
|
|
1280
|
-
## E1. Assign Performance Audit ID
|
|
1281
|
-
|
|
1282
|
-
### E1a. Assign ID
|
|
1283
|
-
|
|
1284
|
-
1. Read `state.perf_audit_counter` from config (default: 1).
|
|
1285
|
-
2. Assign: `PERF-{NNN}` where NNN is zero-padded to 3 digits.
|
|
1286
|
-
3. Increment `perf_audit_counter` and write back to config.
|
|
1287
|
-
|
|
1288
|
-
### E1b. Record Performance Audit in State
|
|
1289
|
-
|
|
1290
|
-
Add to `state.perf_audits[]`:
|
|
1291
|
-
|
|
1292
|
-
```yaml
|
|
1293
|
-
- id: "PERF-{NNN}"
|
|
1294
|
-
title: "{description or 'Full performance audit'}"
|
|
1295
|
-
status: analyzing
|
|
1296
|
-
created_at: "{current ISO timestamp}"
|
|
1297
|
-
completed_at: null
|
|
1298
|
-
scope_dirs: ["{from --scope, or empty for full codebase}"]
|
|
1299
|
-
focus: "{null | profile | benchmarks}"
|
|
1300
|
-
stories_total: 0
|
|
1301
|
-
stories_complete: 0
|
|
1302
|
-
```
|
|
1303
|
-
|
|
1304
|
-
### E1c. Create Audit Directory
|
|
1305
|
-
|
|
1306
|
-
```
|
|
1307
|
-
docs/audits/PERF-{NNN}/
|
|
1308
|
-
```
|
|
1309
|
-
|
|
1310
|
-
---
|
|
1311
|
-
|
|
1312
|
-
## E2. Profiling Phase (Single Agent — You Do This Directly)
|
|
1313
|
-
|
|
1314
|
-
**Note:** Unlike tests and security audits which use 2-agent teams for analysis, performance auditing uses a single profiler agent. This is because performance analysis is more sequential than parallel — the optimization plan depends heavily on a coherent profiling analysis.
|
|
1315
|
-
|
|
1316
|
-
### E2a. Read Context
|
|
1317
|
-
|
|
1318
|
-
1. Performance concern description (if provided by user)
|
|
1319
|
-
2. `docs/architecture.md` (if exists) — to identify performance-critical paths
|
|
1320
|
-
3. Source code in the scoped directories
|
|
1321
|
-
4. Database schema and query files (if identifiable)
|
|
1322
|
-
5. Route/endpoint definitions
|
|
1323
|
-
6. Any existing benchmark files
|
|
1324
|
-
|
|
1325
|
-
### E2b. Compose Profiler Persona
|
|
1326
|
-
|
|
1327
|
-
Read persona layers:
|
|
1328
|
-
1. `.sniper/personas/process/perf-profiler.md`
|
|
1329
|
-
2. `.sniper/personas/technical/backend.md`
|
|
1330
|
-
3. `.sniper/personas/cognitive/systems-thinker.md`
|
|
1331
|
-
|
|
1332
|
-
Apply these perspectives as you produce the analysis.
|
|
1333
|
-
|
|
1334
|
-
### E2c. Produce Profile Report
|
|
1335
|
-
|
|
1336
|
-
Read the template at `.sniper/templates/performance-profile.md`.
|
|
1337
|
-
|
|
1338
|
-
Write `docs/audits/PERF-{NNN}/profile-report.md` following the template:
|
|
1339
|
-
- **Performance Context** — what was investigated and why
|
|
1340
|
-
- **Critical Path Analysis** — performance-sensitive paths (request chains, data pipelines, background jobs)
|
|
1341
|
-
- **Bottleneck Inventory** — each bottleneck with location, category, evidence, impact, complexity
|
|
1342
|
-
- **Resource Usage Patterns** — memory allocation, connection pools, compute patterns
|
|
1343
|
-
- **Existing Optimizations** — caching, indexing, and optimization already in place
|
|
1344
|
-
- **Benchmark Coverage** — which critical paths have benchmarks and which don't
|
|
1345
|
-
|
|
1346
|
-
**Profiling approach (static code analysis):**
|
|
1347
|
-
1. Identify all request handling paths and trace their execution
|
|
1348
|
-
2. Search for N+1 query patterns (loops containing database calls)
|
|
1349
|
-
3. Identify missing database indexes by cross-referencing queries with schema
|
|
1350
|
-
4. Find synchronous I/O in async contexts
|
|
1351
|
-
5. Detect unbounded data processing (no pagination, full-table scans)
|
|
1352
|
-
6. Check for missing caching on frequently-accessed, rarely-changed data
|
|
1353
|
-
7. Identify large object serialization/deserialization
|
|
1354
|
-
8. If a specific concern is provided, trace that path in detail
|
|
1355
|
-
|
|
1356
|
-
### E2d. Present Profile
|
|
1357
|
-
|
|
1358
|
-
```
|
|
1359
|
-
============================================
|
|
1360
|
-
Performance Profile: PERF-{NNN}
|
|
1361
|
-
============================================
|
|
1362
|
-
|
|
1363
|
-
Context: {description or 'General performance audit'}
|
|
1364
|
-
Bottlenecks Found: {count}
|
|
1365
|
-
Critical: {count} | High: {count}
|
|
1366
|
-
Medium: {count} | Low: {count}
|
|
1367
|
-
Benchmark Coverage: {count}/{total} critical paths
|
|
1368
|
-
|
|
1369
|
-
Full profile: docs/audits/PERF-{NNN}/profile-report.md
|
|
1370
|
-
|
|
1371
|
-
Options:
|
|
1372
|
-
yes — Continue to optimization planning
|
|
1373
|
-
edit — Edit the profile, then say "continue"
|
|
1374
|
-
cancel — Pause (resume later with --resume)
|
|
1375
|
-
|
|
1376
|
-
============================================
|
|
1377
|
-
```
|
|
1378
|
-
|
|
1379
|
-
Wait for user response.
|
|
1380
|
-
|
|
1381
|
-
If `--dry-run` was passed, STOP here after presenting the profile.
|
|
1382
|
-
If `--focus profile` was passed, STOP here.
|
|
1383
|
-
|
|
1384
|
-
---
|
|
1385
|
-
|
|
1386
|
-
## E3. Transition to Planning
|
|
1387
|
-
|
|
1388
|
-
Update `state.perf_audits[]` for this audit: `status: planning`
|
|
1389
|
-
|
|
1390
|
-
---
|
|
1391
|
-
|
|
1392
|
-
## E4. Optimization Planning (Single Agent — You Do This Directly)
|
|
1393
|
-
|
|
1394
|
-
### E4a. Read Context
|
|
1395
|
-
|
|
1396
|
-
1. `docs/audits/PERF-{NNN}/profile-report.md`
|
|
1397
|
-
2. `docs/architecture.md` (if exists)
|
|
1398
|
-
|
|
1399
|
-
### E4b. Produce Optimization Plan
|
|
1400
|
-
|
|
1401
|
-
Read the template at `.sniper/templates/optimization-plan.md`.
|
|
1402
|
-
|
|
1403
|
-
Write `docs/audits/PERF-{NNN}/optimization-plan.md` following the template:
|
|
1404
|
-
- **Priority Matrix** — bottlenecks ranked by impact / effort ratio
|
|
1405
|
-
- **Optimization Recommendations** — what to change, expected improvement, approach, risks
|
|
1406
|
-
- **Benchmark Requirements** — what benchmarks to write to verify each optimization
|
|
1407
|
-
- **Quick Wins** — low-effort, high-impact optimizations
|
|
1408
|
-
- **Monitoring Recommendations** — metrics to track for regression prevention
|
|
1409
|
-
|
|
1410
|
-
### E4c. Present Plan
|
|
1411
|
-
|
|
1412
|
-
```
|
|
1413
|
-
============================================
|
|
1414
|
-
Optimization Plan: PERF-{NNN}
|
|
1415
|
-
============================================
|
|
1416
|
-
|
|
1417
|
-
Quick Wins: {count}
|
|
1418
|
-
Total Optimizations: {count}
|
|
1419
|
-
Benchmark Stories: {count}
|
|
1420
|
-
|
|
1421
|
-
Full plan: docs/audits/PERF-{NNN}/optimization-plan.md
|
|
1422
|
-
|
|
1423
|
-
Options:
|
|
1424
|
-
yes — Generate stories
|
|
1425
|
-
edit — Edit the plan, then say "continue"
|
|
1426
|
-
cancel — Pause
|
|
1427
|
-
|
|
1428
|
-
============================================
|
|
1429
|
-
```
|
|
1430
|
-
|
|
1431
|
-
Wait for user response.
|
|
1432
|
-
|
|
1433
|
-
---
|
|
1434
|
-
|
|
1435
|
-
## E5. Story Generation
|
|
1436
|
-
|
|
1437
|
-
### E5a. Generate Stories
|
|
1438
|
-
|
|
1439
|
-
1. Read the optimization plan at `docs/audits/PERF-{NNN}/optimization-plan.md`
|
|
1440
|
-
2. Generate 3-12 stories under `docs/audits/PERF-{NNN}/stories/`
|
|
1441
|
-
3. Each optimization gets a story, plus a companion benchmark story if needed
|
|
1442
|
-
4. Quick wins come first, then higher-effort optimizations
|
|
1443
|
-
5. Name stories: `S01-{slug}.md`, `S02-{slug}.md`, etc.
|
|
1444
|
-
6. Use the story template from `.sniper/templates/story.md`
|
|
1445
|
-
|
|
1446
|
-
If `--focus benchmarks` was passed, generate benchmark-only stories (skip optimization stories).
|
|
1447
|
-
|
|
1448
|
-
### E5b. Update State
|
|
1449
|
-
|
|
1450
|
-
Update `state.perf_audits[]`: `stories_total: {count}`
|
|
1451
|
-
|
|
1452
|
-
### E5c. Present Stories
|
|
1453
|
-
|
|
1454
|
-
```
|
|
1455
|
-
============================================
|
|
1456
|
-
Performance Stories: PERF-{NNN}
|
|
1457
|
-
============================================
|
|
1458
|
-
|
|
1459
|
-
{count} stories generated:
|
|
1460
|
-
S01 {title}
|
|
1461
|
-
S02 {title}
|
|
1462
|
-
...
|
|
1463
|
-
|
|
1464
|
-
Stories: docs/audits/PERF-{NNN}/stories/
|
|
1465
|
-
|
|
1466
|
-
Options:
|
|
1467
|
-
yes — Start optimization sprint
|
|
1468
|
-
edit — Edit stories, then say "continue"
|
|
1469
|
-
cancel — Pause
|
|
1470
|
-
|
|
1471
|
-
============================================
|
|
1472
|
-
```
|
|
1473
|
-
|
|
1474
|
-
Wait for user response.
|
|
1475
|
-
|
|
1476
|
-
---
|
|
1477
|
-
|
|
1478
|
-
## E6. Review Gate
|
|
1479
|
-
|
|
1480
|
-
Run `/sniper-review` against the performance audit artifacts using the checklist at `.sniper/checklists/perf-review.md`.
|
|
1481
|
-
|
|
1482
|
-
---
|
|
1483
|
-
|
|
1484
|
-
## E7. Sprint Execution
|
|
1485
|
-
|
|
1486
|
-
### E7a. Transition to In-Progress
|
|
1487
|
-
|
|
1488
|
-
Update `state.perf_audits[]` for this audit: `status: in-progress`
|
|
1489
|
-
|
|
1490
|
-
### E7b. Run Sprint
|
|
1491
|
-
|
|
1492
|
-
Execute the sprint using the standard sprint infrastructure with these adjustments:
|
|
1493
|
-
|
|
1494
|
-
1. **Story source:** Read stories from `docs/audits/PERF-{NNN}/stories/`
|
|
1495
|
-
2. **State tracking:** Does NOT increment `state.current_sprint`. Updates `state.perf_audits[].stories_complete`.
|
|
1496
|
-
3. **Team naming:** Team is named `sniper-perf-sprint-PERF-{NNN}`.
|
|
1497
|
-
4. **Context:** Include profile-report.md and optimization-plan.md in spawn prompts.
|
|
1498
|
-
5. **phase_log:** Append to `state.phase_log` with `context: "perf-sprint-PERF-{NNN}"`.
|
|
1499
|
-
|
|
1500
|
-
### E7c. On Completion
|
|
1501
|
-
|
|
1502
|
-
If all stories complete:
|
|
1503
|
-
1. Update `state.perf_audits[]`: `status: complete`, `completed_at: "{timestamp}"`
|
|
1504
|
-
|
|
1505
|
-
---
|
|
1506
|
-
|
|
1507
|
-
## E8. Present Final Results
|
|
1508
|
-
|
|
1509
|
-
```
|
|
1510
|
-
============================================
|
|
1511
|
-
Performance Audit Complete: PERF-{NNN}
|
|
1512
|
-
============================================
|
|
1513
|
-
|
|
1514
|
-
{title}
|
|
1515
|
-
|
|
1516
|
-
Optimizations: {count}
|
|
1517
|
-
Benchmarks Added: {count}
|
|
1518
|
-
Stories: {complete}/{total}
|
|
1519
|
-
|
|
1520
|
-
Artifacts:
|
|
1521
|
-
Profile: docs/audits/PERF-{NNN}/profile-report.md
|
|
1522
|
-
Plan: docs/audits/PERF-{NNN}/optimization-plan.md
|
|
1523
|
-
Stories: docs/audits/PERF-{NNN}/stories/
|
|
1524
|
-
|
|
1525
|
-
============================================
|
|
1526
|
-
Next Steps
|
|
1527
|
-
============================================
|
|
1528
|
-
|
|
1529
|
-
1. Run benchmarks to verify performance improvements
|
|
1530
|
-
2. Compare against the original profile baseline
|
|
1531
|
-
3. Run /sniper-status to see overall project state
|
|
1532
|
-
|
|
1533
|
-
============================================
|
|
1534
|
-
```
|
|
1535
|
-
|
|
1536
|
-
---
|
|
1537
|
-
|
|
1538
|
-
## IMPORTANT RULES
|
|
1539
|
-
|
|
1540
|
-
- This command does NOT write production code — it produces analysis reports and documentation only.
|
|
1541
|
-
- Exception: `--target refactor` Phase 3, `--target tests` Phase 3, `--target security` Phase 3, and `--target performance` Phase 3 (sprint execution) write code through the standard sprint infrastructure.
|
|
1542
|
-
- Reviews (`--target review`) do NOT post to GitHub automatically. They produce local reports.
|
|
1543
|
-
- Reviews do NOT write to `state.phase_log`. They are tracked in `state.reviews[]` only.
|
|
1544
|
-
- Refactor scoping and planning do NOT write to `state.phase_log`. Refactor sprints DO append to `state.phase_log` with `context: "refactor-sprint-REF-{NNN}"`.
|
|
1545
|
-
- Test, security, and performance audits do NOT write to `state.phase_log` during analysis/planning. Their sprints DO append to `state.phase_log` with the appropriate context.
|
|
1546
|
-
- Cancel at any checkpoint leaves the audit in its current status for later `--resume`.
|
|
1547
|
-
- Resume restarts from the beginning of the current phase (agent state is ephemeral).
|
|
1548
|
-
- All file paths are relative to the project root.
|
|
1549
|
-
- The `--dry-run` flag limits each mode to its first analysis step only.
|