forgedev 1.1.3 → 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 (167) hide show
  1. package/README.md +58 -10
  2. package/bin/chainproof.js +126 -0
  3. package/bin/devforge.js +2 -1
  4. package/package.json +33 -7
  5. package/src/chainproof-bridge.js +330 -0
  6. package/src/ci-mode.js +85 -0
  7. package/src/claude-configurator.js +87 -49
  8. package/src/cli.js +35 -12
  9. package/src/composer.js +159 -34
  10. package/src/doctor-checks-chainproof.js +106 -0
  11. package/src/doctor-checks.js +39 -20
  12. package/src/doctor-prompts.js +9 -9
  13. package/src/doctor.js +37 -4
  14. package/src/guided.js +3 -3
  15. package/src/index.js +31 -10
  16. package/src/init-mode.js +64 -11
  17. package/src/menu.js +178 -0
  18. package/src/prompts.js +5 -12
  19. package/src/recommender.js +134 -10
  20. package/src/scanner.js +57 -2
  21. package/src/uat-generator.js +204 -189
  22. package/src/update-check.js +9 -4
  23. package/src/update.js +1 -1
  24. package/src/utils.js +65 -6
  25. package/templates/ai/guardrails-py/backend/app/ai/__init__.py +29 -0
  26. package/templates/ai/guardrails-py/backend/app/ai/audit_log.py +133 -0
  27. package/templates/ai/guardrails-py/backend/app/ai/client.py.template +323 -0
  28. package/templates/ai/guardrails-py/backend/app/ai/health.py.template +157 -0
  29. package/templates/ai/guardrails-py/backend/app/ai/input_guard.py +98 -0
  30. package/templates/ai/guardrails-ts/src/lib/ai/audit-log.ts.template +164 -0
  31. package/templates/ai/guardrails-ts/src/lib/ai/client.ts.template +403 -0
  32. package/templates/ai/guardrails-ts/src/lib/ai/health.ts.template +165 -0
  33. package/templates/ai/guardrails-ts/src/lib/ai/index.ts.template +17 -0
  34. package/templates/ai/guardrails-ts/src/lib/ai/input-guard.ts.template +124 -0
  35. package/templates/auth/nextauth/src/lib/auth.ts.template +12 -7
  36. package/templates/backend/express/Dockerfile.template +18 -0
  37. package/templates/backend/express/package.json.template +33 -0
  38. package/templates/backend/express/src/index.ts.template +34 -0
  39. package/templates/backend/express/src/routes/health.ts.template +27 -0
  40. package/templates/backend/express/tsconfig.json +17 -0
  41. package/templates/backend/fastapi/backend/Dockerfile.template +5 -0
  42. package/templates/backend/fastapi/backend/app/api/health.py.template +1 -1
  43. package/templates/backend/fastapi/backend/app/core/config.py.template +1 -1
  44. package/templates/backend/fastapi/backend/app/core/errors.py +1 -1
  45. package/templates/backend/fastapi/backend/app/main.py.template +3 -1
  46. package/templates/backend/fastapi/backend/requirements.txt.template +2 -0
  47. package/templates/backend/hono/Dockerfile.template +18 -0
  48. package/templates/backend/hono/package.json.template +31 -0
  49. package/templates/backend/hono/src/index.ts.template +32 -0
  50. package/templates/backend/hono/src/routes/health.ts.template +27 -0
  51. package/templates/backend/hono/tsconfig.json +18 -0
  52. package/templates/base/docs/plans/.gitkeep +0 -0
  53. package/templates/base/docs/uat/UAT_CHECKLIST.csv.template +2 -0
  54. package/templates/base/docs/uat/UAT_TEMPLATE.md.template +22 -0
  55. package/templates/chainproof/base/.chainproof/config.json.template +11 -0
  56. package/templates/chainproof/base/.chainproof/mcp-server.mjs +310 -0
  57. package/templates/chainproof/base/.mcp.json +9 -0
  58. package/templates/chainproof/fastapi/.chainproof/middleware.json.template +14 -0
  59. package/templates/chainproof/nextjs/.chainproof/hooks.json.template +19 -0
  60. package/templates/chainproof/polyglot/.chainproof/config.json.template +21 -0
  61. package/templates/claude-code/agents/architect.md +25 -11
  62. package/templates/claude-code/agents/build-error-resolver.md +22 -7
  63. package/templates/claude-code/agents/chief-of-staff.md +42 -8
  64. package/templates/claude-code/agents/code-quality-reviewer.md +15 -1
  65. package/templates/claude-code/agents/database-reviewer.md +16 -2
  66. package/templates/claude-code/agents/deep-reviewer.md +191 -0
  67. package/templates/claude-code/agents/doc-updater.md +19 -5
  68. package/templates/claude-code/agents/docs-lookup.md +19 -5
  69. package/templates/claude-code/agents/e2e-runner.md +26 -12
  70. package/templates/claude-code/agents/enforcement-gate.md +102 -0
  71. package/templates/claude-code/agents/frontend-builder.md +188 -0
  72. package/templates/claude-code/agents/harness-optimizer.md +61 -0
  73. package/templates/claude-code/agents/loop-operator.md +27 -12
  74. package/templates/claude-code/agents/planner.md +21 -7
  75. package/templates/claude-code/agents/product-strategist.md +138 -0
  76. package/templates/claude-code/agents/production-readiness.md +14 -0
  77. package/templates/claude-code/agents/prompt-auditor.md +115 -0
  78. package/templates/claude-code/agents/refactor-cleaner.md +22 -8
  79. package/templates/claude-code/agents/security-reviewer.md +15 -0
  80. package/templates/claude-code/agents/spec-validator.md +45 -1
  81. package/templates/claude-code/agents/tdd-guide.md +21 -7
  82. package/templates/claude-code/agents/uat-validator.md +18 -0
  83. package/templates/claude-code/claude-md/base.md +15 -7
  84. package/templates/claude-code/claude-md/fastapi.md +8 -8
  85. package/templates/claude-code/claude-md/fullstack.md +6 -6
  86. package/templates/claude-code/claude-md/hono.md +18 -0
  87. package/templates/claude-code/claude-md/nextjs.md +5 -5
  88. package/templates/claude-code/claude-md/remix.md +18 -0
  89. package/templates/claude-code/commands/audit-security.md +14 -0
  90. package/templates/claude-code/commands/audit-spec.md +14 -0
  91. package/templates/claude-code/commands/audit-wiring.md +14 -0
  92. package/templates/claude-code/commands/build-fix.md +28 -0
  93. package/templates/claude-code/commands/build-ui.md +59 -0
  94. package/templates/claude-code/commands/code-review.md +54 -26
  95. package/templates/claude-code/commands/fix-loop.md +211 -0
  96. package/templates/claude-code/commands/full-audit.md +37 -8
  97. package/templates/claude-code/commands/generate-prd.md +1 -1
  98. package/templates/claude-code/commands/generate-sdd.md +74 -0
  99. package/templates/claude-code/commands/generate-uat.md +107 -35
  100. package/templates/claude-code/commands/help.md +68 -0
  101. package/templates/claude-code/commands/live-uat.md +268 -0
  102. package/templates/claude-code/commands/optimize-claude-md.md +15 -1
  103. package/templates/claude-code/commands/plan.md +3 -3
  104. package/templates/claude-code/commands/pre-pr.md +57 -19
  105. package/templates/claude-code/commands/product-strategist.md +21 -0
  106. package/templates/claude-code/commands/resume-session.md +10 -10
  107. package/templates/claude-code/commands/run-uat.md +59 -2
  108. package/templates/claude-code/commands/save-session.md +10 -10
  109. package/templates/claude-code/commands/simplify.md +36 -0
  110. package/templates/claude-code/commands/tdd.md +17 -18
  111. package/templates/claude-code/commands/verify-all.md +24 -0
  112. package/templates/claude-code/commands/verify-intent.md +55 -0
  113. package/templates/claude-code/commands/workflows.md +52 -37
  114. package/templates/claude-code/hooks/polyglot.json +10 -1
  115. package/templates/claude-code/hooks/python.json +10 -1
  116. package/templates/claude-code/hooks/scripts/autofix-polyglot.mjs +20 -10
  117. package/templates/claude-code/hooks/scripts/autofix-python.mjs +4 -5
  118. package/templates/claude-code/hooks/scripts/autofix-typescript.mjs +4 -4
  119. package/templates/claude-code/hooks/scripts/code-hygiene.mjs +293 -0
  120. package/templates/claude-code/hooks/scripts/guard-protected-files.mjs +2 -2
  121. package/templates/claude-code/hooks/scripts/pre-commit-gate.mjs +207 -0
  122. package/templates/claude-code/hooks/typescript.json +10 -1
  123. package/templates/claude-code/skills/ai-prompts/SKILL.md +119 -41
  124. package/templates/claude-code/skills/git-workflow/SKILL.md +6 -6
  125. package/templates/claude-code/skills/nextjs/SKILL.md +1 -1
  126. package/templates/claude-code/skills/playwright/SKILL.md +6 -5
  127. package/templates/claude-code/skills/security-api/SKILL.md +1 -1
  128. package/templates/claude-code/skills/security-web/SKILL.md +2 -1
  129. package/templates/claude-code/skills/testing-patterns/SKILL.md +9 -9
  130. package/templates/database/prisma-postgres/{.env.example → .env.example.template} +1 -0
  131. package/templates/database/sqlalchemy-postgres/{.env.example → .env.example.template} +1 -0
  132. package/templates/docs-portal/fastapi/backend/app/portal/__init__.py +0 -0
  133. package/templates/docs-portal/fastapi/backend/app/portal/__pycache__/docs_reader.cpython-314.pyc +0 -0
  134. package/templates/docs-portal/fastapi/backend/app/portal/docs_reader.py +201 -0
  135. package/templates/docs-portal/fastapi/backend/app/portal/html_renderer.py +229 -0
  136. package/templates/docs-portal/fastapi/backend/app/portal/router.py.template +35 -0
  137. package/templates/docs-portal/nextjs/src/app/portal/[category]/[slug]/page.tsx +81 -0
  138. package/templates/docs-portal/nextjs/src/app/portal/[category]/page.tsx +65 -0
  139. package/templates/docs-portal/nextjs/src/app/portal/layout.tsx.template +54 -0
  140. package/templates/docs-portal/nextjs/src/app/portal/page.tsx +85 -0
  141. package/templates/docs-portal/nextjs/src/components/portal/markdown-renderer.tsx +101 -0
  142. package/templates/docs-portal/nextjs/src/components/portal/mobile-portal-nav.tsx +81 -0
  143. package/templates/docs-portal/nextjs/src/components/portal/portal-nav.tsx +86 -0
  144. package/templates/docs-portal/nextjs/src/lib/docs.ts +139 -0
  145. package/templates/frontend/nextjs/package.json.template +3 -1
  146. package/templates/frontend/react/index.html.template +12 -0
  147. package/templates/frontend/react/package.json.template +34 -0
  148. package/templates/frontend/react/src/App.tsx.template +10 -0
  149. package/templates/frontend/react/src/index.css +1 -0
  150. package/templates/frontend/react/src/main.tsx +10 -0
  151. package/templates/frontend/react/tsconfig.json +17 -0
  152. package/templates/frontend/react/vite.config.ts.template +15 -0
  153. package/templates/frontend/react/vitest.config.ts +9 -0
  154. package/templates/frontend/remix/app/root.tsx.template +31 -0
  155. package/templates/frontend/remix/app/routes/_index.tsx.template +19 -0
  156. package/templates/frontend/remix/app/routes/api.health.ts.template +10 -0
  157. package/templates/frontend/remix/app/tailwind.css +1 -0
  158. package/templates/frontend/remix/package.json.template +39 -0
  159. package/templates/frontend/remix/tsconfig.json +18 -0
  160. package/templates/frontend/remix/vite.config.ts.template +7 -0
  161. package/templates/infra/github-actions/.github/workflows/ci.yml.template +52 -0
  162. package/templates/testing/pytest/backend/tests/__init__.py +0 -0
  163. package/templates/testing/pytest/backend/tests/conftest.py.template +11 -0
  164. package/templates/testing/pytest/backend/tests/test_health.py.template +10 -0
  165. package/templates/testing/vitest/vitest.config.ts.template +18 -0
  166. package/CLAUDE.md +0 -38
  167. package/templates/claude-code/commands/done.md +0 -19
