wiggum-cli 0.1.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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -0
  3. package/bin/ralph.js +8 -0
  4. package/dist/ai/enhancer.d.ts +100 -0
  5. package/dist/ai/enhancer.d.ts.map +1 -0
  6. package/dist/ai/enhancer.js +233 -0
  7. package/dist/ai/enhancer.js.map +1 -0
  8. package/dist/ai/index.d.ts +8 -0
  9. package/dist/ai/index.d.ts.map +1 -0
  10. package/dist/ai/index.js +11 -0
  11. package/dist/ai/index.js.map +1 -0
  12. package/dist/ai/prompts.d.ts +26 -0
  13. package/dist/ai/prompts.d.ts.map +1 -0
  14. package/dist/ai/prompts.js +201 -0
  15. package/dist/ai/prompts.js.map +1 -0
  16. package/dist/ai/providers.d.ts +35 -0
  17. package/dist/ai/providers.d.ts.map +1 -0
  18. package/dist/ai/providers.js +104 -0
  19. package/dist/ai/providers.js.map +1 -0
  20. package/dist/cli.d.ts +6 -0
  21. package/dist/cli.d.ts.map +1 -0
  22. package/dist/cli.js +196 -0
  23. package/dist/cli.js.map +1 -0
  24. package/dist/commands/init.d.ts +16 -0
  25. package/dist/commands/init.d.ts.map +1 -0
  26. package/dist/commands/init.js +124 -0
  27. package/dist/commands/init.js.map +1 -0
  28. package/dist/commands/monitor.d.ts +17 -0
  29. package/dist/commands/monitor.d.ts.map +1 -0
  30. package/dist/commands/monitor.js +342 -0
  31. package/dist/commands/monitor.js.map +1 -0
  32. package/dist/commands/new.d.ts +19 -0
  33. package/dist/commands/new.d.ts.map +1 -0
  34. package/dist/commands/new.js +272 -0
  35. package/dist/commands/new.js.map +1 -0
  36. package/dist/commands/run.d.ts +16 -0
  37. package/dist/commands/run.d.ts.map +1 -0
  38. package/dist/commands/run.js +175 -0
  39. package/dist/commands/run.js.map +1 -0
  40. package/dist/generator/config.d.ts +59 -0
  41. package/dist/generator/config.d.ts.map +1 -0
  42. package/dist/generator/config.js +68 -0
  43. package/dist/generator/config.js.map +1 -0
  44. package/dist/generator/index.d.ts +64 -0
  45. package/dist/generator/index.d.ts.map +1 -0
  46. package/dist/generator/index.js +147 -0
  47. package/dist/generator/index.js.map +1 -0
  48. package/dist/generator/templates.d.ts +70 -0
  49. package/dist/generator/templates.d.ts.map +1 -0
  50. package/dist/generator/templates.js +296 -0
  51. package/dist/generator/templates.js.map +1 -0
  52. package/dist/generator/writer.d.ts +93 -0
  53. package/dist/generator/writer.d.ts.map +1 -0
  54. package/dist/generator/writer.js +213 -0
  55. package/dist/generator/writer.js.map +1 -0
  56. package/dist/index.d.ts +12 -0
  57. package/dist/index.d.ts.map +1 -0
  58. package/dist/index.js +17 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/scanner/detectors/core/framework.d.ts +11 -0
  61. package/dist/scanner/detectors/core/framework.d.ts.map +1 -0
  62. package/dist/scanner/detectors/core/framework.js +275 -0
  63. package/dist/scanner/detectors/core/framework.js.map +1 -0
  64. package/dist/scanner/detectors/core/packageManager.d.ts +11 -0
  65. package/dist/scanner/detectors/core/packageManager.d.ts.map +1 -0
  66. package/dist/scanner/detectors/core/packageManager.js +74 -0
  67. package/dist/scanner/detectors/core/packageManager.js.map +1 -0
  68. package/dist/scanner/detectors/core/styling.d.ts +12 -0
  69. package/dist/scanner/detectors/core/styling.d.ts.map +1 -0
  70. package/dist/scanner/detectors/core/styling.js +230 -0
  71. package/dist/scanner/detectors/core/styling.js.map +1 -0
  72. package/dist/scanner/detectors/core/testing.d.ts +12 -0
  73. package/dist/scanner/detectors/core/testing.d.ts.map +1 -0
  74. package/dist/scanner/detectors/core/testing.js +190 -0
  75. package/dist/scanner/detectors/core/testing.js.map +1 -0
  76. package/dist/scanner/detectors/data/api.d.ts +12 -0
  77. package/dist/scanner/detectors/data/api.d.ts.map +1 -0
  78. package/dist/scanner/detectors/data/api.js +261 -0
  79. package/dist/scanner/detectors/data/api.js.map +1 -0
  80. package/dist/scanner/detectors/data/database.d.ts +12 -0
  81. package/dist/scanner/detectors/data/database.d.ts.map +1 -0
  82. package/dist/scanner/detectors/data/database.js +213 -0
  83. package/dist/scanner/detectors/data/database.js.map +1 -0
  84. package/dist/scanner/detectors/data/orm.d.ts +12 -0
  85. package/dist/scanner/detectors/data/orm.d.ts.map +1 -0
  86. package/dist/scanner/detectors/data/orm.js +160 -0
  87. package/dist/scanner/detectors/data/orm.js.map +1 -0
  88. package/dist/scanner/detectors/frontend/formHandling.d.ts +12 -0
  89. package/dist/scanner/detectors/frontend/formHandling.d.ts.map +1 -0
  90. package/dist/scanner/detectors/frontend/formHandling.js +211 -0
  91. package/dist/scanner/detectors/frontend/formHandling.js.map +1 -0
  92. package/dist/scanner/detectors/frontend/stateManagement.d.ts +12 -0
  93. package/dist/scanner/detectors/frontend/stateManagement.d.ts.map +1 -0
  94. package/dist/scanner/detectors/frontend/stateManagement.js +221 -0
  95. package/dist/scanner/detectors/frontend/stateManagement.js.map +1 -0
  96. package/dist/scanner/detectors/frontend/uiComponents.d.ts +12 -0
  97. package/dist/scanner/detectors/frontend/uiComponents.d.ts.map +1 -0
  98. package/dist/scanner/detectors/frontend/uiComponents.js +285 -0
  99. package/dist/scanner/detectors/frontend/uiComponents.js.map +1 -0
  100. package/dist/scanner/detectors/infra/deployment.d.ts +12 -0
  101. package/dist/scanner/detectors/infra/deployment.d.ts.map +1 -0
  102. package/dist/scanner/detectors/infra/deployment.js +301 -0
  103. package/dist/scanner/detectors/infra/deployment.js.map +1 -0
  104. package/dist/scanner/detectors/infra/monorepo.d.ts +12 -0
  105. package/dist/scanner/detectors/infra/monorepo.d.ts.map +1 -0
  106. package/dist/scanner/detectors/infra/monorepo.js +219 -0
  107. package/dist/scanner/detectors/infra/monorepo.js.map +1 -0
  108. package/dist/scanner/detectors/mcp/mcpProject.d.ts +12 -0
  109. package/dist/scanner/detectors/mcp/mcpProject.d.ts.map +1 -0
  110. package/dist/scanner/detectors/mcp/mcpProject.js +154 -0
  111. package/dist/scanner/detectors/mcp/mcpProject.js.map +1 -0
  112. package/dist/scanner/detectors/mcp/mcpServers.d.ts +17 -0
  113. package/dist/scanner/detectors/mcp/mcpServers.d.ts.map +1 -0
  114. package/dist/scanner/detectors/mcp/mcpServers.js +193 -0
  115. package/dist/scanner/detectors/mcp/mcpServers.js.map +1 -0
  116. package/dist/scanner/detectors/services/analytics.d.ts +12 -0
  117. package/dist/scanner/detectors/services/analytics.d.ts.map +1 -0
  118. package/dist/scanner/detectors/services/analytics.js +236 -0
  119. package/dist/scanner/detectors/services/analytics.js.map +1 -0
  120. package/dist/scanner/detectors/services/auth.d.ts +12 -0
  121. package/dist/scanner/detectors/services/auth.d.ts.map +1 -0
  122. package/dist/scanner/detectors/services/auth.js +217 -0
  123. package/dist/scanner/detectors/services/auth.js.map +1 -0
  124. package/dist/scanner/detectors/services/email.d.ts +12 -0
  125. package/dist/scanner/detectors/services/email.d.ts.map +1 -0
  126. package/dist/scanner/detectors/services/email.js +211 -0
  127. package/dist/scanner/detectors/services/email.js.map +1 -0
  128. package/dist/scanner/detectors/services/payments.d.ts +12 -0
  129. package/dist/scanner/detectors/services/payments.d.ts.map +1 -0
  130. package/dist/scanner/detectors/services/payments.js +185 -0
  131. package/dist/scanner/detectors/services/payments.js.map +1 -0
  132. package/dist/scanner/detectors/utils.d.ts +160 -0
  133. package/dist/scanner/detectors/utils.d.ts.map +1 -0
  134. package/dist/scanner/detectors/utils.js +222 -0
  135. package/dist/scanner/detectors/utils.js.map +1 -0
  136. package/dist/scanner/index.d.ts +42 -0
  137. package/dist/scanner/index.d.ts.map +1 -0
  138. package/dist/scanner/index.js +282 -0
  139. package/dist/scanner/index.js.map +1 -0
  140. package/dist/scanner/registry.d.ts +43 -0
  141. package/dist/scanner/registry.d.ts.map +1 -0
  142. package/dist/scanner/registry.js +243 -0
  143. package/dist/scanner/registry.js.map +1 -0
  144. package/dist/scanner/types.d.ts +112 -0
  145. package/dist/scanner/types.d.ts.map +1 -0
  146. package/dist/scanner/types.js +6 -0
  147. package/dist/scanner/types.js.map +1 -0
  148. package/dist/templates/config/ralph.config.js.tmpl +38 -0
  149. package/dist/templates/guides/AGENTS.md.tmpl +100 -0
  150. package/dist/templates/guides/FRONTEND.md.tmpl +523 -0
  151. package/dist/templates/guides/PERFORMANCE.md.tmpl +264 -0
  152. package/dist/templates/guides/SECURITY.md.tmpl +100 -0
  153. package/dist/templates/prompts/PROMPT.md.tmpl +77 -0
  154. package/dist/templates/prompts/PROMPT_e2e.md.tmpl +234 -0
  155. package/dist/templates/prompts/PROMPT_feature.md.tmpl +83 -0
  156. package/dist/templates/prompts/PROMPT_review.md.tmpl +167 -0
  157. package/dist/templates/prompts/PROMPT_verify.md.tmpl +72 -0
  158. package/dist/templates/root/.gitignore.tmpl +5 -0
  159. package/dist/templates/root/LEARNINGS.md.tmpl +24 -0
  160. package/dist/templates/root/README.md.tmpl +61 -0
  161. package/dist/templates/scripts/feature-loop.sh.tmpl +267 -0
  162. package/dist/templates/scripts/loop.sh.tmpl +59 -0
  163. package/dist/templates/scripts/ralph-monitor.sh.tmpl +244 -0
  164. package/dist/templates/specs/README.md.tmpl +57 -0
  165. package/dist/templates/specs/_example.md.tmpl +71 -0
  166. package/dist/utils/config.d.ts +95 -0
  167. package/dist/utils/config.d.ts.map +1 -0
  168. package/dist/utils/config.js +148 -0
  169. package/dist/utils/config.js.map +1 -0
  170. package/dist/utils/header.d.ts +5 -0
  171. package/dist/utils/header.d.ts.map +1 -0
  172. package/dist/utils/header.js +15 -0
  173. package/dist/utils/header.js.map +1 -0
  174. package/dist/utils/logger.d.ts +11 -0
  175. package/dist/utils/logger.d.ts.map +1 -0
  176. package/dist/utils/logger.js +24 -0
  177. package/dist/utils/logger.js.map +1 -0
  178. package/package.json +44 -0
  179. package/src/ai/enhancer.ts +350 -0
  180. package/src/ai/index.ts +38 -0
  181. package/src/ai/prompts.ts +217 -0
  182. package/src/ai/providers.ts +136 -0
  183. package/src/cli.ts +255 -0
  184. package/src/commands/init.ts +149 -0
  185. package/src/commands/monitor.ts +412 -0
  186. package/src/commands/new.ts +312 -0
  187. package/src/commands/run.ts +214 -0
  188. package/src/generator/config.ts +116 -0
  189. package/src/generator/index.ts +227 -0
  190. package/src/generator/templates.ts +412 -0
  191. package/src/generator/writer.ts +293 -0
  192. package/src/index.ts +41 -0
  193. package/src/scanner/detectors/core/framework.ts +332 -0
  194. package/src/scanner/detectors/core/packageManager.ts +91 -0
  195. package/src/scanner/detectors/core/styling.ts +261 -0
  196. package/src/scanner/detectors/core/testing.ts +221 -0
  197. package/src/scanner/detectors/data/api.ts +303 -0
  198. package/src/scanner/detectors/data/database.ts +245 -0
  199. package/src/scanner/detectors/data/orm.ts +180 -0
  200. package/src/scanner/detectors/frontend/formHandling.ts +244 -0
  201. package/src/scanner/detectors/frontend/stateManagement.ts +261 -0
  202. package/src/scanner/detectors/frontend/uiComponents.ts +328 -0
  203. package/src/scanner/detectors/infra/deployment.ts +343 -0
  204. package/src/scanner/detectors/infra/monorepo.ts +251 -0
  205. package/src/scanner/detectors/mcp/mcpProject.ts +176 -0
  206. package/src/scanner/detectors/mcp/mcpServers.ts +237 -0
  207. package/src/scanner/detectors/services/analytics.ts +273 -0
  208. package/src/scanner/detectors/services/auth.ts +254 -0
  209. package/src/scanner/detectors/services/email.ts +244 -0
  210. package/src/scanner/detectors/services/payments.ts +213 -0
  211. package/src/scanner/detectors/utils.ts +251 -0
  212. package/src/scanner/index.ts +354 -0
  213. package/src/scanner/registry.ts +301 -0
  214. package/src/scanner/types.ts +152 -0
  215. package/src/templates/config/ralph.config.js.tmpl +38 -0
  216. package/src/templates/guides/AGENTS.md.tmpl +100 -0
  217. package/src/templates/guides/FRONTEND.md.tmpl +523 -0
  218. package/src/templates/guides/PERFORMANCE.md.tmpl +264 -0
  219. package/src/templates/guides/SECURITY.md.tmpl +100 -0
  220. package/src/templates/prompts/PROMPT.md.tmpl +77 -0
  221. package/src/templates/prompts/PROMPT_e2e.md.tmpl +234 -0
  222. package/src/templates/prompts/PROMPT_feature.md.tmpl +83 -0
  223. package/src/templates/prompts/PROMPT_review.md.tmpl +167 -0
  224. package/src/templates/prompts/PROMPT_verify.md.tmpl +72 -0
  225. package/src/templates/root/.gitignore.tmpl +5 -0
  226. package/src/templates/root/LEARNINGS.md.tmpl +24 -0
  227. package/src/templates/root/README.md.tmpl +61 -0
  228. package/src/templates/scripts/feature-loop.sh.tmpl +267 -0
  229. package/src/templates/scripts/loop.sh.tmpl +59 -0
  230. package/src/templates/scripts/ralph-monitor.sh.tmpl +244 -0
  231. package/src/templates/specs/README.md.tmpl +57 -0
  232. package/src/templates/specs/_example.md.tmpl +71 -0
  233. package/src/utils/config.ts +221 -0
  234. package/src/utils/header.ts +15 -0
  235. package/src/utils/logger.ts +28 -0
  236. package/tsconfig.json +19 -0
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Scanner Types
3
+ * Type definitions for the project scanner system
4
+ */
5
+
6
+ /**
7
+ * Result of detecting a single technology/tool
8
+ */
9
+ export interface DetectionResult {
10
+ /** Name of the detected technology (e.g., "Next.js", "pnpm") */
11
+ name: string;
12
+ /** Version if detectable from package.json */
13
+ version?: string;
14
+ /** Variant or additional context (e.g., "app-router" for Next.js) */
15
+ variant?: string;
16
+ /** Confidence score from 0-100 */
17
+ confidence: number;
18
+ /** Evidence that led to this detection (files found, deps matched) */
19
+ evidence: string[];
20
+ }
21
+
22
+ /**
23
+ * MCP detection result
24
+ */
25
+ export interface MCPStack {
26
+ /** Detected MCP servers from config */
27
+ detected?: DetectionResult[];
28
+ /** Recommended MCP servers based on stack */
29
+ recommended?: string[];
30
+ /** Is this an MCP server project */
31
+ isProject?: boolean;
32
+ /** MCP project detection result (if it's an MCP server project) */
33
+ projectInfo?: DetectionResult;
34
+ }
35
+
36
+ /**
37
+ * Complete detected tech stack for a project
38
+ */
39
+ export interface DetectedStack {
40
+ // ============ Core ============
41
+ /** Web framework (Next.js, React, Vue, etc.) */
42
+ framework?: DetectionResult;
43
+ /** Package manager (pnpm, yarn, npm, bun) */
44
+ packageManager?: DetectionResult;
45
+ /** Testing frameworks */
46
+ testing?: {
47
+ unit?: DetectionResult;
48
+ e2e?: DetectionResult;
49
+ };
50
+ /** Styling approach (Tailwind, CSS Modules, etc.) */
51
+ styling?: DetectionResult;
52
+
53
+ // ============ Data Layer ============
54
+ /** Database (Supabase, Firebase, MongoDB, PostgreSQL) */
55
+ database?: DetectionResult;
56
+ /** ORM (Prisma, Drizzle) */
57
+ orm?: DetectionResult;
58
+ /** API patterns (tRPC, GraphQL, TanStack Query, REST) - can have multiple */
59
+ api?: DetectionResult[];
60
+
61
+ // ============ Frontend ============
62
+ /** State management (Redux, Zustand, Jotai, Pinia, etc.) */
63
+ stateManagement?: DetectionResult;
64
+ /** UI component libraries (shadcn, Radix, MUI, etc.) - can have multiple */
65
+ uiComponents?: DetectionResult[];
66
+ /** Form handling and validation (React Hook Form, Zod, etc.) - can have multiple */
67
+ formHandling?: DetectionResult[];
68
+
69
+ // ============ Services ============
70
+ /** Auth provider (NextAuth, Clerk, Auth0, Supabase Auth) */
71
+ auth?: DetectionResult;
72
+ /** Analytics (PostHog, Mixpanel, Vercel Analytics, etc.) - can have multiple */
73
+ analytics?: DetectionResult[];
74
+ /** Payment provider (Stripe, Lemon Squeezy, Paddle) */
75
+ payments?: DetectionResult;
76
+ /** Email provider (Resend, SendGrid, Nodemailer) */
77
+ email?: DetectionResult;
78
+
79
+ // ============ Infrastructure ============
80
+ /** Deployment targets (Vercel, Netlify, Railway, Docker) - can have multiple */
81
+ deployment?: DetectionResult[];
82
+ /** Monorepo tools (Turborepo, Nx, pnpm workspaces, Lerna) */
83
+ monorepo?: DetectionResult;
84
+
85
+ // ============ MCP ============
86
+ /** MCP (Model Context Protocol) related detection */
87
+ mcp?: MCPStack;
88
+ }
89
+
90
+ /**
91
+ * Category of detector
92
+ */
93
+ export type DetectorCategory =
94
+ // Core
95
+ | 'framework'
96
+ | 'packageManager'
97
+ | 'testing'
98
+ | 'styling'
99
+ // Data Layer
100
+ | 'database'
101
+ | 'orm'
102
+ | 'api'
103
+ // Frontend
104
+ | 'stateManagement'
105
+ | 'uiComponents'
106
+ | 'formHandling'
107
+ // Services
108
+ | 'auth'
109
+ | 'analytics'
110
+ | 'payments'
111
+ | 'email'
112
+ // Infrastructure
113
+ | 'deployment'
114
+ | 'monorepo'
115
+ // MCP
116
+ | 'mcp';
117
+
118
+ /**
119
+ * Interface for a detector function
120
+ */
121
+ export interface Detector {
122
+ /** Category this detector belongs to */
123
+ category: DetectorCategory;
124
+ /** Human-readable name */
125
+ name: string;
126
+ /** Run detection on a project directory */
127
+ detect: (projectRoot: string) => Promise<DetectionResult | DetectionResult[] | null>;
128
+ }
129
+
130
+ /**
131
+ * Options for the scanner
132
+ */
133
+ export interface ScannerOptions {
134
+ /** Whether to include low-confidence results */
135
+ includeLowConfidence?: boolean;
136
+ /** Minimum confidence threshold (0-100) */
137
+ minConfidence?: number;
138
+ }
139
+
140
+ /**
141
+ * Result of a full project scan
142
+ */
143
+ export interface ScanResult {
144
+ /** Path that was scanned */
145
+ projectRoot: string;
146
+ /** Detected tech stack */
147
+ stack: DetectedStack;
148
+ /** Time taken to scan in milliseconds */
149
+ scanTime: number;
150
+ /** Any errors encountered during scanning */
151
+ errors?: string[];
152
+ }
@@ -0,0 +1,38 @@
1
+ module.exports = {
2
+ name: '{{projectName}}',
3
+ stack: {
4
+ framework: {
5
+ name: '{{framework}}',
6
+ version: '{{frameworkVersion}}',
7
+ variant: '{{frameworkVariant}}',
8
+ },
9
+ packageManager: '{{packageManager}}',
10
+ testing: {
11
+ unit: '{{unitTest}}',
12
+ e2e: '{{e2eTest}}',
13
+ },
14
+ styling: '{{styling}}',
15
+ },
16
+ commands: {
17
+ dev: '{{devCommand}}',
18
+ build: '{{buildCommand}}',
19
+ test: '{{testCommand}}',
20
+ lint: '{{lintCommand}}',
21
+ typecheck: '{{typecheckCommand}}',
22
+ },
23
+ paths: {
24
+ root: '.ralph',
25
+ prompts: '.ralph/prompts',
26
+ guides: '.ralph/guides',
27
+ specs: '.ralph/specs',
28
+ scripts: '.ralph/scripts',
29
+ learnings: '.ralph/LEARNINGS.md',
30
+ agents: '.ralph/AGENTS.md',
31
+ },
32
+ loop: {
33
+ maxIterations: 10,
34
+ maxE2eAttempts: 5,
35
+ defaultModel: 'sonnet',
36
+ planningModel: 'opus',
37
+ },
38
+ };
@@ -0,0 +1,100 @@
1
+ # AGENTS.md
2
+
3
+ ## Stack
4
+ {{framework}}{{#if frameworkVersion}} {{frameworkVersion}}{{/if}}{{#if frameworkVariant}} ({{frameworkVariant}}){{/if}}, TypeScript, {{styling || css}}{{#if unitTest}}, {{unitTest}}{{/if}}{{#if e2eTest}}, {{e2eTest}}{{/if}}
5
+
6
+ ## Commands
7
+ All commands run from `{{appDir}}/` directory:
8
+
9
+ | Action | Command |
10
+ |--------|---------|
11
+ | Dev | `cd {{appDir}} && {{devCommand}}` |
12
+ | Build | `cd {{appDir}} && {{buildCommand}}` |
13
+ | Lint | `cd {{appDir}} && {{lintCommand}}` |
14
+ | Lint fix | `cd {{appDir}} && {{lintCommand}} -- --fix` |
15
+ | Format | `cd {{appDir}} && {{formatCommand}}` |
16
+ | Typecheck | `cd {{appDir}} && {{typecheckCommand}}` |
17
+ {{#if unitTest}}| Test | `cd {{appDir}} && {{testCommand}}` |
18
+ | Test watch | `cd {{appDir}} && {{testCommand}} -- --watch` |{{/if}}
19
+
20
+ ## Validation (run before commit)
21
+ ```bash
22
+ cd {{appDir}} && {{lintCommand}} -- --fix && {{typecheckCommand}}{{#if unitTest}} && {{testCommand}}{{/if}} && {{buildCommand}}
23
+ ```
24
+
25
+ ## Security Review (run before commit)
26
+ ```bash
27
+ cd {{appDir}} && {{packageManager}} audit # Check vulnerable dependencies
28
+ ```
29
+ Then review changes against @.ralph/guides/SECURITY.md checklist.
30
+ Use `mcp__supabase__get_advisors` with type "security" to check RLS policies.
31
+
32
+ ## Patterns
33
+ - Pages: `{{appDir}}/app/` - Next.js App Router
34
+ - Components: `{{appDir}}/components/` - see ui/, ai-elements/, survey-editor/
35
+ - API: `{{appDir}}/app/api/` - streaming endpoints with tool calling
36
+ - Store: `{{appDir}}/store/` - State management
37
+ - Server Actions: `{{appDir}}/app/actions.ts` and `{{appDir}}/app/actions/`
38
+ - Libs: `{{appDir}}/lib/` - utilities and integrations
39
+
40
+ ## Search Tools
41
+ - **Codebase search**: Use `mgrep "query"` (preferred over Grep/Glob)
42
+ - **Documentation lookup**: Use Context7 MCP for library/framework docs
43
+ - **Web search**: Use `mgrep --web "query"` for general web lookups
44
+
45
+ ## Code Rules
46
+ - Explicit return types on functions
47
+ - No `any` - use `unknown` if truly unknown
48
+ - Early returns over nested conditionals
49
+ - Named exports, not default exports
50
+ - Path alias `@/` maps to `{{appDir}}/` root
51
+ - Follow patterns in existing components
52
+ - 2-space indentation, single quotes
53
+ - PascalCase for components, `use` prefix for hooks
54
+ - kebab-case for folder names (e.g., `survey-editor`)
55
+
56
+ {{#if unitTest}}## Testing
57
+ - Framework: {{unitTest}}{{#if unitTestVersion}} {{unitTestVersion}}{{/if}}
58
+ - Test location: next to component as `*.test.tsx` or in `__tests__/`
59
+ - Run: `cd {{appDir}} && {{testCommand}}`
60
+ - Each feature task should include tests
61
+ - Validation fails if tests fail
62
+ {{/if}}
63
+
64
+ ## Secrets
65
+ - Use `.env.local` for secrets, never commit API keys
66
+ - Use `process.env.*` for all secrets
67
+
68
+ ## Git
69
+ - Commits: `type(scope): description` (conventional commits)
70
+ - Types: feat, fix, docs, refactor, test, chore
71
+ - After changes: validate, commit, push
72
+
73
+ ## MCP Servers Available
74
+ - **Supabase**: Query DB, manage migrations, generate types
75
+ - **PostHog**: Analytics, feature flags, experiments
76
+ - **Playwright**: Browser automation for E2E testing
77
+ - Navigate: `browser_navigate`, `browser_snapshot`
78
+ - Interact: `browser_click`, `browser_type`, `browser_fill_form`
79
+ - Verify: `browser_wait_for`, `browser_console_messages`
80
+ - Debug: `browser_take_screenshot`
81
+ - **Codex CLI** (shell command, not MCP): PR review
82
+ - Command: `echo "prompt" | codex exec --full-auto -`
83
+ - For reviews: `codex review --base main` (interactive mode)
84
+ - Location: `/opt/homebrew/bin/codex`
85
+ - Use for: code review, PR feedback before merge
86
+ - **Context7**: Documentation lookup for libraries/frameworks
87
+
88
+ ## Quick Triggers
89
+ | Keywords | Action |
90
+ |----------|--------|
91
+ | type error, ts | Run typecheck |
92
+ | lint, format | Run lint --fix and prettier |
93
+ | deploy, build | Run full build |
94
+ | error, debug | Check PostHog logs or console |
95
+ | database, table | Use Supabase MCP |
96
+ | e2e, browser test | Use Playwright MCP |
97
+
98
+ ## Detailed Docs
99
+ - Architecture: `{{appDir}}/.claude/CLAUDE.md` - comprehensive codebase details
100
+ - Frontend: `.ralph/guides/FRONTEND.md` - design patterns, component usage, quality checklist