forgedev 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/README.md +57 -10
  2. package/bin/chainproof.js +126 -0
  3. package/package.json +25 -7
  4. package/src/chainproof-bridge.js +330 -0
  5. package/src/ci-mode.js +85 -0
  6. package/src/claude-configurator.js +86 -49
  7. package/src/cli.js +30 -7
  8. package/src/composer.js +159 -34
  9. package/src/doctor-checks-chainproof.js +106 -0
  10. package/src/doctor-checks.js +39 -20
  11. package/src/doctor-prompts.js +9 -9
  12. package/src/doctor.js +37 -4
  13. package/src/guided.js +3 -3
  14. package/src/index.js +31 -10
  15. package/src/init-mode.js +64 -11
  16. package/src/menu.js +178 -0
  17. package/src/prompts.js +5 -12
  18. package/src/recommender.js +134 -10
  19. package/src/scanner.js +57 -2
  20. package/src/uat-generator.js +204 -189
  21. package/src/update-check.js +9 -4
  22. package/src/update.js +1 -1
  23. package/src/utils.js +64 -5
  24. package/templates/ai/guardrails-py/backend/app/ai/__init__.py +29 -0
  25. package/templates/ai/guardrails-py/backend/app/ai/audit_log.py +133 -0
  26. package/templates/ai/guardrails-py/backend/app/ai/client.py.template +323 -0
  27. package/templates/ai/guardrails-py/backend/app/ai/health.py.template +157 -0
  28. package/templates/ai/guardrails-py/backend/app/ai/input_guard.py +98 -0
  29. package/templates/ai/guardrails-ts/src/lib/ai/audit-log.ts.template +164 -0
  30. package/templates/ai/guardrails-ts/src/lib/ai/client.ts.template +403 -0
  31. package/templates/ai/guardrails-ts/src/lib/ai/health.ts.template +165 -0
  32. package/templates/ai/guardrails-ts/src/lib/ai/index.ts.template +17 -0
  33. package/templates/ai/guardrails-ts/src/lib/ai/input-guard.ts.template +124 -0
  34. package/templates/auth/nextauth/src/lib/auth.ts.template +12 -7
  35. package/templates/backend/express/Dockerfile.template +18 -0
  36. package/templates/backend/express/package.json.template +33 -0
  37. package/templates/backend/express/src/index.ts.template +34 -0
  38. package/templates/backend/express/src/routes/health.ts.template +27 -0
  39. package/templates/backend/express/tsconfig.json +17 -0
  40. package/templates/backend/fastapi/backend/Dockerfile.template +5 -0
  41. package/templates/backend/fastapi/backend/app/api/health.py.template +1 -1
  42. package/templates/backend/fastapi/backend/app/core/config.py.template +1 -1
  43. package/templates/backend/fastapi/backend/app/core/errors.py +1 -1
  44. package/templates/backend/fastapi/backend/app/main.py.template +3 -1
  45. package/templates/backend/fastapi/backend/requirements.txt.template +2 -0
  46. package/templates/backend/hono/Dockerfile.template +18 -0
  47. package/templates/backend/hono/package.json.template +31 -0
  48. package/templates/backend/hono/src/index.ts.template +32 -0
  49. package/templates/backend/hono/src/routes/health.ts.template +27 -0
  50. package/templates/backend/hono/tsconfig.json +18 -0
  51. package/templates/base/docs/uat/UAT_TEMPLATE.md.template +1 -1
  52. package/templates/chainproof/base/.chainproof/config.json.template +11 -0
  53. package/templates/chainproof/base/.chainproof/mcp-server.mjs +310 -0
  54. package/templates/chainproof/base/.mcp.json +9 -0
  55. package/templates/chainproof/fastapi/.chainproof/middleware.json.template +14 -0
  56. package/templates/chainproof/nextjs/.chainproof/hooks.json.template +19 -0
  57. package/templates/chainproof/polyglot/.chainproof/config.json.template +21 -0
  58. package/templates/claude-code/agents/architect.md +25 -11
  59. package/templates/claude-code/agents/build-error-resolver.md +19 -5
  60. package/templates/claude-code/agents/chief-of-staff.md +42 -8
  61. package/templates/claude-code/agents/code-quality-reviewer.md +14 -0
  62. package/templates/claude-code/agents/database-reviewer.md +15 -1
  63. package/templates/claude-code/agents/deep-reviewer.md +191 -0
  64. package/templates/claude-code/agents/doc-updater.md +19 -5
  65. package/templates/claude-code/agents/docs-lookup.md +19 -5
  66. package/templates/claude-code/agents/e2e-runner.md +26 -12
  67. package/templates/claude-code/agents/enforcement-gate.md +102 -0
  68. package/templates/claude-code/agents/frontend-builder.md +188 -0
  69. package/templates/claude-code/agents/harness-optimizer.md +36 -1
  70. package/templates/claude-code/agents/loop-operator.md +27 -13
  71. package/templates/claude-code/agents/planner.md +21 -7
  72. package/templates/claude-code/agents/product-strategist.md +24 -10
  73. package/templates/claude-code/agents/production-readiness.md +14 -0
  74. package/templates/claude-code/agents/prompt-auditor.md +115 -0
  75. package/templates/claude-code/agents/refactor-cleaner.md +22 -8
  76. package/templates/claude-code/agents/security-reviewer.md +14 -0
  77. package/templates/claude-code/agents/spec-validator.md +15 -1
  78. package/templates/claude-code/agents/tdd-guide.md +21 -7
  79. package/templates/claude-code/agents/uat-validator.md +14 -0
  80. package/templates/claude-code/claude-md/base.md +14 -7
  81. package/templates/claude-code/claude-md/fastapi.md +8 -8
  82. package/templates/claude-code/claude-md/fullstack.md +6 -6
  83. package/templates/claude-code/claude-md/hono.md +18 -0
  84. package/templates/claude-code/claude-md/nextjs.md +5 -5
  85. package/templates/claude-code/claude-md/remix.md +18 -0
  86. package/templates/claude-code/commands/audit-security.md +14 -0
  87. package/templates/claude-code/commands/audit-spec.md +14 -0
  88. package/templates/claude-code/commands/audit-wiring.md +14 -0
  89. package/templates/claude-code/commands/build-fix.md +28 -0
  90. package/templates/claude-code/commands/build-ui.md +59 -0
  91. package/templates/claude-code/commands/code-review.md +53 -31
  92. package/templates/claude-code/commands/fix-loop.md +211 -0
  93. package/templates/claude-code/commands/full-audit.md +36 -8
  94. package/templates/claude-code/commands/generate-prd.md +1 -1
  95. package/templates/claude-code/commands/generate-sdd.md +74 -0
  96. package/templates/claude-code/commands/generate-uat.md +107 -35
  97. package/templates/claude-code/commands/help.md +68 -0
  98. package/templates/claude-code/commands/live-uat.md +268 -0
  99. package/templates/claude-code/commands/optimize-claude-md.md +15 -1
  100. package/templates/claude-code/commands/plan.md +3 -3
  101. package/templates/claude-code/commands/pre-pr.md +57 -19
  102. package/templates/claude-code/commands/product-strategist.md +21 -0
  103. package/templates/claude-code/commands/resume-session.md +10 -10
  104. package/templates/claude-code/commands/run-uat.md +59 -2
  105. package/templates/claude-code/commands/save-session.md +10 -10
  106. package/templates/claude-code/commands/simplify.md +36 -0
  107. package/templates/claude-code/commands/tdd.md +17 -18
  108. package/templates/claude-code/commands/verify-all.md +24 -0
  109. package/templates/claude-code/commands/verify-intent.md +55 -0
  110. package/templates/claude-code/commands/workflows.md +52 -40
  111. package/templates/claude-code/hooks/polyglot.json +10 -1
  112. package/templates/claude-code/hooks/python.json +10 -1
  113. package/templates/claude-code/hooks/scripts/autofix-polyglot.mjs +2 -2
  114. package/templates/claude-code/hooks/scripts/autofix-python.mjs +1 -1
  115. package/templates/claude-code/hooks/scripts/autofix-typescript.mjs +1 -1
  116. package/templates/claude-code/hooks/scripts/code-hygiene.mjs +293 -0
  117. package/templates/claude-code/hooks/scripts/pre-commit-gate.mjs +207 -0
  118. package/templates/claude-code/hooks/typescript.json +10 -1
  119. package/templates/claude-code/skills/ai-prompts/SKILL.md +119 -41
  120. package/templates/claude-code/skills/git-workflow/SKILL.md +5 -5
  121. package/templates/claude-code/skills/nextjs/SKILL.md +1 -1
  122. package/templates/claude-code/skills/playwright/SKILL.md +5 -5
  123. package/templates/claude-code/skills/security-api/SKILL.md +1 -1
  124. package/templates/claude-code/skills/security-web/SKILL.md +1 -1
  125. package/templates/claude-code/skills/testing-patterns/SKILL.md +9 -9
  126. package/templates/database/prisma-postgres/{.env.example → .env.example.template} +1 -0
  127. package/templates/database/sqlalchemy-postgres/{.env.example → .env.example.template} +1 -0
  128. package/templates/docs-portal/fastapi/backend/app/portal/__pycache__/docs_reader.cpython-314.pyc +0 -0
  129. package/templates/docs-portal/fastapi/backend/app/portal/docs_reader.py +201 -0
  130. package/templates/docs-portal/fastapi/backend/app/portal/html_renderer.py +229 -0
  131. package/templates/docs-portal/fastapi/backend/app/portal/router.py.template +35 -0
  132. package/templates/docs-portal/nextjs/src/app/portal/[category]/[slug]/page.tsx +81 -0
  133. package/templates/docs-portal/nextjs/src/app/portal/[category]/page.tsx +65 -0
  134. package/templates/docs-portal/nextjs/src/app/portal/layout.tsx.template +54 -0
  135. package/templates/docs-portal/nextjs/src/app/portal/page.tsx +85 -0
  136. package/templates/docs-portal/nextjs/src/components/portal/markdown-renderer.tsx +101 -0
  137. package/templates/docs-portal/nextjs/src/components/portal/mobile-portal-nav.tsx +81 -0
  138. package/templates/docs-portal/nextjs/src/components/portal/portal-nav.tsx +86 -0
  139. package/templates/docs-portal/nextjs/src/lib/docs.ts +139 -0
  140. package/templates/frontend/nextjs/package.json.template +3 -1
  141. package/templates/frontend/react/index.html.template +12 -0
  142. package/templates/frontend/react/package.json.template +34 -0
  143. package/templates/frontend/react/src/App.tsx.template +10 -0
  144. package/templates/frontend/react/src/index.css +1 -0
  145. package/templates/frontend/react/src/main.tsx +10 -0
  146. package/templates/frontend/react/tsconfig.json +17 -0
  147. package/templates/frontend/react/vite.config.ts.template +15 -0
  148. package/templates/frontend/react/vitest.config.ts +9 -0
  149. package/templates/frontend/remix/app/root.tsx.template +31 -0
  150. package/templates/frontend/remix/app/routes/_index.tsx.template +19 -0
  151. package/templates/frontend/remix/app/routes/api.health.ts.template +10 -0
  152. package/templates/frontend/remix/app/tailwind.css +1 -0
  153. package/templates/frontend/remix/package.json.template +39 -0
  154. package/templates/frontend/remix/tsconfig.json +18 -0
  155. package/templates/frontend/remix/vite.config.ts.template +7 -0
  156. package/templates/infra/github-actions/.github/workflows/ci.yml.template +3 -0
  157. package/docs/00-README.md +0 -310
  158. package/docs/01-universal-prompt-library.md +0 -1049
  159. package/docs/02-claude-code-mastery-playbook.md +0 -283
  160. package/docs/03-multi-agent-verification.md +0 -565
  161. package/docs/04-errata-and-verification-checklist.md +0 -284
  162. package/docs/05-universal-scaffolder-vision.md +0 -452
  163. package/docs/06-confidence-assessment-and-repo-prompt.md +0 -407
  164. package/docs/errata.md +0 -58
  165. package/docs/multi-agent-verification.md +0 -66
  166. package/docs/playbook.md +0 -95
  167. package/docs/prompt-library.md +0 -160
  168. package/docs/uat/UAT_CHECKLIST.csv +0 -9
  169. package/docs/uat/UAT_TEMPLATE.md +0 -163
  170. package/templates/claude-code/commands/done.md +0 -19
  171. /package/{docs/plans/.gitkeep → templates/docs-portal/fastapi/backend/app/portal/__init__.py} +0 -0