@@ -1,19 +1,57 @@
1
- Run the complete pre-PR checklist before creating a pull request.
2
-
3
- 1. Run lint: `{{LINT_COMMAND}}`
4
- 2. Run type check: `{{TYPE_CHECK_COMMAND}}`
5
- 3. Run tests: `{{TEST_COMMAND}}`
6
- 4. Check for uncommitted changes
7
- 5. Launch code-quality-reviewer agent on the PR diff
8
- 6. Launch security-reviewer agent on the PR diff
9
- 7. Check that no `.env` files or secrets are staged
10
-
11
- If all checks pass, output:
12
- - Summary of changes (files changed, lines added/removed)
13
- - Suggested PR title and description
14
- - Any warnings (non-blocking issues)
15
-
16
- If any check fails, output:
17
- - Which checks failed
18
- - How to fix each failure
19
- - Do NOT proceed with PR creation
1
+ Prepare a pull request. Quality checks (lint, tests, code review, security) already ran at commit time via the pre-commit gate. This command handles PR-specific preparation.
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
+
17
+ ## Step 1: Verify Commit State
18
+
19
+ 1. Check that all changes are committed (no uncommitted changes)
20
+ 2. Check that the branch is pushed to remote
21
+ 3. If there are uncommitted changes, tell the user to commit first (the pre-commit gate will handle quality checks)
22
+
23
+ ## Step 2: Review the Full PR Diff
24
+
25
+ 1. Get the base branch: `git rev-parse --abbrev-ref HEAD@{upstream} 2>/dev/null || echo main`
26
+ 2. Get the full diff: `git diff <base-branch>...HEAD`
27
+ 3. Get all commits in this branch: `git log <base-branch>..HEAD --oneline`
28
+ 4. Review the full diff for:
29
+ - Coherence: do all changes serve the same purpose?
30
+ - Completeness: are there any half-finished features?
31
+ - Any `.env` files, secrets, or debug code that slipped through
32
+
33
+ ## Step 3: Generate PR Description
34
+
35
+ Based on the diff and commit history, generate:
36
+
37
+ ```
38
+ ## Summary
39
+ <1-3 bullet points describing what changed and why>
40
+
41
+ ## Changes
42
+ <grouped list of changes by area>
43
+
44
+ ## Test plan
45
+ <bulleted checklist of what to test>
46
+ ```
47
+
48
+ ## Step 4: Create PR
49
+
50
+ Use `gh pr create` with the generated title and description.
51
+ If the user hasn't pushed yet, push first with `git push -u origin <branch>`.
52
+
53
+ ## Output
54
+
55
+ - PR URL
56
+ - Summary of what was included
57
+ - Any warnings (large diff, many files, etc.)
@@ -0,0 +1,21 @@
1
+ Run the product-strategist agent to evaluate this project against real competitors and industry best practices.
2
+
3
+ ## What This Does
4
+
5
+ The product-strategist agent will:
6
+ 1. Read your project structure, CLAUDE.md, and any product docs
7
+ 2. **Web search** for 5-7 direct competitors and best-in-class examples
8
+ 3. Evaluate your project against them across DX, API design, testing, security, observability, deployment, and docs
9
+ 4. Score each category: AHEAD, ON PAR, or BEHIND with specific competitor benchmarks
10
+ 5. Recommend strategic improvements with a prioritized roadmap
11
+
12
+ ## How To Use
13
+
14
+ Run this command. The agent will ask no questions — it researches autonomously and returns a full competitive analysis with actionable recommendations.
15
+
16
+ ## When To Use
17
+
18
+ - Before planning a new major feature (to avoid building what competitors already do better)
19
+ - Before a launch or public release (to identify gaps)
20
+ - Quarterly, to track how your project compares to the evolving landscape
21
+ - When deciding between build vs. buy for a capability
@@ -2,8 +2,8 @@ Load a saved session file and orient before doing any work.
2
2
 
