@nforma.ai/nforma 0.2.1

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 (215) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1024 -0
  3. package/agents/qgsd-codebase-mapper.md +764 -0
  4. package/agents/qgsd-debugger.md +1201 -0
  5. package/agents/qgsd-executor.md +472 -0
  6. package/agents/qgsd-integration-checker.md +443 -0
  7. package/agents/qgsd-phase-researcher.md +502 -0
  8. package/agents/qgsd-plan-checker.md +643 -0
  9. package/agents/qgsd-planner.md +1182 -0
  10. package/agents/qgsd-project-researcher.md +621 -0
  11. package/agents/qgsd-quorum-orchestrator.md +628 -0
  12. package/agents/qgsd-quorum-slot-worker.md +41 -0
  13. package/agents/qgsd-quorum-synthesizer.md +133 -0
  14. package/agents/qgsd-quorum-test-worker.md +37 -0
  15. package/agents/qgsd-quorum-worker.md +161 -0
  16. package/agents/qgsd-research-synthesizer.md +239 -0
  17. package/agents/qgsd-roadmapper.md +660 -0
  18. package/agents/qgsd-verifier.md +628 -0
  19. package/bin/accept-debug-invariant.cjs +165 -0
  20. package/bin/account-manager.cjs +719 -0
  21. package/bin/aggregate-requirements.cjs +466 -0
  22. package/bin/analyze-assumptions.cjs +757 -0
  23. package/bin/analyze-state-space.cjs +921 -0
  24. package/bin/attribute-trace-divergence.cjs +150 -0
  25. package/bin/auth-drivers/gh-cli.cjs +93 -0
  26. package/bin/auth-drivers/index.cjs +46 -0
  27. package/bin/auth-drivers/pool.cjs +67 -0
  28. package/bin/auth-drivers/simple.cjs +95 -0
  29. package/bin/autoClosePtoF.cjs +110 -0
  30. package/bin/blessed-terminal.cjs +350 -0
  31. package/bin/build-phase-index.cjs +472 -0
  32. package/bin/call-quorum-slot.cjs +541 -0
  33. package/bin/ccr-secure-config.cjs +99 -0
  34. package/bin/ccr-secure-start.cjs +83 -0
  35. package/bin/check-bundled-sdks.cjs +177 -0
  36. package/bin/check-coverage-guard.cjs +112 -0
  37. package/bin/check-liveness-fairness.cjs +95 -0
  38. package/bin/check-mcp-health.cjs +123 -0
  39. package/bin/check-provider-health.cjs +395 -0
  40. package/bin/check-results-exit.cjs +24 -0
  41. package/bin/check-spec-sync.cjs +360 -0
  42. package/bin/check-trace-redaction.cjs +271 -0
  43. package/bin/check-trace-schema-drift.cjs +99 -0
  44. package/bin/compareDrift.cjs +21 -0
  45. package/bin/conformance-schema.cjs +12 -0
  46. package/bin/count-scenarios.cjs +420 -0
  47. package/bin/debt-dedup.cjs +144 -0
  48. package/bin/debt-ledger.cjs +61 -0
  49. package/bin/debt-retention.cjs +76 -0
  50. package/bin/debt-state-machine.cjs +80 -0
  51. package/bin/detect-coverage-gaps.cjs +204 -0
  52. package/bin/detect-project-intent.cjs +362 -0
  53. package/bin/export-prism-constants.cjs +164 -0
  54. package/bin/extract-annotations.cjs +633 -0
  55. package/bin/extractFormalExpected.cjs +104 -0
  56. package/bin/fingerprint-drift.cjs +24 -0
  57. package/bin/fingerprint-issue.cjs +46 -0
  58. package/bin/formal-core.cjs +519 -0
  59. package/bin/formal-ref-linker.cjs +141 -0
  60. package/bin/formal-test-sync.cjs +788 -0
  61. package/bin/generate-formal-specs.cjs +588 -0
  62. package/bin/generate-petri-net.cjs +397 -0
  63. package/bin/generate-phase-spec.cjs +249 -0
  64. package/bin/generate-proposed-changes.cjs +194 -0
  65. package/bin/generate-tla-cfg.cjs +122 -0
  66. package/bin/generate-traceability-matrix.cjs +701 -0
  67. package/bin/generate-triage-bundle.cjs +300 -0
  68. package/bin/gh-account-rotate.cjs +34 -0
  69. package/bin/initialize-model-registry.cjs +105 -0
  70. package/bin/install-formal-tools.cjs +382 -0
  71. package/bin/install.js +2424 -0
  72. package/bin/isNumericThreshold.cjs +34 -0
  73. package/bin/issue-classifier.cjs +151 -0
  74. package/bin/levenshtein.cjs +74 -0
  75. package/bin/lint-formal-models.cjs +580 -0
  76. package/bin/load-baseline-requirements.cjs +275 -0
  77. package/bin/manage-agents-core.cjs +815 -0
  78. package/bin/migrate-formal-dir.cjs +172 -0
  79. package/bin/migrate-planning.cjs +206 -0
  80. package/bin/migrate-to-slots.cjs +255 -0
  81. package/bin/nForma.cjs +2726 -0
  82. package/bin/observe-config.cjs +353 -0
  83. package/bin/observe-debt-writer.cjs +140 -0
  84. package/bin/observe-handler-grafana.cjs +128 -0
  85. package/bin/observe-handler-internal.cjs +301 -0
  86. package/bin/observe-handler-logstash.cjs +153 -0
  87. package/bin/observe-handler-prometheus.cjs +185 -0
  88. package/bin/observe-handlers.cjs +436 -0
  89. package/bin/observe-registry.cjs +131 -0
  90. package/bin/observe-render.cjs +168 -0
  91. package/bin/planning-paths.cjs +167 -0
  92. package/bin/polyrepo.cjs +560 -0
  93. package/bin/prism-priority.cjs +153 -0
  94. package/bin/probe-quorum-slots.cjs +167 -0
  95. package/bin/promote-model.cjs +225 -0
  96. package/bin/propose-debug-invariants.cjs +165 -0
  97. package/bin/providers.json +392 -0
  98. package/bin/pty-proxy.py +129 -0
  99. package/bin/qgsd-solve.cjs +2477 -0
  100. package/bin/quorum-consensus-gate.cjs +238 -0
  101. package/bin/quorum-formal-context.cjs +183 -0
  102. package/bin/quorum-slot-dispatch.cjs +934 -0
  103. package/bin/read-policy.cjs +60 -0
  104. package/bin/requirement-map.cjs +63 -0
  105. package/bin/requirements-core.cjs +247 -0
  106. package/bin/resolve-cli.cjs +101 -0
  107. package/bin/review-mcp-logs.cjs +294 -0
  108. package/bin/run-account-manager-tlc.cjs +188 -0
  109. package/bin/run-account-pool-alloy.cjs +158 -0
  110. package/bin/run-alloy.cjs +153 -0
  111. package/bin/run-audit-alloy.cjs +187 -0
  112. package/bin/run-breaker-tlc.cjs +181 -0
  113. package/bin/run-formal-check.cjs +395 -0
  114. package/bin/run-formal-verify.cjs +701 -0
  115. package/bin/run-installer-alloy.cjs +188 -0
  116. package/bin/run-oauth-rotation-prism.cjs +132 -0
  117. package/bin/run-oscillation-tlc.cjs +202 -0
  118. package/bin/run-phase-tlc.cjs +228 -0
  119. package/bin/run-prism.cjs +446 -0
  120. package/bin/run-protocol-tlc.cjs +201 -0
  121. package/bin/run-quorum-composition-alloy.cjs +155 -0
  122. package/bin/run-sensitivity-sweep.cjs +231 -0
  123. package/bin/run-stop-hook-tlc.cjs +188 -0
  124. package/bin/run-tlc.cjs +467 -0
  125. package/bin/run-transcript-alloy.cjs +173 -0
  126. package/bin/run-uppaal.cjs +264 -0
  127. package/bin/secrets.cjs +134 -0
  128. package/bin/sensitivity-report.cjs +219 -0
  129. package/bin/sensitivity-sweep-feedback.cjs +194 -0
  130. package/bin/set-secret.cjs +29 -0
  131. package/bin/setup-telemetry-cron.sh +36 -0
  132. package/bin/sweepPtoF.cjs +63 -0
  133. package/bin/sync-baseline-requirements.cjs +290 -0
  134. package/bin/task-envelope.cjs +360 -0
  135. package/bin/telemetry-collector.cjs +229 -0
  136. package/bin/unified-mcp-server.mjs +735 -0
  137. package/bin/update-agents.cjs +369 -0
  138. package/bin/update-scoreboard.cjs +1134 -0
  139. package/bin/validate-debt-entry.cjs +207 -0
  140. package/bin/validate-invariant.cjs +419 -0
  141. package/bin/validate-memory.cjs +389 -0
  142. package/bin/validate-requirements-haiku.cjs +435 -0
  143. package/bin/validate-traces.cjs +438 -0
  144. package/bin/verify-formal-results.cjs +124 -0
  145. package/bin/verify-quorum-health.cjs +273 -0
  146. package/bin/write-check-result.cjs +106 -0
  147. package/bin/xstate-to-tla.cjs +483 -0
  148. package/bin/xstate-trace-walker.cjs +205 -0
  149. package/commands/qgsd/add-phase.md +43 -0
  150. package/commands/qgsd/add-requirement.md +24 -0
  151. package/commands/qgsd/add-todo.md +47 -0
  152. package/commands/qgsd/audit-milestone.md +37 -0
  153. package/commands/qgsd/check-todos.md +45 -0
  154. package/commands/qgsd/cleanup.md +18 -0
  155. package/commands/qgsd/close-formal-gaps.md +33 -0
  156. package/commands/qgsd/complete-milestone.md +136 -0
  157. package/commands/qgsd/debug.md +166 -0
  158. package/commands/qgsd/discuss-phase.md +83 -0
  159. package/commands/qgsd/execute-phase.md +117 -0
  160. package/commands/qgsd/fix-tests.md +27 -0
  161. package/commands/qgsd/formal-test-sync.md +32 -0
  162. package/commands/qgsd/health.md +22 -0
  163. package/commands/qgsd/help.md +22 -0
  164. package/commands/qgsd/insert-phase.md +32 -0
  165. package/commands/qgsd/join-discord.md +18 -0
  166. package/commands/qgsd/list-phase-assumptions.md +46 -0
  167. package/commands/qgsd/map-codebase.md +71 -0
  168. package/commands/qgsd/map-requirements.md +20 -0
  169. package/commands/qgsd/mcp-restart.md +176 -0
  170. package/commands/qgsd/mcp-set-model.md +134 -0
  171. package/commands/qgsd/mcp-setup.md +1371 -0
  172. package/commands/qgsd/mcp-status.md +274 -0
  173. package/commands/qgsd/mcp-update.md +238 -0
  174. package/commands/qgsd/new-milestone.md +44 -0
  175. package/commands/qgsd/new-project.md +42 -0
  176. package/commands/qgsd/observe.md +260 -0
  177. package/commands/qgsd/pause-work.md +38 -0
  178. package/commands/qgsd/plan-milestone-gaps.md +34 -0
  179. package/commands/qgsd/plan-phase.md +44 -0
  180. package/commands/qgsd/polyrepo.md +50 -0
  181. package/commands/qgsd/progress.md +24 -0
  182. package/commands/qgsd/queue.md +54 -0
  183. package/commands/qgsd/quick.md +133 -0
  184. package/commands/qgsd/quorum-test.md +275 -0
  185. package/commands/qgsd/quorum.md +707 -0
  186. package/commands/qgsd/reapply-patches.md +110 -0
  187. package/commands/qgsd/remove-phase.md +31 -0
  188. package/commands/qgsd/research-phase.md +189 -0
  189. package/commands/qgsd/resume-work.md +40 -0
  190. package/commands/qgsd/set-profile.md +34 -0
  191. package/commands/qgsd/settings.md +39 -0
  192. package/commands/qgsd/solve.md +565 -0
  193. package/commands/qgsd/sync-baselines.md +119 -0
  194. package/commands/qgsd/triage.md +233 -0
  195. package/commands/qgsd/update.md +37 -0
  196. package/commands/qgsd/verify-work.md +38 -0
  197. package/hooks/dist/config-loader.js +297 -0
  198. package/hooks/dist/conformance-schema.cjs +12 -0
  199. package/hooks/dist/gsd-context-monitor.js +64 -0
  200. package/hooks/dist/qgsd-check-update.js +62 -0
  201. package/hooks/dist/qgsd-circuit-breaker.js +682 -0
  202. package/hooks/dist/qgsd-precompact.js +156 -0
  203. package/hooks/dist/qgsd-prompt.js +653 -0
  204. package/hooks/dist/qgsd-session-start.js +122 -0
  205. package/hooks/dist/qgsd-slot-correlator.js +58 -0
  206. package/hooks/dist/qgsd-spec-regen.js +86 -0
  207. package/hooks/dist/qgsd-statusline.js +91 -0
  208. package/hooks/dist/qgsd-stop.js +553 -0
  209. package/hooks/dist/qgsd-token-collector.js +133 -0
  210. package/hooks/dist/unified-mcp-server.mjs +669 -0
  211. package/package.json +95 -0
  212. package/scripts/build-hooks.js +46 -0
  213. package/scripts/postinstall.js +48 -0
  214. package/scripts/secret-audit.sh +45 -0
  215. package/templates/qgsd.json +49 -0
