its-magic 0.1.2-9 → 0.1.3-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +1602 -755
  2. package/bin/its-magic.js +121 -11
  3. package/bin/postinstall.js +93 -0
  4. package/installer.ps1 +759 -0
  5. package/installer.py +1036 -0
  6. package/installer.sh +649 -0
  7. package/package.json +18 -14
  8. package/scripts/check_intake_template_parity.py +312 -0
  9. package/scripts/doc_profile_lib.py +415 -0
  10. package/scripts/guard_installer_publish.py +88 -0
  11. package/scripts/intake_bug_routing_guard.py +67 -0
  12. package/scripts/intake_evidence_lib.py +802 -0
  13. package/scripts/intake_evidence_validate.py +73 -0
  14. package/scripts/materialize_codebase_map.py +184 -0
  15. package/scripts/remote_config_summary.py +243 -0
  16. package/template/.cursor/agents/curator.mdc +35 -0
  17. package/template/.cursor/agents/dev.mdc +29 -0
  18. package/template/.cursor/agents/po.mdc +141 -0
  19. package/template/.cursor/agents/qa.mdc +28 -0
  20. package/template/.cursor/agents/release.mdc +28 -0
  21. package/template/.cursor/agents/security.mdc +98 -0
  22. package/template/.cursor/agents/tech-lead.mdc +57 -0
  23. package/template/.cursor/commands/architecture.md +127 -0
  24. package/template/.cursor/commands/ask.md +55 -0
  25. package/template/.cursor/commands/auto.md +533 -0
  26. package/template/.cursor/commands/discovery.md +47 -0
  27. package/template/.cursor/commands/execute.md +343 -0
  28. package/template/.cursor/commands/intake.md +323 -0
  29. package/template/.cursor/commands/map-codebase.md +46 -0
  30. package/template/.cursor/commands/memory-audit.md +175 -0
  31. package/template/.cursor/commands/milestone-complete.md +51 -0
  32. package/template/.cursor/commands/milestone-start.md +59 -0
  33. package/template/.cursor/commands/pause.md +64 -0
  34. package/{.cursor/commands/gsd-phase-context.md → template/.cursor/commands/phase-context.md} +6 -2
  35. package/template/.cursor/commands/plan-verify.md +34 -0
  36. package/template/.cursor/commands/qa.md +226 -0
  37. package/template/.cursor/commands/quick.md +41 -0
  38. package/template/.cursor/commands/refresh-context.md +82 -0
  39. package/template/.cursor/commands/release.md +523 -0
  40. package/template/.cursor/commands/research.md +49 -0
  41. package/template/.cursor/commands/resume.md +67 -0
  42. package/template/.cursor/commands/security-review.md +81 -0
  43. package/template/.cursor/commands/sprint-plan.md +103 -0
  44. package/template/.cursor/commands/status-reconcile.md +95 -0
  45. package/template/.cursor/commands/verify-work.md +152 -0
  46. package/template/.cursor/dev-environment.json.example +22 -0
  47. package/{.cursor → template/.cursor}/hooks/README.md +3 -2
  48. package/{.cursor/hooks/gsd-hook.py → template/.cursor/hooks/hook.py} +15 -6
  49. package/template/.cursor/hooks.json +26 -0
  50. package/template/.cursor/remote.json +31 -0
  51. package/template/.cursor/rules/caveman.mdc +184 -0
  52. package/template/.cursor/rules/coding-standards.mdc +39 -0
  53. package/template/.cursor/rules/core.mdc +111 -0
  54. package/template/.cursor/rules/handoffs.mdc +27 -0
  55. package/template/.cursor/rules/quality.mdc +49 -0
  56. package/template/.cursor/scratchpad.local.example.md +323 -0
  57. package/template/.cursor/scratchpad.md +324 -0
  58. package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/SKILL.md +2 -2
  59. package/template/.cursorignore +6 -0
  60. package/template/.env.example +28 -0
  61. package/template/.github/workflows/ci.yml +194 -0
  62. package/{.github → template/.github}/workflows/deploy.yml +5 -2
  63. package/template/.its-magic-version +1 -0
  64. package/template/CHANGELOG.md +11 -0
  65. package/template/README.md +1602 -0
  66. package/template/decisions/DEC-0001.md +11 -0
  67. package/template/decisions/DEC-0002.md +11 -0
  68. package/template/docs/developer/README.md +44 -0
  69. package/template/docs/engineering/architecture.md +9 -0
  70. package/template/docs/engineering/artifact-ordering-policy.md +48 -0
  71. package/template/docs/engineering/artifact-ownership-policy.md +57 -0
  72. package/template/docs/engineering/auto-orchestration-reference.md +1211 -0
  73. package/{docs → template/docs}/engineering/codebase-map.md +0 -5
  74. package/template/docs/engineering/compatibility-report.md +20 -0
  75. package/template/docs/engineering/compatibility-signals.md +7 -0
  76. package/template/docs/engineering/component-scope-report.md +16 -0
  77. package/template/docs/engineering/component-scope.md +19 -0
  78. package/template/docs/engineering/context/installer-owned-paths.manifest +96 -0
  79. package/template/docs/engineering/context/readme-section-affinity.json +30 -0
  80. package/template/docs/engineering/decisions.md +16 -0
  81. package/template/docs/engineering/legacy-drift-audit.md +21 -0
  82. package/template/docs/engineering/manifests/components/api-gateway.manifest.yaml +12 -0
  83. package/template/docs/engineering/manifests/registry.manifest.yaml +20 -0
  84. package/template/docs/engineering/manifests/repo.manifest.yaml +11 -0
  85. package/template/docs/engineering/phase-context.md +16 -0
  86. package/template/docs/engineering/release-targets.json +123 -0
  87. package/template/docs/engineering/research.md +29 -0
  88. package/template/docs/engineering/runbook.md +2391 -0
  89. package/template/docs/engineering/runtime-connectivity.md +81 -0
  90. package/template/docs/engineering/security-review.md +33 -0
  91. package/template/docs/engineering/spec-pack/README.md +20 -0
  92. package/template/docs/engineering/state-archive/README.md +15 -0
  93. package/template/docs/engineering/state.md +20 -0
  94. package/template/docs/engineering/status-normalization-report.md +19 -0
  95. package/template/docs/engineering/token-cost-parity-manifest.md +16 -0
  96. package/template/docs/engineering/us-0084-remote-e2e.md +44 -0
  97. package/template/docs/product/acceptance.md +1 -0
  98. package/template/docs/product/backlog.md +5 -0
  99. package/template/docs/product/vision.md +11 -0
  100. package/template/docs/user-guides/README.md +40 -0
  101. package/{handoffs → template/handoffs}/dev_to_qa.md +0 -3
  102. package/{handoffs → template/handoffs}/po_to_tl.md +0 -3
  103. package/{handoffs → template/handoffs}/qa_to_dev.md +1 -2
  104. package/template/handoffs/release_notes.md +51 -0
  105. package/template/handoffs/release_queue.md +47 -0
  106. package/template/handoffs/release_to_dev.md +31 -0
  107. package/template/handoffs/releases/Sxxxx-release-notes.md +62 -0
  108. package/template/handoffs/releases/vX.Y.Z-release-notes.md.example +21 -0
  109. package/template/handoffs/resume_brief.md +14 -0
  110. package/{handoffs → template/handoffs}/tl_to_dev.md +0 -2
  111. package/template/handoffs/token_cost_runs/README.md +26 -0
  112. package/template/its_magic/.its-magic-version +1 -0
  113. package/template/its_magic/README.md +9 -0
  114. package/template/scripts/auto_outer_driver.py +521 -0
  115. package/template/scripts/caveman_compress_input.py +903 -0
  116. package/template/scripts/check_downstream_ci_guard.py +67 -0
  117. package/template/scripts/check_intake_template_parity.py +312 -0
  118. package/template/scripts/check_token_cost_parity.py +69 -0
  119. package/template/scripts/dev_environment_lib.py +601 -0
  120. package/template/scripts/doc_profile_lib.py +415 -0
  121. package/template/scripts/downstream_ci_guard_lib.py +222 -0
  122. package/template/scripts/enforce-triad-hot-surface.py +753 -0
  123. package/template/scripts/guard_installer_publish.py +88 -0
  124. package/template/scripts/intake_bug_resume_brief_refresh.py +303 -0
  125. package/template/scripts/intake_bug_routing_guard.py +67 -0
  126. package/template/scripts/intake_evidence_lib.py +802 -0
  127. package/template/scripts/intake_evidence_validate.py +73 -0
  128. package/template/scripts/materialize_codebase_map.py +184 -0
  129. package/template/scripts/pack_json_validate.py +130 -0
  130. package/template/scripts/project_readme_coverage_lib.py +417 -0
  131. package/template/scripts/readme_feature_coverage_lib.py +608 -0
  132. package/{scripts → template/scripts}/release-all.sh +27 -4
  133. package/template/scripts/release_changelog_backfill.py +153 -0
  134. package/template/scripts/release_changelog_lib.py +544 -0
  135. package/template/scripts/release_changelog_validate.py +134 -0
  136. package/template/scripts/remote_config_summary.py +243 -0
  137. package/template/scripts/sync_push_gates.py +198 -0
  138. package/template/scripts/token_cost_compare.py +40 -0
  139. package/template/scripts/token_cost_lib.py +108 -0
  140. package/template/scripts/uat_probe_lib.py +868 -0
  141. package/template/scripts/validate-and-push.ps1 +280 -0
  142. package/template/scripts/validate-and-push.sh +243 -0
  143. package/template/scripts/validate_doc_profile.py +103 -0
  144. package/template/scripts/validate_project_readme_coverage.py +151 -0
  145. package/template/scripts/validate_readme_feature_coverage.py +140 -0
  146. package/template/sprints/S0001/progress.md +1 -0
  147. package/template/sprints/S0001/qa-findings.md +9 -0
  148. package/template/sprints/S0001/release-findings.md +24 -0
  149. package/template/sprints/S0001/sprint.md +9 -0
  150. package/template/sprints/S0001/summary.md +7 -0
  151. package/template/sprints/S0001/tasks.md +1 -0
  152. package/template/sprints/S0001/uat.json +6 -0
  153. package/template/sprints/S0001/uat.md +5 -0
  154. package/template/sprints/quick/Q0001/summary.md +1 -0
  155. package/{sprints → template/sprints}/quick/Q0001/task.json +0 -1
  156. package/.cursor/agents/curator.mdc +0 -21
  157. package/.cursor/agents/dev.mdc +0 -20
  158. package/.cursor/agents/po.mdc +0 -19
  159. package/.cursor/agents/qa.mdc +0 -19
  160. package/.cursor/agents/release.mdc +0 -19
  161. package/.cursor/agents/tech-lead.mdc +0 -21
  162. package/.cursor/commands/gsd-architecture.md +0 -29
  163. package/.cursor/commands/gsd-auto.md +0 -27
  164. package/.cursor/commands/gsd-discovery.md +0 -27
  165. package/.cursor/commands/gsd-execute.md +0 -32
  166. package/.cursor/commands/gsd-intake.md +0 -28
  167. package/.cursor/commands/gsd-map-codebase.md +0 -25
  168. package/.cursor/commands/gsd-milestone-complete.md +0 -24
  169. package/.cursor/commands/gsd-milestone-start.md +0 -26
  170. package/.cursor/commands/gsd-pause.md +0 -25
  171. package/.cursor/commands/gsd-plan-verify.md +0 -26
  172. package/.cursor/commands/gsd-qa.md +0 -28
  173. package/.cursor/commands/gsd-quick.md +0 -24
  174. package/.cursor/commands/gsd-refresh-context.md +0 -26
  175. package/.cursor/commands/gsd-release.md +0 -29
  176. package/.cursor/commands/gsd-research.md +0 -28
  177. package/.cursor/commands/gsd-resume.md +0 -26
  178. package/.cursor/commands/gsd-sprint-plan.md +0 -30
  179. package/.cursor/commands/gsd-verify-work.md +0 -25
  180. package/.cursor/hooks.json +0 -26
  181. package/.cursor/plans/cursor-gsd-team-kit_8cfee9b8.plan.md +0 -57
  182. package/.cursor/remote.json +0 -18
  183. package/.cursor/rules/gsd-core.mdc +0 -18
  184. package/.cursor/rules/gsd-handoffs.mdc +0 -10
  185. package/.cursor/rules/gsd-quality.mdc +0 -15
  186. package/.cursor/scratchpad.md +0 -34
  187. package/.github/workflows/ci.yml +0 -47
  188. package/decisions/DEC-0001.md +0 -21
  189. package/decisions/DEC-0002.md +0 -21
  190. package/docs/engineering/architecture.md +0 -354
  191. package/docs/engineering/decisions.md +0 -6
  192. package/docs/engineering/research.md +0 -11
  193. package/docs/engineering/runbook.md +0 -32
  194. package/docs/engineering/state.md +0 -33
  195. package/docs/product/acceptance.md +0 -6
  196. package/docs/product/backlog.md +0 -7
  197. package/docs/product/vision.md +0 -46
  198. package/gsd-installer.ps1 +0 -189
  199. package/gsd-installer.py +0 -195
  200. package/gsd-installer.sh +0 -201
  201. package/handoffs/release_notes.md +0 -14
  202. package/handoffs/resume_brief.md +0 -8
  203. package/milestones/M0001/milestone.json +0 -7
  204. package/milestones/M0001/phases.json +0 -9
  205. package/milestones/M0001/progress.md +0 -3
  206. package/milestones/M0001/summary.md +0 -3
  207. package/scripts/generate-release-notes.ps1 +0 -74
  208. package/scripts/generate-release-notes.sh +0 -63
  209. package/scripts/release-all.ps1 +0 -423
  210. package/sprints/S0001/progress.md +0 -4
  211. package/sprints/S0001/qa-findings.md +0 -113
  212. package/sprints/S0001/sprint.md +0 -70
  213. package/sprints/S0001/summary.md +0 -46
  214. package/sprints/S0001/tasks.md +0 -35
  215. package/sprints/S0001/uat.json +0 -8
  216. package/sprints/S0001/uat.md +0 -8
  217. package/sprints/quick/Q0001/summary.md +0 -3
  218. /package/{.cursor/rules/gsd-escalation.mdc → template/.cursor/rules/escalation.mdc} +0 -0
  219. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/acceptance.json +0 -0
  220. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/acceptance.md +0 -0
  221. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/architecture.json +0 -0
  222. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/architecture.md +0 -0
  223. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/decision.json +0 -0
  224. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/decision.md +0 -0
  225. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/handoff.json +0 -0
  226. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/handoff.md +0 -0
  227. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/milestone.json +0 -0
  228. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/phase-context.json +0 -0
  229. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/plan-verify.json +0 -0
  230. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/sprint.json +0 -0
  231. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/sprint.md +0 -0
  232. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/story.json +0 -0
  233. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/story.md +0 -0
  234. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/uat.json +0 -0
  235. /package/{docs → template/docs}/engineering/context/phase-template.json +0 -0
  236. /package/{docs → template/docs}/engineering/dependencies.json +0 -0
  237. /package/{sprints → template/sprints}/S0001/plan-verify.json +0 -0