3
3
  ## Process
4
4
 
5
- 1. **Find the session file** Check `docs/sessions/` for the most recent `*-session.md` file
6
- 2. **Read the entire file** Do not summarize yet
5
+ 1. **Find the session file**: Check `docs/sessions/` for the most recent `*-session.md` file
6
+ 2. **Read the entire file**: Do not summarize yet
7
7
  3. **Present a briefing** in this format:
8
8
 
9
9
  ```
@@ -33,18 +33,18 @@ NEXT STEP:
33
33
  Ready to continue. What would you like to do?
34
34
  ```
35
35
 
36
- 4. **WAIT for the user** Do NOT start working automatically
36
+ 4. **WAIT for the user**. Do NOT start working automatically
37
37
 
38
38
  ## Edge Cases
39
39
 
40
- - **No session files found** Tell the user to run `/save-session` first
41
- - **Session references deleted files** Note "⚠️ file.ts referenced but not found on disk"
42
- - **Session is > 7 days old** Note "⚠️ This session is N days old, things may have changed"
43
- - **Empty or malformed file** Report and suggest creating a new session
40
+ - **No session files found**: Tell the user to run `/save-session` first
41
+ - **Session references deleted files**: Note "file.ts referenced but not found on disk"
42
+ - **Session is > 7 days old**: Note "This session is N days old, things may have changed"
43
+ - **Empty or malformed file**: Report and suggest creating a new session
44
44
 