package/README.md ADDED
@@ -0,0 +1,1024 @@
1
+ <div align="center">
2
+
3
+ # nForma — Quorum Gets Shit Done
4
+
5
+ **Every planning decision verified by a quorum of AI models before Claude executes a single line.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@nforma.ai/nforma?style=for-the-badge&logo=npm&logoColor=white&color=CB3837)](https://www.npmjs.com/package/@nforma.ai/nforma)
8
+ [![npm downloads](https://img.shields.io/npm/dm/@nforma.ai/nforma?style=for-the-badge&logo=npm&logoColor=white&color=CB3837)](https://www.npmjs.com/package/@nforma.ai/nforma)
9
+ [![Discord](https://img.shields.io/badge/Discord-Join-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/M8SevJEuZG)
10
+ [![X (Twitter)](https://img.shields.io/badge/X-@JonathanBorduas-000000?style=for-the-badge&logo=x&logoColor=white)](https://x.com/JonathanBorduas)
11
+ [![GitHub stars](https://img.shields.io/github/stars/nForma-AI/nForma?style=for-the-badge&logo=github&color=181717)](https://github.com/nForma-AI/nForma)
12
+ [![License](https://img.shields.io/badge/license-MIT-blue?style=for-the-badge)](LICENSE)
13
+
14
+ <br>
15
+
16
+ ```bash
17
+ npx nforma@latest
18
+ ```
19
+
20
+ **Works on Mac, Windows, and Linux.**
21
+
22
+ <br>
23
+
24
+ ![nForma Install](assets/terminal.svg)
25
+
26
+ <br>
27
+
28
+ [Why I Built nForma](#why-i-built-nforma) · [How It Works](#how-it-works) · [Why It Works](#why-it-works) · [Formal Verification](#formal-verification) · [Commands](#commands) · [User Guide](docs/USER-GUIDE.md)
29
+
30
+ </div>
31
+
32
+ ---
33
+
34
+ ## Why I Built nForma
35
+
36
+ GSD nailed the workflow. But I wanted to push it further.
37
+
38
+ I believe diverse AI agents — running on diverse models — bring meaningfully different knowledge, reasoning patterns, and instincts to any given problem. Claude is extraordinary. But Gemini sees different things. Codex catches different edge cases. OpenCode and Copilot have different priors. That diversity, when structured properly, produces better strategies than any single model running alone — even the strongest one available.
39
+
40
+ So I forked GSD and built a multi-model quorum layer on top of it. Every planning decision, every research output, every roadmap — reviewed by five models before Claude executes a single line. Not as a committee to slow things down, but as a structured deliberation to surface blind spots.
41
+
42
+ The deeper goal: the first truly autonomous coding agent that only escalates to a human when there's a genuine lack of consensus. Not when it's uncertain. Not when it's guessing. Only when the quorum, after deliberation, can't agree — because that's the signal that a human judgment call is actually needed.
43
+
44
+ — **Jonathan Borduas**
45
+
46
+ ---
47
+
48
+ ## Who This Is For
49
+
50
+ People who want to describe what they want and have it built correctly — with a system that challenges its own assumptions before writing a single line of code.
51
+
52
+ ---
53
+
54
+ ## Getting Started
55
+
56
+ ```bash
57
+ npx nforma@latest
58
+ ```
59
+
60
+ The installer prompts you to choose:
61
+ 1. **Runtime** — Claude Code, OpenCode, Gemini, or all
62
+ 2. **Location** — Global (all projects) or local (current project only)
63
+
64
+ Verify with `/nf:help` inside your chosen runtime.
65
+
66
+ ### Setting Up Your Quorum
67
+
68
+ The fastest path is the interactive wizard — it handles everything from installing CLI tools to registering MCP servers and configuring API keys:
69
+
70
+ ```
71
+ /nf:mcp-setup
72
+ ```
73
+
74
+ **First run:** linear onboarding — picks provider, configures API key (stored in system keychain), registers MCP server with Claude Code, verifies live connectivity via identity ping.
75
+
76
+ **Re-run:** navigable agent menu — reconfigure any agent's key, provider, model, or toggle which agents participate in quorum (composition screen).
77
+
78
+ <details>
79
+ <summary><strong>Manual setup (advanced)</strong></summary>
80
+
81
+ All quorum agents run through nForma's **unified MCP server** (`bin/unified-mcp-server.mjs`). There are two agent families:
82
+
83
+ - **CLI agents** (codex, gemini, opencode, copilot) — wrap native CLI tools
84
+ - **API agents** (claude-1..6) — route requests to third-party LLM providers via [Claude Code Router (CCR)](https://github.com/musistudio/claude-code-router)
85
+
86
+ nForma uses a **slot-based naming scheme** (`<family>-<N>`) so you can run multiple instances of the same agent family. `claude-1` is the first Claude slot, `copilot-1` is the first Copilot slot, etc.
87
+
88
+ ---
89
+
90
+ #### CLI Agents — Prerequisites
91
+
92
+ Each CLI agent needs its native tool installed and authenticated:
93
+
94
+ ```bash
95
+ # OpenAI Codex (v0.75.0+)
96
+ npm i -g @openai/codex
97
+ codex login --api-key "your-openai-api-key"
98
+
99
+ # Google Gemini (free tier: 60 req/min, 1000 req/day)
100
+ npm install -g @google/gemini-cli
101
+ gemini # follow the Google login flow
102
+
103
+ # OpenCode
104
+ npm install -g opencode-ai
105
+ opencode # follow the auth flow
106
+
107
+ # GitHub Copilot (requires active subscription)
108
+ gh auth login
109
+ ```
110
+
111
+ ---
112
+
113
+ #### API Agents — Claude Code Router (CCR)
114
+
115
+ API-based slots (`claude-1` through `claude-6`) use [Claude Code Router](https://github.com/musistudio/claude-code-router) to route requests to providers like AkashML, Together.xyz, and Fireworks. See the [CCR README](https://github.com/musistudio/claude-code-router#-getting-started) for installation and configuration.
116
+
117
+ ---
118
+
119
+ #### Registration
120
+
121
+ The `/nf:mcp-setup` wizard handles all registration automatically. If you prefer manual setup, slots are registered in `~/.claude.json` pointing to the unified server:
122
+
123
+ ```bash
124
+ # All slots use the same entrypoint
125
+ claude mcp add <slot-name> -- node /path/to/nForma/bin/unified-mcp-server.mjs
126
+ ```
127
+
128
+ After adding or renaming any MCP server, re-run with `--redetect-mcps` to update the cache:
129
+
130
+ ```bash
131
+ npx nforma@latest --redetect-mcps
132
+ ```
133
+
134
+ This re-reads `~/.claude.json`, re-derives tool prefixes from your registered servers, and rewrites `~/.claude/qgsd.json`.
135
+
136
+ </details>
137
+
138
+ ### Agent Manager TUI
139
+
140
+ A full-featured keyboard-navigable terminal interface for managing your quorum agents — add, edit, reorder, health-check, and rotate keys without touching `~/.claude.json` by hand.
141
+
142
+ ```bash
143
+ # Requires a local clone
144
+ git clone https://github.com/nForma-AI/nForma.git
145
+ cd nForma && npm install
146
+
147
+ node bin/qgsd.cjs
148
+ ```
149
+
150
+ The TUI opens as a split-pane screen: left panel is the menu, right panel shows your agent roster or context for the selected action.
151
+
152
+ ![Agent Manager TUI](docs/assets/roster.png)
153
+
154
+ **Capabilities:**
155
+
156
+ | Action | What it does |
157
+ |--------|--------------|
158
+ | List Agents | Show all configured slots with provider, model, key status |
159
+ | Add Agent | Add a new slot with provider preset, model, and API key |
160
+ | Clone Slot | Duplicate an existing slot to a new name |
161
+ | Edit Agent | Update provider, base URL, model, or key for a slot |
162
+ | Remove Agent | Delete a slot from `~/.claude.json` |
163
+ | Reorder Agents | Drag slots up/down to change quorum priority order |
164
+ | Check Agent Health | Ping a single slot and show latency + model response |
165
+ | Login / Auth | Open the auth flow for CLI-based agents (gh, gemini, codex) |
166
+ | Provider Keys | View and update global API keys (AkashML, Together.xyz, Fireworks.ai) |
167
+ | Batch Rotate Keys | Rotate API keys across multiple slots in one operation |
168
+ | Live Health | Poll all configured slots simultaneously and display health table |
169
+ | Scoreboard | Quorum performance dashboard — normalized scores, TP/TN/FP/FN breakdown per slot |
170
+ | Update Agents | Pull the latest version of CLI tools and CCR |
171
+ | Settings | View current quorum composition and configuration |
172
+ | Tune Timeouts | Adjust per-slot timeout values |
173
+ | Set Update Policy | Configure auto-update behavior per slot |
174
+ | Export Roster | Save the full agent configuration to a portable JSON file |
175
+ | Import Roster | Load agent configuration from a previously exported file |
176
+
177
+ The TUI also includes a **requirements management** section — browse, filter, check coverage, and view traceability for all requirements in `.planning/formal/requirements.json`.
178
+
179
+ ![Requirements Management](docs/assets/requirements.png)
180
+
181
+ **Navigation:** arrow keys to move, Enter to select, Escape or `q` to go back or exit.
182
+
183
+ > [!NOTE]
184
+ > nForma works with as few as one quorum member — more models means stronger consensus. Claude is always the fifth voting member in every quorum round.
185
+
186
+ ### Staying Updated
187
+
188
+ nForma evolves fast. Update periodically:
189
+
190
+ ```bash
191
+ npx nforma@latest
192
+ ```
193
+
194
+ <details>
195
+ <summary><strong>Non-interactive Install (Docker, CI, Scripts)</strong></summary>
196
+
197
+ ```bash
198
+ # Claude Code
199
+ npx qgsd --claude --global # Install to ~/.claude/
200
+ npx qgsd --claude --local # Install to ./.claude/
201
+
202
+ # OpenCode (open source, free models)
203
+ npx qgsd --opencode --global # Install to ~/.config/opencode/
204
+
205
+ # Gemini CLI
206
+ npx qgsd --gemini --global # Install to ~/.gemini/
207
+
208
+ # All runtimes
209
+ npx qgsd --all --global # Install to all directories
210
+ ```
211
+
212
+ Use `--global` (`-g`) or `--local` (`-l`) to skip the location prompt.
213
+ Use `--claude`, `--opencode`, `--gemini`, or `--all` to skip the runtime prompt.
214
+
215
+ </details>
216
+
217
+ <details>
218
+ <summary><strong>Development Installation</strong></summary>
219
+
220
+ Clone the repository and run the installer locally:
221
+
222
+ ```bash
223
+ git clone https://github.com/nForma-AI/nForma.git
224
+ cd nForma
225
+ node bin/install.js --claude --local
226
+ ```
227
+
228
+ Installs to `./.claude/` for testing modifications before contributing.
229
+
230
+ </details>
231
+
232
+ ### Recommended: Skip Permissions Mode
233
+
234
+ nForma is designed for frictionless automation. Run Claude Code with:
235
+
236
+ ```bash
237
+ claude --dangerously-skip-permissions
238
+ ```
239
+
240
+ > [!TIP]
241
+ > This is how nForma is intended to be used — stopping to approve `date` and `git commit` 50 times defeats the purpose.
242
+
243
+ <details>
244
+ <summary><strong>Alternative: Granular Permissions</strong></summary>
245
+
246
+ If you prefer not to use that flag, add this to your project's `.claude/settings.json`:
247
+
248
+ ```json
249
+ {
250
+ "permissions": {
251
+ "allow": [
252
+ "Bash(date:*)",
253
+ "Bash(echo:*)",
254
+ "Bash(cat:*)",
255
+ "Bash(ls:*)",
256
+ "Bash(mkdir:*)",
257
+ "Bash(wc:*)",
258
+ "Bash(head:*)",
259
+ "Bash(tail:*)",
260
+ "Bash(sort:*)",
261
+ "Bash(grep:*)",
262
+ "Bash(tr:*)",
263
+ "Bash(git add:*)",
264
+ "Bash(git commit:*)",
265
+ "Bash(git status:*)",
266
+ "Bash(git log:*)",
267
+ "Bash(git diff:*)",
268
+ "Bash(git tag:*)"
269
+ ]
270
+ }
271
+ }
272
+ ```
273
+
274
+ </details>
275
+
276
+ ---
277
+
278
+ ## How It Works
279
+
280
+ > **Already have code?** Run `/nf:map-codebase` first. It spawns parallel agents to analyze your stack, architecture, conventions, and concerns. Then `/nf:new-project` knows your codebase — questions focus on what you're adding, and planning automatically loads your patterns.
281
+
282
+ ### 1. Initialize Project
283
+
284
+ ```
285
+ /nf:new-project
286
+ ```
287
+
288
+ One command, one flow. The system:
289
+
290
+ 1. **Questions** — Asks until it understands your idea completely (goals, constraints, tech preferences, edge cases)
291
+ 2. **Research** — Spawns parallel agents to investigate the domain (optional but recommended)
292
+ 3. **Requirements** — Extracts what's v1, v2, and out of scope
293
+ 4. **Roadmap** — Creates phases mapped to requirements
294
+
295
+ You approve the roadmap. Now you're ready to build.
296
+
297
+ **Creates:** `PROJECT.md`, `REQUIREMENTS.md`, `ROADMAP.md`, `STATE.md`, `.planning/research/`
298
+
299
+ ---
300
+
301
+ ### 2. Discuss Phase
302
+
303
+ ```
304
+ /nf:discuss-phase 1
305
+ ```
306
+
307
+ **This is where you shape the implementation.**
308
+
309
+ Your roadmap has a sentence or two per phase. That's not enough context to build something the way *you* imagine it. This step captures your preferences before anything gets researched or planned.
310
+
311
+ The system analyzes the phase and identifies gray areas based on what's being built:
312
+
313
+ - **Visual features** → Layout, density, interactions, empty states
314
+ - **APIs/CLIs** → Response format, flags, error handling, verbosity
315
+ - **Content systems** → Structure, tone, depth, flow
316
+ - **Organization tasks** → Grouping criteria, naming, duplicates, exceptions
317
+
318
+ For each area you select, it asks until you're satisfied. The output — `CONTEXT.md` — feeds directly into the next two steps:
319
+
320
+ 1. **Researcher reads it** — Knows what patterns to investigate ("user wants card layout" → research card component libraries)
321
+ 2. **Planner reads it** — Knows what decisions are locked ("infinite scroll decided" → plan includes scroll handling)
322
+
323
+ The deeper you go here, the more the system builds what you actually want. Skip it and you get reasonable defaults. Use it and you get *your* vision.
324
+
325
+ **Creates:** `{phase_num}-CONTEXT.md`
326
+
327
+ ---
328
+
329
+ ### 3. Plan Phase
330
+
331
+ ```
332
+ /nf:plan-phase 1
333
+ ```
334
+
335
+ The system:
336
+
337
+ 1. **Researches** — Investigates how to implement this phase, guided by your CONTEXT.md decisions
338
+ 2. **Plans** — Creates 2-3 atomic task plans with XML structure
339
+ 3. **Verifies** — Checks plans against requirements, loops until they pass
340
+
341
+ Each plan is small enough to execute in a fresh context window. No degradation, no "I'll be more concise now."
342
+
343
+ **Creates:** `{phase_num}-RESEARCH.md`, `{phase_num}-{N}-PLAN.md`
344
+
345
+ ---
346
+
347
+ ### 4. Execute Phase
348
+
349
+ ```
350
+ /nf:execute-phase 1
351
+ ```
352
+
353
+ The system:
354
+
355
+ 1. **Runs plans in waves** — Parallel where possible, sequential when dependent
356
+ 2. **Fresh context per plan** — 200k tokens purely for implementation, zero accumulated garbage
357
+ 3. **Commits per task** — Every task gets its own atomic commit
358
+ 4. **Verifies against goals** — Checks the codebase delivers what the phase promised
359
+
360
+ Walk away, come back to completed work with clean git history.
361
+
362
+ **How Wave Execution Works:**
363
+
364
+ Plans are grouped into "waves" based on dependencies. Within each wave, plans run in parallel. Waves run sequentially.
365
+
366
+ ```
367
+ ┌─────────────────────────────────────────────────────────────────────┐
368
+ │ PHASE EXECUTION │
369
+ ├─────────────────────────────────────────────────────────────────────┤
370
+ │ │
371
+ │ WAVE 1 (parallel) WAVE 2 (parallel) WAVE 3 │
372
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
373
+ │ │ Plan 01 │ │ Plan 02 │ → │ Plan 03 │ │ Plan 04 │ → │ Plan 05 │ │
374
+ │ │ │ │ │ │ │ │ │ │ │ │
375
+ │ │ User │ │ Product │ │ Orders │ │ Cart │ │ Checkout│ │
376
+ │ │ Model │ │ Model │ │ API │ │ API │ │ UI │ │
377
+ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
378
+ │ │ │ ↑ ↑ ↑ │
379
+ │ └───────────┴──────────────┴───────────┘ │ │
380
+ │ Dependencies: Plan 03 needs Plan 01 │ │
381
+ │ Plan 04 needs Plan 02 │ │
382
+ │ Plan 05 needs Plans 03 + 04 │ │
383
+ │ │
384
+ └─────────────────────────────────────────────────────────────────────┘
385
+ ```
386
+
387
+ **Why waves matter:**
388
+ - Independent plans → Same wave → Run in parallel
389
+ - Dependent plans → Later wave → Wait for dependencies
390
+ - File conflicts → Sequential plans or same plan
391
+
392
+ This is why "vertical slices" (Plan 01: User feature end-to-end) parallelize better than "horizontal layers" (Plan 01: All models, Plan 02: All APIs).
393
+
394
+ **Creates:** `{phase_num}-{N}-SUMMARY.md`, `{phase_num}-VERIFICATION.md`
395
+
396
+ ---
397
+
398
+ ### 5. Verify Work
399
+
400
+ ```
401
+ /nf:verify-work 1
402
+ ```
403
+
404
+ **This is where you confirm it actually works.**
405
+
406
+ Automated verification checks that code exists and tests pass. But does the feature *work* the way you expected? This is your chance to use it.
407
+
408
+ The system:
409
+
410
+ 1. **Extracts testable deliverables** — What you should be able to do now
411
+ 2. **Walks you through one at a time** — "Can you log in with email?" Yes/no, or describe what's wrong
412
+ 3. **Diagnoses failures automatically** — Spawns debug agents to find root causes
413
+ 4. **Creates verified fix plans** — Ready for immediate re-execution
414
+
415
+ If everything passes, you move on. If something's broken, you don't manually debug — you just run `/nf:execute-phase` again with the fix plans it created.
416
+
417
+ **Creates:** `{phase_num}-UAT.md`, fix plans if issues found
418
+
419
+ ---
420
+
421
+ ### 6. Repeat → Complete → Next Milestone
422
+
423
+ ```
424
+ /nf:discuss-phase 2
425
+ /nf:plan-phase 2
426
+ /nf:execute-phase 2
427
+ /nf:verify-work 2
428
+ ...
429
+ /nf:complete-milestone
430
+ /nf:new-milestone
431
+ ```
432
+
433
+ Loop **discuss → plan → execute → verify** until milestone complete.
434
+
435
+ Each phase gets your input (discuss), proper research (plan), clean execution (execute), and human verification (verify). Context stays fresh. Quality stays high.
436
+
437
+ When all phases are done, `/nf:complete-milestone` archives the milestone and tags the release.
438
+
439
+ Then `/nf:new-milestone` starts the next version — same flow as `new-project` but for your existing codebase. You describe what you want to build next, the system researches the domain, you scope requirements, and it creates a fresh roadmap. Each milestone is a clean cycle: define → build → ship.
440
+
441
+ ---
442
+
443
+ ### Quick Mode
444
+
445
+ ```
446
+ /nf:quick
447
+ ```
448
+
449
+ **For ad-hoc tasks that don't need full planning.**
450
+
451
+ Quick mode gives you nForma guarantees (atomic commits, state tracking) with a faster path:
452
+
453
+ - **Same agents** — Planner + executor, same quality
454
+ - **Skips optional steps** — No research, no plan checker, no verifier
455
+ - **Separate tracking** — Lives in `.planning/quick/`, not phases
456
+
457
+ Use for: bug fixes, small features, config changes, one-off tasks.
458
+
459
+ ```
460
+ /nf:quick
461
+ > What do you want to do? "Add dark mode toggle to settings"
462
+ ```
463
+
464
+ **Creates:** `.planning/quick/001-add-dark-mode-toggle/PLAN.md`, `SUMMARY.md`
465
+
466
+ ---
467
+
468
+ ### Test Suite Maintenance
469
+
470
+ ```
471
+ /nf:fix-tests
472
+ ```
473
+
474
+ An autonomous command that discovers every test in your project, runs them, diagnoses failures, and dispatches fix tasks — looping until all tests are either passing or classified.
475
+
476
+ **How it works:**
477
+
478
+ 1. **Discover** — Framework-native discovery (Jest, Playwright, pytest); never globs
479
+ 2. **Batch & run** — Random batch order with flakiness detection (runs each batch twice)
480
+ 3. **Categorize** — AI classifies each failure into one of 5 types:
481
+ - `valid-skip` — Test is intentionally skipped; no action needed
482
+ - `adapt` — Test broke because code changed; links to the causative commit via git pickaxe
483
+ - `isolate` — Test only fails alongside specific other tests (pollution); ddmin algorithm finds the minimal polluter set
484
+ - `real-bug` — Genuine regression; deferred to user report
485
+ - `fixture` — Missing test data or environment setup
486
+ 4. **Dispatch** — `adapt`, `fixture`, and `isolate` failures are dispatched as `/nf:quick` fix tasks automatically
487
+ 5. **Loop** — Repeats until all tests pass or no progress for 5 consecutive batches
488
+
489
+ Interrupted runs resume to the exact batch step via `/nf:resume-work`.
490
+
491
+ ---
492
+
493
+ ## Why It Works
494
+
495
+ ### Context Engineering
496
+
497
+ Claude Code is incredibly powerful *if* you give it the context it needs. Most people don't.
498
+
499
+ nForma handles it for you:
500
+
501
+ | File | What it does |
502
+ |------|--------------|
503
+ | `PROJECT.md` | Project vision, always loaded |
504
+ | `research/` | Ecosystem knowledge (stack, features, architecture, pitfalls) |
505
+ | `REQUIREMENTS.md` | Scoped v1/v2 requirements with phase traceability |
506
+ | `ROADMAP.md` | Where you're going, what's done |
507
+ | `STATE.md` | Decisions, blockers, position — memory across sessions |
508
+ | `PLAN.md` | Atomic task with XML structure, verification steps |
509
+ | `SUMMARY.md` | What happened, what changed, committed to history |
510
+ | `todos/` | Captured ideas and tasks for later work |
511
+
512
+ Size limits based on where Claude's quality degrades. Stay under, get consistent excellence.
513
+
514
+ ### XML Prompt Formatting
515
+
516
+ Every plan is structured XML optimized for Claude:
517
+
518
+ ```xml
519
+ <task type="auto">
520
+ <name>Create login endpoint</name>
521
+ <files>src/app/api/auth/login/route.ts</files>
522
+ <action>
523
+ Use jose for JWT (not jsonwebtoken - CommonJS issues).
524
+ Validate credentials against users table.
525
+ Return httpOnly cookie on success.
526
+ </action>
527
+ <verify>curl -X POST localhost:3000/api/auth/login returns 200 + Set-Cookie</verify>
528
+ <done>Valid credentials return cookie, invalid return 401</done>
529
+ </task>
530
+ ```
531
+
532
+ Precise instructions. No guessing. Verification built in.
533
+
534
+ ### Multi-Agent Orchestration
535
+
536
+ Every stage uses the same pattern: a thin orchestrator spawns specialized agents, collects results, and routes to the next step.
537
+
538
+ | Stage | Orchestrator does | Agents do |
539
+ |-------|------------------|-----------|
540
+ | Research | Coordinates, presents findings | 4 parallel researchers investigate stack, features, architecture, pitfalls |
541
+ | Planning | Validates, manages iteration | Planner creates plans, checker verifies, loop until pass |
542
+ | Execution | Groups into waves, tracks progress | Executors implement in parallel, each with fresh 200k context |
543
+ | Verification | Presents results, routes next | Verifier checks codebase against goals, debuggers diagnose failures |
544
+
545
+ The orchestrator never does heavy lifting. It spawns agents, waits, integrates results.
546
+
547
+ **The result:** You can run an entire phase — deep research, multiple plans created and verified, thousands of lines of code written across parallel executors, automated verification against goals — and your main context window stays at 30-40%. The work happens in fresh subagent contexts. Your session stays fast and responsive.
548
+
549
+ ### Token Efficiency
550
+
551
+ nForma manages token consumption automatically across three mechanisms:
552
+
553
+ **Tiered model sizing** — Researcher and plan-checker sub-agents use a smaller model (haiku by default) for a 15–20x cost reduction vs. using sonnet everywhere. The primary planner and executor retain sonnet. Configure via `model_tier_planner` and `model_tier_worker` keys in qgsd.json, or switch via `/nf:set-profile`.
554
+
555
+ **Adaptive quorum fan-out** — Quorum dispatches fewer workers for routine tasks (2 workers) than for high-risk ones (max). The task envelope's `risk_level` field drives this automatically. Override with `--n N` in any quorum call.
556
+
557
+ **Token observability** — The SubagentStop hook collects per-slot token usage and writes to `.planning/token-usage.jsonl`. Run `/nf:health` to see a ranked breakdown of token consumption by slot and stage — spot which agents are spending the most before it becomes a problem.
558
+
559
+ ### Autonomous Milestone Loop
560
+
561
+ From `/nf:new-milestone` through `/nf:complete-milestone`, the execution chain runs without AskUserQuestion interruptions. When audit-milestone detects gaps, plan-milestone-gaps is spawned automatically. All confirmation gates (plan approval, gap resolution, gray-area discussion) route to quorum consensus instead of pausing for a human. The loop only escalates when the quorum cannot reach consensus — which is the signal that a human judgment call is actually needed.
562
+
563
+ Enable auto-chaining via the `workflow.auto_advance` setting.
564
+
565
+ ### Pre-Execution Test Mapping (Nyquist)
566
+
567
+ Before producing plans, plan-phase generates a `VALIDATION.md` test map for the phase — listing which tests must pass before execution starts (Wave 0) and what to verify after each task. This surfaces test-to-task traceability early and catches missing test coverage before a single line of code runs. Controlled by `nyquist_validation_enabled` in qgsd.json (default: true). The generation logic lives in `commands/qgsd/plan-phase.md` (search for `nyquist` or `VALIDATION.md` in that file to trace from this description to the implementation).
568
+
569
+ ### Ping-Pong Commit Loop Breaker
570
+
571
+ **The problem no one talks about:** AI agents get stuck in ping-pong commit loops.
572
+
573
+ Not randomly. In a specific, predictable way. A bug exists at the boundary between two components — a contract mismatch, a shared assumption that's subtly wrong. The agent fixes the symptom in file A. That shifts the pressure to file B. The agent fixes file B. That breaks file A again. Repeat.
574
+
575
+ Each individual fix is locally correct. The agent is reasoning well about the immediate problem. But it's applying a **local fix to a global problem** — and no amount of trying harder at the local level solves a structural coupling issue.
576
+
577
+ ```text
578
+ Agent fixes file A → File B breaks → Agent fixes file B → File A breaks
579
+ ↑ |
580
+ └───────────────────────────────────────────────────────────────┘
581
+ The loop runs indefinitely
582
+ ```
583
+
584
+ This isn't a hypothetical. It happens in production. It wastes hours. And it leaves your git history looking like:
585
+
586
+ ```text
587
+ fix: correct auth token handling ← file A
588
+ fix: fix session expiry logic ← file B
589
+ fix: auth token was wrong ← file A again
590
+ fix: session expiry broke again ← file B again
591
+ ```
592
+
593
+ **What nForma does about it:**
594
+
595
+ nForma's circuit breaker watches your git history for exactly this pattern. It collapses consecutive commits on the same file set into run-groups, then flags when the same file set alternates across 3+ run-groups. That's the structural signal: not "these files changed a lot," but "these files are ping-ponging."
596
+
597
+ When the pattern is detected, a Haiku reviewer first checks whether this is genuine oscillation or normal iterative refinement (polishing the same files toward a clear goal). If it's genuine, the circuit breaker fires.
598
+
599
+ **When the breaker fires:**
600
+
601
+ All write commands are blocked. Read-only commands (git log, diff, grep) remain available. The system doesn't just stop — it activates **Oscillation Resolution Mode**:
602
+
603
+ 1. **Build the commit graph** — Makes the A→B→A→B ping-pong visually obvious
604
+ 2. **Quorum diagnosis** — Every available model diagnoses the *structural coupling* causing both sides to oscillate — not the surface symptom
605
+ 3. **Unified solution required** — Partial or incremental fixes are explicitly rejected. The quorum must propose a single change that resolves both sides simultaneously
606
+ 4. **User approval gate** — No code runs until you approve the plan *and* run `npx qgsd --reset-breaker`
607
+
608
+ The key constraint in the resolution prompt: *"Diagnose the structural coupling — not the surface symptoms. Propose a unified solution. Partial fixes are not acceptable."*
609
+
610
+ This is the difference between a local fix and a global fix. A local fix patches the symptom. A global fix identifies why the two components are structurally coupled in a way that makes each fix shift the problem elsewhere — then eliminates the coupling.
611
+
612
+ ```bash
613
+ # After approving the unified fix and committing it:
614
+ npx qgsd --reset-breaker
615
+
616
+ # For deliberate iterative work (temporary):
617
+ npx qgsd --disable-breaker
618
+ npx qgsd --enable-breaker
619
+ ```
620
+
621
+ ---
622
+
623
+ ### Hooks Ecosystem
624
+
625
+ nForma installs seven Claude Code hooks that fire at different lifecycle points:
626
+
627
+ | Hook Type | File | When it fires | What it does |
628
+ |-----------|------|---------------|--------------|
629
+ | UserPromptSubmit | qgsd-prompt.js | Every user message | Injects quorum instructions at planning turns |
630
+ | Stop | qgsd-stop.js | Before Claude delivers output | Verifies quorum actually happened by parsing the transcript; blocks non-compliant responses |
631
+ | PreToolUse | qgsd-circuit-breaker.js | Before every tool execution | Detects ping-pong oscillation in git history; blocks Bash when breaker is active |
632
+ | PostToolUse | gsd-context-monitor.js | After every tool execution | Monitors context usage; injects WARNING at 70%, CRITICAL at 90% |
633
+ | SubagentStop | qgsd-token-collector.js | When a quorum slot finishes | Reads token usage from transcript and appends to token-usage.jsonl |
634
+ | PreCompact | qgsd-precompact.js | Before context compaction | Injects current STATE.md position so context survives compaction without losing progress |
635
+ | SessionStart | qgsd-session-start.js | Once per Claude Code session | Syncs keychain secrets into ~/.claude.json (zero prompts after bootstrap) |
636
+
637
+ All hooks fail open — any hook error exits 0 and never blocks Claude.
638
+
639
+ ---
640
+
641
+ ### Atomic Git Commits
642
+
643
+ Each task gets its own commit immediately after completion:
644
+
645
+ ```bash
646
+ abc123f docs(08-02): complete user registration plan
647
+ def456g feat(08-02): add email confirmation flow
648
+ hij789k feat(08-02): implement password hashing
649
+ lmn012o feat(08-02): create registration endpoint
650
+ ```
651
+
652
+ > [!NOTE]
653
+ > **Benefits:** Git bisect finds exact failing task. Each task independently revertable. Clear history for Claude in future sessions. Better observability in AI-automated workflow.
654
+
655
+ Every commit is surgical, traceable, and meaningful.
656
+
657
+ ### Modular by Design
658
+
659
+ - Add phases to current milestone
660
+ - Insert urgent work between phases
661
+ - Complete milestones and start fresh
662
+ - Adjust plans without rebuilding everything
663
+
664
+ You're never locked in. The system adapts.
665
+
666
+ ---
667
+
668
+ ## Formal Verification
669
+
670
+ > **Note:** The formal verification pipeline is optional. If you just want to use nForma, skip this section — you do not need Java 17, PRISM, or Alloy to run nForma normally. This is for developers who want to verify the correctness of nForma's protocol implementation.
671
+
672
+ nForma ships executable formal models of its core protocols — not documentation, but machine-checked specs that verify safety, liveness, and probabilistic properties of the protocols that govern how your planning decisions get made.
673
+
674
+ ### What's Modeled
675
+
676
+ The `.planning/formal/` directory contains 25+ specs across five verification tools:
677
+
678
+ | Tool | Specs | What they model |
679
+ |------|-------|-----------------|
680
+ | **TLA+** (11 models) | `QGSDQuorum`, `QGSDCircuitBreaker`, `QGSDOscillation`, `QGSDConvergence`, `QGSDDeliberation`, `QGSDPreFilter`, `QGSDAccountManager`, `QGSDMCPEnv`, `QGSDRecruiting`, `QGSDStopHook`, `TUINavigation` | State-space exhaustive model checking — safety invariants and liveness properties |
681
+ | **Alloy** (8 models) | quorum-votes, quorum-composition, scoreboard-recompute, availability-parsing, transcript-scan, install-scope, taxonomy-safety, account-pool-structure | Structural correctness — no impossible states, constraint satisfaction |
682
+ | **PRISM** (3 models) | quorum consensus, OAuth rotation, MCP availability | Probabilistic model checking — convergence probability, expected rounds to consensus |
683
+ | **Petri nets** (2 models) | quorum flow, account manager lifecycle | Visual concurrency models — token flow, place/transition reachability |
684
+ | **UPPAAL** (1 model) | quorum timed races | Real-time model checking — timeout race conditions between concurrent slots |
685
+
686
+ ### Spec Sources
687
+
688
+ Each protocol has a human-readable spec in `.planning/formal/spec/` that defines the invariants, then one or more tool-specific models that check them:
689
+
690
+ ```
691
+ .planning/formal/
692
+ ├── spec/ # Human-readable protocol specs (invariants.md per protocol)
693
+ ├── tla/ # TLA+ models + config files (MCsafety.cfg, MCliveness.cfg, etc.)
694
+ ├── alloy/ # Alloy 6 models (.als)
695
+ ├── prism/ # PRISM models (.pm) + property files (.props)
696
+ ├── petri/ # Petri net DOT sources + rendered SVGs
697
+ ├── uppaal/ # UPPAAL timed automata (.xml) + queries (.q)
698
+ ├── trace/ # TLA+ counterexample traces for debugging
699
+ ├── model-registry.json # Version tracking for all spec files
700
+ ├── diff-report.md # Delta between current and previous verification runs
701
+ ├── suspects.md # Failing or inconclusive checks needing attention
702
+ ├── requirements.json # Formal requirements with traceability to specs
703
+ └── policy.yaml # Calibration governance (cold-start thresholds, PRISM priors)
704
+ ```
705
+
706
+ ### Prerequisites
707
+
708
+ TLA+, Alloy, and PRISM all require Java 17+. Petri nets need no extra install (bundled via npm).
709
+
710
+ One-step install:
711
+
712
+ ```bash
713
+ node bin/install-formal-tools.cjs
714
+ # or: node bin/install.js --formal
715
+ ```
716
+
717
+ Full per-tool documentation: **[VERIFICATION_TOOLS.md](VERIFICATION_TOOLS.md)**
718
+
719
+ | Tool | Requires | One-time setup |
720
+ |------|----------|----------------|
721
+ | TLA+ | Java 17+ | Auto-downloaded to `.planning/formal/tla/` by install script |
722
+ | Alloy 6 | Java 17+ | Auto-downloaded to `.planning/formal/alloy/` by install script |
723
+ | PRISM | Java 17+ | Downloaded + installed by script; set `PRISM_BIN` as instructed |
724
+ | Petri nets | — | Nothing — bundled via `@hpcc-js/wasm-graphviz` |
725
+ | UPPAAL | Java 17+ | Manual install — [uppaal.org](https://uppaal.org) |
726
+
727
+ ### Running Verification
728
+
729
+ ```bash
730
+ # Full pipeline — all steps (generate → Petri → TLA+ → Alloy → PRISM)
731
+ node bin/run-formal-verify.cjs
732
+
733
+ # Subsets
734
+ node bin/run-formal-verify.cjs --only=tla # TLA+ model checks
735
+ node bin/run-formal-verify.cjs --only=alloy # Alloy assertions
736
+ node bin/run-formal-verify.cjs --only=prism # PRISM probabilistic analyses
737
+ node bin/run-formal-verify.cjs --only=petri # Petri net renders
738
+ node bin/run-formal-verify.cjs --only=generate # Regenerate specs from source only
739
+ ```
740
+
741
+ Exit code 0 = all checks pass. Exit code 1 = at least one violation or configuration error.
742
+
743
+ Individual runners: `bin/run-tlc.cjs`, `bin/run-alloy.cjs`, `bin/run-prism.cjs`, `bin/generate-petri-net.cjs`.
744
+
745
+ ### CI Pipeline Artifacts
746
+
747
+ Each verification run produces machine-readable outputs:
748
+
749
+ | File | Purpose |
750
+ |------|---------|
751
+ | `check-results.ndjson` | Structured results per check (pass/fail/warn with timing) |
752
+ | `diff-report.md` | What changed since last run — new failures, regressions, fixes |
753
+ | `suspects.md` | Failing or inconclusive checks that need attention |
754
+ | `model-registry.json` | Version tracking — detects when specs drift from source |
755
+
756
+ ---
757
+
758
+ ## Commands
759
+
760
+ ### Core Workflow
761
+
762
+ | Command | What it does |
763
+ |---------|--------------|
764
+ | `/nf:new-project [--auto]` | Full initialization: questions → research → requirements → roadmap |
765
+ | `/nf:discuss-phase [N] [--auto]` | Capture implementation decisions before planning |
766
+ | `/nf:plan-phase [N] [--auto]` | Research + plan + verify for a phase |
767
+ | `/nf:execute-phase <N>` | Execute all plans in parallel waves, verify when complete |
768
+ | `/nf:verify-work [N]` | Manual user acceptance testing |
769
+ | `/nf:audit-milestone` | Verify milestone achieved its definition of done |
770
+ | `/nf:complete-milestone` | Archive milestone, tag release |
771
+ | `/nf:new-milestone [name]` | Start next version: questions → research → requirements → roadmap |
772
+
773
+ ### Navigation
774
+
775
+ | Command | What it does |
776
+ |---------|--------------|
777
+ | `/nf:progress` | Where am I? What's next? |
778
+ | `/nf:help` | Show all commands and usage guide |
779
+ | `/nf:update` | Update nForma with changelog preview |
780
+ | `/nf:join-discord` | Join the nForma Discord community |
781
+
782
+ ### Brownfield
783
+
784
+ | Command | What it does |
785
+ |---------|--------------|
786
+ | `/nf:map-codebase` | Analyze existing codebase before new-project |
787
+ | `/nf:map-requirements [--dry-run] [--skip-archive] [--skip-validate]` | Merge current + archived milestone requirements into `.planning/formal/requirements.json` |
788
+ | `/nf:add-requirement [--id=PREFIX-NN] [--text="..."]` | Add a single requirement with duplicate/conflict checks |
789
+ | `/nf:close-formal-gaps [--category="..."] [--ids=...] [--all]` | Generate formal models for uncovered requirements |
790
+
791
+ ### Phase Management
792
+
793
+ | Command | What it does |
794
+ |---------|--------------|
795
+ | `/nf:add-phase` | Append phase to roadmap |
796
+ | `/nf:insert-phase [N]` | Insert urgent work between phases |
797
+ | `/nf:remove-phase [N]` | Remove future phase, renumber |
798
+ | `/nf:research-phase [N]` | Deep ecosystem research only (usually prefer plan-phase) |
799
+ | `/nf:list-phase-assumptions [N]` | See Claude's intended approach before planning |
800
+ | `/nf:plan-milestone-gaps` | Create phases to close gaps from audit |
801
+ | `/nf:cleanup` | Archive completed phase directories |
802
+
803
+ ### Session
804
+
805
+ | Command | What it does |
806
+ |---------|--------------|
807
+ | `/nf:pause-work` | Create handoff when stopping mid-phase |
808
+ | `/nf:resume-work` | Restore from last session |
809
+
810
+ ### MCP Management
811
+
812
+ | Command | What it does |
813
+ |---------|--------------|
814
+ | `/nf:mcp-setup` | Interactive wizard: first-run onboarding or reconfigure any agent (key, provider, model, composition) |
815
+ | `/nf:mcp-status` | Poll all quorum agents for identity and availability; show scoreboard |
816
+ | `/nf:mcp-set-model <agent> <model>` | Switch a quorum agent's model with live validation and preference persistence |
817
+ | `/nf:mcp-update` | Update all quorum agent MCP servers (npm/npx/git install methods auto-detected) |
818
+ | `/nf:mcp-restart` | Restart all quorum agent processes and verify reconnection via identity ping |
819
+
820
+ ### Test Maintenance
821
+
822
+ | Command | What it does |
823
+ |---------|--------------|
824
+ | `/nf:fix-tests` | Discover all tests, AI-categorize failures into 5 types, dispatch fixes, loop until clean |
825
+
826
+ ### Utilities
827
+
828
+ | Command | What it does |
829
+ |---------|--------------|
830
+ | `/nf:settings` | Configure model profile and workflow agents |
831
+ | `/nf:set-profile <profile>` | Switch model profile (quality/balanced/budget) |
832
+ | `/nf:add-todo [desc]` | Capture idea for later |
833
+ | `/nf:check-todos` | List pending todos |
834
+ | `/nf:debug [desc]` | Start a debugging session with persistent state: spawns quorum diagnosis on failure, tracks hypotheses across invocations, resumes where it left off |
835
+ | `/nf:quorum-test` | Run multi-model quorum on a plan or verification artifact |
836
+ | `/nf:quorum [question]` | Ask a question and get full five-model consensus answer |
837
+ | `/nf:quick [--full]` | Execute ad-hoc task with nForma guarantees (`--full` adds plan-checking and verification) |
838
+ | `/nf:triage [--source github\|sentry\|bash] [--since 24h\|7d] [--limit N]` | Fetch and prioritize issues from GitHub, Sentry, or custom sources; route selected issue to nForma workflow |
839
+ | `/nf:queue <command>` | Queue a command to auto-invoke after the next /clear — survives context compaction |
840
+ | `/nf:reapply-patches` | Restore local modifications after an update |
841
+ | `/nf:health [--repair]` | Validate `.planning/` directory integrity, auto-repair with `--repair` |
842
+
843
+ ---
844
+
845
+ ## Configuration
846
+
847
+ nForma stores project settings in `.planning/config.json`. Configure during `/nf:new-project` or update later with `/nf:settings`. For the full config schema, workflow toggles, git branching options, and per-agent model breakdown, see the [User Guide](docs/USER-GUIDE.md#configuration-reference).
848
+
849
+ ### Core Settings
850
+
851
+ | Setting | Options | Default | What it controls |
852
+ |---------|---------|---------|------------------|
853
+ | `mode` | `yolo`, `interactive` | `interactive` | Auto-approve vs confirm at each step |
854
+ | `depth` | `quick`, `standard`, `comprehensive` | `standard` | Planning thoroughness (phases × plans) |
855
+
856
+ ### Model Profiles
857
+
858
+ Control which Claude model each agent uses. Balance quality vs token spend.
859
+
860
+ | Profile | Planning | Execution | Verification |
861
+ |---------|----------|-----------|--------------|
862
+ | `quality` | Opus | Opus | Sonnet |
863
+ | `balanced` (default) | Opus | Sonnet | Sonnet |
864
+ | `budget` | Sonnet | Sonnet | Haiku |
865
+
866
+ Switch profiles:
867
+ ```
868
+ /nf:set-profile budget
869
+ ```
870
+
871
+ Or configure via `/nf:settings`.
872
+
873
+ ### Workflow Agents
874
+
875
+ These spawn additional agents during planning/execution. They improve quality but add tokens and time.
876
+
877
+ | Setting | Default | What it does |
878
+ |---------|---------|--------------|
879
+ | `workflow.research` | `true` | Researches domain before planning each phase |
880
+ | `workflow.plan_check` | `true` | Verifies plans achieve phase goals before execution |
881
+ | `workflow.verifier` | `true` | Confirms must-haves were delivered after execution |
882
+ | `workflow.auto_advance` | `false` | Auto-chain discuss → plan → execute without stopping |
883
+
884
+ Use `/nf:settings` to toggle these, or override per-invocation:
885
+ - `/nf:plan-phase --skip-research`
886
+ - `/nf:plan-phase --skip-verify`
887
+
888
+ ### Execution
889
+
890
+ | Setting | Default | What it controls |
891
+ |---------|---------|------------------|
892
+ | `parallelization.enabled` | `true` | Run independent plans simultaneously |
893
+ | `planning.commit_docs` | `true` | Track `.planning/` in git |
894
+
895
+ ### Git Branching
896
+
897
+ Control how nForma handles branches during execution.
898
+
899
+ | Setting | Options | Default | What it does |
900
+ |---------|---------|---------|--------------|
901
+ | `git.branching_strategy` | `none`, `phase`, `milestone` | `none` | Branch creation strategy |
902
+ | `git.phase_branch_template` | string | `gsd/phase-{phase}-{slug}` | Template for phase branches |
903
+ | `git.milestone_branch_template` | string | `gsd/{milestone}-{slug}` | Template for milestone branches |
904
+
905
+ **Strategies:**
906
+ - **`none`** — Commits to current branch (default nForma behavior)
907
+ - **`phase`** — Creates a branch per phase, merges at phase completion
908
+ - **`milestone`** — Creates one branch for entire milestone, merges at completion
909
+
910
+ At milestone completion, nForma offers squash merge (recommended) or merge with history.
911
+
912
+ ### Quorum Composition
913
+
914
+ Control which agent slots participate in quorum via `quorum_active` in your `qgsd.json`:
915
+
916
+ ```json
917
+ {
918
+ "quorum_active": ["claude-1", "gemini-cli-1", "copilot-1"]
919
+ }
920
+ ```
921
+
922
+ This is auto-populated at install time based on your registered MCP servers. Toggle slots on/off via `/nf:mcp-setup` → "Edit Quorum Composition" without editing config files directly.
923
+
924
+ You can run multiple instances of the same agent family (multi-slot): `claude-1` and `claude-2` for two Claude agent slots, `copilot-1` and `copilot-2` for two Copilot slots, etc.
925
+
926
+ ---
927
+
928
+ ## Security
929
+
930
+ ### Protecting Sensitive Files
931
+
932
+ nForma's codebase mapping and analysis commands read files to understand your project. **Protect files containing secrets** by adding them to Claude Code's deny list:
933
+
934
+ 1. Open Claude Code settings (`.claude/settings.json` or global)
935
+ 2. Add sensitive file patterns to the deny list:
936
+
937
+ ```json
938
+ {
939
+ "permissions": {
940
+ "deny": [
941
+ "Read(.env)",
942
+ "Read(.env.*)",
943
+ "Read(**/secrets/*)",
944
+ "Read(**/*credential*)",
945
+ "Read(**/*.pem)",
946
+ "Read(**/*.key)"
947
+ ]
948
+ }
949
+ }
950
+ ```
951
+
952
+ This prevents Claude from reading these files entirely, regardless of what commands you run.
953
+
954
+ > [!IMPORTANT]
955
+ > nForma includes built-in protections against committing secrets, but defense-in-depth is best practice. Deny read access to sensitive files as a first line of defense.
956
+
957
+ ---
958
+
959
+ ## Troubleshooting
960
+
961
+ **Commands not found after install?**
962
+ - Restart Claude Code to reload slash commands
963
+ - Verify files exist in `~/.claude/commands/qgsd/` (global) or `./.claude/commands/qgsd/` (local)
964
+
965
+ **Commands not working as expected?**
966
+ - Run `/nf:help` to verify installation
967
+ - Re-run `npx nforma@latest` to reinstall
968
+
969
+ **Updating to the latest version?**
970
+ ```bash
971
+ npx nforma@latest
972
+ ```
973
+
974
+ **Using Docker or containerized environments?**
975
+
976
+ If file reads fail with tilde paths (`~/.claude/...`), set `CLAUDE_CONFIG_DIR` before installing:
977
+ ```bash
978
+ CLAUDE_CONFIG_DIR=/home/youruser/.claude npx nforma@latest
979
+ ```
980
+ This ensures absolute paths are used instead of `~` which may not expand correctly in containers.
981
+
982
+ ### Uninstalling
983
+
984
+ To remove nForma completely:
985
+
986
+ ```bash
987
+ # Global installs
988
+ npx qgsd --claude --global --uninstall
989
+ npx qgsd --opencode --global --uninstall
990
+
991
+ # Local installs (current project)
992
+ npx qgsd --claude --local --uninstall
993
+ npx qgsd --opencode --local --uninstall
994
+ ```
995
+
996
+ This removes all nForma commands, agents, hooks, and settings while preserving your other configurations.
997
+
998
+ ---
999
+
1000
+ ## Star History
1001
+
1002
+ <a href="https://star-history.com/#nForma-AI/nForma&Date">
1003
+ <picture>
1004
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=nForma-AI/nForma&type=Date&theme=dark" />
1005
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=nForma-AI/nForma&type=Date" />
1006
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=nForma-AI/nForma&type=Date" />
1007
+ </picture>
1008
+ </a>
1009
+
1010
+ ---
1011
+
1012
+ ## License
1013
+
1014
+ MIT License. See [LICENSE](LICENSE) for details.
1015
+
1016
+ ---
1017
+
1018
+ <div align="center">
1019
+
1020
+ *"The task of leadership is to create an alignment of strengths so strong that it makes the system's weaknesses irrelevant."*
1021
+
1022
+ — Peter Drucker
1023
+
1024
+ </div>