@@ -1,19 +1,19 @@
1
1
  ## Next.js Conventions
2
- - Use App Router (src/app/) no pages/ directory
2
+ - Use App Router (src/app/). No pages/ directory
3
3
  - Server Components by default; add 'use client' only when needed (event handlers, hooks, browser APIs)
4
4
  - Use server actions for mutations, not API routes
5
5
  - Colocate loading.tsx, error.tsx, not-found.tsx with page.tsx
6
6
  - Use `@/` path alias for imports from src/
7
- - Tailwind CSS for styling use `cn()` from `@/lib/utils` for conditional classes
7
+ - Tailwind CSS for styling. Use `cn()` from `@/lib/utils` for conditional classes
8
8
  - Prisma client accessed via `@/lib/db` singleton (includes retry + graceful shutdown)
9
9
  - Form validation with Zod schemas shared between client and server
10
10
  - Images via `next/image`, links via `next/link`
11
11
  - Environment variables: NEXT_PUBLIC_ prefix for client-side, plain for server-side
12
12
 
13
13
  ## Next.js Pitfalls
14
- - Avoid Client Components with `useEffect` for data fetching prefer async Server Components instead
15
- - Never use `router.push()` when `<Link>` works Link enables prefetching
14
+ - Avoid Client Components with `useEffect` for data fetching. Prefer async Server Components instead
15
+ - Never use `router.push()` when `<Link>` works. Link enables prefetching
16
16
  - Always add `loading.tsx` for pages with async data fetching