45
45
  ## Rules
46
46
 
47
- - Never modify the session file — it's a read-only historical record
48
- - Never skip the "What Not To Retry" section — it's the most important
47
+ - Never modify the session file. It's a read-only historical record
48
+ - Never skip the "What Not To Retry" section. It's the most important
49
49
  - Always wait for the user before starting work
50
- - If the next step is defined and the user says "continue" proceed with that exact step
50
+ - If the next step is defined and the user says "continue", proceed with that exact step
@@ -1,13 +1,39 @@
1
1
  Read docs/uat/UAT_TEMPLATE.md and execute the UAT verification process.
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
+
17
+ ## Phase 1: Automated Verification
18
+
3
19
  For each scenario in the UAT template:
4
20
  1. Check if automated tests exist that cover this scenario
5
21
  2. If automated: run the test and report PASS/FAIL
6
22
  3. If not automated: flag as MANUAL REQUIRED
7
23
  4. Update docs/uat/UAT_CHECKLIST.csv with results
8
24
 
25
+ ## Phase 2: Business Rules Verification
26
+
27
+ If `docs/uat/BUSINESS_RULES.md` exists (generated by `/generate-uat`):
28
+ 1. For each business rule, check if an automated test validates it
29
+ 2. If yes: run the test, compare actual output against the documented expected output
30
+ 3. If no: flag the rule as UNTESTED and add it to the manual testing queue
31
+
32
+ ## Phase 3: Results Summary
33
+
9
34
  Output:
