its-magic 0.1.2-25 → 0.1.2-27

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 CHANGED
@@ -1,1214 +1,1241 @@
1
- # its-magic — AI dev team
2
-
3
- [GitHub Repository](https://github.com/fl0wm0ti0n/its-magic)
4
-
5
- Happy coding! Build something awesome.
6
-
7
- Drop-in template repo that implements a structured its-magic workflow in Cursor:
8
- intake -> discovery -> architecture -> sprint plan -> execute -> QA -> release,
9
- with pause/resume, decision gates, and persistent artifacts.
10
-
11
- ## Features (what its-magic can do)
12
-
13
- - Structured phase workflow with explicit artifacts.
14
- - Artifact-first memory (state in files, not chat only).
15
- - Decision gate + escalation (`decisions/DEC-xxxx.md`).
16
- - Pause/resume with checkpoints (`handoffs/resume_brief.md`).
17
- - Automated execute/QA loop with safety caps (optional).
18
- - 3-layer quality chain: AI loop → local validate-and-push → CI auto-fix.
19
- - CI/CD templates driven by `docs/engineering/runbook.md`.
20
- - Team-friendly local overrides (`scratchpad.local.md`).
21
- - Optional remote/docker execution and autonomous installs.
22
- - Built-in benchmarks (live, prompted, headless).
23
- - Multiplatform distribution (npm, Chocolatey, Homebrew).
24
-
25
- ## Setup
26
-
27
- its-magic is an installer you run once per repo. It copies the AI dev team
28
- workflow files (`.cursor/` commands, rules, agents, hooks, skills, plus `docs/`,
29
- `sprints/`, `handoffs/`, etc.) into your project.
30
-
31
- Starter artifacts are shipped as clean placeholders (no preloaded sprint/demo
32
- history), so `/intake` starts from your own idea.
33
-
34
- ### 1) Install its-magic (once)
35
-
36
- Pick one method:
37
-
38
- | Method | Install command |
39
- |--------|----------------|
40
- | npm | `npm install -g its-magic` |
41
- | npx | `npx its-magic --target . --mode missing` |
42
- | Chocolatey | `choco install its-magic` (Admin shell) |
43
- | Homebrew | `brew tap USER/tap && brew install its-magic` |
44
-
45
- ### 2) Apply to a repo
46
-
47
- New repo:
48
-
49
- ```bash
50
- mkdir my-project && cd my-project
51
- git init
52
- its-magic --target . --mode missing --create
53
- ```
54
-
55
- Existing repo (safe merge):
56
-
57
- ```bash
58
- its-magic --target . --mode missing
59
- ```
60
-
61
- Existing repo (overwrite + backup):
62
-
63
- ```bash
64
- its-magic --target . --mode overwrite --backup
65
- ```
66
-
67
- ### Upgrading an existing repo
68
-
69
- When you update its-magic to a newer version (`npm update -g its-magic`), run
70
- upgrade mode to update framework files while preserving your project data:
71
-
72
- ```bash
73
- its-magic --target . --mode upgrade
74
- ```
75
-
76
- What upgrade does:
77
-
78
- - **Framework files** (commands, rules, agents, hooks, skills, CI, scripts) are
79
- updated to the latest version.
80
- - **User data** (docs, sprints, handoffs, decisions, runbook) is never touched.
81
- - **Mixed files** (`.cursor/scratchpad.md`, `README.md`) are preserved. If the
82
- template version has new content, a review notice is printed.
83
- - A `.its-magic-version` file tracks the installed version in your repo.
84
-
85
- Upgrade with backup (backs up framework files before updating):
86
-
87
- ```bash
88
- its-magic --target . --mode upgrade --backup
89
- ```
90
-
91
- ### 3) Open in Cursor
92
-
93
- 1. Open the project folder
94
- 2. Run `/intake` with your idea
95
- 3. Follow the workflow
96
-
97
- ### CLI quick commands
98
-
99
- ```bash
100
- # Show banner + help
101
- its-magic
102
-
103
- # Show version only
104
- its-magic --version
105
-
106
- # Install workflow files into current repo
107
- its-magic --target . --mode missing
108
-
109
- # Clean previously installed workflow artifacts
110
- its-magic --clean-repo --target .
111
- ```
112
-
113
- ### Installer options
114
-
115
- **Install options**
116
-
117
- | Flag | Description |
118
- |------|-------------|
119
- | `--target <path>` | Path to the repository where workflow files are installed. If omitted you are prompted interactively. |
120
- | `--mode missing` | **Default.** Only copy files that do not exist yet. Safe for repos that already have some workflow files. |
121
- | `--mode overwrite` | Replace every file, even if it already exists. Combine with `--backup` to keep a snapshot first. |
122
- | `--mode interactive` | Ask per file whether to overwrite or skip. Useful when you want to cherry-pick updates. |
123
- | `--mode upgrade` | Update framework files (commands, rules, agents, hooks, skills, CI, scripts) while preserving user data (docs, sprints, handoffs, decisions). Use after updating its-magic to a newer version. |
124
- | `--backup` | Before overwriting, save existing files to `backups/<timestamp>/`. Ignored in `missing` mode (nothing gets replaced). |
125
- | `--create` | Create the target directory if it does not exist. |
126
-
127
- **Clean options**
128
-
129
- | Flag | Description |
130
- |------|-------------|
131
- | `--clean-repo` | Remove installer-owned its-magic workflow artifacts from the target repo (manifest-owned paths including `.cursor`, `docs/product`, `docs/engineering`, `docs/user-guides`, `sprints`, `handoffs`, `decisions`, workflow scripts, CI files, `.its-magic-version`). Your own source code is never touched. |
132
- | `--yes` | Skip the confirmation prompt when cleaning. |
133
-
134
- **Info**
135
-
136
- | Flag | Description |
137
- |------|-------------|
138
- | `--help`, `-h` | Show banner, version, repo URL, and full usage reference. |
139
- | `--version`, `-v` | Print the installed its-magic version and exit. |
140
-
141
- ### Lifecycle QA matrix (US-0041)
142
-
143
- `its-magic` lifecycle behavior is validated in both installer and CLI paths.
144
- Primary coverage:
145
-
146
- | Scenario | Local coverage | CI coverage | Expected evidence |
147
- |---|---|---|---|
148
- | Fresh install (`missing`) | `tests/run-tests.ps1`, `tests/run-tests.sh` | npm/brew/choco jobs | Required files + `.its-magic-version` |
149
- | Overwrite + backup | `tests/run-tests.ps1`, `tests/run-tests.sh` | lifecycle subset in CI jobs | Backup snapshot contains overwritten framework file |
150
- | Upgrade lifecycle | `tests/run-tests.ps1`, `tests/run-tests.sh`, npm local package tests | lifecycle subset in CI jobs | Framework file restored, user-data preserved |
151
- | Clean-repo safety | `tests/run-tests.ps1`, `tests/run-tests.sh`, npm local package tests | lifecycle subset in CI jobs | Framework artifacts removed, non-framework marker preserved |
152
- | Negative-path invalid mode/args | `tests/run-tests.ps1`, `tests/run-tests.sh` | lifecycle subset in CI jobs | Non-zero fail-fast behavior |
153
-
154
- Run locally:
155
-
156
- ```bash
157
- sh tests/run-tests.sh
158
- powershell -ExecutionPolicy Bypass -File tests/run-tests.ps1
159
- ```
160
-
161
- ## How-to
162
-
163
- ### Command usage pattern
164
-
165
- - Best practice: use `/<command>` + 1-3 lines context.
166
- - For quick ops (`/pause`, `/resume`, `/refresh-context`) command-only is fine.
167
-
168
- ### What gets installed
169
-
170
- ```text
171
- your-project/
172
- .cursor/commands/ Cursor slash commands
173
- .cursor/rules/ AI behavior rules
174
- .cursor/agents/ Subagent definitions
175
- .cursor/skills/ Reusable skills
176
- .cursor/hooks/ Automation hooks
177
- .cursor/scratchpad.md Shared configuration flags
178
- .cursor/scratchpad.local.example.md
179
- docs/ Engineering & product docs, runbook
180
- sprints/ Sprint tracking artifacts
181
- handoffs/ Phase handoff artifacts
182
- decisions/ Decision records
183
- scripts/validate-and-push.ps1 Local test-fix-push loop (Windows)
184
- scripts/validate-and-push.sh Local test-fix-push loop (Linux/Mac)
185
- .github/workflows/ CI with auto-fix loop
186
- README.md
187
- ```
188
-
189
- ### Team mode local overrides (recommended)
190
-
191
- Use two layers:
192
-
193
- - Shared defaults: `.cursor/scratchpad.md` (committed)
194
- - Personal overrides: `.cursor/scratchpad.local.md` (gitignored)
195
-
196
- Setup:
197
-
198
- 1. Copy `.cursor/scratchpad.local.example.md` to `.cursor/scratchpad.local.md`
199
- 2. Set personal values there (`TEAM_MEMBER`, `ACTIVE_TASK_IDS`, automation style)
200
- 3. Hook merges shared + local (local wins)
201
-
202
- Upgrade behavior (US-0057):
203
- - `.cursor/scratchpad.local.example.md` is framework-owned and refreshed on `--mode upgrade`.
204
- - `.cursor/scratchpad.local.md` is user-owned and preserved on `--mode upgrade`.
205
- - Installer output includes scratchpad example refresh status and local-preserved signal.
206
-
207
- Deterministic ordering behavior (US-0058):
208
- - Mutable artifacts follow `docs/engineering/artifact-ordering-policy.md`.
209
- - `state.md` checkpoints are append-bottom; `backlog.md` and `acceptance.md`
210
- remain sorted-canonical by story ID.
211
- - Commands fail closed on ambiguous placement anchors using
212
- `ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS`.
213
- - Commands fail closed on non-monotonic state checkpoint timestamps using
214
- `STATE_TIMESTAMP_NON_MONOTONIC`.
215
-
216
- Intake runtime safety behavior (US-0059):
217
- - `/intake` requires role-specific `po` capability by default and fails fast with
218
- `SUBAGENT_CAPABILITY_UNAVAILABLE` when unavailable.
219
- - Silent in-band fallback is disabled by default and only allowed with explicit
220
- `INTAKE_SUBAGENT_FALLBACK=allow`.
221
- - Drift detection distinguishes self-write updates from external concurrent
222
- writers; true conflicting external writes fail safe with
223
- `INTAKE_CONCURRENT_WRITER_DETECTED`.
224
-
225
- ## Workflow
226
-
227
- ### Core commands
228
-
229
- - `/ask`: ask questions using project context (read-only, no artifacts created).
230
- - `/intake`: capture idea, backlog, acceptance.
231
- - `/discovery`: collect UX/product references.
232
- - `/research`: risks, patterns, dependencies.
233
- - `/architecture`: technical approach and decisions.
234
- - `/sprint-plan`: sprint and task list.
235
- - `/plan-verify`: acceptance coverage check.
236
- - `/execute`: implement tasks.
237
- - `/qa`: test and report findings.
238
- - `/verify-work`: UAT.
239
- - `/release`: release notes + runbook updates.
240
- - `/memory-audit`: read-only memory drift check with advisory report.
241
- - `/pause`, `/resume`, `/refresh-context`.
242
- - `/auto`: orchestration mode that spawns a fresh subagent per phase.
243
-
244
- ### Guided intake behavior (US-0033)
245
-
246
- `/intake` supports two PO interaction modes via `.cursor/scratchpad.md`:
247
-
248
- - `INTAKE_GUIDED_MODE=1` (default)
249
- - asks targeted follow-up only when needed for concrete acceptance
250
- - presents options/alternatives before recommendation
251
- - preserves user decision authority
252
- - runs intake-time research and persists R-xxxx evidence
253
- - `INTAKE_GUIDED_MODE=0` (low-touch)
254
- - skips proactive follow-up/options/research overhead unless user requests it
255
- - still performs duplicate/overlap check against backlog
256
-
257
- ### Intake decomposition + risk-aware questioning (US-0051)
258
-
259
- When guided mode is enabled, `/intake` now supports bounded decomposition for
260
- broad/high-risk requests:
261
-
262
- - runs deterministic breadth/risk heuristics (feature/workflow count,
263
- cross-cutting impact, acceptance breadth, unknown dependencies)
264
- - proposes bounded multi-story decomposition when heuristics indicate broad
265
- scope; keeps single-story default for narrow scope
266
- - enforces vertical-slice/workflow-step split quality (independently valuable,
267
- testable stories; avoid technical-layer-only splits by default)
268
- - preserves user control before persistence: accept, merge, or adjust split
269
- - asks additional targeted questions on high-risk/high-impact intake (not
270
- ambiguity-only), but keeps rounds bounded and concise
271
- - keeps low-touch compatibility: no forced decomposition when
272
- `INTAKE_GUIDED_MODE=0` unless explicitly requested
273
- - records decomposition/questioning evidence in intake artifacts
274
- (`docs/product/backlog.md`, `docs/product/acceptance.md`,
275
- `handoffs/po_to_tl.md`)
276
-
277
- ### Optional ID namespace bootstrap (US-0052)
278
-
279
- Fresh-project ID bootstrap behavior is explicit and default-off:
280
-
281
- - `ID_NAMESPACE_BOOTSTRAP=0|1` in `.cursor/scratchpad.md` (default `0`)
282
-
283
- When enabled (`1`), workflows use deterministic freshness checks before first ID
284
- creation:
285
-
286
- - no `US-` IDs in `docs/product/backlog.md`
287
- - no `DEC-` IDs in `docs/engineering/decisions.md` / `decisions/DEC-*.md`
288
- - no `R-` IDs in `docs/engineering/research.md`
289
-
290
- If eligible, first IDs start at `US-0001`, `DEC-0001`, and `R-0001`. If not
291
- eligible (or mode is off), generation continues from highest existing IDs.
292
- Historical IDs are never rewritten or renumbered. Ineligible bootstrap requests
293
- emit deterministic diagnostic `ID_BOOTSTRAP_NOT_FRESH`.
294
-
295
- ### Context compaction + tiered token profile (US-0053)
296
-
297
- Token-cost behavior is controlled by `.cursor/scratchpad.md`:
298
-
299
- - `TOKEN_PROFILE=lean|balanced|full` (default `balanced`)
300
-
301
- Profile behavior:
302
-
303
- - `lean`: reduce non-critical overhead defaults (automation/research/context
304
- breadth) while keeping mandatory quality gates intact.
305
- - `balanced`: preserve current capabilities with moderate overhead.
306
- - `full`: maximize context breadth/autonomy for high-uncertainty work.
307
-
308
- Manual override precedence:
309
-
310
- - Explicit scratchpad flag values override profile defaults for that flag.
311
- - Profile mode never disables mandatory `/qa` -> `/verify-work` -> `/release`
312
- gate semantics.
313
-
314
- Compaction behavior:
315
-
316
- - `docs/engineering/state.md` is the active hot surface.
317
- - Historical checkpoints move to append-only packs under
318
- `docs/engineering/state-archive/`.
319
- - `docs/engineering/decisions.md` stays a compact index with bounded summaries
320
- and canonical links to `decisions/DEC-xxxx.md`.
321
- - Enforced rollover thresholds:
322
- - `STATE_HOT_MAX_LINES` (default `1200`)
323
- - `STATE_HOT_MAX_CHECKPOINTS` (default `80`)
324
- `/refresh-context` must archive oldest checkpoints into deterministic
325
- `state-pack-*` files when thresholds are exceeded, keeping only bounded recent
326
- checkpoints in hot surface.
327
-
328
- `/ask` policy (read-only):
329
-
330
- - question-scoped retrieval first
331
- - targeted sections before broad file reads
332
- - bounded expansion only when unresolved
333
- - explicit "not found in artifacts" when still unresolved
334
-
335
- ### Configurable multi-target publish + confirmation gate (US-0054)
336
-
337
- Post-release publish behavior is configurable per repository:
338
-
339
- - `RELEASE_PUBLISH_MODE=disabled|confirm|auto` (default `confirm`)
340
- - `RELEASE_TARGETS_FILE=docs/engineering/release-targets.json`
341
- - `RELEASE_TARGETS_DEFAULT=` optional comma-separated default targets
342
-
343
- Supported target types include:
344
-
345
- - `npm`, `choco`, `brew`, `git`, `docker`, `cloud`
346
- - `custom` (generic command target)
347
- - `ssh` (generic server deployment over SSH)
348
-
349
- Safety defaults:
350
-
351
- - Mandatory `/release` gates are unchanged and must pass first.
352
- - `confirm` mode enforces explicit operator approval before publish execution.
353
- - Sensitive values are env-referenced (for example `tokenEnv`, `authEnv`), not
354
- inline literals.
355
-
356
- ### Deterministic status reconciliation command (US-0055)
357
-
358
- Use `/status-reconcile` to normalize status drift between canonical and derived
359
- workflow artifacts before continuation:
360
-
361
- - canonical source: `docs/product/backlog.md` story status
362
- - derived targets: `docs/product/acceptance.md`, `docs/engineering/state.md`,
363
- `handoffs/resume_brief.md`
364
- - deterministic outcomes: apply/no-op/fail-safe reason codes with audit evidence
365
- in `docs/engineering/status-normalization-report.md`
366
-
367
- This command is the bounded repair counterpart to `/memory-audit`
368
- (read-only detection).
369
-
370
- ### Optional cross-repo observability (US-0034)
371
-
372
- Use optional compatibility visibility with default-safe off behavior:
373
-
374
- - `CROSS_REPO_OBSERVABILITY=0|1` (default `0`)
375
- - `COMPATIBILITY_GATE_ON_CRITICAL=0|1` (default `1`)
376
- - `COMPATIBILITY_SOURCES=` monitored `repo/module/contract/docs` declarations
377
-
378
- When disabled (`0`), workflow adds zero required compatibility overhead.
379
-
380
- When enabled (`1`), compatibility signals/findings are tracked in:
381
-
382
- - `docs/engineering/compatibility-signals.md`
383
- - `docs/engineering/compatibility-report.md`
384
- - `docs/engineering/manifests/registry.manifest.yaml`
385
- - `docs/engineering/manifests/repo.manifest.yaml`
386
-
387
- If unresolved critical findings remain and
388
- `COMPATIBILITY_GATE_ON_CRITICAL=1`, release progression must stop for a
389
- decision gate (`COMPATIBILITY_CRITICAL_OPEN`).
390
-
391
- ### Optional component-scoped execution (US-0035)
392
-
393
- Enable scoped workflow behavior with:
394
-
395
- - `COMPONENT_SCOPE_MODE=0|1` (default `0`)
396
- - `TARGET_COMPONENTS=<comma-separated-component-ids>`
397
-
398
- When disabled (`0`), workflow adds zero required scope overhead.
399
-
400
- When enabled (`1`):
401
-
402
- - Scope declaration is tracked in `docs/engineering/component-scope.md`.
403
- - Sprint tasks should declare target components and expected impacted interfaces.
404
- - QA records unaffected-component protection checks in
405
- `docs/engineering/component-scope-report.md`.
406
- - Unapproved out-of-scope impact must block release via decision gate
407
- (`COMPONENT_SCOPE_VIOLATION_UNAPPROVED`).
408
-
409
- ### Optional spec-pack documentation (US-0031)
410
-
411
- Optional Design Concept, CRS, and Technical Specification artifacts are
412
- controlled by:
413
-
414
- - `SPEC_PACK_MODE=0|1` (default `0`)
415
-
416
- When disabled (`0`), intake/architecture/execute/qa/release add no required
417
- spec-pack steps (zero overhead).
418
-
419
- When enabled (`1`):
420
-
421
- - Canonical paths per story: `docs/engineering/spec-pack/<story_id>-design-concept.md`,
422
- `docs/engineering/spec-pack/<story_id>-crs.md`,
423
- `docs/engineering/spec-pack/<story_id>-technical-specification.md`.
424
- - Minimum required sections and ownership are in `docs/engineering/runbook.md`.
425
- - Release gate validates completeness and blocks with `SPEC_PACK_INCOMPLETE` when
426
- required sections are missing.
427
-
428
- ### Optional user-guide documentation (US-0032)
429
-
430
- Optional per-feature user guides (end-user how-to docs) are controlled by:
431
-
432
- - `USER_GUIDE_MODE=0|1` (default `0`)
433
-
434
- When disabled (`0`), intake/architecture/sprint-plan/execute/qa/release add no
435
- required user-guide steps or blocking checks (zero overhead).
436
-
437
- When enabled (`1`):
438
-
439
- - Canonical path per feature story: `docs/user-guides/US-xxxx.md`.
440
- - Minimum required sections: Purpose, Prerequisites, Usage steps, Example,
441
- Limitations, Troubleshooting (see `docs/engineering/runbook.md` and
442
- `docs/user-guides/README.md`).
443
- - Release gate validates guide completeness and blocks with `USER_GUIDE_INCOMPLETE`
444
- when enabled and required sections are missing.
445
- - User guides are end-user only; they do not duplicate spec-pack (US-0031) content.
446
-
447
- ### Release notes model (US-0040)
448
-
449
- Release history is sprint-scoped and queue-backed:
450
-
451
- - Canonical sprint notes: `handoffs/releases/Sxxxx-release-notes.md`
452
- - Canonical queue tracker: `handoffs/release_queue.md`
453
- - Legacy compatibility pointer: `handoffs/release_notes.md`
454
-
455
- Deterministic release semantics:
456
- - Only target sprint artifacts/queue row may be mutated during one `/release` run.
457
- - Entering release flow sets target row to `unreleased`.
458
- - Successful finalization transitions same row to `released`.
459
- - Unresolved sprint identity or queue/notes mismatch fails closed with reason
460
- codes and remediation guidance; no destructive reconciliation by default.
461
-
462
- ### Post-QA release issue workflow (US-0042)
463
-
464
- Release gate chain (US-0039): `/release` enforces mandatory gates in order — check-in test, QA completion, UAT completion — then finalization. Blank optional runbook keys (`LINT_COMMAND`, `TYPECHECK_COMMAND`) do not block release; they are reported as skipped.
465
-
466
- If a problem appears **after QA** (during `/release`), record it separately from
467
- QA findings:
468
-
469
- - Release findings artifact: `sprints/Sxxxx/release-findings.md`
470
- - Release-to-dev handoff: `handoffs/release_to_dev.md`
471
-
472
- Boundary:
473
- - QA-phase issues -> `sprints/Sxxxx/qa-findings.md`
474
- - Post-QA release-gate issues -> `sprints/Sxxxx/release-findings.md`
475
-
476
- Each blocked release finding should include reason code, evidence refs,
477
- remediation, and rerun criteria.
478
-
479
- ### Backlog reconciliation invariant (US-0043)
480
-
481
- Release completion must not leave stale backlog status for target sprint stories.
482
- At release finalization:
483
-
484
- - reconcile target story status to `DONE` using canonical release evidence;
485
- - reconcile target story acceptance checkboxes to checked state;
486
- - mutate only target sprint stories (never unrelated backlog entries);
487
- - fail safe with `BACKLOG_STATUS_DRIFT` if contradiction remains (e.g. released
488
- sprint but backlog still `OPEN`/unchecked).
489
-
490
- ### Canonical story status + normalization guard (US-0045)
491
-
492
- - `docs/product/backlog.md` is canonical for story `OPEN|DONE` status.
493
- - `docs/product/acceptance.md` and `docs/engineering/state.md` are derived views
494
- reconciled from canonical backlog status plus release evidence.
495
- - One-time normalization baseline is recorded in
496
- `docs/engineering/status-normalization-report.md`.
497
- - Contradictory resolution at release/reconciliation boundaries fails safe with:
498
- - `BACKLOG_STATUS_DRIFT`
499
- - `CANONICAL_STATUS_CONFLICT`
500
-
501
- ### Agent isolation model
502
-
503
- - Every phase command runs in a fresh agent/subagent context.
504
- - Handoff files are the only cross-phase memory (`handoffs/*.md` + artifact
505
- files).
506
- - Never rely on "ignore prior chat"; use a new context boundary instead.
507
- - `/auto` is orchestration only: it calls phase subagents and transfers context
508
- through artifacts.
509
-
510
- #### Per-phase isolation evidence (US-0048 / DEC-0029)
511
-
512
- Isolation is enforced with auditable evidence written to `docs/engineering/state.md`.
513
- Each phase run appends:
514
-
515
- - `phase_id`, `role`, `fresh_context_marker`, `timestamp`, `evidence_ref`
516
-
517
- Missing/invalid/stale evidence fails closed with reason codes:
518
- `PHASE_CONTEXT_ISOLATION_MISSING`, `PHASE_CONTEXT_ISOLATION_VIOLATION`,
519
- `ISOLATION_EVIDENCE_STALE`, `ISOLATION_EVIDENCE_INVALID`.
520
-
521
- #### Strict runtime proof (US-0056 / DEC-0038)
522
-
523
- Per-phase isolation also requires strict runtime attestation tuples at
524
- boundaries (not artifact fields alone):
525
-
526
- - `orchestrator_run_id`, `runtime_proof_id`, `phase_id`, `role`
527
- - `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`
528
-
529
- Fail-closed reason codes:
530
- `RUNTIME_PROOF_MISSING`, `RUNTIME_PROOF_INVALID`, `RUNTIME_PROOF_REUSED`,
531
- `RUNTIME_PROOF_STALE`, `RUNTIME_PROOF_AMBIGUOUS_LINK`.
532
-
533
- `/auto`, `/verify-work`, and `/release` must validate these tuples before
534
- continuation/finalization.
535
-
536
- ### Lightweight interaction
537
-
538
- Use `/ask` when you want to query the project without triggering the workflow:
539
-
540
- - "What's the current sprint status?"
541
- - "Which stories are still open?"
542
- - "How does the upgrade mode work?"
543
- - "What decision was made about X?"
544
-
545
- `/ask` reads the project artifacts (state, backlog, architecture, decisions, sprint
546
- progress) and answers from them. It never creates or modifies files. If your question
547
- reveals a bug or feature idea, it will suggest running `/intake`.
548
-
549
- ### Memory drift auditing
550
-
551
- Use `/memory-audit` to check whether project memory artifacts still match
552
- repository reality. This is a read-only, non-blocking command that produces an
553
- advisory report at `docs/engineering/memory-drift-report.md`.
554
-
555
- **When to run:**
556
-
557
- - **Pre-handoff**: before writing any role handoff artifact.
558
- - **Pre-QA**: before `/qa` or `/verify-work`.
559
- - **Pre-release**: before `/release`.
560
- - **Ad-hoc**: after external code changes, long pauses, or whenever artifacts
561
- feel stale.
562
-
563
- **How to interpret output:**
564
-
565
- The report contains a severity summary (`high` / `medium` / `low`) and a
566
- findings table with concrete evidence for each inconsistency. High-severity
567
- findings should be resolved before the next handoff or release. Medium and low
568
- findings can be addressed during `/refresh-context` or the next sprint.
569
-
570
- The report also includes a reference-only "Template drift" section. Template
571
- drift remediation belongs to US-0017 — `/memory-audit` only flags it for
572
- awareness.
573
-
574
- **Follow-up commands:**
575
-
576
- - `/refresh-context` update stale artifacts.
577
- - `/sprint-plan` — if new work is discovered.
578
- - `/verify-work` if acceptance status needs re-validation.
579
- - `/intake` if findings reveal a new story or bug.
580
-
581
- ### Workflow diagrams
582
-
583
- ```mermaid
584
- flowchart TD
585
- Intake[/intake/] --> Discovery[/discovery/]
586
- Discovery --> Research[/research/]
587
- Research --> Architecture[/architecture/]
588
- Architecture --> SprintPlan[/sprint-plan/]
589
- SprintPlan --> PlanVerify[/plan-verify/]
590
- PlanVerify --> Execute[/execute/]
591
- Execute --> QA[/qa/]
592
- QA -->|fixes needed| Execute
593
- QA --> VerifyWork[/verify-work/]
594
- VerifyWork --> Release[/release/]
595
- Release --> Refresh[/refresh-context/]
596
- Execute --> Pause[/pause/]
597
- QA --> Pause
598
- Release --> Pause
599
- Pause --> Resume[/resume/]
600
- Resume --> Execute
601
- ```
602
-
603
- ```mermaid
604
- flowchart TD
605
- Start[Idea] --> Intake2[/intake/]
606
- Intake2 -->|DecisionGate| Decision{DecisionRequired}
607
- Decision -->|ChooseOption| Discovery2[/discovery/]
608
- Decision -->|ChooseOption| Research2[/research/]
609
- Decision -->|ChooseOption| Architecture2[/architecture/]
610
- Decision -->|ChooseOption| SprintPlan2[/sprint-plan/]
611
- Decision -->|ChooseOption| PlanVerify2[/plan-verify/]
612
- Decision -->|ChooseOption| Execute2[/execute/]
613
- Decision -->|ChooseOption| QA2[/qa/]
614
- Decision -->|ChooseOption| VerifyWork2[/verify-work/]
615
- Decision -->|ChooseOption| Release2[/release/]
616
- Decision -->|ChooseOption| Refresh2[/refresh-context/]
617
- Decision -->|ChooseOption| Pause2[/pause/]
618
- Discovery2 --> Research2
619
- Research2 --> Architecture2
620
- Architecture2 --> SprintPlan2
621
- SprintPlan2 --> PlanVerify2
622
- PlanVerify2 --> Execute2
623
- Execute2 --> QA2
624
- QA2 -->|fixes needed| Execute2
625
- QA2 --> VerifyWork2
626
- VerifyWork2 --> Release2
627
- Release2 --> Refresh2
628
- Execute2 --> Pause2
629
- QA2 --> Pause2
630
- Release2 --> Pause2
631
- Pause2 --> Resume2[/resume/]
632
- Resume2 --> Execute2
633
- Execute2 --> HandoffDevQA[handoffs/dev_to_qa.md]
634
- QA2 --> HandoffQAD[handoffs/qa_to_dev.md]
635
- Intake2 --> HandoffPOTL[handoffs/po_to_tl.md]
636
- SprintPlan2 --> HandoffTLDev[handoffs/tl_to_dev.md]
637
- ```
638
-
639
- ### Automation modes
640
-
641
- Configure in `.cursor/scratchpad.md`:
642
-
643
- - `AUTO_FLOW_MODE=manual|auto_until_decision`
644
- - `manual`: you trigger each phase/command yourself.
645
- - `auto_until_decision`: `/auto` continues by spawning fresh phase subagents until a decision gate, blocker, or pause boundary.
646
- - `PHASE_MODE=interactive|auto`
647
- - `interactive`: agent asks clarifying questions more often.
648
- - `auto`: agent minimizes prompts and proceeds with best effort.
649
- - `PERMISSION_MODE=interactive|auto`
650
- - `interactive`: ask before routine actions.
651
- - `auto`: reduce routine permission prompts.
652
- - `RUN_TESTS_ON_EDIT=0|1`
653
- - `1`: runs configured tests after meaningful edits.
654
- - `0`: tests only when you explicitly run QA/test phases.
655
- - `LOOP_UNTIL_GREEN=0|1`
656
- - `1`: keep iterating fix -> test until green (bounded).
657
- - `0`: run one pass and report failures.
658
- - `AUTO_IMPLEMENTATION_LOOP=0|1`
659
- - `1`: enables execute -> QA -> execute loop automatically with new Dev/QA subagent instances on each cycle.
660
- - `AUTO_LOOP_MAX_CYCLES=<n>`
661
- - safety cap for auto loops (recommended `3-7`, default `5`).
662
- - `AUTO_PAUSE_REQUEST=0|1`
663
- - `1`: request graceful stop at next safe boundary.
664
- - `AUTO_PAUSE_POLICY=after_task|after_phase`
665
- - `after_task`: faster stop, more frequent boundaries.
666
- - `after_phase`: cleaner checkpoints, fewer interruptions.
667
-
668
- ### Sync policy (US-0038)
669
-
670
- Phase-triggered sync is policy-controlled and safe by default.
671
-
672
- Scratchpad controls:
673
-
674
- - `SYNC_POLICY_MODE=disabled|manual|by_phase|by_milestone|custom_phase_list`
675
- - `SYNC_CUSTOM_PHASES=<comma-separated canonical phases>`
676
- - `ALLOW_AUTO_PUSH=0|1`
677
- - `AUTO_PUSH_BRANCH_ALLOWLIST=<comma-separated branches/patterns>`
678
-
679
- Default-safe behavior:
680
-
681
- - Default mode is `manual` with `ALLOW_AUTO_PUSH=0` (no automatic push).
682
- - `disabled` and `manual` add near-zero overhead and preserve manual workflows.
683
- - Sync policy is evaluated only at completed phase boundaries.
684
-
685
- Guarded auto-push conditions (all must pass):
686
-
687
- 1. Boundary matches configured mode.
688
- 2. Auto-push is explicitly enabled (`ALLOW_AUTO_PUSH=1`).
689
- 3. QA-first safety holds (feature work cannot auto-push pre-QA).
690
- 4. No unresolved blocking QA findings/critical issues.
691
- 5. Branch safety holds (protected/default branches denied unless allowlisted).
692
- 6. Check chain passes (`TEST_COMMAND` required; optional lint/typecheck only if configured).
693
-
694
- Deterministic reason codes include:
695
- `SYNC_DISABLED`, `MANUAL_MODE_NO_AUTO`, `PRE_QA_AUTOPUSH_FORBIDDEN`,
696
- `BLOCKING_QA_FINDINGS`, `BRANCH_NOT_ALLOWLISTED`, `TEST_COMMAND_MISSING`,
697
- `TEST_FAILED`, `TEST_TIMEOUT`, `OPTIONAL_CHECK_FAILED`, `SYNC_PUSHED`.
698
-
699
- ### Full scratchpad reference (detailed)
700
-
701
- - `MAGIC_CONTEXT_STRICT=0|1`
702
- - `1`: enforces context refresh discipline after code edits.
703
- - `DONE=0|1`
704
- - `1`: stop hook reminder loops when session is complete.
705
- - `MAGIC_BENCH_SESSION=<id>`
706
- - enables live benchmark event logging under one session id.
707
- - `AUTO_INSTALL_DEPS=0|1`
708
- - `1`: agent may install dependencies/runtimes automatically.
709
- - `AUTO_RELEASE_NOTES=0|1`
710
- - `1`: auto-generate `handoffs/release_notes.md`.
711
- - `REMOTE_EXECUTION=0|1`
712
- - `1`: allow remote/docker execution if configured.
713
- - `REMOTE_CONFIG=.cursor/remote.json`
714
- - path to remote execution server config.
715
-
716
- ### Remote execution config (`.cursor/remote.json`)
717
-
718
- Remote config is optional and mode-aware:
719
-
720
- - `REMOTE_EXECUTION=0` (default): skip remote config checks entirely.
721
- - `REMOTE_EXECUTION=1`: validate `.cursor/remote.json` first and fail fast on
722
- missing/malformed/invalid or insecure config.
723
-
724
- Canonical contract (DEC-0016):
725
-
726
- - Required root fields:
727
- - `version` (integer)
728
- - `defaultTarget` (string)
729
- - `targets` (array)
730
- - Required target fields:
731
- - `id` (string)
732
- - `type` (`docker|ssh|vm`)
733
- - `enabled` (boolean)
734
- - `host` (string)
735
- - `port` (integer `1..65535`)
736
- - `workspaceRoot` (string)
737
- - Optional:
738
- - `auth.mode` (`none|env`)
739
- - If `auth.mode=env`, use env-var references only (`tokenEnv`,
740
- `passwordEnv`, `privateKeyPathEnv`, ...).
741
-
742
- Two safe target examples are shipped in:
743
-
744
- - `.cursor/remote.json` (active repo)
745
- - `template/.cursor/remote.json` (template parity copy)
746
-
747
- The examples include:
748
-
749
- - `local-docker`: local network/docker-like endpoint.
750
- - `remote-vm-ssh`: remote VM/SSH-like endpoint.
751
-
752
- No secrets policy:
753
-
754
- - Never commit inline tokens/passwords/private keys in `remote.json`.
755
- - Commit env-var reference names only.
756
-
757
- Fail-fast error format:
758
-
759
- - `[REMOTE_CONFIG_ERROR] <path>: expected <rule>, got <actual>. Fix: <hint>.`
760
-
761
- Troubleshooting quick guide:
762
-
763
- - Missing file in remote mode:
764
- - Create `.cursor/remote.json` from the template copy, or set
765
- `REMOTE_EXECUTION=0`.
766
- - Invalid enum/type/range:
767
- - Update the failing field to match allowed values/ranges.
768
- - Malformed JSON:
769
- - Fix JSON syntax and retry.
770
- - Secret-like inline value detected:
771
- - Replace literal secret with an env-var reference field.
772
-
773
- Team/local (recommended in `.cursor/scratchpad.local.md`):
774
-
775
- - `TEAM_MODE=0|1`
776
- - `TEAM_MEMBER=<your-id>`
777
- - `ACTIVE_TASK_IDS=T-12,T-13`
778
-
779
- ### Automated feature loop (optional)
780
-
781
- Enable:
782
-
783
- - `AUTO_FLOW_MODE=auto_until_decision`
784
- - `PHASE_MODE=auto`
785
- - `PERMISSION_MODE=auto`
786
- - `RUN_TESTS_ON_EDIT=1`
787
- - `LOOP_UNTIL_GREEN=1`
788
- - `AUTO_IMPLEMENTATION_LOOP=1`
789
- - `AUTO_LOOP_MAX_CYCLES=5`
790
-
791
- Then run `/auto`.
792
-
793
- Graceful stop (for shutdown/end of day):
794
-
795
- 1. Set `AUTO_PAUSE_REQUEST=1`
796
- 2. Flow stops at next configured boundary (`AUTO_PAUSE_POLICY`)
797
- 3. `/pause` artifacts are written
798
- 4. Next day run `/resume` or `/auto`
799
-
800
- ### Recommended profiles
801
-
802
- **Max automation (high autonomy):**
803
-
804
- - `AUTO_FLOW_MODE=auto_until_decision`
805
- - `PHASE_MODE=auto`
806
- - `PERMISSION_MODE=auto`
807
- - `RUN_TESTS_ON_EDIT=1`
808
- - `LOOP_UNTIL_GREEN=1`
809
- - `AUTO_IMPLEMENTATION_LOOP=1`
810
- - `AUTO_LOOP_MAX_CYCLES=5`
811
- - `AUTO_INSTALL_DEPS=1` (optional, if you trust auto installs)
812
- - `AUTO_PAUSE_POLICY=after_phase`
813
-
814
- **Safer automation (recommended for most teams):**
815
-
816
- - same as above, but keep:
817
- - `PERMISSION_MODE=interactive`
818
- - `AUTO_INSTALL_DEPS=0`
819
- - `AUTO_PAUSE_POLICY=after_task`
820
-
821
- ### Quality chain (3-layer auto-fix)
822
-
823
- its-magic provides a complete quality chain that catches issues at three levels.
824
- Each layer catches problems the previous layer missed:
825
-
826
- ```text
827
- ┌─────────────────────────────────────────────────────────────────┐
828
- │ Layer 1: Cursor AI loop (in-editor) OFF by default │
829
- │ AUTO_IMPLEMENTATION_LOOP + LOOP_UNTIL_GREEN │
830
- │ execute → QA → fix → execute (bounded by AUTO_LOOP_MAX_CYCLES)│
831
- └──────────────────────────┬──────────────────────────────────────┘
832
- code ready to push
833
- ┌──────────────────────────▼──────────────────────────────────────┐
834
- │ Layer 2: validate-and-push (local pre-push) MANUAL (run it)│
835
- │ scripts/validate-and-push.sh / .ps1 │
836
- │ test → format → lint-fix → test → commit + push │
837
- └──────────────────────────┬──────────────────────────────────────┘
838
- pushed to GitHub
839
- ┌──────────────────────────▼──────────────────────────────────────┐
840
- │ Layer 3: CI auto-fix (GitHub Actions) OFF by default │
841
- │ .github/workflows/ci.yml │
842
- │ test/lint → auto-fix → commit → re-run (up to 3 retries) │
843
- └─────────────────────────────────────────────────────────────────┘
844
- ```
845
-
846
- | Layer | Default | Enable |
847
- |-------|---------|--------|
848
- | 1 - Cursor AI loop | off | Set `AUTO_IMPLEMENTATION_LOOP=1` + `LOOP_UNTIL_GREEN=1` in scratchpad |
849
- | 2 - validate-and-push | manual | Run `scripts/validate-and-push.sh` or `.ps1` before pushing |
850
- | 3 - CI auto-fix | off | Set `CI_AUTO_FIX: true` in `docs/engineering/runbook.md` |
851
-
852
- CI itself (tests, lint, typecheck) always runs on push/PR. Only the **auto-fix
853
- retry loop** is gated behind `CI_AUTO_FIX`. When disabled, CI still reports
854
- failures -- it just won't try to fix and commit automatically.
855
-
856
- All commands are read from `docs/engineering/runbook.md`. Fill in your
857
- project-specific commands once and every layer uses them:
858
-
859
- ```text
860
- TEST_COMMAND: npm test
861
- LINT_COMMAND: npx eslint .
862
- LINT_FIX_COMMAND: npx eslint --fix .
863
- FORMAT_COMMAND: npx prettier --write .
864
- CI_AUTO_FIX: true
865
- ```
866
-
867
- #### Layer 1: Cursor AI loop
868
-
869
- Enabled via scratchpad flags (see [Automation modes](#automation-modes)).
870
- The AI runs execute → QA → fix cycles inside Cursor until tests pass or
871
- the safety cap (`AUTO_LOOP_MAX_CYCLES`) is reached.
872
-
873
- #### Layer 2: Local validate-and-push
874
-
875
- Run before pushing to catch anything the AI loop missed:
876
-
877
- ```bash
878
- # Bash (Linux / macOS)
879
- sh scripts/validate-and-push.sh
880
-
881
- # PowerShell (Windows)
882
- powershell scripts/validate-and-push.ps1
883
- powershell scripts/validate-and-push.ps1 -MaxAttempts 3
884
- ```
885
-
886
- The script:
887
- 1. Runs `FORMAT_COMMAND` and `LINT_FIX_COMMAND` to auto-fix what it can
888
- 2. Runs `LINT_COMMAND` and `TEST_COMMAND` to verify
889
- 3. If checks fail, pauses and waits for you to fix
890
- 4. Re-runs (up to 5 attempts, configurable)
891
- 5. When green, commits and pushes automatically
892
-
893
- Use `-NoCommit` (PowerShell) or `false` as third arg (Bash) to skip auto-push.
894
-
895
- #### Layer 3: CI auto-fix (GitHub Actions)
896
-
897
- **Disabled by default.** Set `CI_AUTO_FIX: true` in `docs/engineering/runbook.md`
898
- to enable. When enabled and CI fails after a push, the auto-fix job kicks in:
899
-
900
- ```text
901
- push / PR ──> checks ──> PASS ──> done
902
-
903
- FAIL
904
-
905
- auto-fix job
906
-
907
- run LINT_FIX_COMMAND
908
- run FORMAT_COMMAND
909
-
910
- changes found?
911
- ╱ ╲
912
- yes no
913
- │ │
914
- commit + push report failure
915
- │ (manual fix needed)
916
- CI re-runs
917
- (up to 3x)
918
- ```
919
-
920
- Auto-fix commits appear as `ci: auto-fix attempt N/3`. After 3 retries the
921
- workflow stops and points you to `scripts/validate-and-push` for local fixing.
922
-
923
- ## Examples
924
-
925
- ### Example 1: New feature from idea
926
-
927
- 1. `/intake`
928
- 2. `/research`
929
- 3. `/architecture`
930
- 4. `/sprint-plan`
931
- 5. `/plan-verify`
932
- 6. `/execute`
933
- 7. `/qa`
934
- 8. `/verify-work`
935
- 9. `/release`
936
- 10. `/refresh-context`
937
-
938
- ### Example 2: Mid-flight idea change
939
-
940
- 1. Set `AUTO_PAUSE_REQUEST=1`
941
- 2. Run `/intake` to update story/acceptance
942
- 3. Re-run `/sprint-plan` + `/plan-verify`
943
- 4. Resume via `/auto`
944
-
945
- ### Example 3: Pause/resume
946
-
947
- 1. `/pause`
948
- 2. Close work
949
- 3. `/resume` next session
950
-
951
- ### Deterministic `/auto` continuation
952
-
953
- When resuming mid-process, `/auto` resolves start phase deterministically:
954
-
955
- 1. explicit `/auto start-from=<phase>`
956
- 2. `handoffs/resume_brief.md`
957
- 3. conservative `docs/engineering/state.md` fallback
958
- 4. fail-fast (no guessing)
959
-
960
- Canonical phases:
961
- `intake`, `discovery`, `research`, `architecture`, `sprint-plan`,
962
- `plan-verify`, `execute`, `qa`, `verify-work`, `release`, `refresh-context`.
963
-
964
- Fail-fast message format:
965
- `[AUTO_RESUME_ERROR] <code>: <summary>. Source=<source>. Fix: <action>.`
966
-
967
- Compatibility and safety:
968
- - Manual/interactive workflow stays unchanged unless `/auto` continuation is used.
969
- - Existing stop conditions remain enforced (decision gate, missing input,
970
- pause request, loop max).
971
-
972
- ### Optional `/auto` backlog-drain mode (US-0044)
973
-
974
- If you want `/auto` to continue across multiple planned stories in one run,
975
- enable backlog-drain switches in `.cursor/scratchpad.md`:
976
-
977
- - `AUTO_BACKLOG_DRAIN=1`
978
- - `AUTO_BACKLOG_MAX_STORIES=<n>`
979
- - `AUTO_BACKLOG_ON_BLOCK=stop|skip`
980
- - `AUTO_STORY_SELECTION=priority_then_backlog_order`
981
-
982
- Default-safe behavior remains unchanged with `AUTO_BACKLOG_DRAIN=0`.
983
-
984
- ### Explicit `/sprint-plan --bulk` mode (US-0046)
985
-
986
- By default, `/sprint-plan` plans one scope at a time. For multi-story planning,
987
- run explicit bulk mode:
988
-
989
- - `/sprint-plan --bulk`
990
-
991
- Bulk planning remains bounded and deterministic via `.cursor/scratchpad.md`:
992
-
993
- - `SPRINT_BULK_MAX_STORIES=<n>`
994
- - `SPRINT_BULK_MAX_SPRINTS=<n>`
995
- - `SPRINT_BULK_SELECTION=priority_then_backlog_order`
996
-
997
- Bounded stop reason codes:
998
- `SPRINT_BULK_MAX_STORIES_REACHED`, `SPRINT_BULK_MAX_SPRINTS_REACHED`,
999
- `SPRINT_BULK_NO_ELIGIBLE_STORIES`, `SPRINT_BULK_MISSING_ACCEPTANCE`.
1000
-
1001
- ### Explicit `/auto --execute-bulk` mode (US-0047)
1002
-
1003
- Bulk execution is explicit-mode only. Default `/auto` behavior remains unchanged.
1004
-
1005
- Enable either way:
1006
-
1007
- - one-run explicit argument: `/auto --execute-bulk`
1008
- - scratchpad switch: `AUTO_EXECUTE_BULK=1`
1009
-
1010
- Deterministic controls in `.cursor/scratchpad.md`:
1011
-
1012
- - `AUTO_EXECUTE_MAX_ITEMS=<n>`
1013
- - `AUTO_EXECUTE_ON_BLOCK=stop|skip`
1014
- - `AUTO_EXECUTE_SELECTION=planned_then_priority`
1015
- - `AUTO_TEAM_SCOPE_ENFORCE=0|1`
1016
-
1017
- Deterministic reason codes:
1018
- `EXEC_BULK_MAX_ITEMS_REACHED`, `EXEC_BULK_NO_ELIGIBLE_ITEMS`,
1019
- `EXEC_BULK_ITEM_BLOCKED_STOP`, `EXEC_BULK_ITEM_BLOCKED_SKIPPED`,
1020
- `EXEC_TEAM_SCOPE_BLOCKED`, `EXEC_TEAM_SCOPE_SKIPPED`.
1021
-
1022
- Team-mode safety:
1023
- - In `TEAM_MODE=1`, bulk execute records `TEAM_MODE`, `TEAM_MEMBER`,
1024
- `ACTIVE_TASK_IDS` in state breadcrumbs.
1025
- - With `AUTO_TEAM_SCOPE_ENFORCE=1`, out-of-scope tasks are blocked/skipped
1026
- deterministically and never mutated.
1027
-
1028
- ### Example 4: Existing project onboarding
1029
-
1030
- 1. `/map-codebase`
1031
- 2. Review generated mapping artifacts
1032
- 3. Continue with `/intake` or `/architecture`
1033
-
1034
- ## Other useful capabilities
1035
-
1036
- ### Voice input (multilingual)
1037
-
1038
- Voice is an input layer only; it feeds normal slash commands.
1039
-
1040
- - OS dictation
1041
- - Cursor voice (if available)
1042
- - Local STT tooling
1043
-
1044
- Reliable pattern:
1045
-
1046
- - bind `/intake ` insertion shortcut
1047
- - dictate only the content after the command
1048
-
1049
- ### Repository layout (quick orientation)
1050
-
1051
- - `.cursor/`: commands, rules, agents, hooks, skills, scratchpad.
1052
- - `docs/`: product + engineering docs.
1053
- - `sprints/`: sprint planning/tracking.
1054
- - `handoffs/`: role-to-role transfers.
1055
- - `decisions/`: decision records.
1056
- - `.github/workflows/`: CI/CD templates.
1057
-
1058
- ## Developer and release deep-dive
1059
-
1060
- ### CI/CD via runbook
1061
-
1062
- Workflows read keys from `docs/engineering/runbook.md`:
1063
-
1064
- - `TEST_COMMAND`
1065
- - `LINT_COMMAND`
1066
- - `TYPECHECK_COMMAND`
1067
- - `DEPLOY_STAGING_COMMAND`
1068
- - `DEPLOY_PROD_COMMAND`
1069
-
1070
- Unset keys are skipped. The template ships with empty values for `LINT_COMMAND`,
1071
- `FORMAT_COMMAND`, and `TYPECHECK_COMMAND` -- this is intentional. its-magic is a
1072
- template/installer project; fill in your project-specific commands after setup.
1073
-
1074
- US-0015 intent contract:
1075
- - Empty optional runbook keys are valid defaults for this repository type.
1076
- - They must not be treated as missing required configuration.
1077
-
1078
- ### Installer internals
1079
-
1080
- - `installer.ps1` (Windows)
1081
- - `installer.sh` (macOS/Linux)
1082
- - `installer.py` (fallback)
1083
-
1084
- Modes: `missing`, `overwrite`, `interactive`, `upgrade` (+ optional backup).
1085
-
1086
- ### Release automation
1087
-
1088
- Unified release scripts:
1089
-
1090
- - Windows: `scripts/release-all.ps1`
1091
- - macOS/Linux: `scripts/release-all.sh`
1092
-
1093
- NPM helpers:
1094
-
1095
- - `npm run release:all`
1096
- - `npm run release:all:patch|minor|major|beta|dry`
1097
- - `npm run release:npm-only|choco-only|brew-only`
1098
-
1099
- Release script flow:
1100
-
1101
- 1. bump `package.json` version
1102
- 2. publish npm
1103
- 3. create GitHub release
1104
- 4. update/publish Chocolatey package
1105
- 5. update/push Homebrew formula (stable or beta)
1106
-
1107
- ```mermaid
1108
- flowchart LR
1109
- ReleaseAll[scripts/release-all.*] --> VerCheck{version has -?}
1110
- VerCheck -->|stable| NPM["npm publish --tag latest"]
1111
- VerCheck -->|prerelease| NPMBeta["npm publish --tag beta"]
1112
- ReleaseAll --> GH["gh release create"]
1113
- VerCheck -->|prerelease| GHPre["--prerelease flag"]
1114
- GH --> Choco[choco pack + push]
1115
- GH --> BrewCheck{prerelease?}
1116
- BrewCheck -->|no| BrewStable[its-magic.rb]
1117
- BrewCheck -->|yes| BrewBeta[its-magic-beta.rb]
1118
- NPM --> U1["npx its-magic"]
1119
- NPMBeta --> U1b["npx its-magic@beta"]
1120
- Choco --> U2["choco install its-magic"]
1121
- Choco --> U2b["choco install its-magic --pre"]
1122
- BrewStable --> U3["brew install its-magic"]
1123
- BrewBeta --> U3b["brew install its-magic-beta"]
1124
- ```
1125
-
1126
- Prereqs:
1127
-
1128
- - `npm login`
1129
- - `gh auth login`
1130
- - Chocolatey API key (if choco publish)
1131
- - Homebrew tap repo for formula distribution
1132
-
1133
- ### Package manager installation matrix
1134
-
1135
- | Manager | Stable | Beta / Pre-release |
1136
- |------------|-------------------------------------------|---------------------------------------------|
1137
- | npm/npx | `npx its-magic --target . --mode missing` | `npx its-magic@beta --target . --mode missing` |
1138
- | Chocolatey | `choco install its-magic` | `choco install its-magic --pre` |
1139
- | Homebrew | `brew install USER/tap/its-magic` | `brew install USER/tap/its-magic-beta` |
1140
-
1141
- ### Release package contents
1142
-
1143
- Published npm package includes runtime content only (commands/rules/agents/docs/installers).
1144
-
1145
- Excluded from npm package:
1146
-
1147
- - `benchmarks/`
1148
- - `tests/`
1149
- - `packaging/`
1150
- - `Plan.md`
1151
-
1152
- ### Benchmarks
1153
-
1154
- - Main benchmark: `benchmarks/run-bench.ps1` or `benchmarks/run-bench.sh`
1155
- - Live benchmark: `benchmarks/live/run-live-bench.*`
1156
- - Prompted benchmark: `benchmarks/prompts/run-prompts.*`
1157
- - Headless benchmark: `benchmarks/headless/run-headless.*`
1158
-
1159
- Reports:
1160
-
1161
- - `benchmarks/bench-report.md`
1162
- - `benchmarks/live/live-bench-report.md`
1163
- - `benchmarks/headless/headless-report.md`
1164
- - `benchmarks/headless/protocol.md`
1165
-
1166
- ```mermaid
1167
- flowchart TD
1168
- StartBench[Start benchmark] --> SelectScenario[Load scenarios]
1169
- SelectScenario --> InstallKit[Install its-magic into temp workspace]
1170
- InstallKit --> RunChecks[Validate required files/sections]
1171
- RunChecks --> BenchReport[Write benchmarks/bench-report.md]
1172
- ```
1173
-
1174
- ```mermaid
1175
- flowchart TD
1176
- StartLive[Start live benchmark] --> SetSession[Set MAGIC_BENCH_SESSION]
1177
- SetSession --> RunCommands[Run /* commands in Cursor]
1178
- RunCommands --> LogHooks[Hook telemetry to bench-log.jsonl]
1179
- LogHooks --> LiveReport[Write live-bench-report.md]
1180
- ```
1181
-
1182
- ```mermaid
1183
- flowchart TD
1184
- StartHeadless[Start headless run] --> LoadPrompt[Load prompt blocks]
1185
- LoadPrompt --> TempWorkspace[Create temp workspace]
1186
- TempWorkspace --> InstallHeadless[Install its-magic]
1187
- InstallHeadless --> RunAgent[agent -p --force for each step]
1188
- RunAgent --> ValidateOutputs[Validate files/sections/smoke checks]
1189
- ValidateOutputs --> WriteProtocol[Write protocol.md]
1190
- WriteProtocol --> WriteHeadlessReport[Write headless-report.md]
1191
- ```
1192
-
1193
- ### Rules
1194
-
1195
- - `core.mdc`: phase flow, context pack, pause/resume, remote usage.
1196
- - `quality.mdc`: small steps, tests/quality, optional auto-install.
1197
- - `coding-standards.mdc`: strict language best practices and code quality rules.
1198
- - `handoffs.mdc`: handoffs + state updates required.
1199
- - `escalation.mdc`: decision gate and stop conditions.
1200
-
1201
- ### Hooks
1202
-
1203
- - `beforeShellExecution`: blocks dangerous commands.
1204
- - `beforeReadFile`: warns on secret-like files.
1205
- - `afterFileEdit`: tracks code edits vs context refresh.
1206
- - `stop`: reminds context refresh when needed.
1207
-
1208
- ### Artifacts (single source of truth)
1209
-
1210
- - `docs/product/*`: vision, backlog, acceptance.
1211
- - `docs/engineering/*`: architecture, decisions, state, runbook.
1212
- - `sprints/Sxxxx/*`: sprint scope, tasks, progress, QA findings, summary.
1213
- - `decisions/*`: decision records.
1214
- - `handoffs/*`: role-to-role transfer notes.
1
+ # its-magic — AI dev team
2
+
3
+ [GitHub Repository](https://github.com/fl0wm0ti0n/its-magic)
4
+
5
+ Happy coding! Build something awesome.
6
+
7
+ Drop-in template repo that implements a structured its-magic workflow in Cursor:
8
+ intake -> discovery -> architecture -> sprint plan -> execute -> QA -> release,
9
+ with pause/resume, decision gates, and persistent artifacts.
10
+
11
+ ## Features (what its-magic can do)
12
+
13
+ - Structured phase workflow with explicit artifacts.
14
+ - Artifact-first memory (state in files, not chat only).
15
+ - Decision gate + escalation (`decisions/DEC-xxxx.md`).
16
+ - Pause/resume with checkpoints (`handoffs/resume_brief.md`).
17
+ - Automated execute/QA loop with safety caps (optional).
18
+ - 3-layer quality chain: AI loop → local validate-and-push → CI auto-fix.
19
+ - CI/CD templates driven by `docs/engineering/runbook.md`.
20
+ - Team-friendly local overrides (`scratchpad.local.md`).
21
+ - Optional remote/docker execution and autonomous installs.
22
+ - Built-in benchmarks (live, prompted, headless).
23
+ - Multiplatform distribution (npm, Chocolatey, Homebrew).
24
+
25
+ ## Setup
26
+
27
+ its-magic is an installer you run once per repo. It copies the AI dev team
28
+ workflow files (`.cursor/` commands, rules, agents, hooks, skills, plus `docs/`,
29
+ `sprints/`, `handoffs/`, etc.) into your project.
30
+
31
+ Starter artifacts are shipped as clean placeholders (no preloaded sprint/demo
32
+ history), so `/intake` starts from your own idea.
33
+
34
+ ### 1) Install its-magic (once)
35
+
36
+ Pick one method:
37
+
38
+ | Method | Install command |
39
+ |--------|----------------|
40
+ | npm | `npm install -g its-magic` |
41
+ | npx | `npx its-magic --target . --mode missing` |
42
+ | Chocolatey | `choco install its-magic` (Admin shell) |
43
+ | Homebrew | `brew tap USER/tap && brew install its-magic` |
44
+
45
+ ### 2) Apply to a repo
46
+
47
+ New repo:
48
+
49
+ ```bash
50
+ mkdir my-project && cd my-project
51
+ git init
52
+ its-magic --target . --mode missing --create
53
+ ```
54
+
55
+ Existing repo (safe merge):
56
+
57
+ ```bash
58
+ its-magic --target . --mode missing
59
+ ```
60
+
61
+ Existing repo (overwrite + backup):
62
+
63
+ ```bash
64
+ its-magic --target . --mode overwrite --backup
65
+ ```
66
+
67
+ ### Upgrading an existing repo
68
+
69
+ When you update its-magic to a newer version (`npm update -g its-magic`), run
70
+ upgrade mode to update framework files while preserving your project data:
71
+
72
+ ```bash
73
+ its-magic --target . --mode upgrade
74
+ ```
75
+
76
+ What upgrade does:
77
+
78
+ - **Framework files** (commands, rules, agents, hooks, skills, CI, scripts) are
79
+ updated to the latest version.
80
+ - **User data** (docs, sprints, handoffs, decisions, runbook) is never touched.
81
+ - **Mixed files** (`.cursor/scratchpad.md`, `README.md`) are preserved. If the
82
+ template version has new content, a review notice is printed.
83
+ - A canonical version marker is stored at `its_magic/.its-magic-version` in your repo.
84
+ - Installer bootstrap is OS-aware + stack-aware for runbook command defaults
85
+ (`TEST_COMMAND`, optional `LINT_COMMAND`/`TYPECHECK_COMMAND`) and preserves
86
+ explicit user overrides.
87
+
88
+ Upgrade with backup (backs up framework files before updating):
89
+
90
+ ```bash
91
+ its-magic --target . --mode upgrade --backup
92
+ ```
93
+
94
+ ### 3) Open in Cursor
95
+
96
+ 1. Open the project folder
97
+ 2. Run `/intake` with your idea
98
+ 3. Follow the workflow
99
+
100
+ ### CLI quick commands
101
+
102
+ ```bash
103
+ # Show banner + help
104
+ its-magic
105
+
106
+ # Show version only
107
+ its-magic --version
108
+
109
+ # Install workflow files into current repo
110
+ its-magic --target . --mode missing
111
+
112
+ # Clean previously installed workflow artifacts
113
+ its-magic --clean-repo --target .
114
+ ```
115
+
116
+ ### Installer options
117
+
118
+ **Install options**
119
+
120
+ | Flag | Description |
121
+ |------|-------------|
122
+ | `--target <path>` | Path to the repository where workflow files are installed. If omitted you are prompted interactively. |
123
+ | `--mode missing` | **Default.** Only copy files that do not exist yet. Safe for repos that already have some workflow files. |
124
+ | `--mode overwrite` | Replace every file, even if it already exists. Combine with `--backup` to keep a snapshot first. |
125
+ | `--mode interactive` | Ask per file whether to overwrite or skip. Useful when you want to cherry-pick updates. |
126
+ | `--mode upgrade` | Update framework files (commands, rules, agents, hooks, skills, CI, scripts) while preserving user data (docs, sprints, handoffs, decisions). Use after updating its-magic to a newer version. |
127
+ | `--backup` | Before overwriting, save existing files to `backups/<timestamp>/`. Ignored in `missing` mode (nothing gets replaced). |
128
+ | `--create` | Create the target directory if it does not exist. |
129
+
130
+ **Clean options**
131
+
132
+ | Flag | Description |
133
+ |------|-------------|
134
+ | `--clean-repo` | Remove installer-owned its-magic workflow artifacts from the target repo (manifest-owned paths including `.cursor`, `docs/product`, `docs/engineering`, `docs/user-guides`, `sprints`, `handoffs`, `decisions`, workflow scripts, CI files, installer metadata in `its_magic/`, and legacy `.its-magic-version`). Your own source code is never touched. |
135
+ | `--yes` | Skip the confirmation prompt when cleaning. |
136
+
137
+ **Info**
138
+
139
+ | Flag | Description |
140
+ |------|-------------|
141
+ | `--help`, `-h` | Show banner, version, repo URL, and full usage reference. |
142
+ | `--version`, `-v` | Print the installed its-magic version and exit. |
143
+
144
+ ### Lifecycle QA matrix (US-0041)
145
+
146
+ `its-magic` lifecycle behavior is validated in both installer and CLI paths.
147
+ Primary coverage:
148
+
149
+ | Scenario | Local coverage | CI coverage | Expected evidence |
150
+ |---|---|---|---|
151
+ | Fresh install (`missing`) | `tests/run-tests.ps1`, `tests/run-tests.sh` | npm/brew/choco jobs | Required files + `its_magic/.its-magic-version` |
152
+ | Overwrite + backup | `tests/run-tests.ps1`, `tests/run-tests.sh` | lifecycle subset in CI jobs | Backup snapshot contains overwritten framework file |
153
+ | Upgrade lifecycle | `tests/run-tests.ps1`, `tests/run-tests.sh`, npm local package tests | lifecycle subset in CI jobs | Framework file restored, user-data preserved |
154
+ | Clean-repo safety | `tests/run-tests.ps1`, `tests/run-tests.sh`, npm local package tests | lifecycle subset in CI jobs | Framework artifacts removed, non-framework marker preserved |
155
+ | Negative-path invalid mode/args | `tests/run-tests.ps1`, `tests/run-tests.sh` | lifecycle subset in CI jobs | Non-zero fail-fast behavior |
156
+
157
+ Run locally:
158
+
159
+ ```bash
160
+ sh tests/run-tests.sh
161
+ powershell -ExecutionPolicy Bypass -File tests/run-tests.ps1
162
+ ```
163
+
164
+ ## How-to
165
+
166
+ ### Command usage pattern
167
+
168
+ - Best practice: use `/<command>` + 1-3 lines context.
169
+ - For quick ops (`/pause`, `/resume`, `/refresh-context`) command-only is fine.
170
+
171
+ ### What gets installed
172
+
173
+ ```text
174
+ your-project/
175
+ .cursor/commands/ Cursor slash commands
176
+ .cursor/rules/ AI behavior rules
177
+ .cursor/agents/ Subagent definitions
178
+ .cursor/skills/ Reusable skills
179
+ .cursor/hooks/ Automation hooks
180
+ .cursor/scratchpad.md Shared configuration flags
181
+ .cursor/scratchpad.local.example.md
182
+ docs/ Engineering & product docs, runbook
183
+ sprints/ Sprint tracking artifacts
184
+ handoffs/ Phase handoff artifacts
185
+ decisions/ Decision records
186
+ scripts/validate-and-push.ps1 Local test-fix-push loop (Windows)
187
+ scripts/validate-and-push.sh Local test-fix-push loop (Linux/Mac)
188
+ .github/workflows/ CI with auto-fix loop
189
+ README.md
190
+ ```
191
+
192
+ ### Team mode local overrides (recommended)
193
+
194
+ Use two layers:
195
+
196
+ - Shared defaults: `.cursor/scratchpad.md` (committed)
197
+ - Personal overrides: `.cursor/scratchpad.local.md` (gitignored)
198
+
199
+ Setup:
200
+
201
+ 1. Copy `.cursor/scratchpad.local.example.md` to `.cursor/scratchpad.local.md`
202
+ 2. Set personal values there (`TEAM_MEMBER`, `ACTIVE_TASK_IDS`, automation style)
203
+ 3. Hook merges shared + local (local wins)
204
+
205
+ Upgrade behavior (US-0057):
206
+ - `.cursor/scratchpad.local.example.md` is framework-owned and refreshed on `--mode upgrade`.
207
+ - `.cursor/scratchpad.local.md` is user-owned and preserved on `--mode upgrade`.
208
+ - Installer output includes scratchpad example refresh status and local-preserved signal.
209
+
210
+ Deterministic ordering behavior (US-0058):
211
+ - Mutable artifacts follow `docs/engineering/artifact-ordering-policy.md`.
212
+ - `state.md` checkpoints are append-bottom; `backlog.md` and `acceptance.md`
213
+ remain sorted-canonical by story ID.
214
+ - Commands fail closed on ambiguous placement anchors using
215
+ `ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS`.
216
+ - Commands fail closed on non-monotonic state checkpoint timestamps using
217
+ `STATE_TIMESTAMP_NON_MONOTONIC`.
218
+
219
+ Intake runtime safety behavior (US-0059):
220
+ - `/intake` requires role-specific `po` capability by default and fails fast with
221
+ `SUBAGENT_CAPABILITY_UNAVAILABLE` when unavailable.
222
+ - Silent in-band fallback is disabled by default and only allowed with explicit
223
+ `INTAKE_SUBAGENT_FALLBACK=allow`.
224
+ - Drift detection distinguishes self-write updates from external concurrent
225
+ writers; true conflicting external writes fail safe with
226
+ `INTAKE_CONCURRENT_WRITER_DETECTED`.
227
+
228
+ ## Workflow
229
+
230
+ ### Core commands
231
+
232
+ - `/ask`: ask questions using project context (read-only, no artifacts created).
233
+ - `/intake`: capture idea, backlog, acceptance.
234
+ - `/discovery`: collect UX/product references.
235
+ - `/research`: risks, patterns, dependencies.
236
+ - `/architecture`: technical approach and decisions.
237
+ - `/sprint-plan`: sprint and task list.
238
+ - `/plan-verify`: acceptance coverage check.
239
+ - `/execute`: implement tasks.
240
+ - `/qa`: test and report findings.
241
+ - `/verify-work`: UAT.
242
+ - `/release`: release notes + runbook updates.
243
+ - `/memory-audit`: read-only memory drift check with advisory report.
244
+ - `/pause`, `/resume`, `/refresh-context`.
245
+ - `/auto`: orchestration mode that spawns a fresh subagent per phase.
246
+
247
+ ### Guided intake behavior (US-0033)
248
+
249
+ `/intake` supports two PO interaction modes via `.cursor/scratchpad.md`:
250
+
251
+ - `INTAKE_GUIDED_MODE=1` (default)
252
+ - asks targeted follow-up only when needed for concrete acceptance
253
+ - presents options/alternatives before recommendation
254
+ - preserves user decision authority
255
+ - runs intake-time research and persists R-xxxx evidence
256
+ - `INTAKE_GUIDED_MODE=0` (low-touch)
257
+ - skips proactive follow-up/options/research overhead unless user requests it
258
+ - still performs duplicate/overlap check against backlog
259
+
260
+ ### Intake decomposition + risk-aware questioning (US-0051)
261
+
262
+ When guided mode is enabled, `/intake` now supports bounded decomposition for
263
+ broad/high-risk requests:
264
+
265
+ - runs deterministic breadth/risk heuristics (feature/workflow count,
266
+ cross-cutting impact, acceptance breadth, unknown dependencies)
267
+ - proposes bounded multi-story decomposition when heuristics indicate broad
268
+ scope; keeps single-story default for narrow scope
269
+ - enforces vertical-slice/workflow-step split quality (independently valuable,
270
+ testable stories; avoid technical-layer-only splits by default)
271
+ - preserves user control before persistence: accept, merge, or adjust split
272
+ - asks additional targeted questions on high-risk/high-impact intake (not
273
+ ambiguity-only), but keeps rounds bounded and concise
274
+ - keeps low-touch compatibility: no forced decomposition when
275
+ `INTAKE_GUIDED_MODE=0` unless explicitly requested
276
+ - records decomposition/questioning evidence in intake artifacts
277
+ (`docs/product/backlog.md`, `docs/product/acceptance.md`,
278
+ `handoffs/po_to_tl.md`)
279
+
280
+ ### Optional ID namespace bootstrap (US-0052)
281
+
282
+ Fresh-project ID bootstrap behavior is explicit and default-off:
283
+
284
+ - `ID_NAMESPACE_BOOTSTRAP=0|1` in `.cursor/scratchpad.md` (default `0`)
285
+
286
+ When enabled (`1`), workflows use deterministic freshness checks before first ID
287
+ creation:
288
+
289
+ - no `US-` IDs in `docs/product/backlog.md`
290
+ - no `DEC-` IDs in `docs/engineering/decisions.md` / `decisions/DEC-*.md`
291
+ - no `R-` IDs in `docs/engineering/research.md`
292
+
293
+ If eligible, first IDs start at `US-0001`, `DEC-0001`, and `R-0001`. If not
294
+ eligible (or mode is off), generation continues from highest existing IDs.
295
+ Historical IDs are never rewritten or renumbered. Ineligible bootstrap requests
296
+ emit deterministic diagnostic `ID_BOOTSTRAP_NOT_FRESH`.
297
+
298
+ ### Context compaction + tiered token profile (US-0053)
299
+
300
+ Token-cost behavior is controlled by `.cursor/scratchpad.md`:
301
+
302
+ - `TOKEN_PROFILE=lean|balanced|full` (default `balanced`)
303
+
304
+ Profile behavior:
305
+
306
+ - `lean`: reduce non-critical overhead defaults (automation/research/context
307
+ breadth) while keeping mandatory quality gates intact.
308
+ - `balanced`: preserve current capabilities with moderate overhead.
309
+ - `full`: maximize context breadth/autonomy for high-uncertainty work.
310
+
311
+ Manual override precedence:
312
+
313
+ - Explicit scratchpad flag values override profile defaults for that flag.
314
+ - Profile mode never disables mandatory `/qa` -> `/verify-work` -> `/release`
315
+ gate semantics.
316
+
317
+ Compaction behavior:
318
+
319
+ - `docs/engineering/state.md` is the active hot surface.
320
+ - Historical checkpoints move to append-only packs under
321
+ `docs/engineering/state-archive/`.
322
+ - `docs/engineering/decisions.md` stays a compact index with bounded summaries
323
+ and canonical links to `decisions/DEC-xxxx.md`.
324
+ - Enforced rollover thresholds:
325
+ - `STATE_HOT_MAX_LINES` (default `1200`)
326
+ - `STATE_HOT_MAX_CHECKPOINTS` (default `80`)
327
+ `/refresh-context` must archive oldest checkpoints into deterministic
328
+ `state-pack-*` files when thresholds are exceeded, keeping only bounded recent
329
+ checkpoints in hot surface.
330
+ Archive verification mismatch fails with
331
+ `STATE_ARCHIVE_VERIFICATION_FAILED`.
332
+
333
+ ### Cross-phase artifact ownership guard (US-0061)
334
+
335
+ To prevent accidental history loss across workflow phases:
336
+
337
+ - canonical ownership policy: `docs/engineering/artifact-ownership-policy.md`
338
+ - non-authorized phases must not delete or rewrite other-phase owned sections
339
+ - `docs/engineering/architecture.md` is history-preserving (append or
340
+ target-section-only mutation)
341
+ - deterministic fail-safe diagnostics:
342
+ `PHASE_OWNERSHIP_VIOLATION`,
343
+ `PHASE_OVERRIDE_EVIDENCE_MISSING`,
344
+ `ARCH_HISTORY_DELETION_DETECTED`
345
+
346
+ `/ask` policy (read-only):
347
+
348
+ - question-scoped retrieval first
349
+ - targeted sections before broad file reads
350
+ - bounded expansion only when unresolved
351
+ - explicit "not found in artifacts" when still unresolved
352
+
353
+ ### Configurable multi-target publish + confirmation gate (US-0054)
354
+
355
+ Post-release publish behavior is configurable per repository:
356
+
357
+ - `RELEASE_PUBLISH_MODE=disabled|confirm|auto` (default `confirm`)
358
+ - `RELEASE_TARGETS_FILE=docs/engineering/release-targets.json`
359
+ - `RELEASE_TARGETS_DEFAULT=` optional comma-separated default targets
360
+
361
+ Supported target types include:
362
+
363
+ - `npm`, `choco`, `brew`, `git`, `docker`, `cloud`
364
+ - `custom` (generic command target)
365
+ - `ssh` (generic server deployment over SSH)
366
+ - Connectivity metadata for remote/local operator context:
367
+ - `runtime.mode` (`local|remote`)
368
+ - endpoint fields (`domainEnv|ipEnv|hostEnv`, `port`, `protocol`)
369
+ - optional Traefik/ingress metadata
370
+ - optional `dockerOverSsh` contract for remote Docker execution over SSH
371
+
372
+ Safety defaults:
373
+
374
+ - Mandatory `/release` gates are unchanged and must pass first.
375
+ - `confirm` mode enforces explicit operator approval before publish execution.
376
+ - Sensitive values are env-referenced (for example `tokenEnv`, `authEnv`), not
377
+ inline literals.
378
+ - Remote connectivity config errors fail fast with
379
+ `REMOTE_CONNECTIVITY_CONFIG_INVALID`.
380
+ - Release/QA outputs use canonical operator connectivity doc:
381
+ `docs/engineering/runtime-connectivity.md`.
382
+
383
+ ### Deterministic status reconciliation command (US-0055)
384
+
385
+ Use `/status-reconcile` to normalize status drift between canonical and derived
386
+ workflow artifacts before continuation:
387
+
388
+ - canonical source: `docs/product/backlog.md` story status
389
+ - derived targets: `docs/product/acceptance.md`, `docs/engineering/state.md`,
390
+ `handoffs/resume_brief.md`
391
+ - deterministic outcomes: apply/no-op/fail-safe reason codes with audit evidence
392
+ in `docs/engineering/status-normalization-report.md`
393
+
394
+ This command is the bounded repair counterpart to `/memory-audit`
395
+ (read-only detection).
396
+
397
+ ### Optional cross-repo observability (US-0034)
398
+
399
+ Use optional compatibility visibility with default-safe off behavior:
400
+
401
+ - `CROSS_REPO_OBSERVABILITY=0|1` (default `0`)
402
+ - `COMPATIBILITY_GATE_ON_CRITICAL=0|1` (default `1`)
403
+ - `COMPATIBILITY_SOURCES=` monitored `repo/module/contract/docs` declarations
404
+
405
+ When disabled (`0`), workflow adds zero required compatibility overhead.
406
+
407
+ When enabled (`1`), compatibility signals/findings are tracked in:
408
+
409
+ - `docs/engineering/compatibility-signals.md`
410
+ - `docs/engineering/compatibility-report.md`
411
+ - `docs/engineering/manifests/registry.manifest.yaml`
412
+ - `docs/engineering/manifests/repo.manifest.yaml`
413
+
414
+ If unresolved critical findings remain and
415
+ `COMPATIBILITY_GATE_ON_CRITICAL=1`, release progression must stop for a
416
+ decision gate (`COMPATIBILITY_CRITICAL_OPEN`).
417
+
418
+ ### Optional component-scoped execution (US-0035)
419
+
420
+ Enable scoped workflow behavior with:
421
+
422
+ - `COMPONENT_SCOPE_MODE=0|1` (default `0`)
423
+ - `TARGET_COMPONENTS=<comma-separated-component-ids>`
424
+
425
+ When disabled (`0`), workflow adds zero required scope overhead.
426
+
427
+ When enabled (`1`):
428
+
429
+ - Scope declaration is tracked in `docs/engineering/component-scope.md`.
430
+ - Sprint tasks should declare target components and expected impacted interfaces.
431
+ - QA records unaffected-component protection checks in
432
+ `docs/engineering/component-scope-report.md`.
433
+ - Unapproved out-of-scope impact must block release via decision gate
434
+ (`COMPONENT_SCOPE_VIOLATION_UNAPPROVED`).
435
+
436
+ ### Optional spec-pack documentation (US-0031)
437
+
438
+ Optional Design Concept, CRS, and Technical Specification artifacts are
439
+ controlled by:
440
+
441
+ - `SPEC_PACK_MODE=0|1` (default `0`)
442
+
443
+ When disabled (`0`), intake/architecture/execute/qa/release add no required
444
+ spec-pack steps (zero overhead).
445
+
446
+ When enabled (`1`):
447
+
448
+ - Canonical paths per story: `docs/engineering/spec-pack/<story_id>-design-concept.md`,
449
+ `docs/engineering/spec-pack/<story_id>-crs.md`,
450
+ `docs/engineering/spec-pack/<story_id>-technical-specification.md`.
451
+ - Minimum required sections and ownership are in `docs/engineering/runbook.md`.
452
+ - Release gate validates completeness and blocks with `SPEC_PACK_INCOMPLETE` when
453
+ required sections are missing.
454
+
455
+ ### Optional user-guide documentation (US-0032)
456
+
457
+ Optional per-feature user guides (end-user how-to docs) are controlled by:
458
+
459
+ - `USER_GUIDE_MODE=0|1` (default `0`)
460
+
461
+ When disabled (`0`), intake/architecture/sprint-plan/execute/qa/release add no
462
+ required user-guide steps or blocking checks (zero overhead).
463
+
464
+ When enabled (`1`):
465
+
466
+ - Canonical path per feature story: `docs/user-guides/US-xxxx.md`.
467
+ - Minimum required sections: Purpose, Prerequisites, Usage steps, Example,
468
+ Limitations, Troubleshooting (see `docs/engineering/runbook.md` and
469
+ `docs/user-guides/README.md`).
470
+ - Release gate validates guide completeness and blocks with `USER_GUIDE_INCOMPLETE`
471
+ when enabled and required sections are missing.
472
+ - User guides are end-user only; they do not duplicate spec-pack (US-0031) content.
473
+
474
+ ### Release notes model (US-0040)
475
+
476
+ Release history is sprint-scoped and queue-backed:
477
+
478
+ - Canonical sprint notes: `handoffs/releases/Sxxxx-release-notes.md`
479
+ - Canonical queue tracker: `handoffs/release_queue.md`
480
+ - Legacy compatibility pointer: `handoffs/release_notes.md`
481
+
482
+ Deterministic release semantics:
483
+ - Only target sprint artifacts/queue row may be mutated during one `/release` run.
484
+ - Entering release flow sets target row to `unreleased`.
485
+ - Successful finalization transitions same row to `released`.
486
+ - Unresolved sprint identity or queue/notes mismatch fails closed with reason
487
+ codes and remediation guidance; no destructive reconciliation by default.
488
+
489
+ ### Post-QA release issue workflow (US-0042)
490
+
491
+ Release gate chain (US-0039): `/release` enforces mandatory gates in order — check-in test, QA completion, UAT completion — then finalization. Blank optional runbook keys (`LINT_COMMAND`, `TYPECHECK_COMMAND`) do not block release; they are reported as skipped.
492
+
493
+ If a problem appears **after QA** (during `/release`), record it separately from
494
+ QA findings:
495
+
496
+ - Release findings artifact: `sprints/Sxxxx/release-findings.md`
497
+ - Release-to-dev handoff: `handoffs/release_to_dev.md`
498
+
499
+ Boundary:
500
+ - QA-phase issues -> `sprints/Sxxxx/qa-findings.md`
501
+ - Post-QA release-gate issues -> `sprints/Sxxxx/release-findings.md`
502
+
503
+ Each blocked release finding should include reason code, evidence refs,
504
+ remediation, and rerun criteria.
505
+
506
+ ### Backlog reconciliation invariant (US-0043)
507
+
508
+ Release completion must not leave stale backlog status for target sprint stories.
509
+ At release finalization:
510
+
511
+ - reconcile target story status to `DONE` using canonical release evidence;
512
+ - reconcile target story acceptance checkboxes to checked state;
513
+ - mutate only target sprint stories (never unrelated backlog entries);
514
+ - fail safe with `BACKLOG_STATUS_DRIFT` if contradiction remains (e.g. released
515
+ sprint but backlog still `OPEN`/unchecked).
516
+
517
+ ### Canonical story status + normalization guard (US-0045)
518
+
519
+ - `docs/product/backlog.md` is canonical for story `OPEN|DONE` status.
520
+ - `docs/product/acceptance.md` and `docs/engineering/state.md` are derived views
521
+ reconciled from canonical backlog status plus release evidence.
522
+ - One-time normalization baseline is recorded in
523
+ `docs/engineering/status-normalization-report.md`.
524
+ - Contradictory resolution at release/reconciliation boundaries fails safe with:
525
+ - `BACKLOG_STATUS_DRIFT`
526
+ - `CANONICAL_STATUS_CONFLICT`
527
+
528
+ ### Agent isolation model
529
+
530
+ - Every phase command runs in a fresh agent/subagent context.
531
+ - Handoff files are the only cross-phase memory (`handoffs/*.md` + artifact
532
+ files).
533
+ - Never rely on "ignore prior chat"; use a new context boundary instead.
534
+ - `/auto` is orchestration only: it calls phase subagents and transfers context
535
+ through artifacts.
536
+
537
+ #### Per-phase isolation evidence (US-0048 / DEC-0029)
538
+
539
+ Isolation is enforced with auditable evidence written to `docs/engineering/state.md`.
540
+ Each phase run appends:
541
+
542
+ - `phase_id`, `role`, `fresh_context_marker`, `timestamp`, `evidence_ref`
543
+
544
+ Missing/invalid/stale evidence fails closed with reason codes:
545
+ `PHASE_CONTEXT_ISOLATION_MISSING`, `PHASE_CONTEXT_ISOLATION_VIOLATION`,
546
+ `ISOLATION_EVIDENCE_STALE`, `ISOLATION_EVIDENCE_INVALID`.
547
+
548
+ #### Strict runtime proof (US-0056 / DEC-0038)
549
+
550
+ Per-phase isolation also requires strict runtime attestation tuples at
551
+ boundaries (not artifact fields alone):
552
+
553
+ - `orchestrator_run_id`, `runtime_proof_id`, `phase_id`, `role`
554
+ - `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`
555
+
556
+ Fail-closed reason codes:
557
+ `RUNTIME_PROOF_MISSING`, `RUNTIME_PROOF_INVALID`, `RUNTIME_PROOF_REUSED`,
558
+ `RUNTIME_PROOF_STALE`, `RUNTIME_PROOF_AMBIGUOUS_LINK`.
559
+
560
+ `/auto`, `/verify-work`, and `/release` must validate these tuples before
561
+ continuation/finalization.
562
+
563
+ ### Lightweight interaction
564
+
565
+ Use `/ask` when you want to query the project without triggering the workflow:
566
+
567
+ - "What's the current sprint status?"
568
+ - "Which stories are still open?"
569
+ - "How does the upgrade mode work?"
570
+ - "What decision was made about X?"
571
+
572
+ `/ask` reads the project artifacts (state, backlog, architecture, decisions, sprint
573
+ progress) and answers from them. It never creates or modifies files. If your question
574
+ reveals a bug or feature idea, it will suggest running `/intake`.
575
+
576
+ ### Memory drift auditing
577
+
578
+ Use `/memory-audit` to check whether project memory artifacts still match
579
+ repository reality. This is a read-only, non-blocking command that produces an
580
+ advisory report at `docs/engineering/memory-drift-report.md`.
581
+
582
+ **When to run:**
583
+
584
+ - **Pre-handoff**: before writing any role handoff artifact.
585
+ - **Pre-QA**: before `/qa` or `/verify-work`.
586
+ - **Pre-release**: before `/release`.
587
+ - **Ad-hoc**: after external code changes, long pauses, or whenever artifacts
588
+ feel stale.
589
+
590
+ **How to interpret output:**
591
+
592
+ The report contains a severity summary (`high` / `medium` / `low`) and a
593
+ findings table with concrete evidence for each inconsistency. High-severity
594
+ findings should be resolved before the next handoff or release. Medium and low
595
+ findings can be addressed during `/refresh-context` or the next sprint.
596
+
597
+ The report also includes a reference-only "Template drift" section. Template
598
+ drift remediation belongs to US-0017 — `/memory-audit` only flags it for
599
+ awareness.
600
+
601
+ **Follow-up commands:**
602
+
603
+ - `/refresh-context` — update stale artifacts.
604
+ - `/sprint-plan` — if new work is discovered.
605
+ - `/verify-work` — if acceptance status needs re-validation.
606
+ - `/intake` — if findings reveal a new story or bug.
607
+
608
+ ### Workflow diagrams
609
+
610
+ ```mermaid
611
+ flowchart TD
612
+ Intake[/intake/] --> Discovery[/discovery/]
613
+ Discovery --> Research[/research/]
614
+ Research --> Architecture[/architecture/]
615
+ Architecture --> SprintPlan[/sprint-plan/]
616
+ SprintPlan --> PlanVerify[/plan-verify/]
617
+ PlanVerify --> Execute[/execute/]
618
+ Execute --> QA[/qa/]
619
+ QA -->|fixes needed| Execute
620
+ QA --> VerifyWork[/verify-work/]
621
+ VerifyWork --> Release[/release/]
622
+ Release --> Refresh[/refresh-context/]
623
+ Execute --> Pause[/pause/]
624
+ QA --> Pause
625
+ Release --> Pause
626
+ Pause --> Resume[/resume/]
627
+ Resume --> Execute
628
+ ```
629
+
630
+ ```mermaid
631
+ flowchart TD
632
+ Start[Idea] --> Intake2[/intake/]
633
+ Intake2 -->|DecisionGate| Decision{DecisionRequired}
634
+ Decision -->|ChooseOption| Discovery2[/discovery/]
635
+ Decision -->|ChooseOption| Research2[/research/]
636
+ Decision -->|ChooseOption| Architecture2[/architecture/]
637
+ Decision -->|ChooseOption| SprintPlan2[/sprint-plan/]
638
+ Decision -->|ChooseOption| PlanVerify2[/plan-verify/]
639
+ Decision -->|ChooseOption| Execute2[/execute/]
640
+ Decision -->|ChooseOption| QA2[/qa/]
641
+ Decision -->|ChooseOption| VerifyWork2[/verify-work/]
642
+ Decision -->|ChooseOption| Release2[/release/]
643
+ Decision -->|ChooseOption| Refresh2[/refresh-context/]
644
+ Decision -->|ChooseOption| Pause2[/pause/]
645
+ Discovery2 --> Research2
646
+ Research2 --> Architecture2
647
+ Architecture2 --> SprintPlan2
648
+ SprintPlan2 --> PlanVerify2
649
+ PlanVerify2 --> Execute2
650
+ Execute2 --> QA2
651
+ QA2 -->|fixes needed| Execute2
652
+ QA2 --> VerifyWork2
653
+ VerifyWork2 --> Release2
654
+ Release2 --> Refresh2
655
+ Execute2 --> Pause2
656
+ QA2 --> Pause2
657
+ Release2 --> Pause2
658
+ Pause2 --> Resume2[/resume/]
659
+ Resume2 --> Execute2
660
+ Execute2 --> HandoffDevQA[handoffs/dev_to_qa.md]
661
+ QA2 --> HandoffQAD[handoffs/qa_to_dev.md]
662
+ Intake2 --> HandoffPOTL[handoffs/po_to_tl.md]
663
+ SprintPlan2 --> HandoffTLDev[handoffs/tl_to_dev.md]
664
+ ```
665
+
666
+ ### Automation modes
667
+
668
+ Configure in `.cursor/scratchpad.md`:
669
+
670
+ - `AUTO_FLOW_MODE=manual|auto_until_decision`
671
+ - `manual`: you trigger each phase/command yourself.
672
+ - `auto_until_decision`: `/auto` continues by spawning fresh phase subagents until a decision gate, blocker, or pause boundary.
673
+ - `PHASE_MODE=interactive|auto`
674
+ - `interactive`: agent asks clarifying questions more often.
675
+ - `auto`: agent minimizes prompts and proceeds with best effort.
676
+ - `PERMISSION_MODE=interactive|auto`
677
+ - `interactive`: ask before routine actions.
678
+ - `auto`: reduce routine permission prompts.
679
+ - `RUN_TESTS_ON_EDIT=0|1`
680
+ - `1`: runs configured tests after meaningful edits.
681
+ - `0`: tests only when you explicitly run QA/test phases.
682
+ - `LOOP_UNTIL_GREEN=0|1`
683
+ - `1`: keep iterating fix -> test until green (bounded).
684
+ - `0`: run one pass and report failures.
685
+ - `AUTO_IMPLEMENTATION_LOOP=0|1`
686
+ - `1`: enables execute -> QA -> execute loop automatically with new Dev/QA subagent instances on each cycle.
687
+ - `AUTO_LOOP_MAX_CYCLES=<n>`
688
+ - safety cap for auto loops (recommended `3-7`, default `5`).
689
+ - `AUTO_PAUSE_REQUEST=0|1`
690
+ - `1`: request graceful stop at next safe boundary.
691
+ - `AUTO_PAUSE_POLICY=after_task|after_phase`
692
+ - `after_task`: faster stop, more frequent boundaries.
693
+ - `after_phase`: cleaner checkpoints, fewer interruptions.
694
+
695
+ ### Sync policy (US-0038)
696
+
697
+ Phase-triggered sync is policy-controlled and safe by default.
698
+
699
+ Scratchpad controls:
700
+
701
+ - `SYNC_POLICY_MODE=disabled|manual|by_phase|by_milestone|custom_phase_list`
702
+ - `SYNC_CUSTOM_PHASES=<comma-separated canonical phases>`
703
+ - `ALLOW_AUTO_PUSH=0|1`
704
+ - `AUTO_PUSH_BRANCH_ALLOWLIST=<comma-separated branches/patterns>`
705
+
706
+ Default-safe behavior:
707
+
708
+ - Default mode is `manual` with `ALLOW_AUTO_PUSH=0` (no automatic push).
709
+ - `disabled` and `manual` add near-zero overhead and preserve manual workflows.
710
+ - Sync policy is evaluated only at completed phase boundaries.
711
+
712
+ Guarded auto-push conditions (all must pass):
713
+
714
+ 1. Boundary matches configured mode.
715
+ 2. Auto-push is explicitly enabled (`ALLOW_AUTO_PUSH=1`).
716
+ 3. QA-first safety holds (feature work cannot auto-push pre-QA).
717
+ 4. No unresolved blocking QA findings/critical issues.
718
+ 5. Branch safety holds (protected/default branches denied unless allowlisted).
719
+ 6. Check chain passes (`TEST_COMMAND` required; optional lint/typecheck only if configured).
720
+
721
+ Deterministic reason codes include:
722
+ `SYNC_DISABLED`, `MANUAL_MODE_NO_AUTO`, `PRE_QA_AUTOPUSH_FORBIDDEN`,
723
+ `BLOCKING_QA_FINDINGS`, `BRANCH_NOT_ALLOWLISTED`, `TEST_COMMAND_MISSING`,
724
+ `TEST_FAILED`, `TEST_TIMEOUT`, `OPTIONAL_CHECK_FAILED`, `SYNC_PUSHED`.
725
+
726
+ ### Full scratchpad reference (detailed)
727
+
728
+ - `MAGIC_CONTEXT_STRICT=0|1`
729
+ - `1`: enforces context refresh discipline after code edits.
730
+ - `DONE=0|1`
731
+ - `1`: stop hook reminder loops when session is complete.
732
+ - `MAGIC_BENCH_SESSION=<id>`
733
+ - enables live benchmark event logging under one session id.
734
+ - `AUTO_INSTALL_DEPS=0|1`
735
+ - `1`: agent may install dependencies/runtimes automatically.
736
+ - `AUTO_RELEASE_NOTES=0|1`
737
+ - `1`: auto-generate `handoffs/release_notes.md`.
738
+ - `REMOTE_EXECUTION=0|1`
739
+ - `1`: allow remote/docker execution if configured.
740
+ - `REMOTE_CONFIG=.cursor/remote.json`
741
+ - path to remote execution server config.
742
+
743
+ ### Remote execution config (`.cursor/remote.json`)
744
+
745
+ Remote config is optional and mode-aware:
746
+
747
+ - `REMOTE_EXECUTION=0` (default): skip remote config checks entirely.
748
+ - `REMOTE_EXECUTION=1`: validate `.cursor/remote.json` first and fail fast on
749
+ missing/malformed/invalid or insecure config.
750
+
751
+ Canonical contract (DEC-0016):
752
+
753
+ - Required root fields:
754
+ - `version` (integer)
755
+ - `defaultTarget` (string)
756
+ - `targets` (array)
757
+ - Required target fields:
758
+ - `id` (string)
759
+ - `type` (`docker|ssh|vm`)
760
+ - `enabled` (boolean)
761
+ - `host` (string)
762
+ - `port` (integer `1..65535`)
763
+ - `workspaceRoot` (string)
764
+ - Optional:
765
+ - `auth.mode` (`none|env`)
766
+ - If `auth.mode=env`, use env-var references only (`tokenEnv`,
767
+ `passwordEnv`, `privateKeyPathEnv`, ...).
768
+
769
+ Two safe target examples are shipped in:
770
+
771
+ - `.cursor/remote.json` (active repo)
772
+ - `template/.cursor/remote.json` (template parity copy)
773
+
774
+ The examples include:
775
+
776
+ - `local-docker`: local network/docker-like endpoint.
777
+ - `remote-vm-ssh`: remote VM/SSH-like endpoint.
778
+
779
+ No secrets policy:
780
+
781
+ - Never commit inline tokens/passwords/private keys in `remote.json`.
782
+ - Commit env-var reference names only.
783
+
784
+ Fail-fast error format:
785
+
786
+ - `[REMOTE_CONFIG_ERROR] <path>: expected <rule>, got <actual>. Fix: <hint>.`
787
+
788
+ Troubleshooting quick guide:
789
+
790
+ - Missing file in remote mode:
791
+ - Create `.cursor/remote.json` from the template copy, or set
792
+ `REMOTE_EXECUTION=0`.
793
+ - Invalid enum/type/range:
794
+ - Update the failing field to match allowed values/ranges.
795
+ - Malformed JSON:
796
+ - Fix JSON syntax and retry.
797
+ - Secret-like inline value detected:
798
+ - Replace literal secret with an env-var reference field.
799
+
800
+ Team/local (recommended in `.cursor/scratchpad.local.md`):
801
+
802
+ - `TEAM_MODE=0|1`
803
+ - `TEAM_MEMBER=<your-id>`
804
+ - `ACTIVE_TASK_IDS=T-12,T-13`
805
+
806
+ ### Automated feature loop (optional)
807
+
808
+ Enable:
809
+
810
+ - `AUTO_FLOW_MODE=auto_until_decision`
811
+ - `PHASE_MODE=auto`
812
+ - `PERMISSION_MODE=auto`
813
+ - `RUN_TESTS_ON_EDIT=1`
814
+ - `LOOP_UNTIL_GREEN=1`
815
+ - `AUTO_IMPLEMENTATION_LOOP=1`
816
+ - `AUTO_LOOP_MAX_CYCLES=5`
817
+
818
+ Then run `/auto`.
819
+
820
+ Graceful stop (for shutdown/end of day):
821
+
822
+ 1. Set `AUTO_PAUSE_REQUEST=1`
823
+ 2. Flow stops at next configured boundary (`AUTO_PAUSE_POLICY`)
824
+ 3. `/pause` artifacts are written
825
+ 4. Next day run `/resume` or `/auto`
826
+
827
+ ### Recommended profiles
828
+
829
+ **Max automation (high autonomy):**
830
+
831
+ - `AUTO_FLOW_MODE=auto_until_decision`
832
+ - `PHASE_MODE=auto`
833
+ - `PERMISSION_MODE=auto`
834
+ - `RUN_TESTS_ON_EDIT=1`
835
+ - `LOOP_UNTIL_GREEN=1`
836
+ - `AUTO_IMPLEMENTATION_LOOP=1`
837
+ - `AUTO_LOOP_MAX_CYCLES=5`
838
+ - `AUTO_INSTALL_DEPS=1` (optional, if you trust auto installs)
839
+ - `AUTO_PAUSE_POLICY=after_phase`
840
+
841
+ **Safer automation (recommended for most teams):**
842
+
843
+ - same as above, but keep:
844
+ - `PERMISSION_MODE=interactive`
845
+ - `AUTO_INSTALL_DEPS=0`
846
+ - `AUTO_PAUSE_POLICY=after_task`
847
+
848
+ ### Quality chain (3-layer auto-fix)
849
+
850
+ its-magic provides a complete quality chain that catches issues at three levels.
851
+ Each layer catches problems the previous layer missed:
852
+
853
+ ```text
854
+ ┌─────────────────────────────────────────────────────────────────┐
855
+ │ Layer 1: Cursor AI loop (in-editor) OFF by default │
856
+ │ AUTO_IMPLEMENTATION_LOOP + LOOP_UNTIL_GREEN │
857
+ │ execute QA fix execute (bounded by AUTO_LOOP_MAX_CYCLES)│
858
+ └──────────────────────────┬──────────────────────────────────────┘
859
+ │ code ready to push
860
+ ┌──────────────────────────▼──────────────────────────────────────┐
861
+ │ Layer 2: validate-and-push (local pre-push) MANUAL (run it)│
862
+ │ scripts/validate-and-push.sh / .ps1 │
863
+ │ test format lint-fix → test → commit + push │
864
+ └──────────────────────────┬──────────────────────────────────────┘
865
+ │ pushed to GitHub
866
+ ┌──────────────────────────▼──────────────────────────────────────┐
867
+ Layer 3: CI auto-fix (GitHub Actions) OFF by default │
868
+ │ .github/workflows/ci.yml │
869
+ │ test/lint auto-fix commit → re-run (up to 3 retries)
870
+ └─────────────────────────────────────────────────────────────────┘
871
+ ```
872
+
873
+ | Layer | Default | Enable |
874
+ |-------|---------|--------|
875
+ | 1 - Cursor AI loop | off | Set `AUTO_IMPLEMENTATION_LOOP=1` + `LOOP_UNTIL_GREEN=1` in scratchpad |
876
+ | 2 - validate-and-push | manual | Run `scripts/validate-and-push.sh` or `.ps1` before pushing |
877
+ | 3 - CI auto-fix | off | Set `CI_AUTO_FIX: true` in `docs/engineering/runbook.md` |
878
+
879
+ CI itself (tests, lint, typecheck) always runs on push/PR. Only the **auto-fix
880
+ retry loop** is gated behind `CI_AUTO_FIX`. When disabled, CI still reports
881
+ failures -- it just won't try to fix and commit automatically.
882
+
883
+ All commands are read from `docs/engineering/runbook.md`. Fill in your
884
+ project-specific commands once and every layer uses them:
885
+
886
+ ```text
887
+ TEST_COMMAND: npm test
888
+ LINT_COMMAND: npx eslint .
889
+ LINT_FIX_COMMAND: npx eslint --fix .
890
+ FORMAT_COMMAND: npx prettier --write .
891
+ CI_AUTO_FIX: true
892
+ ```
893
+
894
+ #### Layer 1: Cursor AI loop
895
+
896
+ Enabled via scratchpad flags (see [Automation modes](#automation-modes)).
897
+ The AI runs execute QA fix cycles inside Cursor until tests pass or
898
+ the safety cap (`AUTO_LOOP_MAX_CYCLES`) is reached.
899
+
900
+ #### Layer 2: Local validate-and-push
901
+
902
+ Run before pushing to catch anything the AI loop missed:
903
+
904
+ ```bash
905
+ # Bash (Linux / macOS)
906
+ sh scripts/validate-and-push.sh
907
+
908
+ # PowerShell (Windows)
909
+ powershell scripts/validate-and-push.ps1
910
+ powershell scripts/validate-and-push.ps1 -MaxAttempts 3
911
+ ```
912
+
913
+ The script:
914
+ 1. Runs `FORMAT_COMMAND` and `LINT_FIX_COMMAND` to auto-fix what it can
915
+ 2. Runs `LINT_COMMAND` and `TEST_COMMAND` to verify
916
+ 3. If checks fail, pauses and waits for you to fix
917
+ 4. Re-runs (up to 5 attempts, configurable)
918
+ 5. When green, commits and pushes automatically
919
+
920
+ Use `-NoCommit` (PowerShell) or `false` as third arg (Bash) to skip auto-push.
921
+
922
+ #### Layer 3: CI auto-fix (GitHub Actions)
923
+
924
+ **Disabled by default.** Set `CI_AUTO_FIX: true` in `docs/engineering/runbook.md`
925
+ to enable. When enabled and CI fails after a push, the auto-fix job kicks in:
926
+
927
+ ```text
928
+ push / PR ──> checks ──> PASS ──> done
929
+
930
+ FAIL
931
+
932
+ auto-fix job
933
+
934
+ run LINT_FIX_COMMAND
935
+ run FORMAT_COMMAND
936
+
937
+ changes found?
938
+ ╱ ╲
939
+ yes no
940
+ │ │
941
+ commit + push report failure
942
+ │ (manual fix needed)
943
+ CI re-runs
944
+ (up to 3x)
945
+ ```
946
+
947
+ Auto-fix commits appear as `ci: auto-fix attempt N/3`. After 3 retries the
948
+ workflow stops and points you to `scripts/validate-and-push` for local fixing.
949
+
950
+ ## Examples
951
+
952
+ ### Example 1: New feature from idea
953
+
954
+ 1. `/intake`
955
+ 2. `/research`
956
+ 3. `/architecture`
957
+ 4. `/sprint-plan`
958
+ 5. `/plan-verify`
959
+ 6. `/execute`
960
+ 7. `/qa`
961
+ 8. `/verify-work`
962
+ 9. `/release`
963
+ 10. `/refresh-context`
964
+
965
+ ### Example 2: Mid-flight idea change
966
+
967
+ 1. Set `AUTO_PAUSE_REQUEST=1`
968
+ 2. Run `/intake` to update story/acceptance
969
+ 3. Re-run `/sprint-plan` + `/plan-verify`
970
+ 4. Resume via `/auto`
971
+
972
+ ### Example 3: Pause/resume
973
+
974
+ 1. `/pause`
975
+ 2. Close work
976
+ 3. `/resume` next session
977
+
978
+ ### Deterministic `/auto` continuation
979
+
980
+ When resuming mid-process, `/auto` resolves start phase deterministically:
981
+
982
+ 1. explicit `/auto start-from=<phase>`
983
+ 2. `handoffs/resume_brief.md`
984
+ 3. conservative `docs/engineering/state.md` fallback
985
+ 4. fail-fast (no guessing)
986
+
987
+ Canonical phases:
988
+ `intake`, `discovery`, `research`, `architecture`, `sprint-plan`,
989
+ `plan-verify`, `execute`, `qa`, `verify-work`, `release`, `refresh-context`.
990
+
991
+ Fail-fast message format:
992
+ `[AUTO_RESUME_ERROR] <code>: <summary>. Source=<source>. Fix: <action>.`
993
+
994
+ Compatibility and safety:
995
+ - Manual/interactive workflow stays unchanged unless `/auto` continuation is used.
996
+ - Existing stop conditions remain enforced (decision gate, missing input,
997
+ pause request, loop max).
998
+
999
+ ### Optional `/auto` backlog-drain mode (US-0044)
1000
+
1001
+ If you want `/auto` to continue across multiple planned stories in one run,
1002
+ enable backlog-drain switches in `.cursor/scratchpad.md`:
1003
+
1004
+ - `AUTO_BACKLOG_DRAIN=1`
1005
+ - `AUTO_BACKLOG_MAX_STORIES=<n>`
1006
+ - `AUTO_BACKLOG_ON_BLOCK=stop|skip`
1007
+ - `AUTO_STORY_SELECTION=priority_then_backlog_order`
1008
+
1009
+ Default-safe behavior remains unchanged with `AUTO_BACKLOG_DRAIN=0`.
1010
+
1011
+ ### Explicit `/sprint-plan --bulk` mode (US-0046)
1012
+
1013
+ By default, `/sprint-plan` plans one scope at a time. For multi-story planning,
1014
+ run explicit bulk mode:
1015
+
1016
+ - `/sprint-plan --bulk`
1017
+
1018
+ Bulk planning remains bounded and deterministic via `.cursor/scratchpad.md`:
1019
+
1020
+ - `SPRINT_BULK_MAX_STORIES=<n>`
1021
+ - `SPRINT_BULK_MAX_SPRINTS=<n>`
1022
+ - `SPRINT_BULK_SELECTION=priority_then_backlog_order`
1023
+
1024
+ Bounded stop reason codes:
1025
+ `SPRINT_BULK_MAX_STORIES_REACHED`, `SPRINT_BULK_MAX_SPRINTS_REACHED`,
1026
+ `SPRINT_BULK_NO_ELIGIBLE_STORIES`, `SPRINT_BULK_MISSING_ACCEPTANCE`.
1027
+
1028
+ ### Explicit `/auto --execute-bulk` mode (US-0047)
1029
+
1030
+ Bulk execution is explicit-mode only. Default `/auto` behavior remains unchanged.
1031
+
1032
+ Enable either way:
1033
+
1034
+ - one-run explicit argument: `/auto --execute-bulk`
1035
+ - scratchpad switch: `AUTO_EXECUTE_BULK=1`
1036
+
1037
+ Deterministic controls in `.cursor/scratchpad.md`:
1038
+
1039
+ - `AUTO_EXECUTE_MAX_ITEMS=<n>`
1040
+ - `AUTO_EXECUTE_ON_BLOCK=stop|skip`
1041
+ - `AUTO_EXECUTE_SELECTION=planned_then_priority`
1042
+ - `AUTO_TEAM_SCOPE_ENFORCE=0|1`
1043
+
1044
+ Deterministic reason codes:
1045
+ `EXEC_BULK_MAX_ITEMS_REACHED`, `EXEC_BULK_NO_ELIGIBLE_ITEMS`,
1046
+ `EXEC_BULK_ITEM_BLOCKED_STOP`, `EXEC_BULK_ITEM_BLOCKED_SKIPPED`,
1047
+ `EXEC_TEAM_SCOPE_BLOCKED`, `EXEC_TEAM_SCOPE_SKIPPED`.
1048
+
1049
+ Team-mode safety:
1050
+ - In `TEAM_MODE=1`, bulk execute records `TEAM_MODE`, `TEAM_MEMBER`,
1051
+ `ACTIVE_TASK_IDS` in state breadcrumbs.
1052
+ - With `AUTO_TEAM_SCOPE_ENFORCE=1`, out-of-scope tasks are blocked/skipped
1053
+ deterministically and never mutated.
1054
+
1055
+ ### Example 4: Existing project onboarding
1056
+
1057
+ 1. `/map-codebase`
1058
+ 2. Review generated mapping artifacts
1059
+ 3. Continue with `/intake` or `/architecture`
1060
+
1061
+ ## Other useful capabilities
1062
+
1063
+ ### Voice input (multilingual)
1064
+
1065
+ Voice is an input layer only; it feeds normal slash commands.
1066
+
1067
+ - OS dictation
1068
+ - Cursor voice (if available)
1069
+ - Local STT tooling
1070
+
1071
+ Reliable pattern:
1072
+
1073
+ - bind `/intake ` insertion shortcut
1074
+ - dictate only the content after the command
1075
+
1076
+ ### Repository layout (quick orientation)
1077
+
1078
+ - `.cursor/`: commands, rules, agents, hooks, skills, scratchpad.
1079
+ - `docs/`: product + engineering docs.
1080
+ - `sprints/`: sprint planning/tracking.
1081
+ - `handoffs/`: role-to-role transfers.
1082
+ - `decisions/`: decision records.
1083
+ - `.github/workflows/`: CI/CD templates.
1084
+
1085
+ ## Developer and release deep-dive
1086
+
1087
+ ### CI/CD via runbook
1088
+
1089
+ Workflows read keys from `docs/engineering/runbook.md`:
1090
+
1091
+ - `TEST_COMMAND`
1092
+ - `LINT_COMMAND`
1093
+ - `TYPECHECK_COMMAND`
1094
+ - `DEPLOY_STAGING_COMMAND`
1095
+ - `DEPLOY_PROD_COMMAND`
1096
+
1097
+ Unset keys are skipped. The template ships with empty values for `LINT_COMMAND`,
1098
+ `FORMAT_COMMAND`, and `TYPECHECK_COMMAND` -- this is intentional. its-magic is a
1099
+ template/installer project; fill in your project-specific commands after setup.
1100
+
1101
+ US-0015 intent contract:
1102
+ - Empty optional runbook keys are valid defaults for this repository type.
1103
+ - They must not be treated as missing required configuration.
1104
+
1105
+ ### Installer internals
1106
+
1107
+ - `installer.ps1` (Windows)
1108
+ - `installer.sh` (macOS/Linux)
1109
+ - `installer.py` (fallback)
1110
+
1111
+ Modes: `missing`, `overwrite`, `interactive`, `upgrade` (+ optional backup).
1112
+
1113
+ ### Release automation
1114
+
1115
+ Unified release scripts:
1116
+
1117
+ - Windows: `scripts/release-all.ps1`
1118
+ - macOS/Linux: `scripts/release-all.sh`
1119
+
1120
+ NPM helpers:
1121
+
1122
+ - `npm run release:all`
1123
+ - `npm run release:all:patch|minor|major|beta|dry`
1124
+ - `npm run release:npm-only|choco-only|brew-only`
1125
+
1126
+ Release script flow:
1127
+
1128
+ 1. bump `package.json` version
1129
+ 2. publish npm
1130
+ 3. create GitHub release
1131
+ 4. update/publish Chocolatey package
1132
+ 5. update/push Homebrew formula (stable or beta)
1133
+
1134
+ ```mermaid
1135
+ flowchart LR
1136
+ ReleaseAll[scripts/release-all.*] --> VerCheck{version has -?}
1137
+ VerCheck -->|stable| NPM["npm publish --tag latest"]
1138
+ VerCheck -->|prerelease| NPMBeta["npm publish --tag beta"]
1139
+ ReleaseAll --> GH["gh release create"]
1140
+ VerCheck -->|prerelease| GHPre["--prerelease flag"]
1141
+ GH --> Choco[choco pack + push]
1142
+ GH --> BrewCheck{prerelease?}
1143
+ BrewCheck -->|no| BrewStable[its-magic.rb]
1144
+ BrewCheck -->|yes| BrewBeta[its-magic-beta.rb]
1145
+ NPM --> U1["npx its-magic"]
1146
+ NPMBeta --> U1b["npx its-magic@beta"]
1147
+ Choco --> U2["choco install its-magic"]
1148
+ Choco --> U2b["choco install its-magic --pre"]
1149
+ BrewStable --> U3["brew install its-magic"]
1150
+ BrewBeta --> U3b["brew install its-magic-beta"]
1151
+ ```
1152
+
1153
+ Prereqs:
1154
+
1155
+ - `npm login`
1156
+ - `gh auth login`
1157
+ - Chocolatey API key (if choco publish)
1158
+ - Homebrew tap repo for formula distribution
1159
+
1160
+ ### Package manager installation matrix
1161
+
1162
+ | Manager | Stable | Beta / Pre-release |
1163
+ |------------|-------------------------------------------|---------------------------------------------|
1164
+ | npm/npx | `npx its-magic --target . --mode missing` | `npx its-magic@beta --target . --mode missing` |
1165
+ | Chocolatey | `choco install its-magic` | `choco install its-magic --pre` |
1166
+ | Homebrew | `brew install USER/tap/its-magic` | `brew install USER/tap/its-magic-beta` |
1167
+
1168
+ ### Release package contents
1169
+
1170
+ Published npm package includes runtime content only (commands/rules/agents/docs/installers).
1171
+
1172
+ Excluded from npm package:
1173
+
1174
+ - `benchmarks/`
1175
+ - `tests/`
1176
+ - `packaging/`
1177
+ - `Plan.md`
1178
+
1179
+ ### Benchmarks
1180
+
1181
+ - Main benchmark: `benchmarks/run-bench.ps1` or `benchmarks/run-bench.sh`
1182
+ - Live benchmark: `benchmarks/live/run-live-bench.*`
1183
+ - Prompted benchmark: `benchmarks/prompts/run-prompts.*`
1184
+ - Headless benchmark: `benchmarks/headless/run-headless.*`
1185
+
1186
+ Reports:
1187
+
1188
+ - `benchmarks/bench-report.md`
1189
+ - `benchmarks/live/live-bench-report.md`
1190
+ - `benchmarks/headless/headless-report.md`
1191
+ - `benchmarks/headless/protocol.md`
1192
+
1193
+ ```mermaid
1194
+ flowchart TD
1195
+ StartBench[Start benchmark] --> SelectScenario[Load scenarios]
1196
+ SelectScenario --> InstallKit[Install its-magic into temp workspace]
1197
+ InstallKit --> RunChecks[Validate required files/sections]
1198
+ RunChecks --> BenchReport[Write benchmarks/bench-report.md]
1199
+ ```
1200
+
1201
+ ```mermaid
1202
+ flowchart TD
1203
+ StartLive[Start live benchmark] --> SetSession[Set MAGIC_BENCH_SESSION]
1204
+ SetSession --> RunCommands[Run /* commands in Cursor]
1205
+ RunCommands --> LogHooks[Hook telemetry to bench-log.jsonl]
1206
+ LogHooks --> LiveReport[Write live-bench-report.md]
1207
+ ```
1208
+
1209
+ ```mermaid
1210
+ flowchart TD
1211
+ StartHeadless[Start headless run] --> LoadPrompt[Load prompt blocks]
1212
+ LoadPrompt --> TempWorkspace[Create temp workspace]
1213
+ TempWorkspace --> InstallHeadless[Install its-magic]
1214
+ InstallHeadless --> RunAgent[agent -p --force for each step]
1215
+ RunAgent --> ValidateOutputs[Validate files/sections/smoke checks]
1216
+ ValidateOutputs --> WriteProtocol[Write protocol.md]
1217
+ WriteProtocol --> WriteHeadlessReport[Write headless-report.md]
1218
+ ```
1219
+
1220
+ ### Rules
1221
+
1222
+ - `core.mdc`: phase flow, context pack, pause/resume, remote usage.
1223
+ - `quality.mdc`: small steps, tests/quality, optional auto-install.
1224
+ - `coding-standards.mdc`: strict language best practices and code quality rules.
1225
+ - `handoffs.mdc`: handoffs + state updates required.
1226
+ - `escalation.mdc`: decision gate and stop conditions.
1227
+
1228
+ ### Hooks
1229
+
1230
+ - `beforeShellExecution`: blocks dangerous commands.
1231
+ - `beforeReadFile`: warns on secret-like files.
1232
+ - `afterFileEdit`: tracks code edits vs context refresh.
1233
+ - `stop`: reminds context refresh when needed.
1234
+
1235
+ ### Artifacts (single source of truth)
1236
+
1237
+ - `docs/product/*`: vision, backlog, acceptance.
1238
+ - `docs/engineering/*`: architecture, decisions, state, runbook.
1239
+ - `sprints/Sxxxx/*`: sprint scope, tasks, progress, QA findings, summary.
1240
+ - `decisions/*`: decision records.
1241
+ - `handoffs/*`: role-to-role transfer notes.