17
17
  - Never add `'use client'` unless the component actually uses browser APIs, event handlers, or hooks
18
- - Never use `fetch()` without error handling always check `response.ok`
18
+ - Never use `fetch()` without error handling. Always check `response.ok`
19
19
  - Never store server-only secrets in `NEXT_PUBLIC_` variables
@@ -0,0 +1,18 @@
1
+ ## Remix Conventions
2
+ - File-based routing in `app/routes/`. Use Remix v2 flat route convention
3
+ - Loaders for data fetching (`loader`), actions for mutations (`action`)
4
+ - Use `useLoaderData()` and `useActionData()` for typed data access in components
5
+ - Server-only code stays in loaders/actions and `.server.ts` files
6
+ - Tailwind CSS for styling. Import styles in `app/root.tsx`
7
+ - Prisma client accessed via singleton in `app/lib/db.server.ts`
8
+ - Form submissions via `<Form>` component, not `fetch()`. Remix handles progressive enhancement
9
+ - API resource routes in `app/routes/api.*.ts` for REST endpoints
10
+ - Environment variables: server-side only by default. Use `loader` to pass to client
11
+
12
+ ## Remix Pitfalls
13
+ - Never use `useEffect` for data fetching. Use `loader` functions instead
14
+ - Never import server-only modules (Prisma, fs) in client components. Use `.server.ts` suffix
15
+ - Never use `fetch()` for mutations when `<Form>` works. Form enables progressive enhancement
16
+ - Never skip error boundaries. Add `ErrorBoundary` exports to route modules
17
+ - Never use `redirect()` outside loaders/actions. It only works in server context
18
+ - Never access `process.env` in client code. Pass values through `loader` data
@@ -1,5 +1,19 @@
1
1
  Run a focused security audit on all changed files.
2
2
 
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request verbatim]"
10
+ SCOPE: "[Files/areas to examine]"
11
+ SUCCESS_CRITERIA: "[What done looks like]"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH, its results are considered unverified.
16
+
3
17
  1. Get list of changed files: `git diff --name-only`
4
18
  2. Launch the security-reviewer agent on those files