10
35
  - Automated coverage: X/Y scenarios have automated tests
36
+ - Business rule coverage: X/Y rules have automated tests
11
37
  - Results: X passed, Y failed, Z need manual testing
12
38
  - Blocking issues: list any P0 failures
13
39
 
@@ -16,6 +42,37 @@ For P0 failures:
16
42
  - Suggest a fix if the failure is obvious
17
43
  - Mark as BLOCKED in the checklist
18
44
 
45
+ ## Phase 4: Manual Testing Bridge
46
+
19
47
  For scenarios needing manual testing:
20
- - Provide step-by-step instructions for the tester
21
- - Note any test data or setup required
48
+ 1. Group them by page/endpoint
49
+ 2. Check if a browser automation tool is available (Claude in Chrome, Playwright MCP)
50
+ 3. If available, ask the user: "I found X scenarios that need manual verification. Would you like me to test them live against the running app? (This will run /live-uat on just these scenarios)"
51
+ 4. If the user agrees, run `/live-uat` with scope limited to the MANUAL REQUIRED scenarios
52
+ 5. If no browser tool available, provide step-by-step manual instructions for each scenario
53
+
54
+ ## Phase 5: Coverage Gap Report
55
+
56
+ After all phases complete, generate a coverage report:
57
+
58
+ ```
59
+ ## UAT Coverage Report
60
+
61
+ ### Automated
62
+ - Scenarios covered: X/Y (Z%)
63
+ - Business rules covered: X/Y (Z%)
64
+ - All P0 scenarios covered: YES/NO
65
+
66
+ ### Manual (tested via /live-uat)
67
+ - Scenarios tested: X
68
+ - Passed: X | Failed: X
69
+
70
+ ### Gaps (no coverage at all)
71
+ - [list scenarios with neither automated nor manual coverage]
72
+
73
+ ### Recommended Actions
74
+ - [write tests for P0 scenarios without automation]
75
+ - [add business rule assertions to existing tests]
76
+ ```
77
+
78
+ Update docs/uat/UAT_CHECKLIST.csv with final results for all scenarios.
@@ -2,10 +2,10 @@ Save the current session state so work can be resumed in a future conversation.
2
2
 
3
3
  ## Process
4
4
 
5
- 1. **Gather context** Review what was discussed, built, and decided this session
6
- 2. **Create folder** `mkdir -p docs/sessions` (or `~/.claude/sessions/`)
7
- 3. **Write session file** `docs/sessions/YYYY-MM-DD-session.md`
8
- 4. **Show to user** Display contents and ask for corrections
5
+ 1. **Gather context**: Review what was discussed, built, and decided this session
6
+ 2. **Create folder**: `mkdir -p docs/sessions` (or `~/.claude/sessions/`)
7
+ 3. **Write session file**: `docs/sessions/YYYY-MM-DD-session.md`
8
+ 4. **Show to user**: Display contents and ask for corrections
9
9
 
10
10
  ## Session File Format
11
11
 
@@ -23,12 +23,12 @@ Save the current session state so work can be resumed in a future conversation.
23
23
  ---
24
24
 
25
25
  ## What WORKED (with evidence)
26
- - **[thing]** confirmed by: [specific evidence like "tests pass", "200 response"]
26
+ - **[thing]** - confirmed by: [specific evidence like "tests pass", "200 response"]
27
27
 
28
28
  ---
29
29
 
30
30
  ## What Did NOT Work (and why)
31
- - **[approach]** failed because: [exact reason / error message]
31
+ - **[approach]** - failed because: [exact reason / error message]
32
32
 
33
33
  ---
34
34
 
@@ -48,7 +48,7 @@ Save the current session state so work can be resumed in a future conversation.
48
48
  ---
49
49
 
50
50
  ## Decisions Made
51
- - **[decision]** reason: [why]
51
+ - **[decision]** - reason: [why]
52
52
 
53
53
  ---
54
54
 
@@ -63,7 +63,7 @@ Save the current session state so work can be resumed in a future conversation.
63
63
 
64
64
  ## Rules
65
65
 
66
- - Write every section honestly "Nothing yet" is better than skipping a section
67
- - The "What Did NOT Work" section is the most critical prevents retrying failed approaches
68
- - Each session gets its own file never append to previous sessions
66
+ - Write every section honestly. "Nothing yet" is better than skipping a section
67
+ - The "What Did NOT Work" section is the most critical because it prevents retrying failed approaches
68
+ - Each session gets its own file. Never append to previous sessions
69
69
  - Wait for user confirmation before closing