@@ -0,0 +1,1602 @@
1
+ # its-magic — AI dev team
2
+
3
+ [GitHub Repository](https://github.com/fl0wm0ti0n/its-magic)
4
+
5
+ You bring the idea; its-magic is your structured **AI dev team** in Cursor — PO, Tech
6
+ Lead, Dev, QA, Release, and Curator — that turns ideas into shipped software through
7
+ explicit phases and handoff artifacts.
8
+
9
+ State lives in repo files (`docs/product`, `handoffs`, `sprints`, `decisions`) — not
10
+ chat-only memory. Run `/intake` with your idea, then follow intake → discovery →
11
+ architecture → sprint plan → execute → QA → release; pause/resume and decision gates
12
+ keep you in control when you want to steer. Implementers: see `docs/developer/README.md`
13
+ for the DEV shard.
14
+
15
+ When you want hands-off delivery, enable **`AUTO_FLOW_MODE=full_autonomy`**
16
+ (default-off), run **`/auto` once in Cursor**, and let the native in-chat auto-chain
17
+ drain your backlog — self-verify UAT, bounded block retry, and advance to the next OPEN
18
+ story or bug without re-invoking each phase manually. The outer driver is **optional**
19
+ (**fallback** for headless/CI or when native chain is unavailable). Guided and
20
+ decision-gated modes remain the default.
21
+
22
+ ## Features (what its-magic can do)
23
+
24
+ ### Autonomous AI workflow
25
+
26
+ - Run `/intake` through `/release` with explicit phase handoffs and fresh subagent contexts.
27
+ - Use `/pause` and `/resume` with checkpoints when you want to steer; escalate blocking
28
+ choices to `decisions/DEC-xxxx.md`.
29
+ - Enable **`AUTO_FLOW_MODE=full_autonomy`** (default-off), run **`/auto` once in Cursor**,
30
+ and drain backlog in-chat; outer driver is **optional** / **fallback** for headless/CI.
31
+ - Team mode routes work across PO, Tech Lead, Dev, QA, Release, and Curator roles.
32
+ - Backlog and bug drain advance OPEN items without re-invoking each phase manually.
33
+ - See the catalog in **Commands and workflow** for phase commands and orchestration details.
34
+
35
+ ### Quality & verification gates
36
+
37
+ - 3-layer quality chain: AI execute/QA loop → local `validate-and-push` → CI auto-fix.
38
+ - Phase gates include `/plan-verify`, `/qa`, `/verify-work`, and `/uat` with fail-closed stops.
39
+ - `/acceptance` blocks README ↔ backlog drift; user-visible metadata guard on operator scripts.
40
+ - Browser UAT probes with structured fallback when live browser checks are unavailable.
41
+ - Release gates enforce coverage, parity, and evidence before publish.
42
+ - See the catalog in **Features** (`/acceptance`) and **Commands and workflow** for gate commands.
43
+
44
+ ### Distribution & install
45
+
46
+ - Global install via npm, npx, Chocolatey, or Homebrew; apply to any repo with
47
+ `its-magic --target`.
48
+ - Modes: `missing` (safe merge), `overwrite` (+ `--backup`), `upgrade` (framework only),
49
+ and `--clean-repo`.
50
+ - Lifecycle QA matrix validates fresh install, upgrade, backup, and clean-repo paths.
51
+ - Multi-target release publish with confirmation gates for npm/choco/brew.
52
+ - See the **Feature coverage catalog** below for distribution-tagged items.
53
+
54
+ ### Operator control & ergonomics
55
+
56
+ - Scratchpad flags and `scratchpad.local.md` tune behavior without rewriting framework files.
57
+ - Guided intake packs structure your first `/intake` conversation.
58
+ - Caveman voice mode and optional input compression for terse operator UX.
59
+ - `TOKEN_PROFILE` cost profiles slim context packs without changing workflow semantics.
60
+ - Voice input shortcuts and permissions/runtime connectivity for remote execution.
61
+ - See the catalog in **Other useful capabilities** for scratchpad and governance flags.
62
+
63
+ <!-- readme-feature-coverage-catalog -->
64
+
65
+ ### Feature coverage catalog (US-0091)
66
+
67
+ - `/acceptance` — README ↔ backlog/acceptance feature coverage backfill + blocking drift gate (`US-0091`).
68
+ - `README.md` — Visionary intro + tiered feature hierarchy (autonomous AI dev team positioning, root/template parity) (`US-0094`).
69
+ - `/auto` — Native in-chat auto-chain + full-autonomy mode (`US-0095`, `US-0092`).
70
+ - `/bin` — POSIX npm installer + Linux remote test targets (WSL / SSH / Docker) (`US-0084`).
71
+ - `/choco` — Configurable Multi-Target Release Publish with Confirmation Gate (`US-0054`).
72
+ - `/devops` — First-Class Bug Issue Workflow (Open/Closed) (`US-0079`).
73
+ - `/engineering` — Agent-Driven Codebase Map Bootstrap (`US-0082`).
74
+ - `/engineering` — Remote Runtime Connectivity Contract for QA/Release/Publish (`US-0064`).
75
+ - `/install` — Template/install payload omits intake gate scripts (`BUG-0001`).
76
+ - `/installed` — its-magic ships its OWN packaging CI into generated repos, breaking CI in every created project (`BUG-0009`).
77
+ - `/intake` — Optional Caveman-style input compression (safe file scope) (`US-0090`).
78
+ - `/lint` — CI/CD Workflows (`US-0007`).
79
+ - `/or` — Cursor Caveman mode (scratchpad-configurable terse responses) (`US-0089`).
80
+ - `/push` — Multiplatform Distribution (`US-0009`).
81
+ - `/run-tests` — Baseline Regression Cleanup for Installer and Version Sync Checks (`US-0074`).
82
+ - `/template` — End-to-End Lifecycle QA for `its-magic` Install/Upgrade/Clean (`US-0041`).
83
+ - `/upgrade` — Missing scripts still occur on install modes missing/upgrade (`BUG-0003`).
84
+ - `/usr` — Global Linux install fails: empty `install_include_paths` when manifest is CRLF (`BUG-0008`).
85
+ - `/workdir` — installer.sh fails in shell path with `set: Illegal option -` (`BUG-0004`).
86
+ - `MIGRATION` scratchpad flag — Smart Upgrade Mode (`US-0018`).
87
+ - `US-0016` scratchpad flag — Homebrew Version Sync (`US-0016`).
88
+
89
+ ## Setup
90
+
91
+ its-magic is an installer you run once per repo. It copies the AI dev team
92
+ workflow files (`.cursor/` commands, rules, agents, hooks, skills, plus `docs/`,
93
+ `sprints/`, `handoffs/`, etc.) into your project.
94
+
95
+ Starter artifacts are shipped as clean placeholders (no preloaded sprint/demo
96
+ history), so `/intake` starts from your own idea.
97
+
98
+ ### 1) Install its-magic (once)
99
+
100
+ Pick one method:
101
+
102
+ | Method | Install command |
103
+ |--------|----------------|
104
+ | npm | `npm install -g its-magic` |
105
+ | npx | `npx its-magic --target . --mode missing` |
106
+ | Chocolatey | `choco install its-magic` (Admin shell) |
107
+ | Homebrew | `brew tap USER/tap && brew install its-magic` |
108
+
109
+ ### Global Linux install: empty `install_include_paths` (CRLF manifest)
110
+
111
+ If **`its-magic --target <repo> --mode missing`** fails with **`[INSTALL_MANIFEST_ERROR] install_include_paths section is empty`** on Debian/Linux while the packaged manifest still lists paths, the global install likely has **CRLF** line endings in **`installer-owned-paths.manifest`** (visible as **`^M$`** with **`cat -A`**). **Fix in-tree** from **`0.1.2-41`**: **`installer.sh`** strips trailing carriage returns before section matching; **`.gitattributes`** keeps **`*.manifest`** LF; **`prepublishOnly`** runs **`guard_installer_publish`**. **Upgrade**: install a build **≥ `0.1.2-41`** (or reinstall from a fresh **`npm pack`** tarball after pull). Older tarballs such as **`its-magic@0.1.2-40`** may remain broken until republished — see **`docs/engineering/architecture.md`** **`# BUG-0008`**.
112
+
113
+ ### 2) Apply to a repo
114
+
115
+ New repo:
116
+
117
+ ```bash
118
+ mkdir my-project && cd my-project
119
+ git init
120
+ its-magic --target . --mode missing --create
121
+ ```
122
+
123
+ Existing repo (safe merge):
124
+
125
+ ```bash
126
+ its-magic --target . --mode missing
127
+ ```
128
+
129
+ Existing repo (overwrite + backup):
130
+
131
+ ```bash
132
+ its-magic --target . --mode overwrite --backup
133
+ ```
134
+
135
+ ### Upgrading an existing repo
136
+
137
+ When you update its-magic to a newer version (`npm update -g its-magic`), run
138
+ upgrade mode to update framework files while preserving your project data:
139
+
140
+ ```bash
141
+ its-magic --target . --mode upgrade
142
+ ```
143
+
144
+ What upgrade does:
145
+
146
+ - **Framework files** (commands, rules, agents, hooks, skills, CI, scripts) are
147
+ updated to the latest version.
148
+ - **User data** (docs, sprints, handoffs, decisions, runbook) is never touched.
149
+ - **Mixed files** (`README.md`) are preserved. If the template version has new
150
+ content, a review notice is printed.
151
+ - **Scratchpad baseline (DEC-0055 / US-0073, Model B):** `.cursor/scratchpad.md`
152
+ is not copied as a manifest file; the installer **materializes** it from the
153
+ packaged template when missing and validates required merged keys (Python
154
+ required). Legacy repos that already committed `.cursor/scratchpad.md` keep it on
155
+ upgrade (not overwritten).
156
+ - A canonical version marker is stored at `its_magic/.its-magic-version` in your repo.
157
+ - Installer bootstrap is OS-aware + stack-aware for runbook command defaults
158
+ (`TEST_COMMAND`, optional `LINT_COMMAND`/`TYPECHECK_COMMAND`) and preserves
159
+ explicit user overrides.
160
+
161
+ Upgrade with backup (backs up framework files before updating):
162
+
163
+ ```bash
164
+ its-magic --target . --mode upgrade --backup
165
+ ```
166
+
167
+ ### 3) Open in Cursor
168
+
169
+ 1. Open the project folder
170
+ 2. Run `/intake` with your idea
171
+ 3. Follow the workflow
172
+
173
+ ### CLI quick commands
174
+
175
+ ```bash
176
+ # Show banner + help
177
+ its-magic
178
+
179
+ # Show version only
180
+ its-magic --version
181
+
182
+ # Install workflow files into current repo
183
+ its-magic --target . --mode missing
184
+
185
+ # Clean previously installed workflow artifacts
186
+ its-magic --clean-repo --target .
187
+ ```
188
+
189
+ ### Installer options
190
+
191
+ **Install options**
192
+
193
+ | Flag | Description |
194
+ |------|-------------|
195
+ | `--target <path>` | Path to the repository where workflow files are installed. If omitted you are prompted interactively. |
196
+ | `--mode missing` | **Default.** Only copy files that do not exist yet. Safe for repos that already have some workflow files. |
197
+ | `--mode overwrite` | Replace every file, even if it already exists. Combine with `--backup` to keep a snapshot first. |
198
+ | `--mode interactive` | Ask per file whether to overwrite or skip. Useful when you want to cherry-pick updates. |
199
+ | `--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. |
200
+ | `--backup` | Before overwriting, save existing files to `backups/<timestamp>/`. Ignored in `missing` mode (nothing gets replaced). |
201
+ | `--create` | Create the target directory if it does not exist. |
202
+
203
+ **Clean options**
204
+
205
+ | Flag | Description |
206
+ |------|-------------|
207
+ | `--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. |
208
+ | `--yes` | Skip the confirmation prompt when cleaning. |
209
+
210
+ **Info**
211
+
212
+ | Flag | Description |
213
+ |------|-------------|
214
+ | `--help`, `-h` | Show banner, version, repo URL, and full usage reference. |
215
+ | `--version`, `-v` | Print the installed its-magic version and exit. |
216
+
217
+ ### Lifecycle QA matrix (US-0041)
218
+
219
+ `its-magic` lifecycle behavior is validated in both installer and CLI paths.
220
+ Primary coverage:
221
+
222
+ | Scenario | Local coverage | CI coverage | Expected evidence |
223
+ |---|---|---|---|
224
+ | Fresh install (`missing`) | `tests/run-tests.ps1`, `tests/run-tests.sh` | npm/brew/choco jobs | Required files + `its_magic/.its-magic-version` |
225
+ | Overwrite + backup | `tests/run-tests.ps1`, `tests/run-tests.sh` | lifecycle subset in CI jobs | Backup snapshot contains overwritten framework file |
226
+ | 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 |
227
+ | 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 |
228
+ | Negative-path invalid mode/args | `tests/run-tests.ps1`, `tests/run-tests.sh` | lifecycle subset in CI jobs | Non-zero fail-fast behavior |
229
+
230
+ Run locally:
231
+
232
+ ```bash
233
+ sh tests/run-tests.sh
234
+ powershell -ExecutionPolicy Bypass -File tests/run-tests.ps1
235
+ ```
236
+
237
+ ## How-to
238
+
239
+ ### Command usage pattern
240
+
241
+ - Best practice: use `/<command>` + 1-3 lines context.
242
+ - For quick ops (`/pause`, `/resume`, `/refresh-context`) command-only is fine.
243
+
244
+ ### What gets installed
245
+
246
+ ```text
247
+ your-project/
248
+ .cursor/commands/ Cursor slash commands
249
+ .cursor/rules/ AI behavior rules
250
+ .cursor/agents/ Subagent definitions
251
+ .cursor/skills/ Reusable skills
252
+ .cursor/hooks/ Automation hooks
253
+ .cursor/scratchpad.md Materialized shared defaults (Model B; not manifest-copied)
254
+ .cursor/scratchpad.local.example.md Framework default key catalog
255
+ docs/ Engineering & product docs, runbook
256
+ sprints/ Sprint tracking artifacts
257
+ handoffs/ Phase handoff artifacts
258
+ decisions/ Decision records
259
+ scripts/validate-and-push.ps1 Local test-fix-push loop (Windows)
260
+ scripts/validate-and-push.sh Local test-fix-push loop (Linux/Mac)
261
+ .github/workflows/ CI with auto-fix loop
262
+ README.md
263
+ ```
264
+
265
+ ### Team mode local overrides (recommended)
266
+
267
+ Use three layers (merge precedence: **local > materialized baseline > example**,
268
+ `DEC-0055`):
269
+
270
+ - Framework catalog: `.cursor/scratchpad.local.example.md` (installed; refreshed on upgrade)
271
+ - Shared team baseline: `.cursor/scratchpad.md` (materialized on install when missing; commit as you prefer)
272
+ - Personal overrides: `.cursor/scratchpad.local.md` (gitignored; never overwritten by install/upgrade)
273
+
274
+ Setup:
275
+
276
+ 1. Run `its-magic` — baseline is materialized and merged validation runs (requires Python on PATH for `installer.ps1` / `installer.sh`).
277
+ 2. Optionally copy `.cursor/scratchpad.local.example.md` to `.cursor/scratchpad.local.md` for personal values (`TEAM_MEMBER`, `ACTIVE_TASK_IDS`, …).
278
+
279
+ Recovery if `.cursor/scratchpad.md` is missing or merge validation fails:
280
+
281
+ ```bash
282
+ python installer.py --scratchpad-postinstall --target . --mode missing
283
+ ```
284
+
285
+ Upgrade behavior (US-0057 / DEC-0057):
286
+ - Aligns with **DEC-0039** (example vs local ownership), **DEC-0057** (example-first
287
+ ordering relative to baseline materialization), and Model B baseline rules below.
288
+
289
+ - `.cursor/scratchpad.local.example.md` is framework-owned and always refreshed from
290
+ the shipped template during post-install **before** baseline handling (`DEC-0057` **AC-1..AC-3**).
291
+ - `.cursor/scratchpad.local.md` is user-owned and preserved on `--mode upgrade`.
292
+ - Existing `.cursor/scratchpad.md` is left untouched on upgrade unless missing (then
293
+ materialized) or `overwrite` / fresh materialize paths apply (Model B).
294
+ - Installer output uses `[SCRATCHPAD_LAYER]` lines to distinguish example refresh,
295
+ baseline materialize/skip, and user-local preservation (`DEC-0057` **AC-5**).
296
+ - Paired catalog parity (baseline vs `.cursor/scratchpad.local.example.md`, active and
297
+ `template/`): `python scripts/check-scratchpad-pair-parity.py --repo .` (wired into
298
+ `tests/run-tests.ps1` / `tests/run-tests.sh`; **AC-11**).
299
+
300
+ Deterministic ordering behavior (US-0058):
301
+ - Mutable artifacts follow `docs/engineering/artifact-ordering-policy.md`.
302
+ - `state.md` checkpoints are append-bottom; `backlog.md` and `acceptance.md`
303
+ remain sorted-canonical by story ID.
304
+ - Commands fail closed on ambiguous placement anchors using
305
+ `ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS`.
306
+ - Commands fail closed on non-monotonic state checkpoint timestamps using
307
+ `STATE_TIMESTAMP_NON_MONOTONIC`.
308
+
309
+ Intake runtime safety behavior (US-0059):
310
+ - `/intake` requires role-specific `po` capability by default and fails fast with
311
+ `SUBAGENT_CAPABILITY_UNAVAILABLE` when unavailable.
312
+ - Silent in-band fallback is disabled by default and only allowed with explicit
313
+ `INTAKE_SUBAGENT_FALLBACK=allow`.
314
+ - Drift detection distinguishes self-write updates from external concurrent
315
+ writers; true conflicting external writes fail safe with
316
+ `INTAKE_CONCURRENT_WRITER_DETECTED`.
317
+
318
+ Runtime QA autopilot behavior (US-0065):
319
+ - Generated-project QA must include runtime proof chain:
320
+ `startup -> readiness/connectivity -> log scan -> bounded retry -> verdict`.
321
+ - Deterministic runtime fail codes:
322
+ `RUNTIME_STARTUP_FAILED`, `RUNTIME_ENDPOINT_UNREACHABLE`,
323
+ `RUNTIME_LOG_CRITICAL_DETECTED`, `RUNTIME_RETRY_BUDGET_EXHAUSTED`,
324
+ `RUNTIME_STACK_PROFILE_UNRESOLVED`.
325
+ - Runtime evidence must include startup command/profile, runtime mode
326
+ (`local|remote`), health result, retry ledger, and log severity summary.
327
+ - Stack-aware runtime profile resolution is required for Node/Python/Go/Java/.NET;
328
+ unresolved stacks fail closed (no generic silent PASS fallback).
329
+ - For webapp contexts, QA includes browser-surface verification with
330
+ console/network error signals.
331
+
332
+ Generated test scaffolding + auto-run behavior (US-0066):
333
+ - `/execute` resolves stack profile (`node|python|go|java|dotnet`) and generates
334
+ missing baseline unit/integration/acceptance tests only.
335
+ - Generation is non-destructive by default: preserve user-authored tests/config,
336
+ fill only missing baseline assets, keep reruns idempotent.
337
+ - `TEST_COMMAND` wiring is deterministic:
338
+ - preserve existing non-empty user command,
339
+ - set stack baseline only when command is missing/unset.
340
+ - `/qa` automatically runs the generated baseline tests and records deterministic
341
+ evidence (`command`, `result`, `output ref`, `generated paths ref`).
342
+ - Fail-closed scaffold diagnostics:
343
+ `TEST_SCAFFOLD_STACK_UNRESOLVED`,
344
+ `TEST_SCAFFOLD_UNSUPPORTED_STACK`,
345
+ `TEST_SCAFFOLD_GENERATION_FAILED`.
346
+ - Static baseline test pass does not bypass runtime autopilot; runtime verdict
347
+ remains mandatory for QA PASS.
348
+
349
+ ## Commands and workflow
350
+
351
+ ### Core commands
352
+
353
+ - `/ask`: ask questions using project context (read-only, no artifacts created).
354
+ - `/intake`: capture idea, backlog, acceptance.
355
+ - `/discovery`: collect UX/product references.
356
+ - `/research`: risks, patterns, dependencies.
357
+ - `/architecture`: technical approach and decisions.
358
+ - `/sprint-plan`: sprint and task list.
359
+ - `/plan-verify`: acceptance coverage check.
360
+ - `/execute`: implement tasks.
361
+ - `/qa`: test and report findings.
362
+ - `/verify-work`: UAT.
363
+ - `/release`: release notes + runbook updates.
364
+ - `/memory-audit`: read-only memory drift check with advisory report.
365
+ - `/pause`, `/resume`, `/refresh-context`.
366
+ - `/auto`: orchestration mode that spawns a fresh subagent per phase.
367
+
368
+ ### Guided intake behavior (US-0033)
369
+
370
+ `/intake` supports two PO interaction modes via `.cursor/scratchpad.md`:
371
+
372
+ - `INTAKE_GUIDED_MODE=1` (default)
373
+ - asks targeted follow-up only when needed for concrete acceptance
374
+ - presents options/alternatives before recommendation
375
+ - preserves user decision authority
376
+ - runs intake-time research and persists R-xxxx evidence
377
+ - `INTAKE_GUIDED_MODE=0` (low-touch)
378
+ - skips proactive follow-up/options/research overhead unless user requests it
379
+ - still performs duplicate/overlap check against backlog
380
+
381
+ ### Intake decomposition + risk-aware questioning (US-0051)
382
+
383
+ When guided mode is enabled, `/intake` now supports bounded decomposition for
384
+ broad/high-risk requests:
385
+
386
+ - runs deterministic breadth/risk heuristics (feature/workflow count,
387
+ cross-cutting impact, acceptance breadth, unknown dependencies)
388
+ - proposes bounded multi-story decomposition when heuristics indicate broad
389
+ scope; keeps single-story default for narrow scope
390
+ - enforces vertical-slice/workflow-step split quality (independently valuable,
391
+ testable stories; avoid technical-layer-only splits by default)
392
+ - preserves user control before persistence: accept, merge, or adjust split
393
+ - asks additional targeted questions on high-risk/high-impact intake (not
394
+ ambiguity-only), but keeps rounds bounded and concise
395
+ - keeps low-touch compatibility: no forced decomposition when
396
+ `INTAKE_GUIDED_MODE=0` unless explicitly requested
397
+ - records decomposition/questioning evidence in intake artifacts
398
+ (`docs/product/backlog.md`, `docs/product/acceptance.md`,
399
+ `handoffs/po_to_tl.md`)
400
+
401
+ ### Mandatory intake question packs (US-0068)
402
+
403
+ `/intake` now enforces deterministic minimum questionnaire packs before
404
+ backlog/acceptance persistence:
405
+
406
+ - `first-intake-pack` for first/new/broad requests
407
+ - `small-intake-pack` for narrow follow-up requests
408
+
409
+ Fail-closed coverage behavior:
410
+
411
+ - required topic answers must be covered for the selected pack before write
412
+ - unknown/ambiguous stack cues fail closed to `first-intake-pack`
413
+ - persistence blocks with deterministic reason codes when required coverage is
414
+ incomplete and assumptions are not explicitly confirmed
415
+
416
+ Deterministic reason codes:
417
+
418
+ - `INTAKE_REQUIRED_TOPIC_MISSING`
419
+ - `INTAKE_REQUIRED_PACK_INCOMPLETE`
420
+ - `INTAKE_ASSUMPTION_CONFIRMATION_REQUIRED`
421
+ - `INTAKE_PERSISTENCE_BLOCKED`
422
+
423
+ Intake artifacts must persist coverage evidence fields:
424
+
425
+ - `asked_topics`
426
+ - `missing_topics`
427
+ - `assumptions_confirmed`
428
+
429
+ ### Interactive intake evidence + validator (US-0078 / DEC-0060)
430
+
431
+ **US-0078** closes silent persistence: every intake that mutates backlog/acceptance must pass the
432
+ deterministic **`intake_evidence`** gate — **`topic_coverage`** with valid **`ie:`** refs,
433
+ asked-vs-covered alignment, and **`assumption_confirmation_ref`** when assumptions are affirmative.
434
+
435
+ - Run `python scripts/intake_evidence_validate.py --self-test` (also exercised via `tests/run-tests.*` §26k).
436
+ - **Packaged installs (BUG-0001 / DEC-0063)**: the intake gate modules (`intake_evidence_validate.py`, `intake_evidence_lib.py`, `intake_bug_routing_guard.py`) ship under **`template/scripts/`** and hydrate consumer repos at **`scripts/`** (npm **`files`**, Chocolatey/Homebrew **`template/`** tree, **`installer.ps1` / `installer.sh`** + **`installer-owned-paths.manifest`**). **`--mode upgrade`** treats them as framework files (added/updated like other shipped scripts). CI parity: **`python scripts/check_intake_template_parity.py --repo .`** (`tests/run-tests.*` §26N).
437
+ - Operator docs: **`decisions/DEC-0060.md`**, **`docs/engineering/architecture.md`** **`# US-0078`**, runbook section **Interactive intake evidence validation (US-0078 / DEC-0060)**.
438
+ - **Guided** and **low-touch** share the **same pre-persistence validation pipeline**; low-touch does not bypass mandatory pack coverage.
439
+
440
+ ### Bug issues + intake routing (US-0079 / DEC-0061)
441
+
442
+ Defects use **`BUG-####`** under **`docs/product/backlog.md`** **`## Bug issues (canonical)`** with **`OPEN`/`DONE`** only and minimum reproducibility fields. Intake must not silently file defect prose as **`US-xxxx`**: set merged scratchpad **`INTAKE_WORK_ITEM_KIND=bug`** and/or use **`/intake bug`**, then run **`python scripts/intake_bug_routing_guard.py --kind story --file <prose.txt>`** before story allocation when in doubt.
443
+
444
+ - Validators: `python scripts/bug_issue_validate.py --self-test`; `python scripts/bug_issue_validate.py --backlog docs/product/backlog.md --check-acceptance`.
445
+ - Operator docs: **`decisions/DEC-0061.md`**, **`docs/engineering/architecture.md`** **`# US-0079`**, runbook **Bug issues (US-0079 / DEC-0061)**.
446
+
447
+ ### Optional ID namespace bootstrap (US-0052)
448
+
449
+ Fresh-project ID bootstrap behavior is explicit and default-off:
450
+
451
+ - `ID_NAMESPACE_BOOTSTRAP=0|1` in `.cursor/scratchpad.md` (default `0`)
452
+
453
+ When enabled (`1`), workflows use deterministic freshness checks before first ID
454
+ creation:
455
+
456
+ - no `US-` IDs in `docs/product/backlog.md`
457
+ - no `DEC-` IDs in `docs/engineering/decisions.md` / `decisions/DEC-*.md`
458
+ - no `R-` IDs in `docs/engineering/research.md`
459
+
460
+ If eligible, first IDs start at `US-0001`, `DEC-0001`, and `R-0001`. If not
461
+ eligible (or mode is off), generation continues from highest existing IDs.
462
+ Historical IDs are never rewritten or renumbered. Ineligible bootstrap requests
463
+ emit deterministic diagnostic `ID_BOOTSTRAP_NOT_FRESH`.
464
+
465
+ ### Context compaction + tiered token profile (US-0053)
466
+
467
+ Token-cost behavior is controlled by `.cursor/scratchpad.md`:
468
+
469
+ - `TOKEN_PROFILE=lean|balanced|full` (default `balanced`)
470
+
471
+ Profile behavior:
472
+
473
+ - `lean`: reduce non-critical overhead defaults (automation/research/context
474
+ breadth) while keeping mandatory quality gates intact.
475
+ - `balanced`: preserve current capabilities with moderate overhead.
476
+ - `full`: maximize context breadth/autonomy for high-uncertainty work.
477
+
478
+ Manual override precedence:
479
+
480
+ - Explicit scratchpad flag values override profile defaults for that flag.
481
+ - Profile mode never disables mandatory `/qa` -> `/verify-work` -> `/release`
482
+ gate semantics.
483
+
484
+ Compaction behavior:
485
+
486
+ - `docs/engineering/state.md` is the active hot surface.
487
+ - Historical checkpoints move to append-only packs under
488
+ `docs/engineering/state-archive/`.
489
+ - `docs/engineering/decisions.md` stays a compact index with bounded summaries
490
+ and canonical links to `decisions/DEC-xxxx.md`.
491
+ - Enforced rollover thresholds:
492
+ - `STATE_HOT_MAX_LINES` (default `1200`)
493
+ - `STATE_HOT_MAX_CHECKPOINTS` (default `80`)
494
+ - `PO_TO_TL_HOT_MAX_LINES` (default `800`)
495
+ - `PO_TO_TL_HOT_MAX_SECTIONS` (default `60`)
496
+ - `ARCH_HOT_MAX_LINES` (default `3500`)
497
+ - `ARCH_HOT_MAX_STORY_SECTIONS` (default `120`)
498
+ Triad hot surfaces (`state.md`, `handoffs/po_to_tl.md`,
499
+ `docs/engineering/architecture.md`) must stay within merged scratchpad caps.
500
+
501
+ ### Token-cost measurement and low-cache patterns (US-0080 / DEC-0062)
502
+
503
+ - Prefer **fresh subagent/chat boundaries** per `/auto` phase spawn (see `.cursor/commands/auto.md`).
504
+ - Use explicit **`/auto start-from=<phase>`** when resuming so **`resolved_phase_plan`**
505
+ intersection stays deterministic (**`DEC-0052`**).
506
+ - Select **`TOKEN_PROFILE=lean`** when compatible with your work to reduce scratchpad-driven
507
+ breadth; mandatory gates (**`US-0048`**, **`US-0056`**, **`US-0069`**, **`US-0039`**) stay on.
508
+ - **Comparable** cache-read baselines require identical **`run_class_hash`**; otherwise
509
+ **`TOKEN_COST_RUN_CLASS_MISMATCH`** (no cross-plan gaming).
510
+ - Committed metrics: **`handoffs/token_cost_runs/<orchestrator_run_id>.md`**; link from
511
+ **`docs/engineering/state.md`** via **`token_cost_evidence_ref`**.
512
+ - Tooling: **`scripts/token_cost_lib.py`**, **`scripts/token_cost_compare.py`**,
513
+ **`python scripts/check_token_cost_parity.py --repo .`**.
514
+ Use `python scripts/enforce-triad-hot-surface.py --check` before completing a
515
+ phase that mutates them; use `--rollover` to archive oldest material into
516
+ deterministic packs when over cap (DEC-0054).
517
+ Archive verification mismatch fails with
518
+ `STATE_ARCHIVE_VERIFICATION_FAILED`.
519
+
520
+ ### Cross-phase artifact ownership guard (US-0061)
521
+
522
+ To prevent accidental history loss across workflow phases:
523
+
524
+ - canonical ownership policy: `docs/engineering/artifact-ownership-policy.md`
525
+ - non-authorized phases must not delete or rewrite other-phase owned sections
526
+ - `docs/engineering/architecture.md` is history-preserving (append or
527
+ target-section-only mutation)
528
+ - deterministic fail-safe diagnostics:
529
+ `PHASE_OWNERSHIP_VIOLATION`,
530
+ `PHASE_OVERRIDE_EVIDENCE_MISSING`,
531
+ `ARCH_HISTORY_DELETION_DETECTED`
532
+
533
+ `/ask` policy (read-only):
534
+
535
+ - question-scoped retrieval first
536
+ - targeted sections before broad file reads
537
+ - bounded expansion only when unresolved
538
+ - explicit "not found in artifacts" when still unresolved
539
+
540
+ ### Configurable multi-target publish + confirmation gate (US-0054)
541
+
542
+ Post-release publish behavior is configurable per repository:
543
+
544
+ - `RELEASE_PUBLISH_MODE=disabled|confirm|auto` (default `confirm`)
545
+ - `RELEASE_TARGETS_FILE=docs/engineering/release-targets.json`
546
+ - `RELEASE_TARGETS_DEFAULT=` optional comma-separated default targets
547
+
548
+ Supported target types include:
549
+
550
+ - `npm`, `choco`, `brew`, `git`, `docker`, `cloud`
551
+ - `custom` (generic command target)
552
+ - `ssh` (generic server deployment over SSH)
553
+ - Connectivity metadata for remote/local operator context:
554
+ - `runtime.mode` (`local|remote`)
555
+ - endpoint fields (`domainEnv|ipEnv|hostEnv`, `port`, `protocol`)
556
+ - optional Traefik/ingress metadata
557
+ - optional `dockerOverSsh` contract for remote Docker execution over SSH
558
+
559
+ Safety defaults:
560
+
561
+ - Mandatory `/release` gates are unchanged and must pass first.
562
+ - `confirm` mode enforces explicit operator approval before publish execution.
563
+ - Sensitive values are env-referenced (for example `tokenEnv`, `authEnv`), not
564
+ inline literals.
565
+ - Remote connectivity config errors fail fast with
566
+ `REMOTE_CONNECTIVITY_CONFIG_INVALID`.
567
+ - Release/QA outputs use canonical operator connectivity doc:
568
+ `docs/engineering/runtime-connectivity.md`.
569
+
570
+ ### Deterministic status reconciliation command (US-0055)
571
+
572
+ Use `/status-reconcile` to normalize status drift between canonical and derived
573
+ workflow artifacts before continuation:
574
+
575
+ - canonical source: `docs/product/backlog.md` story status
576
+ - derived targets: `docs/product/acceptance.md`, `docs/engineering/state.md`,
577
+ `handoffs/resume_brief.md`
578
+ - deterministic outcomes: apply/no-op/fail-safe reason codes with audit evidence
579
+ in `docs/engineering/status-normalization-report.md`
580
+
581
+ This command is the bounded repair counterpart to `/memory-audit`
582
+ (read-only detection).
583
+
584
+ ### Optional cross-repo observability (US-0034)
585
+
586
+ Use optional compatibility visibility with default-safe off behavior:
587
+
588
+ - `CROSS_REPO_OBSERVABILITY=0|1` (default `0`)
589
+ - `COMPATIBILITY_GATE_ON_CRITICAL=0|1` (default `1`)
590
+ - `COMPATIBILITY_SOURCES=` monitored `repo/module/contract/docs` declarations
591
+
592
+ When disabled (`0`), workflow adds zero required compatibility overhead.
593
+
594
+ When enabled (`1`), compatibility signals/findings are tracked in:
595
+
596
+ - `docs/engineering/compatibility-signals.md`
597
+ - `docs/engineering/compatibility-report.md`
598
+ - `docs/engineering/manifests/registry.manifest.yaml`
599
+ - `docs/engineering/manifests/repo.manifest.yaml`
600
+
601
+ If unresolved critical findings remain and
602
+ `COMPATIBILITY_GATE_ON_CRITICAL=1`, release progression must stop for a
603
+ decision gate (`COMPATIBILITY_CRITICAL_OPEN`).
604
+
605
+ ### Optional component-scoped execution (US-0035)
606
+
607
+ Enable scoped workflow behavior with:
608
+
609
+ - `COMPONENT_SCOPE_MODE=0|1` (default `0`)
610
+ - `TARGET_COMPONENTS=<comma-separated-component-ids>`
611
+
612
+ When disabled (`0`), workflow adds zero required scope overhead.
613
+
614
+ When enabled (`1`):
615
+
616
+ - Scope declaration is tracked in `docs/engineering/component-scope.md`.
617
+ - Sprint tasks should declare target components and expected impacted interfaces.
618
+ - QA records unaffected-component protection checks in
619
+ `docs/engineering/component-scope-report.md`.
620
+ - Unapproved out-of-scope impact must block release via decision gate
621
+ (`COMPONENT_SCOPE_VIOLATION_UNAPPROVED`).
622
+
623
+ ### Optional spec-pack documentation (US-0031)
624
+
625
+ Optional Design Concept, CRS, and Technical Specification artifacts are
626
+ controlled by:
627
+
628
+ - `SPEC_PACK_MODE=0|1` (default `0`)
629
+
630
+ When disabled (`0`), intake/architecture/execute/qa/release add no required
631
+ spec-pack steps (zero overhead).
632
+
633
+ When enabled (`1`):
634
+
635
+ - Canonical paths per story: `docs/engineering/spec-pack/<story_id>-design-concept.md`,
636
+ `docs/engineering/spec-pack/<story_id>-crs.md`,
637
+ `docs/engineering/spec-pack/<story_id>-technical-specification.md`.
638
+ - Minimum required sections and ownership are in `docs/engineering/runbook.md`.
639
+ - Release gate validates completeness and blocks with `SPEC_PACK_INCOMPLETE` when
640
+ required sections are missing.
641
+
642
+ ### Optional user-guide documentation (US-0032)
643
+
644
+ Optional per-feature user guides (end-user how-to docs) are controlled by:
645
+
646
+ - `USER_GUIDE_MODE=0|1` (default `0`)
647
+
648
+ When disabled (`0`), intake/architecture/sprint-plan/execute/qa/release add no
649
+ required user-guide steps or blocking checks (zero overhead).
650
+
651
+ When enabled (`1`):
652
+
653
+ - Canonical path per feature story: `docs/user-guides/US-xxxx.md`.
654
+ - Minimum required sections: Purpose, Prerequisites, Usage steps, Example,
655
+ Limitations, Troubleshooting (see `docs/engineering/runbook.md` and
656
+ `docs/user-guides/README.md`).
657
+ - Release gate validates guide completeness and blocks with `USER_GUIDE_INCOMPLETE`
658
+ when enabled and required sections are missing.
659
+ - User guides are end-user only; they do not duplicate spec-pack (US-0031) content.
660
+
661
+ ### Release notes model (US-0040)
662
+
663
+ Release history is sprint-scoped and queue-backed:
664
+
665
+ - Canonical sprint notes: `handoffs/releases/Sxxxx-release-notes.md`
666
+ - Canonical queue tracker: `handoffs/release_queue.md`
667
+ - Legacy compatibility pointer: `handoffs/release_notes.md`
668
+
669
+ Deterministic release semantics:
670
+ - Only target sprint artifacts/queue row may be mutated during one `/release` run.
671
+ - Entering release flow sets target row to `unreleased`.
672
+ - Successful finalization transitions same row to `released`.
673
+ - Unresolved sprint identity or queue/notes mismatch fails closed with reason
674
+ codes and remediation guidance; no destructive reconciliation by default.
675
+
676
+ ### Post-QA release issue workflow (US-0042)
677
+
678
+ 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.
679
+
680
+ If a problem appears **after QA** (during `/release`), record it separately from
681
+ QA findings:
682
+
683
+ - Release findings artifact: `sprints/Sxxxx/release-findings.md`
684
+ - Release-to-dev handoff: `handoffs/release_to_dev.md`
685
+
686
+ Boundary:
687
+ - QA-phase issues -> `sprints/Sxxxx/qa-findings.md`
688
+ - Post-QA release-gate issues -> `sprints/Sxxxx/release-findings.md`
689
+
690
+ Each blocked release finding should include reason code, evidence refs,
691
+ remediation, and rerun criteria.
692
+
693
+ ### Backlog reconciliation invariant (US-0043)
694
+
695
+ Release completion must not leave stale backlog status for target sprint stories.
696
+ At release finalization:
697
+
698
+ - reconcile target story status to `DONE` using canonical release evidence;
699
+ - reconcile target story acceptance checkboxes to checked state;
700
+ - mutate only target sprint stories (never unrelated backlog entries);
701
+ - fail safe with `BACKLOG_STATUS_DRIFT` if contradiction remains (e.g. released
702
+ sprint but backlog still `OPEN`/unchecked).
703
+
704
+ ### Canonical story status + normalization guard (US-0045)
705
+
706
+ - `docs/product/backlog.md` is canonical for story `OPEN|DONE` status.
707
+ - `docs/product/acceptance.md` and `docs/engineering/state.md` are derived views
708
+ reconciled from canonical backlog status plus release evidence.
709
+ - One-time normalization baseline is recorded in
710
+ `docs/engineering/status-normalization-report.md`.
711
+ - Contradictory resolution at release/reconciliation boundaries fails safe with:
712
+ - `BACKLOG_STATUS_DRIFT`
713
+ - `CANONICAL_STATUS_CONFLICT`
714
+
715
+ ### Agent isolation model
716
+
717
+ - Every phase command runs in a fresh agent/subagent context.
718
+ - Handoff files are the only cross-phase memory (`handoffs/*.md` + artifact
719
+ files).
720
+ - Never rely on "ignore prior chat"; use a new context boundary instead.
721
+ - `/auto` is orchestration only: it calls phase subagents and transfers context
722
+ through artifacts.
723
+
724
+ #### Per-phase isolation evidence (US-0048 / DEC-0029)
725
+
726
+ Isolation is enforced with auditable evidence written to `docs/engineering/state.md`.
727
+ Each phase run appends:
728
+
729
+ - `phase_id`, `role`, `fresh_context_marker`, `timestamp`, `evidence_ref`
730
+
731
+ Missing/invalid/stale evidence fails closed with reason codes:
732
+ `PHASE_CONTEXT_ISOLATION_MISSING`, `PHASE_CONTEXT_ISOLATION_VIOLATION`,
733
+ `ISOLATION_EVIDENCE_STALE`, `ISOLATION_EVIDENCE_INVALID`.
734
+
735
+ #### Strict runtime proof (US-0056 / DEC-0038)
736
+
737
+ Per-phase isolation also requires strict runtime attestation tuples at
738
+ boundaries (not artifact fields alone):
739
+
740
+ - `orchestrator_run_id`, `runtime_proof_id`, `phase_id`, `role`
741
+ - `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`
742
+
743
+ Fail-closed reason codes:
744
+ `RUNTIME_PROOF_MISSING`, `RUNTIME_PROOF_INVALID`, `RUNTIME_PROOF_REUSED`,
745
+ `RUNTIME_PROOF_STALE`, `RUNTIME_PROOF_AMBIGUOUS_LINK`.
746
+
747
+ `/auto`, `/verify-work`, and `/release` must validate these tuples before
748
+ continuation/finalization.
749
+
750
+ #### `/auto` phase→role enforcement (US-0069 / DEC-0051)
751
+
752
+ `/auto` uses a deterministic **phase→role matrix** plus scratchpad alternates
753
+ (`AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`, `AUTO_ROLE_REFRESH_CONTEXT`).
754
+ Before each phase spawn it runs a **preflight capability gate**; missing
755
+ capability stops with `PHASE_ROLE_CAPABILITY_MISSING` (no unrelated-role
756
+ substitution). After each phase, isolation `role` and strict-proof `role` must
757
+ match the same expected role or the run stops with `PHASE_ROLE_MISMATCH`.
758
+ `execute` defaults to `dev`; non-`dev` requires
759
+ `AUTO_EXECUTE_ROLE_OVERRIDE=allowed_non_dev_execute` **and**
760
+ `EXECUTE_OVERRIDE_GOVERNANCE_REF` pointing to a parseable approved waiver. See
761
+ `docs/engineering/runbook.md` and `decisions/DEC-0051.md`.
762
+
763
+ #### `/auto` phase selection policy (US-0070 / DEC-0052)
764
+
765
+ `/auto` builds a **resolved phase plan** from scratchpad before spawning phases:
766
+ exactly one of `AUTO_PHASE_PLAN` (default `full`), `AUTO_PHASE_EXCLUDE`,
767
+ `AUTO_PHASE_INCLUDE`, or `AUTO_PHASE_PROFILE` applies; conflicting selectors
768
+ stop with `PHASE_POLICY_CONFLICT`. Non-skippable safety gates (`qa`,
769
+ `verify-work`, `release`) and evidence-chain closure reinstate omitted phases
770
+ with breadcrumb reasons such as `non_skippable_gate`. `start-from` and resume
771
+ anchors **intersect** with the plan (`START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`
772
+ when empty). Backlog-drain, bulk execute, and team-mode runs **recompute** the
773
+ plan each boundary. See `/auto`, `docs/engineering/runbook.md`, and
774
+ `decisions/DEC-0052.md`.
775
+
776
+ ### Lightweight interaction
777
+
778
+ Use `/ask` when you want to query the project without triggering the workflow:
779
+
780
+ - "What's the current sprint status?"
781
+ - "Which stories are still open?"
782
+ - "How does the upgrade mode work?"
783
+ - "What decision was made about X?"
784
+
785
+ `/ask` reads the project artifacts (state, backlog, architecture, decisions, sprint
786
+ progress) and answers from them. It never creates or modifies files. If your question
787
+ reveals a bug or feature idea, it will suggest running `/intake`.
788
+
789
+ ### Memory drift auditing
790
+
791
+ Use `/memory-audit` to check whether project memory artifacts still match
792
+ repository reality. This is a read-only, non-blocking command that produces an
793
+ advisory report at `docs/engineering/memory-drift-report.md`.
794
+
795
+ **When to run:**
796
+
797
+ - **Pre-handoff**: before writing any role handoff artifact.
798
+ - **Pre-QA**: before `/qa` or `/verify-work`.
799
+ - **Pre-release**: before `/release`.
800
+ - **Ad-hoc**: after external code changes, long pauses, or whenever artifacts
801
+ feel stale.
802
+
803
+ **How to interpret output:**
804
+
805
+ The report contains a severity summary (`high` / `medium` / `low`) and a
806
+ findings table with concrete evidence for each inconsistency. High-severity
807
+ findings should be resolved before the next handoff or release. Medium and low
808
+ findings can be addressed during `/refresh-context` or the next sprint.
809
+
810
+ The report also includes a reference-only "Template drift" section. Template
811
+ drift remediation belongs to US-0017 — `/memory-audit` only flags it for
812
+ awareness.
813
+
814
+ **Follow-up commands:**
815
+
816
+ - `/refresh-context` — update stale artifacts.
817
+ - `/sprint-plan` — if new work is discovered.
818
+ - `/verify-work` — if acceptance status needs re-validation.
819
+ - `/intake` — if findings reveal a new story or bug.
820
+
821
+ ### Workflow diagrams
822
+
823
+ ```mermaid
824
+ flowchart TD
825
+ Intake[/intake/] --> Discovery[/discovery/]
826
+ Discovery --> Research[/research/]
827
+ Research --> Architecture[/architecture/]
828
+ Architecture --> SprintPlan[/sprint-plan/]
829
+ SprintPlan --> PlanVerify[/plan-verify/]
830
+ PlanVerify --> Execute[/execute/]
831
+ Execute --> QA[/qa/]
832
+ QA -->|fixes needed| Execute
833
+ QA --> VerifyWork[/verify-work/]
834
+ VerifyWork --> Release[/release/]
835
+ Release --> Refresh[/refresh-context/]
836
+ Execute --> Pause[/pause/]
837
+ QA --> Pause
838
+ Release --> Pause
839
+ Pause --> Resume[/resume/]
840
+ Resume --> Execute
841
+ ```
842
+
843
+ ```mermaid
844
+ flowchart TD
845
+ Start[Idea] --> Intake2[/intake/]
846
+ Intake2 -->|DecisionGate| Decision{DecisionRequired}
847
+ Decision -->|ChooseOption| Discovery2[/discovery/]
848
+ Decision -->|ChooseOption| Research2[/research/]
849
+ Decision -->|ChooseOption| Architecture2[/architecture/]
850
+ Decision -->|ChooseOption| SprintPlan2[/sprint-plan/]
851
+ Decision -->|ChooseOption| PlanVerify2[/plan-verify/]
852
+ Decision -->|ChooseOption| Execute2[/execute/]
853
+ Decision -->|ChooseOption| QA2[/qa/]
854
+ Decision -->|ChooseOption| VerifyWork2[/verify-work/]
855
+ Decision -->|ChooseOption| Release2[/release/]
856
+ Decision -->|ChooseOption| Refresh2[/refresh-context/]
857
+ Decision -->|ChooseOption| Pause2[/pause/]
858
+ Discovery2 --> Research2
859
+ Research2 --> Architecture2
860
+ Architecture2 --> SprintPlan2
861
+ SprintPlan2 --> PlanVerify2
862
+ PlanVerify2 --> Execute2
863
+ Execute2 --> QA2
864
+ QA2 -->|fixes needed| Execute2
865
+ QA2 --> VerifyWork2
866
+ VerifyWork2 --> Release2
867
+ Release2 --> Refresh2
868
+ Execute2 --> Pause2
869
+ QA2 --> Pause2
870
+ Release2 --> Pause2
871
+ Pause2 --> Resume2[/resume/]
872
+ Resume2 --> Execute2
873
+ Execute2 --> HandoffDevQA[handoffs/dev_to_qa.md]
874
+ QA2 --> HandoffQAD[handoffs/qa_to_dev.md]
875
+ Intake2 --> HandoffPOTL[handoffs/po_to_tl.md]
876
+ SprintPlan2 --> HandoffTLDev[handoffs/tl_to_dev.md]
877
+ ```
878
+
879
+ ### Automation modes
880
+
881
+ Configure in `.cursor/scratchpad.md`:
882
+
883
+ - `AUTO_FLOW_MODE=manual|auto_until_decision`
884
+ - `manual`: you trigger each phase/command yourself.
885
+ - `auto_until_decision`: `/auto` continues by spawning fresh phase subagents until a decision gate, blocker, or pause boundary.
886
+ - `PHASE_MODE=interactive|auto`
887
+ - `interactive`: agent asks clarifying questions more often.
888
+ - `auto`: agent minimizes prompts and proceeds with best effort.
889
+ - `PERMISSION_MODE=interactive|auto`
890
+ - `interactive`: ask before routine actions.
891
+ - `auto`: reduce routine permission prompts.
892
+ - `RUN_TESTS_ON_EDIT=0|1`
893
+ - `1`: runs configured tests after meaningful edits.
894
+ - `0`: tests only when you explicitly run QA/test phases.
895
+ - `LOOP_UNTIL_GREEN=0|1`
896
+ - `1`: keep iterating fix -> test until green (bounded).
897
+ - `0`: run one pass and report failures.
898
+ - `AUTO_IMPLEMENTATION_LOOP=0|1`
899
+ - `1`: enables execute -> QA -> execute loop automatically with new Dev/QA subagent instances on each cycle.
900
+ - `AUTO_LOOP_MAX_CYCLES=<n>`
901
+ - safety cap for auto loops (recommended `3-7`, default `5`).
902
+ - `AUTO_PAUSE_REQUEST=0|1`
903
+ - `1`: request graceful stop at next safe boundary.
904
+ - `AUTO_PAUSE_POLICY=after_task|after_phase`
905
+ - `after_task`: faster stop, more frequent boundaries.
906
+ - `after_phase`: cleaner checkpoints, fewer interruptions.
907
+
908
+ ### Sync policy (US-0038)
909
+
910
+ Phase-triggered sync is policy-controlled and safe by default.
911
+
912
+ Scratchpad controls:
913
+
914
+ - `SYNC_POLICY_MODE=disabled|manual|by_phase|by_milestone|custom_phase_list`
915
+ - `SYNC_CUSTOM_PHASES=<comma-separated canonical phases>`
916
+ - `ALLOW_AUTO_PUSH=0|1`
917
+ - `AUTO_PUSH_BRANCH_ALLOWLIST=<comma-separated branches/patterns>`
918
+
919
+ Default-safe behavior:
920
+
921
+ - Default mode is `manual` with `ALLOW_AUTO_PUSH=0` (no automatic push).
922
+ - `disabled` and `manual` add near-zero overhead and preserve manual workflows.
923
+ - Sync policy is evaluated only at completed phase boundaries.
924
+
925
+ Guarded auto-push conditions (all must pass):
926
+
927
+ 1. Boundary matches configured mode.
928
+ 2. Auto-push is explicitly enabled (`ALLOW_AUTO_PUSH=1`).
929
+ 3. QA-first safety holds (feature work cannot auto-push pre-QA).
930
+ 4. No unresolved blocking QA findings/critical issues.
931
+ 5. Branch safety holds (protected/default branches denied unless allowlisted).
932
+ 6. Check chain passes (`TEST_COMMAND` required; optional lint/typecheck only if configured).
933
+
934
+ Deterministic reason codes include:
935
+ `SYNC_DISABLED`, `MANUAL_MODE_NO_AUTO`, `PRE_QA_AUTOPUSH_FORBIDDEN`,
936
+ `BLOCKING_QA_FINDINGS`, `BRANCH_NOT_ALLOWLISTED`, `TEST_COMMAND_MISSING`,
937
+ `TEST_FAILED`, `TEST_TIMEOUT`, `OPTIONAL_CHECK_FAILED`, `SYNC_PUSHED`.
938
+
939
+ ### Full scratchpad reference (detailed)
940
+
941
+ - `MAGIC_CONTEXT_STRICT=0|1`
942
+ - `1`: enforces context refresh discipline after code edits.
943
+ - `DONE=0|1`
944
+ - `1`: stop hook reminder loops when session is complete.
945
+ - `MAGIC_BENCH_SESSION=<id>`
946
+ - enables live benchmark event logging under one session id.
947
+ - `AUTO_INSTALL_DEPS=0|1`
948
+ - `1`: agent may install dependencies/runtimes automatically.
949
+ - `AUTO_RELEASE_NOTES=0|1`
950
+ - `1`: auto-generate `handoffs/release_notes.md`.
951
+ - `REMOTE_EXECUTION=0|1`
952
+ - `1`: allow remote/docker execution if configured.
953
+ - `REMOTE_CONFIG=.cursor/remote.json`
954
+ - path to remote execution server config.
955
+
956
+ ### Remote execution config (`.cursor/remote.json`)
957
+
958
+ Remote config is optional and mode-aware:
959
+
960
+ - `REMOTE_EXECUTION=0` (default): skip remote config checks entirely.
961
+ - `REMOTE_EXECUTION=1`: validate `.cursor/remote.json` first and fail fast on
962
+ missing/malformed/invalid or insecure config.
963
+
964
+ Canonical contract (DEC-0016):
965
+
966
+ - Required root fields:
967
+ - `version` (integer)
968
+ - `defaultTarget` (string)
969
+ - `targets` (array)
970
+ - Required target fields:
971
+ - `id` (string)
972
+ - `type` (`docker|ssh|vm`)
973
+ - `enabled` (boolean)
974
+ - `host` (string)
975
+ - `port` (integer `1..65535`)
976
+ - `workspaceRoot` (string)
977
+ - Optional:
978
+ - `auth.mode` (`none|env`)
979
+ - If `auth.mode=env`, use env-var references only (`tokenEnv`,
980
+ `passwordEnv`, `privateKeyPathEnv`, ...).
981
+
982
+ Two safe target examples are shipped in:
983
+
984
+ - `.cursor/remote.json` (active repo)
985
+ - `template/.cursor/remote.json` (template parity copy)
986
+
987
+ The examples include:
988
+
989
+ - `local-docker`: local network/docker-like endpoint.
990
+ - `remote-vm-ssh`: remote VM/SSH-like endpoint.
991
+
992
+ No secrets policy:
993
+
994
+ - Never commit inline tokens/passwords/private keys in `remote.json`.
995
+ - Commit env-var reference names only.
996
+
997
+ Fail-fast error format:
998
+
999
+ - `[REMOTE_CONFIG_ERROR] <path>: expected <rule>, got <actual>. Fix: <hint>.`
1000
+
1001
+ Troubleshooting quick guide:
1002
+
1003
+ - Missing file in remote mode:
1004
+ - Create `.cursor/remote.json` from the template copy, or set
1005
+ `REMOTE_EXECUTION=0`.
1006
+ - Invalid enum/type/range:
1007
+ - Update the failing field to match allowed values/ranges.
1008
+ - Malformed JSON:
1009
+ - Fix JSON syntax and retry.
1010
+ - Secret-like inline value detected:
1011
+ - Replace literal secret with an env-var reference field.
1012
+ - **CI still runs its-magic packaging jobs?** Your project received a pre-fix workflow.
1013
+ Run **`its-magic --target <repo> --mode upgrade`** (or **`--mode clean`** then reinstall)
1014
+ to refresh `.github/workflows/ci.yml` from the corrected template. After upgrade, GitHub
1015
+ Actions should show only **`checks`** and **`auto-fix`** jobs — not `npm-test`,
1016
+ `brew-test`, or `choco-test`. Fix applies to new installs/upgrades; stale repos heal on
1017
+ next upgrade (**US-0018**).
1018
+
1019
+ Team/local (recommended in `.cursor/scratchpad.local.md`):
1020
+
1021
+ - `TEAM_MODE=0|1`
1022
+ - `TEAM_MEMBER=<your-id>`
1023
+ - `ACTIVE_TASK_IDS=T-12,T-13`
1024
+
1025
+ ### Automated feature loop (optional)
1026
+
1027
+ Enable:
1028
+
1029
+ - `AUTO_FLOW_MODE=auto_until_decision`
1030
+ - `PHASE_MODE=auto`
1031
+ - `PERMISSION_MODE=auto`
1032
+ - `RUN_TESTS_ON_EDIT=1`
1033
+ - `LOOP_UNTIL_GREEN=1`
1034
+ - `AUTO_IMPLEMENTATION_LOOP=1`
1035
+ - `AUTO_LOOP_MAX_CYCLES=5`
1036
+
1037
+ Then run `/auto`.
1038
+
1039
+ Graceful stop (for shutdown/end of day):
1040
+
1041
+ 1. Set `AUTO_PAUSE_REQUEST=1`
1042
+ 2. Flow stops at next configured boundary (`AUTO_PAUSE_POLICY`)
1043
+ 3. `/pause` artifacts are written
1044
+ 4. Next day run `/resume` or `/auto`
1045
+
1046
+ ### Recommended profiles
1047
+
1048
+ **Max automation (high autonomy):**
1049
+
1050
+ - `AUTO_FLOW_MODE=auto_until_decision`
1051
+ - `PHASE_MODE=auto`
1052
+ - `PERMISSION_MODE=auto`
1053
+ - `RUN_TESTS_ON_EDIT=1`
1054
+ - `LOOP_UNTIL_GREEN=1`
1055
+ - `AUTO_IMPLEMENTATION_LOOP=1`
1056
+ - `AUTO_LOOP_MAX_CYCLES=5`
1057
+ - `AUTO_INSTALL_DEPS=1` (optional, if you trust auto installs)
1058
+ - `AUTO_PAUSE_POLICY=after_phase`
1059
+
1060
+ **Safer automation (recommended for most teams):**
1061
+
1062
+ - same as above, but keep:
1063
+ - `PERMISSION_MODE=interactive`
1064
+ - `AUTO_INSTALL_DEPS=0`
1065
+ - `AUTO_PAUSE_POLICY=after_task`
1066
+
1067
+ ### Quality chain (3-layer auto-fix)
1068
+
1069
+ its-magic provides a complete quality chain that catches issues at three levels.
1070
+ Each layer catches problems the previous layer missed:
1071
+
1072
+ ```text
1073
+ ┌─────────────────────────────────────────────────────────────────┐
1074
+ │ Layer 1: Cursor AI loop (in-editor) OFF by default │
1075
+ │ AUTO_IMPLEMENTATION_LOOP + LOOP_UNTIL_GREEN │
1076
+ │ execute → QA → fix → execute (bounded by AUTO_LOOP_MAX_CYCLES)│
1077
+ └──────────────────────────┬──────────────────────────────────────┘
1078
+ │ code ready to push
1079
+ ┌──────────────────────────▼──────────────────────────────────────┐
1080
+ │ Layer 2: validate-and-push (local pre-push) MANUAL (run it)│
1081
+ │ scripts/validate-and-push.sh / .ps1 │
1082
+ │ test → format → lint-fix → test → commit + push │
1083
+ └──────────────────────────┬──────────────────────────────────────┘
1084
+ │ pushed to GitHub
1085
+ ┌──────────────────────────▼──────────────────────────────────────┐
1086
+ │ Layer 3: CI auto-fix (GitHub Actions) OFF by default │
1087
+ │ .github/workflows/ci.yml │
1088
+ │ test/lint → auto-fix → commit → re-run (up to 3 retries) │
1089
+ └─────────────────────────────────────────────────────────────────┘
1090
+ ```
1091
+
1092
+ | Layer | Default | Enable |
1093
+ |-------|---------|--------|
1094
+ | 1 - Cursor AI loop | off | Set `AUTO_IMPLEMENTATION_LOOP=1` + `LOOP_UNTIL_GREEN=1` in scratchpad |
1095
+ | 2 - validate-and-push | manual | Run `scripts/validate-and-push.sh` or `.ps1` before pushing |
1096
+ | 3 - CI auto-fix | off | Set `CI_AUTO_FIX: true` in `docs/engineering/runbook.md` |
1097
+
1098
+ CI itself (tests, lint, typecheck) always runs on push/PR. Only the **auto-fix
1099
+ retry loop** is gated behind `CI_AUTO_FIX`. When disabled, CI still reports
1100
+ failures -- it just won't try to fix and commit automatically.
1101
+
1102
+ All commands are read from `docs/engineering/runbook.md`. Fill in your
1103
+ project-specific commands once and every layer uses them:
1104
+
1105
+ ```text
1106
+ TEST_COMMAND: npm test
1107
+ LINT_COMMAND: npx eslint .
1108
+ LINT_FIX_COMMAND: npx eslint --fix .
1109
+ FORMAT_COMMAND: npx prettier --write .
1110
+ CI_AUTO_FIX: true
1111
+ ```
1112
+
1113
+ #### Layer 1: Cursor AI loop
1114
+
1115
+ Enabled via scratchpad flags (see [Automation modes](#automation-modes)).
1116
+ The AI runs execute → QA → fix cycles inside Cursor until tests pass or
1117
+ the safety cap (`AUTO_LOOP_MAX_CYCLES`) is reached.
1118
+
1119
+ #### Layer 2: Local validate-and-push
1120
+
1121
+ Run before pushing to catch anything the AI loop missed. **Merged scratchpad** (see
1122
+ `docs/engineering/runbook.md`, **Executable validate-and-push wiring (DEC-0058)**) gates
1123
+ **`git push`**: default **`SYNC_POLICY_MODE=manual`** and **`ALLOW_AUTO_PUSH=0`** exit early
1124
+ with a **reason code** (no push). Opt-in push requires an eligible mode, **`ALLOW_AUTO_PUSH=1`**,
1125
+ a non-empty **branch allowlist** match, passing **runbook** checks, and bounded **QA** rules.
1126
+
1127
+ ```bash
1128
+ # Bash (Linux / macOS; bash required for this script)
1129
+ bash scripts/validate-and-push.sh
1130
+
1131
+ # PowerShell (Windows)
1132
+ powershell scripts/validate-and-push.ps1
1133
+ powershell scripts/validate-and-push.ps1 -MaxAttempts 3
1134
+ powershell scripts/validate-and-push.ps1 -DryRun
1135
+ ```
1136
+
1137
+ The script:
1138
+ 1. Evaluates merged scratchpad policy via **`python scripts/sync_push_gates.py`** (Python 3 on PATH)
1139
+ 2. Runs `FORMAT_COMMAND` and `LINT_FIX_COMMAND` to auto-fix what it can
1140
+ 3. Runs `LINT_COMMAND`, optional `TYPECHECK_COMMAND`, and `TEST_COMMAND` to verify (with `TEST_TIMEOUT_SECONDS` when `timeout`/`gtimeout` is available on Unix)
1141
+ 4. If checks fail, pauses and waits for you to fix
1142
+ 5. Re-runs (up to 5 attempts, configurable)
1143
+ 6. When green, re-checks allowlist + QA scan, then commits and pushes automatically (unless dry-run / no-commit)
1144
+
1145
+ Use `-NoCommit` (PowerShell), **`--dry-run`** first arg (Bash), or `false` as third arg (Bash) to skip **push**.
1146
+ **Policy-only** interpretation of scratchpad sync flags is **deprecated** for these scripts; see **`decisions/DEC-0058.md`** (policy semantics remain **`DEC-0018`** / **`US-0038`**).
1147
+
1148
+ #### Layer 3: CI auto-fix (GitHub Actions)
1149
+
1150
+ **Disabled by default.** Set `CI_AUTO_FIX: true` in `docs/engineering/runbook.md`
1151
+ to enable. When enabled and CI fails after a push, the auto-fix job kicks in:
1152
+
1153
+ ```text
1154
+ push / PR ──> checks ──> PASS ──> done
1155
+
1156
+ FAIL
1157
+
1158
+ auto-fix job
1159
+
1160
+ run LINT_FIX_COMMAND
1161
+ run FORMAT_COMMAND
1162
+
1163
+ changes found?
1164
+ ╱ ╲
1165
+ yes no
1166
+ │ │
1167
+ commit + push report failure
1168
+ │ (manual fix needed)
1169
+ CI re-runs
1170
+ (up to 3x)
1171
+ ```
1172
+
1173
+ Auto-fix commits appear as `ci: auto-fix attempt N/3`. After 3 retries the
1174
+ workflow stops and points you to `scripts/validate-and-push` for local fixing.
1175
+
1176
+ <!-- readme-feature-coverage-catalog -->
1177
+
1178
+ ### Feature coverage catalog (US-0091)
1179
+
1180
+ - `/acceptance` — Mandatory Intake Question Packs for First and Small Intakes (`US-0068`).
1181
+ - `/ask` — /ask Command: Context-Aware Questions Without Workflow (`US-0020`).
1182
+ - `/ask` — Context Compaction and Tiered Token-Cost Optimization Mode (`US-0053`).
1183
+ - `/auto` — Architecture triad archiver ignores `## US-xxxx` headings, blocking `/auto` with `STATE_ARCHIVE_BOUNDARY_AMBIGUOUS` (`BUG-0010`).
1184
+ - `/auto` — Configurable Auto Phase Selection Policy (`US-0070`).
1185
+ - `/auto` — Continuous `/auto` Backlog-Drain Mode with Fine-Tune Switches (`US-0044`).
1186
+ - `/auto` — Fresh Subagent Context Per Phase and /auto Orchestration (`US-0023`).
1187
+ - `/auto` — Mid-Process `/auto` Continuation with Deterministic Resume Point (`US-0037`).
1188
+ - `/auto` — Strict Phase Role Enforcement in /auto Orchestration (`US-0069`).
1189
+ - `/auto` — Strict Runtime Proof for Per-Phase Subagent Isolation (`US-0056`).
1190
+ - `/auto` — Token-Cost Hardening for Orchestrated Runs (`US-0080`).
1191
+ - `/auto` — `/auto` continuous multi-phase loop + quiet drain (close one-phase-stop gap) (`US-0088`).
1192
+ - `/auto` — `/auto` executes phases without spawning required subagents (`BUG-0006`).
1193
+ - `/auto` — `/auto` explicit bug targeting (fix all OPEN bugs / fix `BUG-####`) (`US-0087`).
1194
+ - `/auto` — `/auto` fails with stale resume target after bug intake (`BUG-0005`).
1195
+ - `/check` — Optional Documentation Pack (Design Concept, CRS, Technical Spec) (`US-0031`).
1196
+ - `/confirmation` — Enforced Interactive Intake Question Evidence (`US-0078`).
1197
+ - `/connectivity` — Release Operator Run/Connect/Verify Hints Contract (`US-0067`).
1198
+ - `/decision` — Optional Fresh-Project ID Namespace Bootstrap (`US-0052`).
1199
+ - `/derived` — Deterministic Status Reconciliation Command (`US-0055`).
1200
+ - `/developer-dense` — Documentation Audience Profiles and Dual README Strategy (`US-0077`).
1201
+ - `/docs` — Installer-Owned `its_magic/` Folder for Framework Metadata (`US-0062`).
1202
+ - `/engineering` — Deterministic Context Slimming and Archive Enforcement Across Core Artifacts (`US-0072`).
1203
+ - `/engineering` — Deterministic State Hot-Surface Rollover and Archive Enforcement (`US-0060`).
1204
+ - `/engineering` — OS-Aware Runbook Command Auto-Bootstrap with Verified Quality Gates (`US-0063`).
1205
+ - `/flag` — Release Gate for Command/Flag Documentation Delta (`US-0030`).
1206
+ - `/intake` — Critical Evaluation in Intake and Architecture (`US-0021`).
1207
+ - `/intake` — Deterministic Intake Runtime Capability Guard and Single-Writer Drift Safety (`US-0059`).
1208
+ - `/intake` — Multi-Repo and Contract Compatibility Observability (`US-0034`).
1209
+ - `/intake` — intake evidence records asked questions that were never asked (`BUG-0007`).
1210
+ - `/integration` — Generated Test Scaffolding and Auto-Run Contract (`US-0066`).
1211
+ - `/managed` — Runtime QA Autopilot for Generated Projects (`US-0065`).
1212
+ - `/new` — First-Intake Full-Plan Coverage and Story-Map Gate (`US-0081`).
1213
+ - `/order` — Deterministic Artifact Ordering and Write Discipline (`US-0058`).
1214
+ - `/phases` — Cross-Phase Artifact Ownership Guard and Deterministic Archive Control (`US-0061`).
1215
+ - `/planning` — User-Visible Internal Metadata Sanitization Guard (`US-0071`).
1216
+ - `/product` — Backlog Reconciliation Gate for Released Sprints (`US-0043`).
1217
+ - `/push` — Phase-Triggered Sync Policy with Guarded Auto-Push (`US-0038`).
1218
+ - `/release` — Enforced Per-Phase Subagent Isolation with Audit Gate (`US-0048`).
1219
+ - `/release` — Legacy DONE-Story Acceptance/Traceability Backfill Guard (`US-0049`).
1220
+ - `/release` — Per-Sprint Release Notes and Release Queue Tracker (`US-0040`).
1221
+ - `/release` — Release Findings Artifact and Post-QA Issue Workflow (`US-0042`).
1222
+ - `/release` — Release Gate Tightening for Check-In Tests and QA/UAT Completion (`US-0039`).
1223
+ - `/remote` — Automation-driven remote execution selection (Docker / SSH / NL container intent) (`US-0086`).
1224
+ - `/remote` — Gitignored `.env` for remote and release connectivity (no AI read) (`US-0085`).
1225
+ - `/repetitive` — Delegable Intake Clarification Without Hard Blocks (`US-0083`).
1226
+ - `/research` — Knowledge Curation & Early Research (`US-0029`).
1227
+ - `/risk` — Intelligent Intake Decomposition and Risk-Aware PO Questioning (`US-0051`).
1228
+ - `/scratchpad` — Caveman mode missing voice compression rules (US-0089 incomplete delivery) (`BUG-0011`).
1229
+ - `/scratchpad` — Executable Scratchpad-Driven Sync and Auto-Push Wiring (`US-0076`).
1230
+ - `/scratchpad` — Scratchpad Delivery Simplification (Example-Only Install Policy) (`US-0073`).
1231
+ - `/scratchpad` — Upgrade Scratchpad Example–First Refresh (Fix Example Drift vs Materialized Baseline) (`US-0075`).
1232
+ - `/scratchpad` — Upgrade-Safe Scratchpad Example Refresh and Parity (`US-0057`).
1233
+ - `/sprint-plan` — Explicit `/sprint-plan --bulk` Mode (`US-0046`).
1234
+ - `/sprint-plan` — Sprint Sizing Rules and Configurable Sprint Planning (`US-0022`).
1235
+ - `/story` — Optional Feature User Guide Generation (`US-0032`).
1236
+ - `/uat` — Cursor browser-integrated UAT self-test (browser_smoke + automatable manual UI) (`US-0093`).
1237
+ - `/uat` — UAT Artifact Lifecycle and Ownership (`US-0027`).
1238
+ - `SKILL` scratchpad flag — Skill and Templates (`US-0004`).
1239
+ - `US-0001` scratchpad flag — Core Workflow Commands (`US-0001`).
1240
+
1241
+ ## Walkthrough examples
1242
+
1243
+ ### Example 1: New feature from idea
1244
+
1245
+ 1. `/intake`
1246
+ 2. `/research`
1247
+ 3. `/architecture`
1248
+ 4. `/sprint-plan`
1249
+ 5. `/plan-verify`
1250
+ 6. `/execute`
1251
+ 7. `/qa`
1252
+ 8. `/verify-work`
1253
+ 9. `/release`
1254
+ 10. `/refresh-context`
1255
+
1256
+ ### Example 2: Mid-flight idea change
1257
+
1258
+ 1. Set `AUTO_PAUSE_REQUEST=1`
1259
+ 2. Run `/intake` to update story/acceptance
1260
+ 3. Re-run `/sprint-plan` + `/plan-verify`
1261
+ 4. Resume via `/auto`
1262
+
1263
+ ### Example 3: Pause/resume
1264
+
1265
+ 1. `/pause`
1266
+ 2. Close work
1267
+ 3. `/resume` next session
1268
+
1269
+ ### Deterministic `/auto` continuation
1270
+
1271
+ When resuming mid-process, `/auto` resolves start phase deterministically:
1272
+
1273
+ 1. explicit `/auto start-from=<phase>`
1274
+ 2. `handoffs/resume_brief.md`
1275
+ 3. conservative `docs/engineering/state.md` fallback
1276
+ 4. fail-fast (no guessing)
1277
+
1278
+ Canonical phases:
1279
+ `intake`, `discovery`, `research`, `architecture`, `sprint-plan`,
1280
+ `plan-verify`, `execute`, `qa`, `verify-work`, `release`, `refresh-context`.
1281
+
1282
+ Fail-fast message format:
1283
+ `[AUTO_RESUME_ERROR] <code>: <summary>. Source=<source>. Fix: <action>.`
1284
+
1285
+ Compatibility and safety:
1286
+ - Manual/interactive workflow stays unchanged unless `/auto` continuation is used.
1287
+ - Existing stop conditions remain enforced (decision gate, missing input,
1288
+ pause request, loop max).
1289
+
1290
+ ### Optional `/auto` backlog-drain mode (US-0044)
1291
+
1292
+ If you want `/auto` to continue across multiple planned stories in one run,
1293
+ enable backlog-drain switches in `.cursor/scratchpad.md`:
1294
+
1295
+ - `AUTO_BACKLOG_DRAIN=1`
1296
+ - `AUTO_BACKLOG_MAX_STORIES=<n>`
1297
+ - `AUTO_BACKLOG_ON_BLOCK=stop|skip`
1298
+ - `AUTO_STORY_SELECTION=priority_then_backlog_order`
1299
+
1300
+ Default-safe behavior remains unchanged with `AUTO_BACKLOG_DRAIN=0`.
1301
+
1302
+ ### Explicit `/sprint-plan --bulk` mode (US-0046)
1303
+
1304
+ By default, `/sprint-plan` plans one scope at a time. For multi-story planning,
1305
+ run explicit bulk mode:
1306
+
1307
+ - `/sprint-plan --bulk`
1308
+
1309
+ Bulk planning remains bounded and deterministic via `.cursor/scratchpad.md`:
1310
+
1311
+ - `SPRINT_BULK_MAX_STORIES=<n>`
1312
+ - `SPRINT_BULK_MAX_SPRINTS=<n>`
1313
+ - `SPRINT_BULK_SELECTION=priority_then_backlog_order`
1314
+
1315
+ Bounded stop reason codes:
1316
+ `SPRINT_BULK_MAX_STORIES_REACHED`, `SPRINT_BULK_MAX_SPRINTS_REACHED`,
1317
+ `SPRINT_BULK_NO_ELIGIBLE_STORIES`, `SPRINT_BULK_MISSING_ACCEPTANCE`.
1318
+
1319
+ ### Explicit `/auto --execute-bulk` mode (US-0047)
1320
+
1321
+ Bulk execution is explicit-mode only. Default `/auto` behavior remains unchanged.
1322
+
1323
+ Enable either way:
1324
+
1325
+ - one-run explicit argument: `/auto --execute-bulk`
1326
+ - scratchpad switch: `AUTO_EXECUTE_BULK=1`
1327
+
1328
+ Deterministic controls in `.cursor/scratchpad.md`:
1329
+
1330
+ - `AUTO_EXECUTE_MAX_ITEMS=<n>`
1331
+ - `AUTO_EXECUTE_ON_BLOCK=stop|skip`
1332
+ - `AUTO_EXECUTE_SELECTION=planned_then_priority`
1333
+ - `AUTO_TEAM_SCOPE_ENFORCE=0|1`
1334
+
1335
+ Deterministic reason codes:
1336
+ `EXEC_BULK_MAX_ITEMS_REACHED`, `EXEC_BULK_NO_ELIGIBLE_ITEMS`,
1337
+ `EXEC_BULK_ITEM_BLOCKED_STOP`, `EXEC_BULK_ITEM_BLOCKED_SKIPPED`,
1338
+ `EXEC_TEAM_SCOPE_BLOCKED`, `EXEC_TEAM_SCOPE_SKIPPED`.
1339
+
1340
+ Team-mode safety:
1341
+ - In `TEAM_MODE=1`, bulk execute records `TEAM_MODE`, `TEAM_MEMBER`,
1342
+ `ACTIVE_TASK_IDS` in state breadcrumbs.
1343
+ - With `AUTO_TEAM_SCOPE_ENFORCE=1`, out-of-scope tasks are blocked/skipped
1344
+ deterministically and never mutated.
1345
+
1346
+ ### Example 4: Existing project onboarding
1347
+
1348
+ 1. `/map-codebase`
1349
+ 2. Review generated mapping artifacts
1350
+ 3. Continue with `/intake` or `/architecture`
1351
+
1352
+ ## Other useful capabilities
1353
+
1354
+ ### Voice input (multilingual)
1355
+
1356
+ Voice is an input layer only; it feeds normal slash commands.
1357
+
1358
+ - OS dictation
1359
+ - Cursor voice (if available)
1360
+ - Local STT tooling
1361
+
1362
+ Reliable pattern:
1363
+
1364
+ - bind `/intake ` insertion shortcut
1365
+ - dictate only the content after the command
1366
+
1367
+ ### Repository layout (quick orientation)
1368
+
1369
+ - `.cursor/`: commands, rules, agents, hooks, skills, scratchpad.
1370
+ - `docs/`: product + engineering docs.
1371
+ - `sprints/`: sprint planning/tracking.
1372
+ - `handoffs/`: role-to-role transfers.
1373
+ - `decisions/`: decision records.
1374
+ - `.github/workflows/`: CI/CD templates.
1375
+
1376
+ <!-- readme-feature-coverage-catalog -->
1377
+
1378
+ ### Feature coverage catalog (US-0091)
1379
+
1380
+ - `/evidence` — Backlog-to-Sprint Traceability Contract (`US-0025`).
1381
+ - `/exit` — Milestone Lifecycle Definition and Exit Criteria (`US-0026`).
1382
+ - `/field` — Official Remote Config Template, Docs, and Fail-Fast Validation (`US-0036`).
1383
+ - `/installer` — Runbook Completion (`US-0015`).
1384
+ - `/intake` — Component-Scoped Execution Mode with Protection Guards (`US-0035`).
1385
+ - `/intake` — Configurable Guided Intake Behavior (`US-0033`).
1386
+ - `/map-codebase` — map-codebase does not write codebase-map in fresh repos (`BUG-0002`).
1387
+ - `/memory-audit` — Memory Drift Audit Command (`US-0024`).
1388
+ - `/product` — Canonical Story Status Source + Global Drift Guard (`US-0045`).
1389
+ - `/product` — Clean Install Hygiene and Complete Clean-Repo Coverage (`US-0050`).
1390
+ - `/security-review` — Security & Compliance Review Agent (`US-0028`).
1391
+ - `/skip` — Explicit Bulk Execute Orchestration Mode (`US-0047`).
1392
+ - `/strings` — Clean Placeholder Content from Templates and Active Files (`US-0019`).
1393
+ - `/write` — Artifact Templates and Starter Docs (`US-0006`).
1394
+ - `AUTO_FLOW_MODE` scratchpad flag — Automation Modes (`US-0011`).
1395
+ - `README` scratchpad flag — Voice Input Documentation (`US-0010`).
1396
+ - `TEAM_MODE` scratchpad flag — Team Mode (`US-0013`).
1397
+ - `US-0002` scratchpad flag — AI Behavior Rules (`US-0002`).
1398
+ - `US-0003` scratchpad flag — Subagent Definitions (`US-0003`).
1399
+ - `US-0005` scratchpad flag — Hook System (`US-0005`).
1400
+ - `US-0008` scratchpad flag — CLI Installer (`US-0008`).
1401
+ - `US-0012` scratchpad flag — Benchmark Suite (`US-0012`).
1402
+ - `US-0014` scratchpad flag — Quality Chain (3-Layer) (`US-0014`).
1403
+ - `US-0017` scratchpad flag — Template Drift Guard (`US-0017`).
1404
+
1405
+ ## Developer and release deep-dive
1406
+
1407
+ ### CI/CD via runbook
1408
+
1409
+ Workflows read keys from `docs/engineering/runbook.md`:
1410
+
1411
+ - `TEST_COMMAND`
1412
+ - `LINT_COMMAND`
1413
+ - `TYPECHECK_COMMAND`
1414
+ - `DEPLOY_STAGING_COMMAND`
1415
+ - `DEPLOY_PROD_COMMAND`
1416
+
1417
+ Unset keys are skipped. The template ships with empty values for `LINT_COMMAND`,
1418
+ `FORMAT_COMMAND`, and `TYPECHECK_COMMAND` -- this is intentional. its-magic is a
1419
+ template/installer project; fill in your project-specific commands after setup.
1420
+
1421
+ US-0015 intent contract:
1422
+ - Empty optional runbook keys are valid defaults for this repository type.
1423
+ - They must not be treated as missing required configuration.
1424
+
1425
+ ### Installer internals
1426
+
1427
+ - `installer.ps1` (Windows)
1428
+ - `installer.sh` (macOS/Linux)
1429
+ - `installer.py` (fallback)
1430
+
1431
+ Modes: `missing`, `overwrite`, `interactive`, `upgrade` (+ optional backup).
1432
+
1433
+ ### Release automation
1434
+
1435
+ Unified release scripts:
1436
+
1437
+ - Windows: `scripts/release-all.ps1`
1438
+ - macOS/Linux: `scripts/release-all.sh`
1439
+
1440
+ NPM helpers:
1441
+
1442
+ - `npm run release:all`
1443
+ - `npm run release:all:patch|minor|major|beta|dry`
1444
+ - `npm run release:npm-only|choco-only|brew-only`
1445
+
1446
+ Release script flow:
1447
+
1448
+ 1. bump `package.json` version
1449
+ 2. publish npm
1450
+ 3. create GitHub release
1451
+ 4. update/publish Chocolatey package
1452
+ 5. update/push Homebrew formula (stable or beta)
1453
+
1454
+ ```mermaid
1455
+ flowchart LR
1456
+ ReleaseAll[scripts/release-all.*] --> VerCheck{version has -?}
1457
+ VerCheck -->|stable| NPM["npm publish --tag latest"]
1458
+ VerCheck -->|prerelease| NPMBeta["npm publish --tag beta"]
1459
+ ReleaseAll --> GH["gh release create"]
1460
+ VerCheck -->|prerelease| GHPre["--prerelease flag"]
1461
+ GH --> Choco[choco pack + push]
1462
+ GH --> BrewCheck{prerelease?}
1463
+ BrewCheck -->|no| BrewStable[its-magic.rb]
1464
+ BrewCheck -->|yes| BrewBeta[its-magic-beta.rb]
1465
+ NPM --> U1["npx its-magic"]
1466
+ NPMBeta --> U1b["npx its-magic@beta"]
1467
+ Choco --> U2["choco install its-magic"]
1468
+ Choco --> U2b["choco install its-magic --pre"]
1469
+ BrewStable --> U3["brew install its-magic"]
1470
+ BrewBeta --> U3b["brew install its-magic-beta"]
1471
+ ```
1472
+
1473
+ Prereqs:
1474
+
1475
+ - `npm login`
1476
+ - `gh auth login`
1477
+ - Chocolatey API key (if choco publish)
1478
+ - Homebrew tap repo for formula distribution
1479
+
1480
+ ### Package manager installation matrix
1481
+
1482
+ | Manager | Stable | Beta / Pre-release |
1483
+ |------------|-------------------------------------------|---------------------------------------------|
1484
+ | npm/npx | `npx its-magic --target . --mode missing` | `npx its-magic@beta --target . --mode missing` |
1485
+ | Chocolatey | `choco install its-magic` | `choco install its-magic --pre` |
1486
+ | Homebrew | `brew install USER/tap/its-magic` | `brew install USER/tap/its-magic-beta` |
1487
+
1488
+ ### Release package contents
1489
+
1490
+ Published npm package includes runtime content only (commands/rules/agents/docs/installers).
1491
+
1492
+ Excluded from npm package:
1493
+
1494
+ - `benchmarks/`
1495
+ - `tests/`
1496
+ - `packaging/`
1497
+ - `Plan.md`
1498
+
1499
+ ### Benchmarks
1500
+
1501
+ - Main benchmark: `benchmarks/run-bench.ps1` or `benchmarks/run-bench.sh`
1502
+ - Live benchmark: `benchmarks/live/run-live-bench.*`
1503
+ - Prompted benchmark: `benchmarks/prompts/run-prompts.*`
1504
+ - Headless benchmark: `benchmarks/headless/run-headless.*`
1505
+
1506
+ Reports:
1507
+
1508
+ - `benchmarks/bench-report.md`
1509
+ - `benchmarks/live/live-bench-report.md`
1510
+ - `benchmarks/headless/headless-report.md`
1511
+ - `benchmarks/headless/protocol.md`
1512
+
1513
+ ```mermaid
1514
+ flowchart TD
1515
+ StartBench[Start benchmark] --> SelectScenario[Load scenarios]
1516
+ SelectScenario --> InstallKit[Install its-magic into temp workspace]
1517
+ InstallKit --> RunChecks[Validate required files/sections]
1518
+ RunChecks --> BenchReport[Write benchmarks/bench-report.md]
1519
+ ```
1520
+
1521
+ ```mermaid
1522
+ flowchart TD
1523
+ StartLive[Start live benchmark] --> SetSession[Set MAGIC_BENCH_SESSION]
1524
+ SetSession --> RunCommands[Run /* commands in Cursor]
1525
+ RunCommands --> LogHooks[Hook telemetry to bench-log.jsonl]
1526
+ LogHooks --> LiveReport[Write live-bench-report.md]
1527
+ ```
1528
+
1529
+ ```mermaid
1530
+ flowchart TD
1531
+ StartHeadless[Start headless run] --> LoadPrompt[Load prompt blocks]
1532
+ LoadPrompt --> TempWorkspace[Create temp workspace]
1533
+ TempWorkspace --> InstallHeadless[Install its-magic]
1534
+ InstallHeadless --> RunAgent[agent -p --force for each step]
1535
+ RunAgent --> ValidateOutputs[Validate files/sections/smoke checks]
1536
+ ValidateOutputs --> WriteProtocol[Write protocol.md]
1537
+ WriteProtocol --> WriteHeadlessReport[Write headless-report.md]
1538
+ ```
1539
+
1540
+ ### Rules
1541
+
1542
+ - `core.mdc`: phase flow, context pack, pause/resume, remote usage.
1543
+ - `quality.mdc`: small steps, tests/quality, optional auto-install.
1544
+ - `coding-standards.mdc`: strict language best practices and code quality rules.
1545
+ - `handoffs.mdc`: handoffs + state updates required.
1546
+ - `escalation.mdc`: decision gate and stop conditions.
1547
+
1548
+ ### Hooks
1549
+
1550
+ - `beforeShellExecution`: blocks dangerous commands.
1551
+ - `beforeReadFile`: warns on secret-like files.
1552
+ - `afterFileEdit`: tracks code edits vs context refresh.
1553
+ - `stop`: reminds context refresh when needed.
1554
+
1555
+ ### Artifacts (single source of truth)
1556
+
1557
+ - `docs/product/*`: vision, backlog, acceptance.
1558
+ - `docs/engineering/*`: architecture, decisions, state, runbook.
1559
+ - `sprints/Sxxxx/*`: sprint scope, tasks, progress, QA findings, summary.
1560
+ - `decisions/*`: decision records.
1561
+ - `handoffs/*`: role-to-role transfer notes.
1562
+
1563
+ ## Purpose
1564
+
1565
+ This repository publishes the **its-magic** workflow kit: commands, rules, skills, and
1566
+ documentation templates that teams install into their own repositories. The goal is a
1567
+ repeatable, file-backed lifecycle from intake through release.
1568
+
1569
+ ## Quickstart
1570
+
1571
+ Use [Setup](#setup) for install commands. First-time install:
1572
+
1573
+ ```bash
1574
+ npx its-magic --target . --mode missing --create
1575
+ ```
1576
+
1577
+ ## Examples
1578
+
1579
+ - Upgrade an existing repo: `its-magic --target . --mode upgrade`
1580
+ - Run check-in tests: use `TEST_COMMAND` from `docs/engineering/runbook.md` (often `sh tests/run-tests.sh`).
1581
+
1582
+ ## Related documentation
1583
+
1584
+ - Operator commands and gates: `docs/engineering/runbook.md`
1585
+ - Architecture and story contracts: `docs/engineering/architecture.md`
1586
+ - Product backlog and acceptance: `docs/product/backlog.md`, `docs/product/acceptance.md`
1587
+ - Optional spec-pack mode (`SPEC_PACK_MODE=1`): engineering design artifacts under `docs/engineering/` when your team enables it
1588
+ - Optional user guides (`USER_GUIDE_MODE=1`): `docs/user-guides/` when enabled
1589
+
1590
+ ## Limitations
1591
+
1592
+ - its-magic is a **process and documentation** framework; it does not replace your
1593
+ application runtime, hosting, or product-specific compliance work.
1594
+ - Mixed files such as `README.md` are preserved on upgrade; review notices may appear when
1595
+ the template adds new sections.
1596
+ - Documentation profile validation (`scripts/validate_doc_profile.py`) enforces audience and
1597
+ depth choices from the merged scratchpad (`DOC_AUDIENCE_PROFILE`, `DOC_DETAIL_LEVEL`).
1598
+
1599
+ ## Contributing
1600
+
1601
+ Contributor-focused workflow and guardrails live in
1602
+ [`docs/developer/README.md`](docs/developer/README.md).