start-vibing-stacks 2.3.0 → 2.4.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.
- package/dist/detector.js +19 -5
- package/dist/index.js +15 -3
- package/dist/scanner.js +23 -2
- package/dist/setup.js +17 -1
- package/dist/types.d.ts +4 -0
- package/dist/ui.js +6 -5
- package/package.json +1 -1
- package/stacks/_shared/config/security-rules.json +27 -5
- package/stacks/frontend/react/skills/preline-ui/SKILL.md +31 -35
- package/stacks/frontend/react/skills/react-standards/SKILL.md +20 -20
- package/stacks/frontend/react/skills/react-ui-patterns/SKILL.md +78 -42
- package/stacks/frontend/react/skills/tailwind-patterns/SKILL.md +1 -1
- package/stacks/frontend/react/skills/zod-validation/SKILL.md +84 -18
- package/stacks/nodejs/skills/nextjs-app-router/SKILL.md +101 -0
- package/stacks/nodejs/stack.json +43 -121
- package/templates/CLAUDE-nodejs.md +323 -0
- package/templates/CLAUDE-php.md +131 -10
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
> **CHARACTER LIMIT**: Max 40,000 chars. Validate with `wc -m CLAUDE.md` before commit.
|
|
4
|
+
|
|
5
|
+
## Last Change
|
|
6
|
+
|
|
7
|
+
**Branch:** main
|
|
8
|
+
**Date:** {{DATE}}
|
|
9
|
+
**Summary:** Initial project setup with start-vibing-stacks (Node.js)
|
|
10
|
+
|
|
11
|
+
## 30 Seconds Overview
|
|
12
|
+
|
|
13
|
+
{{PROJECT_NAME}} is a TypeScript project using {{FRAMEWORK}}.
|
|
14
|
+
|
|
15
|
+
## Stack
|
|
16
|
+
|
|
17
|
+
| Component | Technology |
|
|
18
|
+
|-----------|------------|
|
|
19
|
+
| Runtime | Bun / Node.js 20+ |
|
|
20
|
+
| Language | TypeScript **strict mode** |
|
|
21
|
+
| Framework | {{FRAMEWORK}} |
|
|
22
|
+
| Database | {{DATABASE}} |
|
|
23
|
+
| Validation | Zod |
|
|
24
|
+
| Testing | Vitest + Playwright |
|
|
25
|
+
| UI | React + Tailwind + shadcn |
|
|
26
|
+
| Data | TanStack Query + Sonner |
|
|
27
|
+
| Forms | react-hook-form + Zod |
|
|
28
|
+
|
|
29
|
+
## Architecture
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
project/
|
|
33
|
+
├── CLAUDE.md # This file (40k char max)
|
|
34
|
+
├── .claude/
|
|
35
|
+
│ ├── agents/ # 6 active subagents
|
|
36
|
+
│ ├── skills/ # Skill systems (auto-injected)
|
|
37
|
+
│ ├── hooks/ # Validation hooks
|
|
38
|
+
│ ├── config/ # Project configuration
|
|
39
|
+
│ └── commands/ # Slash commands (/feature, /fix, /research, /validate)
|
|
40
|
+
├── src/
|
|
41
|
+
│ ├── app/ # Next.js App Router pages
|
|
42
|
+
│ │ ├── (marketing)/ # Route group — public pages
|
|
43
|
+
│ │ ├── (app)/ # Route group — authenticated
|
|
44
|
+
│ │ │ └── dashboard/
|
|
45
|
+
│ │ │ ├── page.tsx
|
|
46
|
+
│ │ │ └── _components/ # Page-specific components
|
|
47
|
+
│ │ ├── api/ # Route handlers (API endpoints)
|
|
48
|
+
│ │ ├── layout.tsx # Root layout with providers
|
|
49
|
+
│ │ └── loading.tsx # Global loading skeleton
|
|
50
|
+
│ ├── components/
|
|
51
|
+
│ │ ├── ui/ # shadcn primitives (Button, Input)
|
|
52
|
+
│ │ ├── layout/ # Header, Sidebar, Footer
|
|
53
|
+
│ │ ├── shared/ # Cross-feature components
|
|
54
|
+
│ │ └── providers.tsx # Context providers (client)
|
|
55
|
+
│ ├── lib/
|
|
56
|
+
│ │ ├── utils.ts # cn utility (clsx + tailwind-merge)
|
|
57
|
+
│ │ ├── api/ # API client instances
|
|
58
|
+
│ │ └── validations/ # Zod schemas
|
|
59
|
+
│ ├── hooks/ # Custom React hooks
|
|
60
|
+
│ └── styles/ # Global styles, theme tokens
|
|
61
|
+
├── types/ # ALL TypeScript interfaces (MANDATORY)
|
|
62
|
+
├── tests/
|
|
63
|
+
│ ├── unit/ # Vitest unit tests
|
|
64
|
+
│ └── e2e/ # Playwright E2E tests
|
|
65
|
+
├── public/ # Static assets
|
|
66
|
+
├── tsconfig.json # TypeScript config (strict: true)
|
|
67
|
+
├── next.config.ts # Framework config
|
|
68
|
+
├── tailwind.config.ts # TailwindCSS config
|
|
69
|
+
├── vitest.config.ts # Test config
|
|
70
|
+
└── package.json # Dependencies
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Workflow
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
0. TODO LIST → Create detailed todo list from prompt
|
|
77
|
+
1. BRANCH → Create feature/ | fix/ | refactor/ | test/
|
|
78
|
+
2. RESEARCH → Run research-web agent for NEW features
|
|
79
|
+
3. IMPLEMENT → Follow project rules + strict types
|
|
80
|
+
4. TEST → Run tester agent (Vitest / Playwright)
|
|
81
|
+
5. DOCUMENT → Run documenter agent for modified files
|
|
82
|
+
6. UPDATE → Update THIS FILE (CLAUDE.md) with changes
|
|
83
|
+
7. QUALITY → bun run typecheck && lint && test
|
|
84
|
+
8. COMMIT → Conventional commits, merge to main
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## CLAUDE.md Update Rules
|
|
88
|
+
|
|
89
|
+
> After ANY implementation, update this file to reflect the current state.
|
|
90
|
+
|
|
91
|
+
| Change Type | Sections to Update |
|
|
92
|
+
|-------------|-------------------|
|
|
93
|
+
| Any file change | Last Change (branch, date, summary) |
|
|
94
|
+
| API/routes | Critical Rules, Architecture |
|
|
95
|
+
| UI components | Architecture, Component Organization |
|
|
96
|
+
| New feature | 30s Overview, Architecture |
|
|
97
|
+
| New gotcha | FORBIDDEN or NRY |
|
|
98
|
+
| New dependency | Stack |
|
|
99
|
+
| Workflow change | Workflow section |
|
|
100
|
+
|
|
101
|
+
1. **Last Change** documents WHAT was done
|
|
102
|
+
2. **Other sections** document HOW things work NOW
|
|
103
|
+
3. **Both must be current** — updating only Last Change is insufficient
|
|
104
|
+
4. Keep only the LATEST Last Change entry (no stacking)
|
|
105
|
+
|
|
106
|
+
## Agent System
|
|
107
|
+
|
|
108
|
+
### Subagents (6)
|
|
109
|
+
|
|
110
|
+
| Agent | Purpose |
|
|
111
|
+
|-------|---------|
|
|
112
|
+
| **research-web** | Researches best practices before new features |
|
|
113
|
+
| **documenter** | Maps files to domains, creates/updates domain docs |
|
|
114
|
+
| **domain-updater** | Records problems, solutions, learnings |
|
|
115
|
+
| **commit-manager** | Manages git commits, conventional format |
|
|
116
|
+
| **claude-md-compactor** | Compacts CLAUDE.md when > 40k chars |
|
|
117
|
+
| **tester** | Creates tests with Vitest/Playwright |
|
|
118
|
+
|
|
119
|
+
### Skills
|
|
120
|
+
|
|
121
|
+
| Category | Skills |
|
|
122
|
+
|----------|--------|
|
|
123
|
+
| **Development** | typescript-strict, react-patterns, nextjs-app-router, zod-validation, shadcn-ui, tailwind-patterns |
|
|
124
|
+
| **Quality** | quality-gate, security-scan, test-coverage, final-check |
|
|
125
|
+
| **Infrastructure** | docker-patterns, git-workflow, performance-patterns, debugging-patterns |
|
|
126
|
+
| **Documentation** | codebase-knowledge, docs-tracker, research-cache, ui-ux-audit |
|
|
127
|
+
|
|
128
|
+
## Critical Rules
|
|
129
|
+
|
|
130
|
+
- **TypeScript strict mode** — `strict: true` in tsconfig.json
|
|
131
|
+
- **Bracket notation** for env vars: `process.env['VARIABLE']`
|
|
132
|
+
- **Zod validation** for ALL external input (forms, API, env)
|
|
133
|
+
- **Server Components by default** — push `'use client'` to leaf components
|
|
134
|
+
- **Parallel data fetching** — `Promise.all()` over waterfall
|
|
135
|
+
- **Type everything** — no `any`, use `unknown` for truly unknown data
|
|
136
|
+
- **Loading states** — every data page must have `loading.tsx`
|
|
137
|
+
- **Error boundaries** — every route should handle errors gracefully
|
|
138
|
+
- **Conventional commits** — `feat:`, `fix:`, `refactor:`, `docs:`, `chore:`
|
|
139
|
+
|
|
140
|
+
### Environment Variables Security (MANDATORY)
|
|
141
|
+
|
|
142
|
+
> **NEVER expose secrets to the browser.** `NEXT_PUBLIC_*` vars are embedded in the JS bundle and visible to anyone.
|
|
143
|
+
|
|
144
|
+
| Prefix | Where it runs | Safe for |
|
|
145
|
+
|--------|--------------|----------|
|
|
146
|
+
| `NEXT_PUBLIC_*` | Browser + Server | Public URLs, analytics IDs, Stripe **publishable** key (`pk_`) |
|
|
147
|
+
| No prefix | Server ONLY | API keys, secrets, tokens, database URLs, private keys |
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// .env.local
|
|
151
|
+
OPENAI_KEY=sk-abc123 // Server only — SAFE
|
|
152
|
+
STRIPE_SECRET_KEY=sk_live_abc // Server only — SAFE
|
|
153
|
+
NEXT_PUBLIC_APP_URL=https://myapp.com // Public — OK (no secret)
|
|
154
|
+
NEXT_PUBLIC_STRIPE_KEY=pk_live_abc // Public — OK (publishable key)
|
|
155
|
+
|
|
156
|
+
// NEXT_PUBLIC_OPENAI_KEY=sk-abc123 // FORBIDDEN — exposed in browser bundle!
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### API Proxy Pattern (MANDATORY for external APIs)
|
|
160
|
+
|
|
161
|
+
> **ALL calls to external APIs with secrets MUST go through server-side Route Handlers or Server Actions. NEVER call external APIs directly from client components.**
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// app/api/chat/route.ts — Server-side proxy (token NEVER leaves server)
|
|
165
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
166
|
+
|
|
167
|
+
export async function POST(req: NextRequest) {
|
|
168
|
+
const { message } = await req.json();
|
|
169
|
+
const response = await fetch('https://api.openai.com/v1/chat/completions', {
|
|
170
|
+
headers: { Authorization: `Bearer ${process.env['OPENAI_KEY']}` },
|
|
171
|
+
method: 'POST',
|
|
172
|
+
body: JSON.stringify({ model: 'gpt-4', messages: [{ role: 'user', content: message }] }),
|
|
173
|
+
});
|
|
174
|
+
return NextResponse.json(await response.json());
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// components/chat.tsx — Client calls YOUR API, not the external one
|
|
178
|
+
'use client';
|
|
179
|
+
const response = await fetch('/api/chat', {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
body: JSON.stringify({ message }),
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Types Location
|
|
186
|
+
|
|
187
|
+
- **ALL** interfaces/types MUST be in `types/` folder
|
|
188
|
+
- **NEVER** define types in `src/` files
|
|
189
|
+
- **EXCEPTION:** Zod inferred types (`z.infer<typeof Schema>`)
|
|
190
|
+
|
|
191
|
+
### TypeScript Strict
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
process.env['VARIABLE']; // CORRECT (bracket notation)
|
|
195
|
+
source: 'listed' as const; // CORRECT (literal type)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Component Organization
|
|
199
|
+
|
|
200
|
+
| Question | Location |
|
|
201
|
+
|----------|----------|
|
|
202
|
+
| Used in ONE page only? | `app/[page]/_components/` |
|
|
203
|
+
| Used across 2+ features? | `components/shared/` |
|
|
204
|
+
| UI primitive (Button, Input)? | `components/ui/` |
|
|
205
|
+
| Layout element (Header)? | `components/layout/` |
|
|
206
|
+
|
|
207
|
+
| Lines | Action |
|
|
208
|
+
|-------|--------|
|
|
209
|
+
| < 200 | Keep in single file |
|
|
210
|
+
| 200-400 | Consider splitting |
|
|
211
|
+
| > 400 | **MUST split** into smaller components |
|
|
212
|
+
|
|
213
|
+
## FORBIDDEN
|
|
214
|
+
|
|
215
|
+
### Security (CRITICAL)
|
|
216
|
+
|
|
217
|
+
| Action | Reason |
|
|
218
|
+
|--------|--------|
|
|
219
|
+
| `NEXT_PUBLIC_` with API keys/secrets/tokens | Exposes credentials in browser JS bundle — use server-side proxy |
|
|
220
|
+
| Call external APIs from client components | Leaks tokens — route through `app/api/` Route Handlers |
|
|
221
|
+
| `process.env['SECRET']` in `'use client'` files | Only `NEXT_PUBLIC_*` vars reach the browser — use Server Actions |
|
|
222
|
+
| Hardcode API keys in source code | Use `.env.local` + server-side access only |
|
|
223
|
+
| Commit `.env.local` / `.env` to git | Add to `.gitignore` — use `.env.example` with empty values |
|
|
224
|
+
|
|
225
|
+
### Code Quality
|
|
226
|
+
|
|
227
|
+
| Action | Reason |
|
|
228
|
+
|--------|--------|
|
|
229
|
+
| `any` type | Defeats strict mode — use `unknown` |
|
|
230
|
+
| Skip typecheck | TypeScript errors become runtime bugs |
|
|
231
|
+
| Relative imports (shared) | Breaks when files move — use `@/` alias |
|
|
232
|
+
| Define types in `src/` | Must be in `types/` folder |
|
|
233
|
+
| `'use client'` at top-level layouts | Breaks server rendering, push to leaves |
|
|
234
|
+
| Waterfall data fetching | Use `Promise.all()` for parallel |
|
|
235
|
+
| Skip `loading.tsx` on data pages | Flash of empty content |
|
|
236
|
+
| Files > 400 lines | MUST split into smaller components |
|
|
237
|
+
| Wildcard icon imports | Use named: `import { X } from 'lucide-react'` |
|
|
238
|
+
| `var` keyword | Use `const` or `let` |
|
|
239
|
+
| Raw `console.log` in production | Use structured logging |
|
|
240
|
+
|
|
241
|
+
### Workflow
|
|
242
|
+
|
|
243
|
+
| Action | Reason |
|
|
244
|
+
|--------|--------|
|
|
245
|
+
| Commit directly to main | Create feature/fix branches |
|
|
246
|
+
| Skip research for new features | Leads to outdated patterns |
|
|
247
|
+
| Skip todo list creation | Loses track of tasks |
|
|
248
|
+
| Skip documenter agent | Documentation is mandatory |
|
|
249
|
+
| Skip domain documentation | MUST update domains/*.md |
|
|
250
|
+
| Stack Last Change entries | Keep only the LATEST |
|
|
251
|
+
| Use MUI/Chakra | Use shadcn/ui + Radix |
|
|
252
|
+
| Skip CLAUDE.md update | MUST update after implementations |
|
|
253
|
+
|
|
254
|
+
## UI Architecture
|
|
255
|
+
|
|
256
|
+
> Web apps MUST have **separate UIs** for each platform, NOT just "responsive design".
|
|
257
|
+
|
|
258
|
+
| Platform | Layout |
|
|
259
|
+
|----------|--------|
|
|
260
|
+
| Mobile (375px) | Full-screen modals, bottom nav, touch-first |
|
|
261
|
+
| Tablet (768px) | Condensed dropdowns, hybrid nav |
|
|
262
|
+
| Desktop (1280px+) | Sidebar left, top navbar with search |
|
|
263
|
+
|
|
264
|
+
## Quality Gates
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
bun run typecheck # MUST pass
|
|
268
|
+
bun run lint # MUST pass
|
|
269
|
+
bun run test # MUST pass
|
|
270
|
+
bun run build # MUST pass
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Domain Documentation
|
|
274
|
+
|
|
275
|
+
> Domain docs prevent Claude from re-exploring the codebase every session.
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
.claude/skills/codebase-knowledge/domains/
|
|
279
|
+
├── authentication.md
|
|
280
|
+
├── api.md
|
|
281
|
+
├── database.md
|
|
282
|
+
├── ui-components.md
|
|
283
|
+
└── [domain-name].md
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Each domain file tracks: Files, Connections, Recent Commits, Attention Points, Problems & Solutions.
|
|
287
|
+
|
|
288
|
+
## Commit Format
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
[type]: [description]
|
|
292
|
+
|
|
293
|
+
- Detail 1
|
|
294
|
+
- Detail 2
|
|
295
|
+
|
|
296
|
+
Generated with Claude Code
|
|
297
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Types: `feat`, `fix`, `refactor`, `docs`, `chore`
|
|
301
|
+
|
|
302
|
+
## NRY (Never Repeat Yourself)
|
|
303
|
+
|
|
304
|
+
- Multi-line bash with `\` continuations (breaks permissions)
|
|
305
|
+
- Relative paths in permission patterns
|
|
306
|
+
- Using bash for file operations (use Read/Write/Edit tools)
|
|
307
|
+
- Ignoring context size (use `/compact`)
|
|
308
|
+
|
|
309
|
+
## Configuration
|
|
310
|
+
|
|
311
|
+
Project settings in `.claude/config/`:
|
|
312
|
+
|
|
313
|
+
- `active-project.json` — Stack, framework, database, skills
|
|
314
|
+
- `domain-mapping.json` — File-to-domain mapping
|
|
315
|
+
- `quality-gates.json` — Quality check commands
|
|
316
|
+
- `testing-config.json` — Test framework config
|
|
317
|
+
- `security-rules.json` — Security audit rules
|
|
318
|
+
- `standards-review.json` — Imported project standards
|
|
319
|
+
|
|
320
|
+
## Setup by start-vibing-stacks
|
|
321
|
+
|
|
322
|
+
This project was set up with `npx start-vibing-stacks`.
|
|
323
|
+
For updates: `npx start-vibing-stacks --force`
|
package/templates/CLAUDE-php.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
+
> **CHARACTER LIMIT**: Max 40,000 chars. Validate with `wc -m CLAUDE.md` before commit.
|
|
4
|
+
|
|
3
5
|
## Last Change
|
|
4
6
|
|
|
5
7
|
**Branch:** main
|
|
@@ -78,6 +80,24 @@ project/
|
|
|
78
80
|
└── CLAUDE.md # This file
|
|
79
81
|
```
|
|
80
82
|
|
|
83
|
+
## CLAUDE.md Update Rules
|
|
84
|
+
|
|
85
|
+
> After ANY implementation, update this file to reflect the current state.
|
|
86
|
+
|
|
87
|
+
| Change Type | Sections to Update |
|
|
88
|
+
|-------------|-------------------|
|
|
89
|
+
| Any file change | Last Change (branch, date, summary) |
|
|
90
|
+
| API/routes | Critical Rules, Architecture |
|
|
91
|
+
| New feature | 30s Overview, Architecture |
|
|
92
|
+
| New gotcha | FORBIDDEN or NRY |
|
|
93
|
+
| New dependency | Stack |
|
|
94
|
+
| Workflow change | Workflow section |
|
|
95
|
+
|
|
96
|
+
1. **Last Change** documents WHAT was done
|
|
97
|
+
2. **Other sections** document HOW things work NOW
|
|
98
|
+
3. **Both must be current** — updating only Last Change is insufficient
|
|
99
|
+
4. Keep only the LATEST Last Change entry (no stacking)
|
|
100
|
+
|
|
81
101
|
## Critical Rules
|
|
82
102
|
|
|
83
103
|
- **PHP >= 8.3** — readonly, enums, typed constants, match expressions
|
|
@@ -94,18 +114,80 @@ project/
|
|
|
94
114
|
- **Config immutable** — never use `config()` to SET values at runtime
|
|
95
115
|
- **Request object** — use `$request->input()`, never `$_GET`/`$_POST`/`$_SESSION`
|
|
96
116
|
|
|
117
|
+
### Environment Variables & Secrets (MANDATORY)
|
|
118
|
+
|
|
119
|
+
> **NEVER use `env()` outside config files.** After `config:cache`, `env()` returns null everywhere except config files.
|
|
120
|
+
|
|
121
|
+
| Location | Access | Safe for |
|
|
122
|
+
|----------|--------|----------|
|
|
123
|
+
| `.env` | `env()` inside `config/*.php` only | API keys, DB credentials, secrets |
|
|
124
|
+
| `config/*.php` | `config('services.stripe.key')` | Application code access |
|
|
125
|
+
| Frontend (Inertia) | `InertiaShare` or controller props | Public data ONLY |
|
|
126
|
+
|
|
127
|
+
```php
|
|
128
|
+
// config/services.php — Bridge between .env and application
|
|
129
|
+
return [
|
|
130
|
+
'openai' => [
|
|
131
|
+
'key' => env('OPENAI_KEY'),
|
|
132
|
+
],
|
|
133
|
+
'stripe' => [
|
|
134
|
+
'key' => env('STRIPE_KEY'), // Publishable (sent to frontend)
|
|
135
|
+
'secret' => env('STRIPE_SECRET'), // NEVER send to frontend
|
|
136
|
+
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
|
|
137
|
+
],
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
// In code: ALWAYS use config()
|
|
141
|
+
$apiKey = config('services.openai.key');
|
|
142
|
+
|
|
143
|
+
// FORBIDDEN:
|
|
144
|
+
$apiKey = env('OPENAI_KEY'); // Returns null when config is cached!
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Frontend Secret Isolation (MANDATORY)
|
|
148
|
+
|
|
149
|
+
> **NEVER send API keys, secrets, or tokens to the frontend via Inertia props or JavaScript.**
|
|
150
|
+
|
|
151
|
+
```php
|
|
152
|
+
// WRONG — secret exposed in page source / DevTools
|
|
153
|
+
return Inertia::render('Dashboard', [
|
|
154
|
+
'stripeSecret' => config('services.stripe.secret'),
|
|
155
|
+
'openaiKey' => config('services.openai.key'),
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
// CORRECT — only public/publishable data to frontend
|
|
159
|
+
return Inertia::render('Dashboard', [
|
|
160
|
+
'stripePublicKey' => config('services.stripe.key'), // pk_ only
|
|
161
|
+
]);
|
|
162
|
+
|
|
163
|
+
// For operations requiring secrets: use backend API routes
|
|
164
|
+
// Frontend calls /api/payment → backend uses secret server-side
|
|
165
|
+
```
|
|
166
|
+
|
|
97
167
|
## FORBIDDEN
|
|
98
168
|
|
|
99
|
-
###
|
|
169
|
+
### Security (CRITICAL)
|
|
100
170
|
|
|
101
171
|
| Action | Reason |
|
|
102
172
|
|--------|--------|
|
|
173
|
+
| `env()` outside config files | Returns null when config is cached — use `config()` |
|
|
174
|
+
| Send API keys/secrets via Inertia props | Exposed in page source — keep secrets server-side |
|
|
175
|
+
| `$guarded = []` on models | Allows mass assignment of any field — use `$fillable` |
|
|
176
|
+
| `DB::raw()` with user input | SQL injection — use Eloquent or parameterized queries |
|
|
177
|
+
| `{!! $userInput !!}` | XSS — use `{{ }}` (auto-escaped) |
|
|
103
178
|
| Dynamic code execution functions | Remote code execution risk |
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
|
|
|
179
|
+
| `md5()` / `sha1()` for passwords | Weak hashing — use `Hash::make()` |
|
|
180
|
+
| `unserialize()` on user data | Object injection — use JSON with model casts |
|
|
181
|
+
| CORS `allowed_origins: ['*']` | Open API — restrict to your domain |
|
|
182
|
+
| `createToken('x', ['*'])` | Over-privileged — use specific abilities |
|
|
183
|
+
| Trust `X-Forwarded-For` directly | Spoofable — use trusted proxies config |
|
|
184
|
+
| `$_GET` / `$_POST` / `$_SESSION` | Stale in Octane — use `$request->input()` |
|
|
185
|
+
|
|
186
|
+
### Backend
|
|
187
|
+
|
|
188
|
+
| Action | Reason |
|
|
189
|
+
|--------|--------|
|
|
107
190
|
| Business logic in controllers | Move to Service classes |
|
|
108
|
-
| `env()` outside config files | Returns null when config is cached |
|
|
109
191
|
| `static` properties on services | Memory leaks in Octane workers |
|
|
110
192
|
| Global variables / superglobals | Stale state in Octane |
|
|
111
193
|
| `die()` / `exit()` | Kills the Octane worker process |
|
|
@@ -113,11 +195,13 @@ project/
|
|
|
113
195
|
| `migrate:fresh` / `db:wipe` / `db:reset` | Destroys production data |
|
|
114
196
|
| `app()` / `resolve()` in constructors | Use constructor DI instead |
|
|
115
197
|
| `Inertia::render()` after POST/PUT/DELETE | Use `redirect()->route()` instead |
|
|
198
|
+
| `dd()` / `dump()` in production code | Use structured `Log::info()` |
|
|
116
199
|
|
|
117
200
|
### Frontend (React)
|
|
118
201
|
|
|
119
202
|
| Action | Reason |
|
|
120
203
|
|--------|--------|
|
|
204
|
+
| Call external APIs with secrets from JS | Exposes tokens — route through Laravel API |
|
|
121
205
|
| `__()` inside JSX / render | Hook violation — define as CONST before hooks |
|
|
122
206
|
| `fetch()` / `axios` for page data | Bypasses Inertia — use props from controller |
|
|
123
207
|
| `<a href>` for internal links | Full page reload — use `<Link>` |
|
|
@@ -160,8 +244,45 @@ $results = DB::select('SELECT * FROM users WHERE id = ?', [$id]);
|
|
|
160
244
|
|
|
161
245
|
## Workflow
|
|
162
246
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
247
|
+
```
|
|
248
|
+
0. TODO LIST → Create detailed todo list from prompt
|
|
249
|
+
1. BRANCH → Create feature/ | fix/ | refactor/ | test/
|
|
250
|
+
2. RESEARCH → Run research-web agent for NEW features
|
|
251
|
+
3. IMPLEMENT → Types, strict mode, Octane-safe, DI
|
|
252
|
+
4. TEST → Run PHPStan + PHPUnit
|
|
253
|
+
5. DOCUMENT → Run documenter agent for modified files
|
|
254
|
+
6. UPDATE → Update THIS FILE (CLAUDE.md) with changes
|
|
255
|
+
7. QUALITY → PHPStan + PHPUnit + PHP-CS-Fixer
|
|
256
|
+
8. COMMIT → Conventional commits, merge to main
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Domain Documentation
|
|
260
|
+
|
|
261
|
+
> Domain docs prevent Claude from re-exploring the codebase every session.
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
.claude/skills/codebase-knowledge/domains/
|
|
265
|
+
├── authentication.md
|
|
266
|
+
├── api.md
|
|
267
|
+
├── database.md
|
|
268
|
+
├── ui-components.md
|
|
269
|
+
└── [domain-name].md
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Each domain file tracks: Files, Connections, Recent Commits, Attention Points, Problems & Solutions.
|
|
273
|
+
|
|
274
|
+
## Configuration
|
|
275
|
+
|
|
276
|
+
Project settings in `.claude/config/` (generated by start-vibing-stacks):
|
|
277
|
+
|
|
278
|
+
- `active-project.json` — Stack, framework, database, skills
|
|
279
|
+
- `domain-mapping.json` — File-to-domain mapping
|
|
280
|
+
- `quality-gates.json` — Quality check commands
|
|
281
|
+
- `testing-config.json` — Test framework config
|
|
282
|
+
- `security-rules.json` — Security audit rules
|
|
283
|
+
- `standards-review.json` — Imported project standards
|
|
284
|
+
|
|
285
|
+
## Setup by start-vibing-stacks
|
|
286
|
+
|
|
287
|
+
This project was set up with `npx start-vibing-stacks`.
|
|
288
|
+
For updates: `npx start-vibing-stacks --force`
|