@@ -0,0 +1,36 @@
1
+ Review the current codebase for structural quality and clean it up. This is not about style or formatting — it is about architecture hygiene.
2
+
3
+ ## What to check
4
+
5
+ 1. **Long files** (over 300 lines): Split into smaller, focused modules. Each file should have a single responsibility.
6
+
7
+ 2. **Long functions** (over 50 lines): Extract helper functions. If a function does more than one thing, break it apart.
8
+
9
+ 3. **Duplicate code**: Find code blocks that appear in multiple files. Extract them into a shared utility module that individual files can import. Common patterns to look for:
10
+ - Repeated validation logic
11
+ - Identical error handling blocks
12
+ - Copy-pasted API call patterns
13
+ - Similar data transformation functions
14
+
15
+ 4. **Directory bloat**: If a directory has more than 20 source files, suggest grouping them into subdirectories by feature or domain.
16
+
17
+ 5. **Stale test files**: Find test files whose corresponding source files have been deleted or renamed. Ask if they should be removed.
18
+
19
+ 6. **Dead exports**: Find exported functions or constants that nothing imports. Ask if they should be removed.
20
+
21
+ ## How to fix
22
+
23
+ For each issue found:
24
+ - Explain what the problem is and why it matters
25
+ - Show the specific files and line numbers
26
+ - Make the fix (extract utility, split file, delete dead code)
27
+ - Verify imports still work after refactoring
28
+ - Run tests to confirm nothing broke
29
+
30
+ ## Rules
31
+ - Do NOT add new dependencies
32
+ - Do NOT change public APIs or function signatures
33
+ - Do NOT refactor code that is already clean
34
+ - Keep the fixes minimal and focused — one problem at a time
35
+ - When extracting shared utilities, place them in the most logical existing directory (e.g., `src/lib/`, `src/utils/`, `shared/`)
36
+ - Always preserve existing test coverage
@@ -6,10 +6,10 @@ Enforce test-driven development: write failing tests FIRST, then implement.
6
6
  RED → GREEN → REFACTOR → REPEAT
7
7
  ```
8
8
 
9
- 1. **RED** Write a failing test (because the code doesn't exist yet)
10
- 2. **GREEN** Write the minimum code to make the test pass
11
- 3. **REFACTOR** Improve the code while keeping tests green
12
- 4. **REPEAT** Next scenario
9
+ 1. **RED**: Write a failing test (because the code doesn't exist yet)
10
+ 2. **GREEN**: Write the minimum code to make the test pass
11
+ 3. **REFACTOR**: Improve the code while keeping tests green
12
+ 4. **REPEAT**: Next scenario
13
13
 
14
14
  ## Process
15
15
 
@@ -17,40 +17,40 @@ RED → GREEN → REFACTOR → REPEAT
17
17
  2. Launch the `tdd-guide` agent
18
18
  3. Define types/interfaces first
19
19
  4. Write failing tests covering: happy path, edge cases, error cases
20
- 5. Run `{{TEST_COMMAND}}` verify tests FAIL for the right reason
20
+ 5. Run `{{TEST_COMMAND}}` to verify tests FAIL for the right reason
21
21
  6. Implement minimal code to pass
22
- 7. Run `{{TEST_COMMAND}}` verify tests PASS
22
+ 7. Run `{{TEST_COMMAND}}` to verify tests PASS
23
23
  8. Refactor if needed, keeping tests green
24
- 9. Check coverage target 80%+ minimum
24
+ 9. Check coverage. Target 80%+ minimum
25
25
 
26
26
  ## Example
27
27
 
28
28
  ```
29
29
  User: /tdd I need a function to validate email addresses
30
30
 
31
- Step 1 SCAFFOLD:
31
+ Step 1 - SCAFFOLD:
32
32
  Create types/interfaces for input and output
33
33
 
34
- Step 2 RED (write failing tests):
34
+ Step 2 - RED (write failing tests):
35
35
  - "should accept valid email: user@example.com"
36
36
  - "should reject email without @"
37
37
  - "should reject email without domain"
38
38
  - "should reject empty string"
39
39
  - "should handle unicode characters"
40
40
 
41
- Step 3 Run tests → all FAIL (expected, no implementation yet)
41
+ Step 3 - Run tests → all FAIL (expected, no implementation yet)
42
42
 
43
- Step 4 GREEN (implement minimal code):
43
+ Step 4 - GREEN (implement minimal code):
44
44
  Write just enough to pass all tests
45
45
 
46
- Step 5 Run tests → all PASS
46
+ Step 5 - Run tests → all PASS
47
47
 
48
- Step 6 REFACTOR:
48
+ Step 6 - REFACTOR:
49
49
  Extract constants, improve naming, add JSDoc
50
50
 
51
- Step 7 Run tests → still PASS
51
+ Step 7 - Run tests → still PASS
52
52
 