5
19
  3. Additionally check:
@@ -1,5 +1,19 @@
1
1
  Run the spec-validator agent against the specification.
2
2
 
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request verbatim]"
10
+ SCOPE: "[Files/areas to examine]"
11
+ SUCCESS_CRITERIA: "[What done looks like]"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH, its results are considered unverified.
16
+
3
17
  1. Find spec files in `docs/` (look for files with "spec", "requirements", or "PRD" in the name)
4
18
  2. If no spec found, ask the user to provide the spec file path
5
19
  3. Launch the spec-validator agent with the spec file
@@ -1,5 +1,19 @@
1
1
  Verify that all API endpoints are properly wired between frontend and backend.
2
2
 
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request verbatim]"
10
+ SCOPE: "[Files/areas to examine]"
11
+ SUCCESS_CRITERIA: "[What done looks like]"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH, its results are considered unverified.
16
+
3
17
  1. Find all backend API endpoints (route handlers, FastAPI routers)
4
18
  2. Find all frontend API calls (fetch, axios, server actions)
5
19
  3. Cross-reference: every backend endpoint should have at least one frontend caller
@@ -1,5 +1,19 @@
1
1
  Incrementally fix build, lint, and type errors with minimal, safe changes.
2
2
 
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request verbatim]"
10
+ SCOPE: "[Files/areas to examine]"
11
+ SUCCESS_CRITERIA: "[What done looks like]"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH, its results are considered unverified.
16
+
3
17
  ## Step 1: Detect and Run Build
4
18
 
5
19
  Run the build and capture errors:
@@ -41,3 +55,17 @@ Show results:
41
55
  - Suggested next steps for unresolved issues
42
56
 
43
57
  Fix one error at a time. Prefer minimal diffs over refactoring.
58
+
59
+ ## Step 6: Recommend Next Step
60
+
61
+ After the fix summary, always recommend the single best next action. Evaluate in this order:
62
+
63
+ 1. **Remaining errors** — if any build/lint/type errors remain, recommend the specific fix
64
+ 2. **Test gaps** — if the fix touched untested code, recommend writing tests
65
+ 3. **Security review** — if the fix touched auth, input handling, or API routes, recommend `/audit-security`
66
+ 4. **Code review** — if significant logic changed, recommend `/code-review`
67
+ 5. **UAT impact** — if the fix affects user-facing behavior, flag which UAT scenarios need re-verification
68
+ 6. **Performance** — if the fix introduced new queries, loops, or async patterns, flag for perf review
69
+ 7. **All clean** — if everything passes, recommend `/pre-pr` or the next feature to build
70
+
71
+ Format: **Next step:** one sentence with the specific command or action to take.
@@ -0,0 +1,59 @@
1
+ Build frontend UI components using AI-powered generation with Google Stitch and UI UX Pro Max design intelligence.
2
+
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request - e.g., 'Build a login page with social auth buttons']"
10
+ SCOPE: "[Components to generate, target directory, framework]"
11
+ SUCCESS_CRITERIA: "[Component renders, matches design system, user accepts preview]"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ ## Step 1: Gather Requirements
16
+
17
+ Ask the user (if not already specified):
18
+ 1. **What to build**: page, component, section, layout?
19
+ 2. **Functionality**: what does it do?
20
+ 3. **Style preference**: any aesthetic direction? (minimal, bold, playful, corporate, etc.)
21
+
22
+ Detect automatically:
23
+ - Project framework (check package.json, tsconfig, etc.)
24
+ - Existing design system or component library
25
+ - CSS approach (Tailwind, CSS Modules, styled-components)
26
+
27
+ ## Step 2: Launch Frontend Builder
28
+
29
+ Invoke the **frontend-builder** agent with:
30
+ - The user's request
31
+ - Detected framework and conventions
32
+ - The Intent Contract
33
+
34
+ The agent will:
35
+ 1. Generate a design system (via UI UX Pro Max if available)
36
+ 2. Generate UI code (via Google Stitch if available, or manually)
37
+ 3. Preview the result for user approval
38
+ 4. Write accepted components to the project
39
+
40
+ ## Step 3: Post-Build Verification
41
+
42
+ After the agent completes:
43
+ 1. Run the project's dev server if not already running
44
+ 2. Verify the component renders without console errors
45
+ 3. Check responsive layout (mobile, tablet, desktop)
46
+ 4. Run lint and type check to ensure no issues introduced
47
+
48
+ ## Quick Examples
49
+
50
+ ```
51
+ # Generate a landing page
52
+ /build-ui Create a SaaS landing page with hero, features grid, pricing table, and CTA
53
+
54
+ # Generate a specific component
55
+ /build-ui Build a data table component with sorting, filtering, and pagination
56
+
57
+ # Generate with style direction
58
+ /build-ui Build a dashboard sidebar with glassmorphism style and dark mode support
59
+ ```
@@ -1,4 +1,20 @@
1
- Review uncommitted changes for security issues and code quality.
1
+ Review uncommitted changes for security issues and code quality. This is the required review step before committing.
2
+
3
+ The pre-commit gate will block commits until this review completes. After review, the commit will be allowed.
4
+
5
+ ## Intent Contract
6
+
7
+ Before invoking any agent, construct this block and pass it as context:
8
+
9
+ ```
10
+ INTENT_CONTRACT:
11
+ INTENT: "[User's original request verbatim]"
12
+ SCOPE: "[Files/areas to examine]"
13
+ SUCCESS_CRITERIA: "[What done looks like]"
14
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
15
+ ```
16
+
17
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH, its results are considered unverified.
2
18
 
