@jamie-tam/forge 6.0.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 (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +389 -0
  3. package/agents/architect.md +92 -0
  4. package/agents/builder.md +122 -0
  5. package/agents/code-reviewer.md +107 -0
  6. package/agents/concept-designer.md +207 -0
  7. package/agents/craft-reviewer.md +132 -0
  8. package/agents/critic.md +130 -0
  9. package/agents/doc-writer.md +85 -0
  10. package/agents/dreamer.md +129 -0
  11. package/agents/e2e-runner.md +89 -0
  12. package/agents/gotcha-hunter.md +127 -0
  13. package/agents/prototype-builder.md +193 -0
  14. package/agents/prototype-codifier.md +204 -0
  15. package/agents/prototype-reviewer.md +163 -0
  16. package/agents/security-reviewer.md +108 -0
  17. package/agents/spec-reviewer.md +94 -0
  18. package/agents/tracer.md +98 -0
  19. package/agents/wireframer.md +109 -0
  20. package/commands/abort.md +25 -0
  21. package/commands/bugfix.md +151 -0
  22. package/commands/evolve.md +118 -0
  23. package/commands/feature.md +236 -0
  24. package/commands/forge.md +100 -0
  25. package/commands/greenfield.md +185 -0
  26. package/commands/hotfix.md +98 -0
  27. package/commands/refactor.md +147 -0
  28. package/commands/resume.md +25 -0
  29. package/commands/setup.md +201 -0
  30. package/commands/status.md +27 -0
  31. package/commands/task-force.md +110 -0
  32. package/commands/validate.md +12 -0
  33. package/dist/__tests__/active-manifest.test.js +272 -0
  34. package/dist/__tests__/copy.test.js +96 -0
  35. package/dist/__tests__/gate-check.test.js +384 -0
  36. package/dist/__tests__/wiki.test.js +472 -0
  37. package/dist/__tests__/work-manifest.test.js +304 -0
  38. package/dist/active-manifest.js +229 -0
  39. package/dist/cli.js +158 -0
  40. package/dist/copy.js +124 -0
  41. package/dist/gate-check.js +326 -0
  42. package/dist/hooks.js +60 -0
  43. package/dist/init.js +140 -0
  44. package/dist/manifest.js +90 -0
  45. package/dist/merge.js +77 -0
  46. package/dist/paths.js +36 -0
  47. package/dist/uninstall.js +216 -0
  48. package/dist/update.js +158 -0
  49. package/dist/verify-manifest.js +65 -0
  50. package/dist/verify.js +98 -0
  51. package/dist/wiki-ui.js +310 -0
  52. package/dist/wiki.js +364 -0
  53. package/dist/work-manifest.js +798 -0
  54. package/hooks/config/gate-requirements.json +79 -0
  55. package/hooks/hooks.json +143 -0
  56. package/hooks/scripts/analyze-telemetry.sh +114 -0
  57. package/hooks/scripts/gate-enforcer.sh +164 -0
  58. package/hooks/scripts/pre-compact.sh +90 -0
  59. package/hooks/scripts/session-start.sh +81 -0
  60. package/hooks/scripts/telemetry.sh +41 -0
  61. package/hooks/scripts/wiki-lint.sh +87 -0
  62. package/hooks/templates/AGENTS.md.template +48 -0
  63. package/hooks/templates/CLAUDE.md.template +45 -0
  64. package/package.json +55 -0
  65. package/protocols/README.md +40 -0
  66. package/protocols/codex.md +151 -0
  67. package/protocols/graphify.md +156 -0
  68. package/references/common/agent-coordination.md +65 -0
  69. package/references/common/coding-standards.md +54 -0
  70. package/references/common/feature-tracking.md +21 -0
  71. package/references/common/io-protocol.md +36 -0
  72. package/references/common/phases.md +57 -0
  73. package/references/common/quality-gates.md +130 -0
  74. package/references/common/skill-authoring.md +154 -0
  75. package/references/common/skill-compliance.md +30 -0
  76. package/references/python/standards.md +44 -0
  77. package/references/react/standards.md +61 -0
  78. package/references/typescript/standards.md +42 -0
  79. package/rules/common/forge-system.md +59 -0
  80. package/rules/common/git-workflow.md +40 -0
  81. package/rules/common/guardrails.md +37 -0
  82. package/rules/common/quality-gates.md +18 -0
  83. package/rules/common/security.md +50 -0
  84. package/rules/common/skill-selection.md +78 -0
  85. package/rules/common/testing.md +58 -0
  86. package/rules/common/verification.md +39 -0
  87. package/skills/build-pr-workflow/SKILL.md +301 -0
  88. package/skills/build-pr-workflow/references/pr-template.md +62 -0
  89. package/skills/build-pr-workflow/references/subagent-merge.md +47 -0
  90. package/skills/build-pr-workflow/references/worktree-setup.md +125 -0
  91. package/skills/build-prototype/SKILL.md +264 -0
  92. package/skills/build-scaffold/SKILL.md +340 -0
  93. package/skills/build-tdd/SKILL.md +89 -0
  94. package/skills/build-wireframe/SKILL.md +110 -0
  95. package/skills/build-wireframe/assets/baseline-template.html +486 -0
  96. package/skills/build-wireframe/references/demo-walkthroughs.md +170 -0
  97. package/skills/build-wireframe/references/gotchas.md +188 -0
  98. package/skills/build-wireframe/references/legend-lines.md +141 -0
  99. package/skills/concept-slides/SKILL.md +192 -0
  100. package/skills/deliver-db-migration/SKILL.md +466 -0
  101. package/skills/deliver-deploy/SKILL.md +407 -0
  102. package/skills/deliver-onboarding/SKILL.md +198 -0
  103. package/skills/deliver-onboarding/references/document-templates.md +393 -0
  104. package/skills/deliver-onboarding/templates/getting-started.md +122 -0
  105. package/skills/discover-codebase-analysis/SKILL.md +448 -0
  106. package/skills/discover-requirements/SKILL.md +418 -0
  107. package/skills/discover-requirements/templates/prd.md +99 -0
  108. package/skills/discover-requirements/templates/technical-spec.md +123 -0
  109. package/skills/discover-requirements/templates/user-stories.md +76 -0
  110. package/skills/harden/SKILL.md +214 -0
  111. package/skills/iterate-prototype/SKILL.md +241 -0
  112. package/skills/plan-architecture/SKILL.md +457 -0
  113. package/skills/plan-architecture/templates/adr-template.md +52 -0
  114. package/skills/plan-architecture/templates/api-contract.md +99 -0
  115. package/skills/plan-architecture/templates/db-schema.md +81 -0
  116. package/skills/plan-architecture/templates/system-design.md +111 -0
  117. package/skills/plan-brainstorm/SKILL.md +433 -0
  118. package/skills/plan-design-system/SKILL.md +279 -0
  119. package/skills/plan-task-decompose/SKILL.md +454 -0
  120. package/skills/quality-code-review/SKILL.md +286 -0
  121. package/skills/quality-security-audit/SKILL.md +292 -0
  122. package/skills/quality-security-audit/references/audit-report-template.md +89 -0
  123. package/skills/quality-security-audit/references/owasp-checks.md +178 -0
  124. package/skills/quality-test-execution/SKILL.md +435 -0
  125. package/skills/quality-test-plan/SKILL.md +297 -0
  126. package/skills/quality-test-plan/references/test-type-guide.md +263 -0
  127. package/skills/quality-test-plan/templates/e2e-test-plan.md +72 -0
  128. package/skills/quality-test-plan/templates/integration-test-plan.md +74 -0
  129. package/skills/quality-test-plan/templates/load-test-plan.md +111 -0
  130. package/skills/quality-test-plan/templates/smoke-test-plan.md +68 -0
  131. package/skills/quality-test-plan/templates/unit-test-plan.md +56 -0
  132. package/skills/quality-uiux/SKILL.md +481 -0
  133. package/skills/support-debug/SKILL.md +464 -0
  134. package/skills/support-dream/SKILL.md +213 -0
  135. package/skills/support-gotcha/SKILL.md +249 -0
  136. package/skills/support-runtime-reachability/SKILL.md +190 -0
  137. package/skills/support-runtime-reachability/scripts/__fixtures__/case-01-passes-app-use/src/app.ts +7 -0
  138. package/skills/support-runtime-reachability/scripts/__fixtures__/case-01-passes-app-use/src/handlers/cases.ts +7 -0
  139. package/skills/support-runtime-reachability/scripts/__fixtures__/case-02-orphan-no-app-use/src/app.ts +8 -0
  140. package/skills/support-runtime-reachability/scripts/__fixtures__/case-02-orphan-no-app-use/src/handlers/cases.ts +7 -0
  141. package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/App.tsx +5 -0
  142. package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/components/RingingBanner.tsx +7 -0
  143. package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/hooks/useTwilio.ts +6 -0
  144. package/skills/support-runtime-reachability/scripts/__fixtures__/case-04-jsx-component-rendered/src/App.tsx +5 -0
  145. package/skills/support-runtime-reachability/scripts/__fixtures__/case-04-jsx-component-rendered/src/components/MyComp.tsx +3 -0
  146. package/skills/support-runtime-reachability/scripts/__fixtures__/case-05-jsx-component-not-rendered/src/App.tsx +3 -0
  147. package/skills/support-runtime-reachability/scripts/__fixtures__/case-05-jsx-component-not-rendered/src/components/Orphan.tsx +3 -0
  148. package/skills/support-runtime-reachability/scripts/__fixtures__/case-06-class-instantiated/src/lib/Service.ts +6 -0
  149. package/skills/support-runtime-reachability/scripts/__fixtures__/case-06-class-instantiated/src/main.ts +4 -0
  150. package/skills/support-runtime-reachability/scripts/__fixtures__/case-07-class-not-instantiated/src/lib/Lonely.ts +5 -0
  151. package/skills/support-runtime-reachability/scripts/__fixtures__/case-07-class-not-instantiated/src/main.ts +2 -0
  152. package/skills/support-runtime-reachability/scripts/__fixtures__/case-08-default-export-imported-and-called/src/handler.ts +3 -0
  153. package/skills/support-runtime-reachability/scripts/__fixtures__/case-08-default-export-imported-and-called/src/main.ts +3 -0
  154. package/skills/support-runtime-reachability/scripts/__fixtures__/case-09-default-export-orphan/src/handler.ts +3 -0
  155. package/skills/support-runtime-reachability/scripts/__fixtures__/case-09-default-export-orphan/src/main.ts +2 -0
  156. package/skills/support-runtime-reachability/scripts/__fixtures__/case-10-aliased-named-export/src/lib.ts +5 -0
  157. package/skills/support-runtime-reachability/scripts/__fixtures__/case-10-aliased-named-export/src/main.ts +3 -0
  158. package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/lib/index.ts +1 -0
  159. package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/lib/internal.ts +3 -0
  160. package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/main.ts +3 -0
  161. package/skills/support-runtime-reachability/scripts/__fixtures__/case-12-test-only-caller/src/util.test.ts +5 -0
  162. package/skills/support-runtime-reachability/scripts/__fixtures__/case-12-test-only-caller/src/util.ts +3 -0
  163. package/skills/support-runtime-reachability/scripts/__fixtures__/case-13-gated-pending-annotation/src/future.ts +4 -0
  164. package/skills/support-runtime-reachability/scripts/__fixtures__/case-14-untraceable-annotation/src/decorated.ts +4 -0
  165. package/skills/support-runtime-reachability/scripts/__fixtures__/case-15-untraceable-empty/src/lazy.ts +4 -0
  166. package/skills/support-runtime-reachability/scripts/__fixtures__/case-16-python-module/src/lib.py +15 -0
  167. package/skills/support-runtime-reachability/scripts/__fixtures__/case-16-python-module/src/main.py +5 -0
  168. package/skills/support-runtime-reachability/scripts/__fixtures__/case-17-router-use/src/parent.ts +5 -0
  169. package/skills/support-runtime-reachability/scripts/__fixtures__/case-17-router-use/src/routes/cases.ts +5 -0
  170. package/skills/support-runtime-reachability/scripts/__fixtures__/case-18-shadowed-name-fp/src/lib/foo.ts +3 -0
  171. package/skills/support-runtime-reachability/scripts/__fixtures__/case-18-shadowed-name-fp/src/other.ts +8 -0
  172. package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/handlers/cases.ts +4 -0
  173. package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/handlers/users.ts +4 -0
  174. package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/main.ts +5 -0
  175. package/skills/support-runtime-reachability/scripts/__fixtures__/case-20-aliased-import-usage/src/handlers/cases.ts +3 -0
  176. package/skills/support-runtime-reachability/scripts/__fixtures__/case-20-aliased-import-usage/src/main.ts +4 -0
  177. package/skills/support-runtime-reachability/scripts/__fixtures__/case-21-mixed-default-and-named/src/lib.ts +5 -0
  178. package/skills/support-runtime-reachability/scripts/__fixtures__/case-21-mixed-default-and-named/src/main.ts +5 -0
  179. package/skills/support-runtime-reachability/scripts/__fixtures__/case-22-dynamic-import-then-caller/src/lib.ts +3 -0
  180. package/skills/support-runtime-reachability/scripts/__fixtures__/case-22-dynamic-import-then-caller/src/main.ts +8 -0
  181. package/skills/support-runtime-reachability/scripts/__fixtures__/case-23-dynamic-import-with-space/src/lib.ts +3 -0
  182. package/skills/support-runtime-reachability/scripts/__fixtures__/case-23-dynamic-import-with-space/src/main.ts +7 -0
  183. package/skills/support-runtime-reachability/scripts/check.mjs +638 -0
  184. package/skills/support-runtime-reachability/scripts/check.test.mjs +244 -0
  185. package/skills/support-skill-validator/SKILL.md +194 -0
  186. package/skills/support-skill-validator/references/false-positives.md +59 -0
  187. package/skills/support-skill-validator/references/validation-checks.md +280 -0
  188. package/skills/support-system-guide/SKILL.md +311 -0
  189. package/skills/support-task-force/SKILL.md +265 -0
  190. package/skills/support-task-force/references/dispatch-pattern.md +178 -0
  191. package/skills/support-task-force/references/synthesis-template.md +126 -0
  192. package/skills/support-wiki-bootstrap/SKILL.md +37 -0
  193. package/skills/support-wiki-lint/SKILL.md +196 -0
  194. package/skills/support-wiki-lint/scripts/lint.mjs +488 -0
  195. package/skills/support-wiki-lint/scripts/lint.test.mjs +196 -0
  196. package/templates/README.md +23 -0
  197. package/templates/aiwiki/CLAUDE.md.template +78 -0
  198. package/templates/aiwiki/schemas/architecture.md +118 -0
  199. package/templates/aiwiki/schemas/convention.md +112 -0
  200. package/templates/aiwiki/schemas/decision.md +144 -0
  201. package/templates/aiwiki/schemas/gotcha.md +118 -0
  202. package/templates/aiwiki/schemas/oracle.md +105 -0
  203. package/templates/aiwiki/schemas/session.md +125 -0
  204. package/templates/manifests/bugfix.yaml +41 -0
  205. package/templates/manifests/feature.yaml +69 -0
  206. package/templates/manifests/greenfield.yaml +61 -0
  207. package/templates/manifests/hotfix.yaml +45 -0
  208. package/templates/manifests/refactor.yaml +44 -0
  209. package/templates/manifests/v5/SCHEMA.md +327 -0
  210. package/templates/manifests/v5/feature.yaml +77 -0
  211. package/templates/manifests/v6/SCHEMA.md +199 -0
  212. package/templates/wiki-html/dream-detail.html +378 -0
  213. package/templates/wiki-html/dreams-list.html +155 -0
@@ -0,0 +1,65 @@
1
+ # Agent Coordination
2
+
3
+ Quality principles for dispatching and managing subagents.
4
+
5
+ ## Agent Roles
6
+
7
+ | Role | Agents | Output type | Review needed? |
8
+ |------|--------|-------------|---------------|
9
+ | **Builder** | builder | Production code + tests via TDD | Yes — quality-code-review after each task |
10
+ | **Producer** | architect, doc-writer | Artifacts that downstream work depends on | Yes — errors cascade |
11
+ | **Reviewer** | critic, code-reviewer, craft-reviewer, security-reviewer, spec-reviewer | Assessments and verdicts | No — output IS the review |
12
+ | **Executor** | e2e-runner | Objective results (pass/fail) | No |
13
+ | **Investigator** | tracer | Hypotheses and analysis | No — feeds back to main agent |
14
+ | **Recall** | gotcha-hunter | Diff-relevant entries from the gotcha catalogs | No — output is a citation list, not a judgment |
15
+
16
+ ## Pre-Dispatch Requirements
17
+
18
+ - API contracts defined before dispatching parallel builders or producers
19
+ - Provide task objective, scope, and success criteria in the prompt
20
+ - Builder agents need architecture artifacts inline in the prompt (`.forge/` is not in version control — worktree checkouts won't have them)
21
+ - Define clear expected outputs to verify delivery
22
+
23
+ ## Communication
24
+
25
+ - Main agent bridges ALL inter-agent communication — subagents never talk directly
26
+ - If a subagent discovers a dependency on another's work, STOP and ask the main agent
27
+
28
+ ## Review Gates
29
+
30
+ Producer output is reviewed in two stages — first `spec-reviewer` for compliance against the source artifact (requirements / architecture / design), then the `quality-code-review` chain (safety → craft → reachability → gotcha-hunter) for code quality. The `critic` agent reviews planning artifacts before they are presented to the user.
31
+
32
+ ## Model Routing
33
+
34
+ | Complexity | Model | Examples |
35
+ |-----------|-------|---------|
36
+ | Simple | Haiku | Formatting, simple refactors |
37
+ | Standard | Sonnet | Implementation, tests, code review, docs |
38
+ | Complex | Opus | Architecture, multi-perspective critique, cross-system design |
39
+
40
+ ## Worktree Isolation
41
+
42
+ `isolation: "worktree"` is a **safety mechanism** preventing file interference, not a speed mechanism. Agents MUST commit changes; merge via `git merge --no-ff`, never `cp`. See `build-pr-workflow` for the full protocol.
43
+
44
+ ## Coupling Rules
45
+
46
+ - If two tasks share a DB table, API endpoint, state, or modify the same file — serialize them
47
+ - Independent modules (separate APIs, separate UI components) can run in parallel
48
+ - When in doubt, serialize — correctness over speed
49
+ - **File-overlap = serialize.** If two tasks in the same phase create or modify the same file, they MUST be in different phases. This is validated during task decomposition. A merge conflict at build time means decomposition failed — resolve the conflict, then re-serialize remaining related tasks in the current and future phases.
50
+
51
+ ## Agent Self-Containment
52
+
53
+ Agents carry their own execution methodology inline in their definition. They do not load skills via frontmatter (`skills:` field).
54
+
55
+ - Skills are for human or inline sessions — they define process and can dispatch agents
56
+ - Agents are execution units — they receive task scope + artifacts and follow their built-in protocol
57
+ - Dispatch prompts pass task + artifacts only, not methodology (the agent already has it)
58
+
59
+ This prevents circular loading (skill dispatches agent, agent loads skill that dispatches agent) and keeps each agent's context focused on the task.
60
+
61
+ ## Failure Handling
62
+
63
+ - If a subagent fails, diagnose before retrying
64
+ - Review partial results before discarding
65
+ - Report failures to the user with context
@@ -0,0 +1,54 @@
1
+ # Coding Standards
2
+
3
+ Universal code quality principles. Language-specific rules extend these.
4
+
5
+ ## Immutability
6
+
7
+ - Prefer creating new objects over mutating existing ones
8
+ - Use `const` by default; `let` only when mutation is required
9
+ - Avoid side effects in functions where possible
10
+
11
+ ## Function Size and Complexity
12
+
13
+ - Functions: 50 lines max (excluding docstring/comments)
14
+ - Max nesting depth: 4 levels (use early returns to flatten)
15
+ - Single responsibility: one function does one thing
16
+ - If a function needs a comment explaining what it does, it needs a better name
17
+
18
+ ## File Size
19
+
20
+ - Typical: 200-400 lines
21
+ - Maximum: 800 lines
22
+ - If a file exceeds 800 lines, split by responsibility
23
+
24
+ ## Organization
25
+
26
+ - Organize by feature/domain, not by file type
27
+ - Good: `features/payments/controller.ts`, `features/payments/service.ts`
28
+ - Bad: `controllers/paymentController.ts`, `services/paymentService.ts`
29
+ - Co-locate tests with implementation (`foo.ts` + `foo.test.ts`)
30
+
31
+ ## No Hardcoded Values
32
+
33
+ - Magic numbers and strings go into named constants
34
+ - Configuration values come from config files or environment variables
35
+ - URLs, ports, timeouts, limits — all configurable
36
+
37
+ ## Error Handling
38
+
39
+ - Handle errors at system boundaries (API calls, file I/O, DB queries)
40
+ - Use typed errors or error codes, not generic catch-all
41
+ - Never swallow errors silently
42
+ - Log errors with context (what was attempted, what failed, relevant IDs)
43
+
44
+ ## Input Validation
45
+
46
+ - Validate all external input at system boundaries
47
+ - Parse, don't validate: transform untyped input into typed structures
48
+ - Fail fast with clear error messages
49
+
50
+ ## DRY Without Over-Abstraction
51
+
52
+ - Three similar lines are better than one premature abstraction
53
+ - Extract when you see the pattern three times (Rule of Three)
54
+ - Abstractions should simplify, not just reduce line count
@@ -0,0 +1,21 @@
1
+ # Work Tracking
2
+
3
+ Every command creates a work manifest that tracks phases, gates, and artifacts. State lives at `.forge/work/{type}/{name}/manifest.yaml`. Each skill reads it to find the work directory, writes to record artifacts and gates passed.
4
+
5
+ Full manifest schema: canonical templates live in `.claude/templates/manifests/`. Commands reference these templates — do not duplicate manifest schemas elsewhere.
6
+
7
+ - `feature.yaml` — template for `/feature`
8
+ - `greenfield.yaml` — template for `/greenfield`
9
+ - `bugfix.yaml` — template for `/bugfix`
10
+ - `refactor.yaml` — template for `/refactor`
11
+ - `hotfix.yaml` — template for `/hotfix` (compressed phases; follow-up tracked via successor_path)
12
+
13
+ ## Rules
14
+
15
+ - One manifest per work item — never share manifests across work items
16
+ - Manifests may be committed to version control for traceability (team preference)
17
+ - Never manually edit a manifest unless debugging the workflow
18
+ - Every command (including `/bugfix` and `/hotfix`) creates a manifest — work state is uniform across types
19
+ - Phases with `status: not-applicable` are skipped during resume and gate checking (e.g., `design-system` for backend-only features)
20
+ - Terminal states (`completed`, `escalated`) must not be resumed — hooks and commands filter them out
21
+ - Work identifier is `{type}/{name}` — names may collide across types (e.g., `feature/add-auth` and `bugfix/add-auth` can coexist)
@@ -0,0 +1,36 @@
1
+ # I/O Protocol
2
+
3
+ Skills that materially participate in artifact handoff declare an I/O contract. This enables dependency checking and workflow automation without forcing pure methodology skills to duplicate orchestration metadata.
4
+
5
+ ## Contract Format
6
+
7
+ When a skill needs an I/O contract, use this section format:
8
+
9
+ ```yaml
10
+ io_contract:
11
+ requires: # Input artifacts that must exist before invocation
12
+ - artifact: "requirements.md"
13
+ path: "{work-dir}/requirements.md"
14
+ produces: # Output artifacts created by this skill
15
+ - artifact: "architecture/api-contract.md"
16
+ path: "{work-dir}/architecture/api-contract.md"
17
+ feeds_into: # Downstream skills that consume this skill's output
18
+ - task-decompose
19
+ updates_manifest: # Which manifest fields this skill writes
20
+ - artifacts.architecture
21
+ ```
22
+
23
+ `{work-dir}` resolves to `.forge/work/{type}/{name}/`.
24
+
25
+ ## Pre-Invocation Check
26
+
27
+ Before invoking any skill with an I/O contract:
28
+ 1. Verify each required artifact exists at the expected path
29
+ 2. If missing: invoke the producing skill first, or ask the user
30
+
31
+ ## Post-Completion Check
32
+
33
+ After a skill with an I/O contract completes:
34
+ 1. Verify all `produces` artifacts were created
35
+ 2. Verify manifest was updated
36
+ 3. If missing: report the gap — do not silently proceed
@@ -0,0 +1,57 @@
1
+ # Phase Vocabulary
2
+
3
+ The canonical phase numbering and names for forge's prototype-driven SDLC. Skills, agents, and command files reference this when stating phase context. Other files must NOT invent their own numbering.
4
+
5
+ ## The seven phases
6
+
7
+ | # | Canonical name | Primary skill | Primary agent | What happens |
8
+ |---|---|---|---|---|
9
+ | 1 | **Concept** | `concept-slides` | `concept-designer` | Low-fidelity slide deck capturing the product idea — hook, sub-concepts, sketch fidelity, user journey, deferrals |
10
+ | 2 | **Wireframe** | `build-wireframe` | `wireframer` | Single-HTML annotated wireframe with click-through demo and callouts; static, no real backend |
11
+ | 3 | **Prototype** | `build-prototype` | `prototype-builder` | Working interactive build with mocked data — fast iteration, manual verification, no test rigor |
12
+ | 4 | **Iterate** | `iterate-prototype` | `prototype-reviewer` | Tighten interactions, fix gotchas, capture conventions as side effects of doing the work |
13
+ | 5 | **Codify** | `harden` | `prototype-codifier` | Transcribe locked prototype into architecture pages, ADRs, slice graph — the bridge to production-build |
14
+ | 6 | **Production-build** | `build-tdd` | `builder` | Real code with full TDD discipline, production standards, gates, and reviews |
15
+ | 7 | **Deliver** | `deliver-deploy` / `deliver-db-migration` / `deliver-onboarding` | (skills only; no dedicated agent) | Ship to production: migrations, deploy, onboarding docs |
16
+
17
+ ## Softening rule
18
+
19
+ Phases are **defaults, not requirements**. The work-item manifest at `.forge/work/{type}/{name}/manifest.yaml` tracks the plan under `phase_plan.{phase}` (v6) with values like `active`, `active-light`, `skipped`, `complete-inline` — skips, reduced-rigor runs, and retroactive entries are all legitimate. See `templates/manifests/v6/SCHEMA.md` §3 for the full vocabulary. Examples:
20
+
21
+ - A 30-line bugfix may skip concept + wireframe + prototype entirely and start at codify
22
+ - A library extraction may skip prototype + iterate (no UI surface to verify against)
23
+ - A spike may stop at prototype and never codify
24
+
25
+ Commands (`/feature`, `/bugfix`, `/greenfield`, `/refactor`) ask the AI to propose phase skips at preflight; the user confirms. Forcing all seven on every work item is wrong shape with current model capability.
26
+
27
+ ## Phase-conditional rules
28
+
29
+ The following rules apply from Phase 5 (codify) onward, per their own phase headers:
30
+
31
+ - `rules/common/testing.md` — TDD becomes mandatory
32
+ - `references/common/quality-gates.md` — full gate set (the rule-tier stub at `rules/common/quality-gates.md` fans out to this reference)
33
+ - `rules/common/git-workflow.md` — conventional commits + branch hygiene
34
+
35
+ Phases 1–4 operate under the safety-floor rules only (`rules/common/security.md`, `guardrails.md`, `verification.md`, `skill-selection.md`).
36
+
37
+ ## How to reference this in agent/skill files
38
+
39
+ When a file needs to state its phase context, use the canonical name and number together on first mention:
40
+
41
+ > "Dispatched at Phase 5 (codify) lock."
42
+ > "This skill runs in Phase 6 (production-build), after harden has produced the architecture and slice graph."
43
+
44
+ Do NOT:
45
+ - Use a different number for the same phase across files
46
+ - Use only the number ("Phase 5") without the canonical name on first mention
47
+ - Coin new phase names ("hardening phase", "the codification step") — use `codify` everywhere
48
+ - Refer to a non-existent phase ("Phase 4 lock" when you mean Phase 3 prototype lock or Phase 4 iterate lock)
49
+
50
+ ## Skill-name vs phase-name mismatches (intentional)
51
+
52
+ Two skills carry names that don't match their phase name:
53
+
54
+ | Phase | Phase name | Skill name | Why mismatch is OK |
55
+ |---|---|---|---|
56
+ | 5 | codify | `harden` | "Harden" describes what the work feels like (production-grade hardening of prototype decisions); "codify" describes what the output is (codified plans). Both names persist; use phase name when stating context, skill name when invoking. |
57
+ | 7 | deliver | `deliver-*` (multiple) | The phase has several skills, not one; "deliver" is the phase, each skill is one delivery surface. |
@@ -0,0 +1,130 @@
1
+ # Quality Gates
2
+
3
+ Phase transition criteria. Every gate must pass before proceeding.
4
+
5
+ > **v6 status — read this first.** The canonical gate list for v6 lives in
6
+ > `hooks/config/gate-requirements.json` (machine-readable; consumed by
7
+ > `gate-enforcer.sh`). The v6 prototype-driven pipeline collapses the v5
8
+ > "brainstorm / architecture / task-decompose" trio into Phase 5 `codify`
9
+ > (the `harden` skill); their checklists below remain accurate for **v5
10
+ > fallback** workflows (`/refactor` keeps the brainstorm + task-decompose
11
+ > shape) and for any v4/v5 manifests still in flight. New `/feature` and
12
+ > `/greenfield` runs will not surface `brainstorm-approved.md` or
13
+ > `architecture-approved.md` — those v5 artifacts have v6 equivalents
14
+ > under `aiwiki/decisions/` and `aiwiki/architecture/`.
15
+
16
+ ## Gate Definitions (v5 — fallback)
17
+
18
+ ### requirements -> brainstorm
19
+ - [ ] Every requirement has acceptance criteria
20
+ - [ ] Every requirement has a priority (must/should/could/won't)
21
+ - [ ] No implementation details in requirements
22
+ - [ ] User has reviewed and approved requirements
23
+
24
+ ### brainstorm -> architecture
25
+ - [ ] User explicitly approved the chosen approach
26
+ - [ ] Rejected alternatives documented with rationale
27
+ - [ ] Approach is documented in brainstorm-approved.md
28
+
29
+ ### architecture -> task-decompose
30
+ - [ ] API contracts fully defined (endpoints, request/response shapes, error codes)
31
+ - [ ] DB schema complete (tables, columns, indexes, constraints)
32
+ - [ ] System diagram created (ASCII format)
33
+ - [ ] ZERO TBDs remaining in architecture documents
34
+ - [ ] Architectural decisions recorded in decision log
35
+
36
+ ### task-decompose -> tdd
37
+ - [ ] Every task has: description, affected files, inputs, expected outputs
38
+ - [ ] Task dependencies identified (which block which)
39
+ - [ ] Parallel vs. sequential tasks marked
40
+ - [ ] Tasks reviewed by spec-reviewer
41
+
42
+ ### tdd -> code-review
43
+ - [ ] All unit tests pass
44
+ - [ ] No skipped tests
45
+ - [ ] Coverage meets project threshold (80%+ default)
46
+ - [ ] Implementation matches API contracts from architecture
47
+
48
+ ### code-review -> test-execution
49
+ - [ ] All critical review items resolved
50
+ - [ ] All important review items resolved or documented as accepted risk
51
+ - [ ] Security audit passed (required when changes touch auth, payments, encryption, PII, user-input handling that introduces injection/XSS surfaces, or external service integrations — see `quality-security-audit`)
52
+
53
+ ### test-execution -> deploy
54
+ - [ ] Every test plan item has a pass/fail result
55
+ - [ ] Zero test failures
56
+ - [ ] Coverage report generated and meets threshold
57
+ - [ ] Traceability: every requirement maps to a passing test
58
+
59
+ ## Refactor Gates
60
+
61
+ Refactoring uses a compressed gate set — no requirements or architecture phases.
62
+
63
+ ### discover -> brainstorm
64
+ - [ ] Codebase analysis complete and approved by user
65
+ - [ ] Refactoring scope, rationale, and constraints documented
66
+
67
+ ### brainstorm -> task-decompose
68
+ - [ ] User approved refactoring approach
69
+ - [ ] Rejected alternatives documented
70
+
71
+ ### task-decompose -> tdd
72
+ - [ ] Tasks reviewed and approved by user
73
+ - [ ] Dependencies and parallel/sequential execution marked
74
+ - [ ] Coverage baseline recorded
75
+
76
+ ### tdd -> test-execution
77
+ - [ ] All phases complete, per-task code reviews passed
78
+ - [ ] All tests pass on merged result
79
+ - [ ] Coverage equals or exceeds baseline
80
+ - [ ] Any test breakage during refactoring was reverted — not fixed by adjusting the test to match new behavior
81
+
82
+ ### test-execution -> assessment
83
+ - [ ] All tests pass
84
+ - [ ] Coverage equals or exceeds baseline from Step 0
85
+
86
+ ### assessment (Refactoring Assessment) -> deliver
87
+ - [ ] Before/after summary produced (quantitative + qualitative)
88
+ - [ ] User has reviewed the assessment
89
+ - [ ] Assessment feeds into PR description
90
+
91
+ ## Bugfix Gates
92
+
93
+ Bugfix uses a minimal gate set — root cause identification is the critical gate.
94
+
95
+ ### debug -> build
96
+ - [ ] Root cause confirmed with evidence trail
97
+ - [ ] Debugging summary produced (root cause, evidence, hypotheses tested)
98
+ - [ ] User reviewed root cause analysis
99
+
100
+ ### build -> code-review
101
+ - [ ] Regression test written and passes
102
+ - [ ] All existing tests still pass
103
+ - [ ] Fix is minimal — no unrelated changes
104
+
105
+ ### code-review -> deliver
106
+ - [ ] All critical and important review items resolved
107
+
108
+ ## Hotfix Gate Exemptions
109
+
110
+ The `/hotfix` command uses a compressed gate set for emergency fixes. These exemptions are intentional, not bugs:
111
+
112
+ | Standard Gate | Hotfix Equivalent | Deferred To |
113
+ |---|---|---|
114
+ | requirements -> brainstorm | Skipped | Follow-up ticket |
115
+ | brainstorm -> architecture | Skipped | Follow-up ticket |
116
+ | architecture -> task-decompose | Skipped | Follow-up ticket |
117
+ | tdd -> test-execution | Existing tests + smoke tests + regression test (not full test plan) | Follow-up ticket |
118
+ | test-execution -> code-review | Critical pass only (not full two-pass) | Follow-up ticket |
119
+ | code-review -> deploy | Direct after critical pass | Follow-up ticket |
120
+
121
+ Every hotfix MUST create a follow-up ticket that completes the skipped gates. A hotfix without follow-up is incomplete.
122
+
123
+ ## Gate Outcomes
124
+
125
+ | Result | Action |
126
+ |--------|--------|
127
+ | **Pass** | Proceed to next phase |
128
+ | **Warn** | Proceed with documented concerns in manifest |
129
+ | **Fail** | STOP. Report what is missing. Return to previous phase. |
130
+ | **Blocked** | Cannot fully verify — proceed to PR with INCOMPLETE flag visible in PR description and test results. Cannot deploy to production without resolution. |
@@ -0,0 +1,154 @@
1
+ # Skill Authoring Guidelines
2
+
3
+ Principles for creating and modifying skills. Reference this when using the skill-creator or `/evolve`.
4
+
5
+ ## Atomic Single-Responsibility
6
+
7
+ Each skill does ONE thing. If a skill has two distinct responsibilities, extract one.
8
+
9
+ **Test:** Can you describe what the skill does in one sentence without "and"? If not, it's compound.
10
+
11
+ | Atomic | Compound (split it) |
12
+ |--------|-------------------|
13
+ | "Enforce TDD discipline" | "Enforce TDD discipline AND decide execution routing" |
14
+ | "Review code quality" | "Review code quality AND manage PR creation" |
15
+ | "Debug systematically" | "Debug systematically AND fix the bug" |
16
+
17
+ ## Do Not Duplicate Rules
18
+
19
+ Rules in `rules/common/` are always loaded. Skills should not restate them.
20
+
21
+ | If this exists in a rule... | The skill should... |
22
+ |---|---|
23
+ | Testing standards (`testing.md`) | Reference, not repeat. Keep only TDD-specific deltas. |
24
+ | Verification protocol (`verification.md`) | Not re-explain "verify before writing code." |
25
+ | Coding standards (`coding-standards.md`) | Not re-explain "minimal code" or "no over-engineering." |
26
+
27
+ **Why:** Duplication drifts. When the rule is updated, the skill copy becomes stale and may contradict it.
28
+
29
+ ## Target Size
30
+
31
+ | Size | Assessment |
32
+ |------|-----------|
33
+ | < 100 lines | Likely too thin — missing process constraints |
34
+ | 100-250 lines | Ideal for most skills |
35
+ | 250-400 lines | Acceptable for complex skills (architecture, task decompose) |
36
+ | > 400 lines | Review for bloat — likely duplicates rules or has compound responsibility |
37
+
38
+ ## Avoid Internal Repetition
39
+
40
+ State each rule once. Do not restate it in:
41
+ - The overview AND the process AND the checklist AND the red flags AND the examples AND the final rule
42
+
43
+ Choose the highest-signal location. One clear statement beats six diluted ones.
44
+
45
+ ## Separate Methodology from Orchestration
46
+
47
+ Skills define HOW to do something (methodology). Orchestration decisions (which agent to dispatch, how to read manifest state, whether to fork or inline) should be minimal — a short section at most, not a parallel responsibility.
48
+
49
+ **Methodology:** RED-GREEN-REFACTOR cycle, review criteria, debugging phases.
50
+
51
+ **Orchestration:** Dispatch builder agent with task + artifacts only, read execution.mode from manifest, merge worktrees. Keep this to a routing table, not a protocol.
52
+
53
+ ## Where Workflow Goes: Command vs Skill (v6 convention)
54
+
55
+ Forge places multi-phase workflows in **commands**, not skills. This is an intentional divergence from the Anthropic Skills convention (which puts multi-step workflows in skills with auto-load on context match).
56
+
57
+ **v6 rule:**
58
+
59
+ | Content type | Goes in |
60
+ |---|---|
61
+ | Phase orchestration across an SDLC pipeline (concept → wireframe → prototype → iterate → codify → production-build → deliver) | Command (`commands/feature.md`, `commands/greenfield.md`, etc.) |
62
+ | Per-phase or per-operation methodology, with its own dispatch logic | Skill (`skills/harden/SKILL.md`, `skills/build-tdd/SKILL.md`, etc.) |
63
+ | Specialized role definitions invoked with their own context window | Agent (`agents/*.md`) |
64
+ | Ad-hoc / one-shot / mid-task corrections | Command (Claude Code's native pattern — `/btw`, `/simplify`, etc.) |
65
+ | Auto-load on user intent description ("add a logger here") | Rule + state-aware routing (`rules/common/skill-selection.md`) |
66
+
67
+ **When tempted to put a multi-step workflow in a skill:** ask whether it needs human-, script-, or CI-readable graph state. If yes (gate-enforcer reads the manifest, telemetry tracks invocations), keep it in a command. If no (pure prose orchestration; no external readers), a skill works.
68
+
69
+ **Why this matters at authoring time:** an inadvertently-skill-shaped workflow with multi-phase orchestration creates a parallel state model alongside commands+manifests. Two sources of truth for "what phase are we in" is the failure mode to avoid.
70
+
71
+ **v7 plan:** Revisit. Anthropic's hybrid pattern (`/feature` command becomes a thin invocation of `feature-workflow` skill) is the long-term direction. Until then, treat the command/skill boundary as documented above. See `AGENTS.md` "Architectural Layers" section.
72
+
73
+ ## Agent/Skill Boundary
74
+
75
+ Agents and skills are different layers:
76
+ - Skills are for human or inline sessions. They can decide when to dispatch an agent.
77
+ - Agents do not load skills via frontmatter. The agent definition must contain its own execution methodology inline.
78
+ - Dispatch prompts should pass task scope and required artifacts only, not a copy of the parent skill text.
79
+
80
+ ## Agent Dispatch Ownership
81
+
82
+ Skills that dispatch agents should:
83
+ - Name the agent and the condition for dispatch
84
+ - Keep the dispatch handoff to task scope plus required artifacts
85
+ - Not duplicate the agent's own protocol (the agent definition handles that)
86
+ - Use a guard only when the skill itself should be skipped in a given context; do not rely on skill-preloading recursion guards
87
+
88
+ ## I/O Contract
89
+
90
+ Use an I/O Contract when the skill's artifact handoffs, downstream consumers, or manifest updates need to be explicit in the workflow graph. Pure methodology skills can omit the table when it only duplicates surrounding orchestration.
91
+
92
+ | Field | Required | Purpose |
93
+ |---|---|---|
94
+ | Requires | Usually | What artifacts must exist before this skill runs |
95
+ | Produces | Usually | What artifacts this skill creates |
96
+ | Feeds into | Usually | Which skills consume this skill's output |
97
+ | Updates manifest | If applicable | Which manifest fields change |
98
+ | Dispatches | If applicable | Which agents this skill dispatches |
99
+
100
+ ## Description Authoring
101
+
102
+ The `description` field in frontmatter drives Claude Code's auto-triggering — it decides whether to load the full SKILL.md. Get this right.
103
+
104
+ **Format:** Single "Use when..." sentence. No "and" joining two responsibilities. Command-agnostic — never reference `/feature`, `/hotfix`, or other command names.
105
+
106
+ **Target:** 15-25 words, under 250 characters. Front-load keywords — truncated text still aids discovery.
107
+
108
+ **What belongs here:** When to use it (triggering conditions) and what it does (one capability).
109
+
110
+ **What belongs in the body:** Detailed triggering scenarios, skip conditions, command-specific scoping, and methodology. Use a `## When to Use` section in the SKILL.md body for this (see `support-skill-validator` for an example).
111
+
112
+ **Why this split:** Claude Code uses semantic matching on descriptions to decide relevance. Long descriptions dilute signal — the matcher weighs every word. Detailed skip/scope logic is needed by the agent *after* the skill is loaded, not before.
113
+
114
+ | Good | Bad (don't do this) |
115
+ |------|---------------------|
116
+ | `"Use when encountering any bug, test failure, or unexpected behavior — enforces systematic root cause investigation."` | `"TRIGGER when: any bug, test failure, error; user says 'it's broken', 'not working'. Enforces root cause investigation, fact-checking, and the 3-fix threshold. SKIP for: cosmetic tweaks, /hotfix emergency path."` |
117
+ | `"Use when code has been written — orchestrates the review chain (safety → craft → reachability → gotcha-hunter → Codex adversarial) with risk-based escalation."` | `"Use after build-tdd completes, per-task during /feature build phase, or as final review before PR. Multi-pass chain. Scope varies: critical-pass only for /hotfix, per-task + final for /feature and /refactor."` |
118
+
119
+ **Standalone vs chained skills:** Most skills are invoked by commands in sequence. Their descriptions must signal *which step they are*, not *what the user's goal is* — otherwise broad intent ("I want to build X") triggers multiple skills simultaneously instead of routing to a command.
120
+
121
+ | Skill type | Description pattern | Example |
122
+ |---|---|---|
123
+ | **Standalone** (user may invoke directly) | "Use when {triggering condition}" | `"Use when encountering any bug, test failure, or unexpected behavior..."` |
124
+ | **Chained** (always inside a command sequence) | "Use {phase signal} to {specific step}" | `"Use during the build phase to write or change production code..."` |
125
+
126
+ Phase signals that prevent false triggers on broad intent: "Use after architecture is approved...", "Use as the first planning step...", "Use during the build phase...", "Use when an approach has been approved...". These imply a prior step completed, so they won't fire on "I want to build a task manager."
127
+
128
+ **Cross-harness reference:**
129
+
130
+ | Harness | Pattern | Lesson for forge |
131
+ |---------|---------|-----------------|
132
+ | SuperPowers (obra) | `"Use when..."` + symptoms, ~200 chars | Concrete triggers, no workflow details — forge's primary lineage |
133
+ | Claude Code official | `"Use when..."` + keywords, ~250 chars | Semantic matching; front-load keywords, third person |
134
+ | Everything Claude Code (AffaanMustafa) | Brief frontmatter + `## When to Activate` in body | Split concerns — forge adopts this with `## When to Use` |
135
+ | gStack (garrytan) | 200-300 word descriptions with voice aliases | Over-specified; command-coupled; descriptions became stale — the anti-pattern |
136
+
137
+ ## Checklist for New Skills
138
+
139
+ - [ ] One sentence description — "Use when..." format, no "and", under 250 chars, command-agnostic
140
+ - [ ] No content duplicated from `rules/common/`
141
+ - [ ] Under 400 lines
142
+ - [ ] Each rule stated once, in one location
143
+ - [ ] Orchestration is a short section, not a parallel responsibility
144
+ - [ ] Agent dispatch passes task scope + artifacts only; agent owns its methodology inline
145
+ - [ ] Add an I/O Contract only when it materially clarifies artifact handoffs or manifest updates
146
+ - [ ] Run `/validate` after adding
147
+
148
+ ## Checklist for Modifying Skills
149
+
150
+ - [ ] Cross-check with rules — did the rule already cover what you're adding?
151
+ - [ ] Check line count before and after — did it grow significantly?
152
+ - [ ] Review for internal repetition — did you add a point already made elsewhere in the file?
153
+ - [ ] If adding agent dispatch — is the handoff limited to task scope + artifacts, with methodology kept in the agent?
154
+ - [ ] Run `/validate` after modifying
@@ -0,0 +1,30 @@
1
+ # Skill Compliance
2
+
3
+ Skills contain critical process constraints. Skipping them produces work that looks complete but misses quality gates.
4
+
5
+ ## REQUIRED SUB-SKILL Means Invoke the Skill Tool
6
+
7
+ When a command says "REQUIRED SUB-SKILL: Use **X**", you MUST invoke the skill via the Skill tool. Do not substitute your own judgment for the skill's process.
8
+
9
+ **Red flags that indicate you are about to skip a skill:**
10
+ - "This is straightforward enough without the skill"
11
+ - "I already know how to do this"
12
+ - "The skill would just slow me down"
13
+ - "I'll follow the spirit of the skill without loading it"
14
+
15
+ If you catch yourself thinking any of these, STOP and load the skill. The skill exists because the process has constraints you will miss without it.
16
+
17
+ ## Dispatch the Agent Means Use the Agent Tool
18
+
19
+ When a skill says "Dispatch the **X** subagent", you MUST call the Agent tool. Do not perform the review yourself — the subagent exists to provide independent evaluation.
20
+
21
+ ## Gate Verification
22
+
23
+ Before marking any manifest gate as `gate-passed: true`:
24
+
25
+ 1. Confirm the required skill was invoked via the Skill tool in this session
26
+ 2. Confirm all agents specified by the skill were dispatched via the Agent tool
27
+ 3. Confirm the skill's `produces` artifacts exist at the expected paths
28
+ 4. If any are missing, go back and complete the requirement
29
+
30
+ A gate-enforcer hook verifies skill and agent invocations against telemetry. If you attempt to pass a gate without the required invocations, the edit will be blocked.
@@ -0,0 +1,44 @@
1
+ # Python Standards
2
+
3
+ Extends common coding standards with Python-specific rules.
4
+
5
+ ## Type Hints
6
+
7
+ - Type hints on all function signatures (PEP 484), return types always specified
8
+ - `from __future__ import annotations` for modern syntax
9
+ - `TypeAlias` for complex definitions, `TypeVar` or PEP 695 for generics
10
+
11
+ ## Data Structures
12
+
13
+ - `dataclasses` (prefer `frozen=True`) for simple data containers
14
+ - Pydantic `BaseModel` for validated data (API boundaries, config, external input)
15
+ - Named tuples or dataclasses over plain tuples/dicts
16
+
17
+ ## Environment and Dependencies
18
+
19
+ - Virtual environments mandatory (`venv`, `poetry`, or `uv`)
20
+ - Pin all versions in lock files; `pyproject.toml` as single config source
21
+ - Separate dev from production dependencies
22
+
23
+ ## Formatting and Linting
24
+
25
+ - **Ruff** for linting and formatting (line length: 88)
26
+ - Import sorting: stdlib → third-party → local
27
+
28
+ ## File System and I/O
29
+
30
+ - `pathlib.Path` over `os.path`
31
+ - Context managers for all resource management
32
+ - `async`/`await` for I/O-bound operations
33
+ - Never bare `open()` without `with`
34
+
35
+ ## Documentation
36
+
37
+ - Google style docstrings (Args / Returns / Raises) on all public functions, classes, modules
38
+
39
+ ## Error Handling
40
+
41
+ - Custom exception classes for domain errors
42
+ - Never bare `except:` — always specify the type
43
+ - `raise ... from e` to preserve chains
44
+ - Return typed results over raising for expected cases
@@ -0,0 +1,61 @@
1
+ # React Standards
2
+
3
+ Extends `references/common/coding-standards.md` with React-specific conventions. Loaded at codify/harden phase — not active during prototype iteration.
4
+
5
+ ## Imports
6
+
7
+ - Named imports only: `import { useState } from 'react'` — never `import React from 'react'`
8
+ - Group: react → third-party → local components → local utils → types
9
+ - Absolute imports via path aliases (`@/components/Button`) over deep relative paths
10
+
11
+ ## Minimize useEffect
12
+
13
+ Most effects are unnecessary. See [React docs: You Might Not Need an Effect](https://react.dev/learn/you-might-not-need-an-effect).
14
+
15
+ | You want to... | Use this instead |
16
+ |---|---|
17
+ | Derive/transform data from props/state | Compute during render (`useMemo` or variable) |
18
+ | Respond to a user event | Event handler (`onClick`, `onSubmit`) |
19
+ | Fetch data | React Query / SWR / loader |
20
+ | Reset state when props change | `key` prop (remount) |
21
+
22
+ **When useEffect IS appropriate:** synchronizing with external systems (WebSocket, DOM APIs, third-party widgets), subscriptions, non-React integrations.
23
+
24
+ **Rules when you must use it:** always specify deps array, one effect per concern, always clean up, never set derivable state, avoid effect chains.
25
+
26
+ ## Component Patterns
27
+
28
+ - Functional components only — no class components
29
+ - Composition over inheritance
30
+ - Custom hooks (`use*`) for shared stateful logic
31
+ - Single responsibility — split at 200 lines
32
+ - Props interface for every component
33
+
34
+ ## State Management
35
+
36
+ - Local state first (`useState`) → lift up only when siblings share → context for low-frequency global (theme, auth) → external store for complex state
37
+ - Avoid prop drilling > 2 levels — use composition or context
38
+ - Derive, don't sync — if B computes from A, compute it. Don't useEffect to sync.
39
+
40
+ ## Performance
41
+
42
+ - `useMemo` for expensive computations, `useCallback` for callbacks to memoized children (only when needed)
43
+ - `React.memo` for components that render often with same props — profile first
44
+ - `React.lazy()` + `Suspense` for routes and heavy components
45
+ - Avoid anonymous objects/arrays in JSX props — extract to stable references
46
+
47
+ ## Event Handling
48
+
49
+ - Handle events in event handlers, not effects
50
+ - Use `useActionState` or form actions (React 19+) for form submissions
51
+
52
+ ## Data Fetching
53
+
54
+ - Use React Query, SWR, or framework loaders — never `useEffect` + `fetch` + `useState` in new code
55
+
56
+ ## Testing
57
+
58
+ - Test behavior (what the user sees), not implementation (hook internals, state)
59
+ - React Testing Library — query by role, label, text; not className or testId
60
+ - "One behavior per test" = one user intent: a full form flow (fill → submit → verify) is ONE test
61
+ - Prefer `msw` for network mocks; render real child components