53
- Step 8 Check coverage → 100%
53
+ Step 8 - Check coverage → 100%
54
54
  ```
55
55
 
56
56
  ## Rules
@@ -75,6 +75,5 @@ Step 8 — Check coverage → 100%
75
75
 
76
76
  ## After TDD
77
77
 
78
- - `/build-fix` if build errors come up
79
- - `/code-review` review the implementation
80
- - `/done` — verify the task is complete
78
+ - `/build-fix` - if build errors come up
79
+ - `/code-review` - review the implementation, then commit
@@ -1,5 +1,19 @@
1
1
  Run the full verification chain on the current 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
  1. Run lint: `{{LINT_COMMAND}}`
4
18
  2. Run type check: `{{TYPE_CHECK_COMMAND}}`
5
19
  3. Run tests: `{{TEST_COMMAND}}`
@@ -9,3 +23,13 @@ Run the full verification chain on the current changes.
9
23
 
10
24
  Summarize all findings grouped by severity (critical, high, medium, low).
11
25
  If any critical issues found, list them prominently at the top.
26
+
27
+ ## Recommend Next Step
28
+
29
+ After the summary, always recommend the single best next action based on findings:
30
+ - **CRITICAL findings** → recommend the specific fix
31
+ - **HIGH findings** → recommend addressing before proceeding
32
+ - **No issues** → recommend `/pre-pr`
33
+ - **MEDIUM/LOW only** → recommend committing, note optional improvements
34
+
35
+ Format: **Next step:** one sentence with the specific command or action to take.
@@ -0,0 +1,55 @@
1
+ Run the Intent Verification Protocol compliance check across all agents and commands.
2
+
3
+ ## Intent Contract
4
+
5
+ Before invoking any agent, construct this block:
6
+
7
+ ```
8
+ INTENT_CONTRACT:
9
+ INTENT: "Verify all agents and commands comply with the Intent Verification Protocol"
10
+ SCOPE: ".claude/agents/, .claude/commands/"
11
+ SUCCESS_CRITERIA: "Every agent has PROOF_OF_INTENT, every command that invokes agents has Intent Contract, no cross-agent consistency violations"
12
+ INTENT_HASH: "IVP-COMPLIANCE"
13
+ ```
14
+
15
+ ## Step 1: Protocol Compliance Scan
16
+
17
+ For each file in `.claude/agents/`:
18
+ 1. Check for `PROOF_OF_INTENT` block in output section
19
+ 2. Check for `NO_CONTRACT_RECEIVED` fallback handling
20
+ 3. Record compliance status
21
+
22
+ For each file in `.claude/commands/` that references an agent:
23
+ 1. Check for `INTENT_CONTRACT` section
24
+ 2. Check that `INTENT_HASH` is referenced
25
+ 3. Record compliance status
26
+
27
+ ## Step 2: Launch prompt-auditor
28
+
29
+ Run the **prompt-auditor** agent on the full `.claude/` configuration with the Intent Contract above.
30
+
31
+ ## Step 3: Cross-Validation
32
+
33
+ 1. Pick 3 agents at random
34
+ 2. For each, evaluate: given a sample intent, would the agent's instructions produce output that includes a valid PROOF_OF_INTENT?
35
+ 3. Flag any agent whose instructions are ambiguous enough that the proof section could be skipped
36
+
37
+ ## Step 4: Compliance Report
38
+
39
+ ```
40
+ INTENT VERIFICATION PROTOCOL - COMPLIANCE REPORT
41
+
42
+ OVERALL: [X/Y agents compliant, A/B commands compliant]
43
+
44
+ NON-COMPLIANT AGENTS:
45
+ - [agent name]: [what's missing]
46
+
47
+ NON-COMPLIANT COMMANDS:
48
+ - [command name]: [what's missing]
49
+
50
+ CONSISTENCY ISSUES:
51
+ - [cross-agent term conflicts, severity definition mismatches]
52
+
53
+ RECOMMENDATIONS:
54
+ - [prioritized list of fixes]
55
+ ```
@@ -1,37 +1,52 @@
1
- Show the developer what workflows are available.
2
-
3
- ## Available Workflows
4
-
5
- ### Development
6
- - `/plan` Create an implementation plan before writing code
7
- - `/tdd` Write failing tests first, then implement (test-driven development)
8
- - `/build-fix` Fix build, lint, and type errors incrementally
9
- - `/code-review` Review uncommitted changes for security and quality
10
-
11
- ### Daily
12
- - `/status` Run all checks and show a project dashboard
13
- - `/next` — Figure out what to work on next
14
- - `/done` — Verify the current task is complete before moving on
15
-
16
- ### Verification
17
- - `/verify-all` Run lint, type check, tests, then launch all reviewers
18
- - `/full-audit` — Run every audit and review agent in a single pass
19
- - `/audit-spec` — Validate implementation against a spec/PRD
20
- - `/audit-wiring` Find dead or unwired features
21
- - `/audit-security` Run a security audit
22
-
23
- ### Release
24
- - `/pre-pr` Run the complete pre-PR checklist
25
- - `/run-uat` Execute UAT scenarios
26
-
27
- ### Generation
28
- - `/generate-prd` Generate a PRD from the current codebase
29
- - `/generate-uat` — Generate UAT scenarios and checklists
30
- - `/optimize-claude-md` — Slim down an oversized CLAUDE.md
31
-
32
- ### Session
33
- - `/save-session` Save current work context for later resumption
34
- - `/resume-session` — Load a saved session and continue where you left off
35
-
36
- ## Quick Start
37
- Run `/status` to see where things stand, then `/next` to pick up work.
1
+ Show the developer what workflows are available.
2
+
3
+ ## Available Workflows
4
+
5
+ ### Development
6
+ - `/plan` - Create an implementation plan before writing code
7
+ - `/tdd` - Write failing tests first, then implement (test-driven development)
8
+ - `/build-fix` - Fix build, lint, and type errors incrementally
9
+ - `/fix-loop` - Automated fix-review-regression loop until green
10
+ - `/build-ui` - Build frontend UI with AI-powered generation (Google Stitch + UI UX Pro Max)
11
+ - `/code-review` - Review changes for security and quality (required before commit)
12
+ - `/simplify` - Find duplicate code, long files, and extract shared utilities
13
+
14
+ ### Daily
15
+ - `/help` - Not sure what to do? This guides you to the right workflow
16
+ - `/status` - Run all checks and show a project dashboard
17
+ - `/next` - Figure out what to work on next
18
+
19
+ ### Verification
20
+ - `/verify-all` - Run lint, type check, tests, then launch all reviewers
21
+ - `/full-audit` - Run every audit and review agent in a single pass
22
+ - `/audit-spec` - Validate implementation against a spec/PRD
23
+ - `/audit-wiring` - Find dead or unwired features
24
+ - `/audit-security` - Run a security audit
25
+ - `/verify-intent` - Verify all agents comply with Intent Verification Protocol
26
+
27
+ ### Strategy
28
+ - Use `product-strategist` agent - Research competitors, evaluate project maturity, recommend improvements
29
+
30
+ ### Release
31
+ - `/pre-pr` - Prepare and create a pull request
32
+ - `/run-uat` - Execute UAT scenarios
33
+ - `/live-uat` - Run live UAT by interacting with the running application
34
+
35
+ ### Generation
36
+ - `/generate-prd` - Generate a PRD from the current codebase
37
+ - `/generate-sdd` - Generate a Software Design Document from the codebase
38
+ - `/generate-uat` - Generate UAT scenarios and checklists
39
+ - `/optimize-claude-md` - Slim down an oversized CLAUDE.md
40
+
41
+ ### Session
42
+ - `/save-session` - Save current work context for later resumption
43
+ - `/resume-session` - Load a saved session and continue where you left off
44
+
45
+ ## Quality Gates (automatic)
46
+
47
+ These run automatically, you don't need to remember them:
48
+ - **On commit**: Pre-commit gate runs lint, tests, secrets check, and requires code review
49
+ - **On stop**: Code hygiene check runs automatically
50
+
51
+ ## Quick Start
52
+ Run `/status` to see where things stand, then `/next` to pick up work.
@@ -9,6 +9,15 @@
9
9
  "command": "node .claude/hooks/guard-protected-files.mjs"
10
10
  }
11
11
  ]
12
+ },
13
+ {
14
+ "matcher": "Bash",
15
+ "hooks": [
16
+ {
17
+ "type": "command",
18
+ "command": "node .claude/hooks/pre-commit-gate.mjs"
19
+ }
20
+ ]
12
21
  }
13
22
  ],
14
23
  "PostToolUse": [
@@ -27,7 +36,7 @@
27
36
  "hooks": [
28
37
  {
29
38
  "type": "command",
30
- "command": "cd frontend && npx tsc --noEmit 2>&1 && npx eslint . 2>&1 && cd ../backend && ruff check . 2>&1"
39
+ "command": "node .claude/hooks/code-hygiene.mjs"
31
40
  }
32
41
  ]
33
42
  }
@@ -9,6 +9,15 @@
9
9
  "command": "node .claude/hooks/guard-protected-files.mjs"
10
10
  }
11
11
  ]
12
+ },
13
+ {
14
+ "matcher": "Bash",
15
+ "hooks": [
16
+ {
17
+ "type": "command",
18
+ "command": "node .claude/hooks/pre-commit-gate.mjs"
19
+ }
20
+ ]
12
21
  }
13
22
  ],
14
23
  "PostToolUse": [
@@ -27,7 +36,7 @@
27
36
  "hooks": [
28
37
  {
29
38
  "type": "command",
30
- "command": "cd backend && ruff check . 2>&1 && pyright 2>&1"
39
+ "command": "node .claude/hooks/code-hygiene.mjs"
31
40
  }
32
41
  ]
33
42
  }