3
19
  ## Step 1: Get Changed Files
4
20
 
@@ -6,45 +22,51 @@ Review uncommitted changes for security issues and code quality.
6
22
  git diff --name-only HEAD
7
23
  ```
8
24
 
9
- ## Step 2: Review Each File
10
-
11
- For each changed file, check:
25
+ If no changes, report "Nothing to review" and exit.
12
26
 
13
- **Security (CRITICAL):**
14
- - Hardcoded credentials, API keys, tokens
15
- - SQL injection vulnerabilities
16
- - XSS vulnerabilities
17
- - Missing input validation
18
- - Path traversal risks
27
+ ## Step 2: Launch Review Agents (in parallel)
19
28
 
20
- **Code Quality (HIGH):**
21
- - Functions > 50 lines
22
- - Files > 800 lines
23
- - Nesting depth > 4 levels
24
- - Missing error handling
25
- - console.log / print statements left in
26
- - TODO/FIXME comments without tracking
29
+ Launch all three agents on the changed files:
27
30
 
28
- **Best Practices (MEDIUM):**
29
- - Missing tests for new code
30
- - Mutation of shared state (use immutable patterns)
31
- - Missing accessibility attributes (a11y)
31
+ | Agent | Focus |
32
+ |-------|-------|
33
+ | `code-quality-reviewer` | Code patterns, complexity, maintainability, naming |
34
+ | `security-reviewer` | Vulnerabilities, injection, credential exposure, input validation |
35
+ | `deep-reviewer` | Behavioral integrity, runtime correctness, configuration validity, dependency quality, user-facing text, regression and scalability risks |
32
36
 
33
- **Code Style (LOW):**
34
- - Naming convention violations
35
- - Minor formatting inconsistencies
36
- - Missing documentation comments
37
-
38
- ## Step 3: Generate Report
37
+ ## Step 3: Collect and Report Findings
39
38
 
40
39
  For each issue found:
41
40
  - **Severity**: CRITICAL, HIGH, MEDIUM, LOW
42
41
  - **File**: path and line number
43
42
  - **Issue**: what's wrong
44
43
  - **Fix**: how to fix it
44
+
45
45
  ## Step 4: Verdict
46
46
 
47
- - If CRITICAL issues found block commit, list required fixes
48
- - If HIGH issues found (no CRITICAL) strongly recommend fixes before commit
49
- - If only MEDIUM/LOW approve with suggestions
50
- - Never approve code with security vulnerabilities
47
+ - If CRITICAL issues found: list required fixes, do NOT mark as reviewed
48
+ - If HIGH issues found (no CRITICAL): strongly recommend fixes, mark as reviewed with warnings
49
+ - If only MEDIUM/LOW: approve with suggestions, mark as reviewed
50
+
51
+ ## Step 5: Update Review Marker
52
+
53
+ After review completes (with no CRITICAL findings), write the review marker so the pre-commit gate knows these files have been reviewed:
54
+
55
+ ```bash
56
+ echo '{"files": [<list of reviewed files>], "timestamp": "<ISO timestamp>", "verdict": "<APPROVED|APPROVED_WITH_WARNINGS>"}' > .claude/.last-review
57
+ ```
58
+
59
+ This marker is checked by the pre-commit gate. If new files are staged after review, the gate will require re-review.
60
+
61
+ ## Step 6: Recommend Next Step
62
+
63
+ After the review, always recommend the single best next action:
64
+
65
+ 1. **CRITICAL fixes** — if any CRITICAL findings, recommend the specific fix with file:line
66
+ 2. **HIGH fixes** — if HIGH findings with clear fixes, recommend `/build-fix` or manual fix
67
+ 3. **Test coverage** — if reviewed code lacks tests, recommend writing tests for the specific functions
68
+ 4. **Security hardening** — if security findings exist, recommend `/audit-security` for a deeper pass
69
+ 5. **Ready to commit** — if review is clean, recommend committing with a suggested commit message
70
+ 6. **Ready for PR** — if already committed, recommend `/pre-pr`
71
+
72
+ Format: **Next step:** one sentence with the specific command or action to take.
@@ -0,0 +1,211 @@
1
+ Run an automated fix-review-regression loop with enforcement gates until all tests pass, code is verified clean, and every agent's work is independently confirmed.
2
+
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request verbatim]"
10
+ SCOPE: "[Files/areas to examine]"
11
+ SUCCESS_CRITERIA: "All tests pass, no lint/type errors, no CRITICAL or HIGH review findings, no regressions, all agents APPROVED by enforcement gate"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH, its results are considered unverified.
16
+
17
+ ## Enforcement Protocol
18
+
19
+ **After every phase that involves an agent doing work**, invoke the `enforcement-gate` agent with:
20
+ 1. The Intent Contract
21
+ 2. The agent's full output (including PROOF_OF_INTENT)
22
+ 3. The baseline metrics from Phase 0
23
+
24
+ **Gate rules:**
25
+ - `APPROVED` (confidence >= 99.99%) → proceed to next phase
26
+ - `NEEDS_REVIEW` (confidence 75-99.98%) → surface discrepancies to user, ask whether to proceed or halt
27
+ - `REJECTED` (confidence < 75% OR false claim OR regression) → halt the loop, report what failed and why
28
+
29
+ No phase transition happens without an APPROVED or explicit user override.
30
+
31
+ ## Phase 0: Baseline
32
+
33
+ Run all checks and capture the starting state:
34
+
35
+ ```bash
36
+ {{TEST_COMMAND}}
37
+ {{LINT_COMMAND}}
38
+ {{TYPE_CHECK_COMMAND}}
39
+ ```
40
+
41
+ Record as structured baseline:
42
+ ```
43
+ BASELINE:
44
+ TESTS: [total, passing, failing]
45
+ LINT_ERRORS: [count]
46
+ TYPE_ERRORS: [count]
47
+ TIMESTAMP: [ISO 8601]
48
+ ```
49
+
50
+ If everything passes already, skip to Phase 2 (deep review only).
51
+
52
+ ## Phase 1: Fix (build-error-resolver agent)
53
+
54
+ Delegate to the `build-error-resolver` agent with the Intent Contract:
55
+
56
+ 1. Group errors by file, sorted by dependency order
57
+ 2. Fix one error at a time with the smallest possible change
58
+ 3. Re-run all checks after each fix to confirm no regressions
59
+ 4. Continue until all errors are resolved
60
+
61
+ **Stop conditions** (bail out and report to user):
62
+ - Same error persists after 3 attempts
63
+ - A fix introduces more errors than it resolves
64
+ - Fix requires architectural changes beyond a simple repair
65
+ - No progress across 2 consecutive iterations
66
+ - Maximum 5 fix iterations reached
67
+
68
+ ### Enforcement Gate 1
69
+
70
+ After build-error-resolver completes, invoke `enforcement-gate`:
71
+ - Verify all claimed fixes are real (re-run `{{TEST_COMMAND}}`, `{{LINT_COMMAND}}`, `{{TYPE_CHECK_COMMAND}}`)
72
+ - Verify no regressions against baseline
73
+ - Verify scope coverage (did the agent touch only files it claimed?)
74
+
75
+ If REJECTED → halt and report. If APPROVED → proceed to Phase 2.
76
+
77
+ ## Phase 2: Deep Review (deep-reviewer agent)
78
+
79
+ Run `git diff` to capture all changes since baseline.
80
+
81
+ Invoke the `deep-reviewer` agent with the Intent Contract and the full diff. The deep reviewer will:
82
+
83
+ 1. Read every changed hunk line-by-line
84
+ 2. Analyze for: correctness, security, data integrity, performance, edge cases, API contract, readability
85
+ 3. For each finding: exact file/line, severity, description, suggested fix, and a runnable test case
86
+ 4. Return structured findings with confidence scores
87
+
88
+ ### Triage Findings
89
+
90
+ Categorize the deep reviewer's output:
91
+
92
+ | Finding Type | Action |
93
+ |-------------|--------|
94
+ | CRITICAL with fix + test case | → Phase 3 (auto-fix) |
95
+ | HIGH with fix + test case | → Phase 3 (auto-fix) |
96
+ | CRITICAL/HIGH needing human judgment | → Halt loop, surface to user |
97
+ | MEDIUM/LOW | → Collect for final report |
98
+ | Confidence < 70% | → Collect for final report, mark as uncertain |
99
+
100
+ ## Phase 3: Fix Review Findings (build-error-resolver agent)
101
+
102
+ For each CRITICAL/HIGH finding from Phase 2 that has an auto-fixable suggestion:
103
+
104
+ 1. Apply the suggested fix from the deep reviewer
105
+ 2. Run the test case the deep reviewer generated — it must pass
106
+ 3. Run `{{TEST_COMMAND}}` — all existing tests must still pass
107
+ 4. Move to next finding
108
+
109
+ **Cap**: Maximum 2 iterations of fix-review. If findings keep appearing, halt and report.
110
+
111
+ ### Enforcement Gate 2
112
+
113
+ After fixing review findings, invoke `enforcement-gate`:
114
+ - Verify every applied fix resolves its finding
115
+ - Verify all generated test cases pass
116
+ - Verify no regressions against baseline
117
+ - Verify the deep reviewer's test cases actually test what they claim
118
+
119
+ If REJECTED → revert the fixes from this phase, report findings to user as manual tasks. If APPROVED → proceed to Phase 4.
120
+
121
+ ## Phase 4: Regression + New Test Validation
122
+
123
+ Run the full test suite:
124
+
125
+ ```bash
126
+ {{TEST_COMMAND}}
127
+ ```
128
+
129
+ Compare against Phase 0 baseline:
130
+ - If any previously passing test now fails → **REGRESSION DETECTED**
131
+ - Delegate to `build-error-resolver` to fix (max 2 iterations)
132
+ - Run through `enforcement-gate` again
133
+ - If regression persists after gate, halt and report
134
+ - If test count decreased (tests were deleted) → flag as **WARNING**
135
+ - If all tests pass and count is stable or increased → **GREEN**
136
+
137
+ Then verify any new test cases generated by the deep reviewer:
138
+ - Each test must target a specific finding
139
+ - Each test must fail WITHOUT the fix and pass WITH the fix (if we can verify this)
140
+ - Tests that pass regardless of the fix are flagged as `WEAK_TEST`
141
+
142
+ ### Enforcement Gate 3 (Final)
143
+
144
+ Invoke `enforcement-gate` one last time on the entire session:
145
+ - Re-run all checks from scratch: `{{TEST_COMMAND}}`, `{{LINT_COMMAND}}`, `{{TYPE_CHECK_COMMAND}}`
146
+ - Verify final state against baseline (test count, pass rate, error counts)
147
+ - Verify every agent's PROOF_OF_INTENT hash matches the original INTENT_HASH
148
+ - Produce final confidence score
149
+
150
+ If REJECTED → report what failed. If APPROVED → proceed to report.
151
+
152
+ ## Phase 5: Final Report
153
+
154
+ ```
155
+ ## Fix Loop Report
156
+
157
+ **Baseline**: X tests (Y passing, Z failing), L lint errors, T type errors
158
+ **Result**: X tests (Y passing, Z failing), L lint errors, T type errors
159
+
160
+ ### Phase Results
161
+ | Phase | Agent | Enforcement Verdict | Confidence |
162
+ |-------|-------|-------------------|------------|
163
+ | 1. Fix | build-error-resolver | APPROVED/REJECTED | XX% |
164
+ | 2. Deep Review | deep-reviewer | N/A (read-only) | N/A |
165
+ | 3. Fix Findings | build-error-resolver | APPROVED/REJECTED | XX% |
166
+ | 4. Regression | enforcement-gate | APPROVED/REJECTED | XX% |
167
+
168
+ ### Deep Review Findings
169
+ | ID | File:Line | Severity | Category | Status |
170
+ |----|-----------|----------|----------|--------|
171
+ | DR-001 | path:line | CRITICAL | Correctness | FIXED / DEFERRED / MANUAL |
172
+
173
+ ### Test Cases Generated
174
+ | Finding | Test File | Status |
175
+ |---------|-----------|--------|
176
+ | DR-001 | path/to/test | PASSING / WEAK / FAILING |
177
+
178
+ ### Enforcement Audit Trail
179
+ [For each gate: what was checked, what passed, what failed, confidence score]
180
+
181
+ ### Remaining Items (MEDIUM/LOW)
182
+ [Non-blocking findings for user to address at their discretion]
183
+
184
+ ### Intent Verification Summary
185
+ [Each agent's INTENT_MATCH status, any DRIFT_DETECTED flags]
186
+ ```
187
+
188
+ ## Guardrails
189
+
190
+ - **Max total iterations across all phases**: 10 (prevents infinite loops)
191
+ - **Regression tolerance**: 0 (no previously passing test may break)
192
+ - **Review-fix cap**: 2 iterations (prevents review-fix ping-pong)
193
+ - **Enforcement gates**: 3 mandatory (after Phase 1, after Phase 3, final)
194
+ - **No phase transition without APPROVED or explicit user override**
195
+ - Never suppress or skip a failing test to make the loop pass
196
+ - Never mark a finding as resolved without the enforcement gate confirming it
197
+ - If any phase halts, the report must still be generated with what was completed
198
+
199
+ ## Phase 6: Recommend Next Step
200
+
201
+ After the final report, always recommend the single best next action:
202
+
203
+ 1. **Manual findings** — if CRITICAL/HIGH findings were deferred, recommend fixing them with specific file:line references
204
+ 2. **Weak tests** — if any generated test cases were flagged WEAK, recommend strengthening them
205
+ 3. **Security** — if changes touched auth, input handling, or API routes, recommend `/audit-security`
206
+ 4. **UAT** — if changes affect user-facing behavior, recommend `/run-uat` with specific scenarios
207
+ 5. **PR readiness** — if everything is green, recommend `/pre-pr`
208
+ 6. **Dependency check** — if the fix revealed outdated deps, recommend updating them
209
+ 7. **Architecture** — if fixes were workarounds, recommend the proper architectural fix
210
+
211
+ Format: **Next step:** one sentence with the specific command or action to take.
@@ -1,5 +1,19 @@
1
1
  Run every audit and review agent in a single pass. Use this when you want a comprehensive project health check.
2
2
 
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block and pass it as context:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "[User's original request - default: 'Run comprehensive project health check']"
10
+ SCOPE: "[Full codebase - all source files, configs, and .claude/ infrastructure]"
11
+ SUCCESS_CRITERIA: "[All review agents run, all findings grouped by severity, no agent skipped]"
12
+ INTENT_HASH: "[First 8 chars of SHA256(INTENT|SCOPE|SUCCESS_CRITERIA)]"
13
+ ```
14
+
15
+ Every agent invocation MUST include this block. If an agent's output does not echo back the INTENT_HASH in its PROOF_OF_INTENT, its results are considered unverified.
16
+
3
17
  ## Step 1: Build + Lint + Tests
4
18
 
5
19
  1. Run lint: `{{LINT_COMMAND}}`
@@ -22,20 +36,27 @@ If any step fails, report the failures but continue with the remaining audits.
22
36
 
23
37
  Run these agents in sequence on the full codebase:
24
38
 
25
- 1. **code-quality-reviewer** code patterns, duplication, naming
26
- 2. **security-reviewer** vulnerabilities, secrets, unsafe operations
27
- 3. **production-readiness** deployment readiness, error handling, health checks
28
- 4. **database-reviewer** query performance, N+1, schema issues (skip if no database)
39
+ 1. **code-quality-reviewer** - code patterns, duplication, naming
40
+ 2. **security-reviewer** - vulnerabilities, secrets, unsafe operations
41
+ 3. **production-readiness** - deployment readiness, error handling, health checks
42
+ 4. **database-reviewer** - query performance, N+1, schema issues (skip if no database)
29
43
 
30
44
  ## Step 4: Structural Audits
31
45
 
32
- 1. **Wiring audit** verify all API endpoints are connected between frontend and backend
33
- 2. **Spec audit** if `docs/` contains a spec/PRD, validate implementation coverage
46
+ 1. **Wiring audit** - verify all API endpoints are connected between frontend and backend
47
+ 2. **Spec audit** - if `docs/` contains a spec/PRD, validate implementation coverage
34
48
 
35
49
  ## Step 5: Claude Code Setup + Product Strategy
36
50
 
37
- 1. **harness-optimizer** check if .claude/ setup follows best practices (includes consistency, accuracy, formatting checks)
38
- 2. **product-strategist** research competitors via web search, evaluate project maturity, recommend improvements
51
+ 1. **harness-optimizer** - check if .claude/ setup follows best practices (includes consistency, accuracy, formatting checks)
52
+ 2. **product-strategist** - research competitors via web search, evaluate project maturity, recommend improvements
53
+
54
+ ## Step 5.5: Intent Verification Protocol Audit
55
+
56
+ 1. **prompt-auditor** - audit all agent prompts for clarity, completeness, and protocol compliance
57
+ 2. Verify every agent invoked in Steps 3-5 returned a PROOF_OF_INTENT block
58
+ 3. Check all INTENT_RECEIVED hashes match the original INTENT_HASH
59
+ 4. Flag any INTENT_MATCH: NO or PARTIAL results
39
60
 
40
61
  ## Step 6: Summary Report
41
62
 
@@ -56,6 +77,13 @@ LOW (nice to have):
56
77
 
57
78
  PASSED:
58
79
  - [list of checks that found no issues]
80
+
81
+ INTENT VERIFICATION:
82
+ Contract issued: YES/NO
83
+ Agents verified: [X of Y returned PROOF_OF_INTENT]
84
+ Intent matches: [X of Y returned INTENT_MATCH: YES]
85
+ Drift detected: [list any agents where INTENT_RECEIVED didn't match]
86
+ Gaps reported: [list any agents that reported coverage gaps]
59
87
  ```
60
88
 
61
89
  Include total counts: X critical, Y high, Z medium, W low.
@@ -42,4 +42,4 @@ Generate a Product Requirements Document (PRD) for this project.
42
42
  ## Output
43
43
 
44
44
  Save the PRD to `docs/PRD.md`. Use Mermaid diagrams (```mermaid blocks) for all visual elements.
45
- Do NOT modify any code this is a documentation-only task.
45
+ Do NOT modify any code. This is a documentation-only task.
@@ -0,0 +1,74 @@
1
+ Generate a Software Design Document (SDD) for this project.
2
+
3
+ ## Instructions
4
+
5
+ 1. Read the entire codebase to understand the system architecture:
6
+ - Entry points and request flow
7
+ - Component/module boundaries and their responsibilities
8
+ - Data models and relationships
9
+ - External integrations and third-party services
10
+ - Authentication and authorization flow
11
+
12
+ 2. If `docs/PRD.md` exists, read it first to align the SDD with product requirements.
13
+
14
+ 3. Generate an SDD with these sections:
15
+
16
+ ### System Overview
17
+ - One-paragraph description of what the system does and how it does it
18
+ - Architecture style (monolith, microservices, serverless, etc.)
19
+ - Key design decisions and their rationale
20
+
21
+ ### Architecture Diagram
22
+ - Mermaid C4 or flowchart showing major components and their interactions
23
+ - Data flow direction between components
24
+ - External system boundaries
25
+
26
+ ### Component Catalog
27
+ For each major component/module:
28
+ - **Name and purpose** (one sentence)
29
+ - **Responsibilities** (bullet list)
30
+ - **Dependencies** (what it imports/calls)
31
+ - **Public interface** (key exports, endpoints, or methods)
32
+
33
+ ### Data Model
34
+ - Mermaid ERD showing all entities and relationships
35
+ - Key fields for each entity (not every column, just the important ones)
36
+ - Relationship types (one-to-many, many-to-many)
37
+
38
+ ### API Reference
39
+ For each API endpoint or public interface:
40
+ - Method and path (e.g., `POST /api/users`)
41
+ - Request/response shape (simplified)
42
+ - Authentication requirements
43
+ - Error responses
44
+
45
+ ### Security Architecture
46
+ - Authentication mechanism
47
+ - Authorization model (roles, permissions)
48
+ - Data protection (encryption, hashing)
49
+ - Input validation strategy
50
+
51
+ ### Infrastructure
52
+ - Deployment topology (Mermaid diagram)
53
+ - Environment configuration
54
+ - Database and caching strategy
55
+ - CI/CD pipeline overview
56
+
57
+ ### Cross-Cutting Concerns
58
+ - Error handling strategy
59
+ - Logging and observability
60
+ - Rate limiting and throttling
61
+ - Background jobs and async processing
62
+
63
+ ## Writing Style
64
+
65
+ Write for two audiences at once:
66
+ - **Non-technical readers** should understand the Overview, Architecture Diagram, and Component Catalog without knowing code
67
+ - **Technical readers** should find enough detail in the API Reference, Data Model, and Security sections to onboard quickly
68
+
69
+ Use plain language. Avoid jargon where a simpler word works. When a technical term is necessary, define it on first use.
70
+
71
+ ## Output
72
+
73
+ Save to `docs/sdd/SDD.md`. Use Mermaid diagrams (```mermaid blocks) for all visual elements.
74
+ Do NOT modify any code. This is a documentation-only task.