summaryrefslogtreecommitdiff
path: root/default/CLAUDE.md
blob: 97e083558ad3ff8ba3993fe7b904022a6a828338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Development Partnership Guide

## Development Partnership Principles

We are partners in creating production-quality code. Every line of code we write together should be:

- Maintainable by the next developer
- Thoroughly tested and documented
- Designed to catch issues early rather than hide them

## 🚨 MANDATORY AI WORKFLOW

**_BEFORE DOING ANYTHING, YOU MUST:_**

**_ALWAYS use zen gemini_** for complex problems and architectural decisions

**_ALWAYS check Context7_** for library documentation and best practices

**_SAY THIS PHRASE_**: "Let me research the codebase using zen gemini and Context7 to create a plan before implementing."

## Critical Workflow

**_Research → Plan → Implement_**

NEVER jump straight to coding. Always follow this sequence:

1. **_Research_**: Use multiple agents to understand the codebase, existing patterns, and requirements
2. **_Plan_**: Create a detailed implementation plan with TodoWrite
3. **_Implement_**: Execute the plan with continuous validation

### Use Multiple Agents for Parallel Problem-Solving

When facing complex problems, launch multiple agents concurrently to:

- Research different aspects of the codebase
- Investigate various implementation approaches
- Validate assumptions and requirements

### Mandatory Automated Checks and Reality Checkpoints

Before any code is considered complete:

- Run all linters and formatters
- Execute all tests
- Validate the feature works end-to-end
- Clean up any old/unused code

## TypeScript/Next.js Specific Rules

### Forbidden Practices

- **_NO any or unknown types_**: Always use specific types
- **_NO console.log in production_**: Use proper logging
- **_NO inline styles_**: Use Tailwind classes or CSS modules
- **_NO direct DOM manipulation_**: Use React patterns
- **_NO drizzle command_**: Skip the drizzle commands

### Implementation Standards

Code is complete when:

- TypeScript compiler passes with strict mode
- ESLint passes with zero warnings
- All tests pass
- Next.js builds successfully
- Feature works end-to-end
- Old code is deleted
- JSDoc comments on all exported functions

## Project Structure Standards

### Next.js App Router Structure

### Component Patterns

## Testing Strategy

### When to Write Tests

- **_Complex business logic_**: Write tests first (TDD)
- **_API routes_**: Write integration tests
- **_Utility functions_**: Write unit tests
- **_Components_**: Write component tests for complex logic

## Communication Protocol

- Provide clear progress updates using TodoWrite
- Suggest improvements transparently
- Prioritize clarity over complexity
- Always explain the "why" behind architectural decisions

## Common Commands

```bash
# Development
npm run dev          # Start development server
npm run build        # Production build
npm run start        # Start production server
npm run lint         # Run ESLint
npm run type-check   # TypeScript checking

# Database (if using Prisma)
npx prisma generate  # Generate Prisma client
npx prisma db push   # Push schema changes
npx prisma studio    # Open Prisma Studio

# Strapi (if backend)
npm run develop      # Start Strapi dev server
npm run build        # Build Strapi admin
npm run start        # Start Strapi production
```

## Performance & Security

### Performance Standards

- Use Next.js Image component for all images
- Implement proper loading states
- Use React.memo for expensive components
- Optimize bundle size with dynamic imports
- Follow Web Vitals guidelines

### Security Standards

- Validate all inputs with Zod
- Use environment variables for secrets
- Implement proper authentication
- Sanitize user-generated content
- Use HTTPS in production

## Quality Gates

### Before Any Commit

1. TypeScript compiler passes ✅
2. ESLint passes with zero warnings ✅
3. All tests pass ✅
4. Build completes successfully ✅
5. Manual testing in development ✅

### Before Deployment

1. Production build works ✅
2. Environment variables configured ✅
3. Database migrations applied ✅
4. API endpoints tested ✅
5. Performance metrics acceptable ✅

## Architecture Principles

- **Single Responsibility**: Each component/function has one job
- **Dependency Injection**: Use context and hooks for dependencies
- **Type Safety**: Leverage TypeScript's type system fully
- **Error Boundaries**: Implement proper error handling
- **Accessibility**: Follow WCAG guidelines
- **Mobile First**: Design for mobile, enhance for desktop

## Common Patterns

### API Route Pattern

### Component Pattern

## Emergency Procedures

### When Hooks Fail

1. STOP immediately
2. Fix ALL reported issues
3. Verify the fix manually
4. Re-run the hook
5. Only continue when ✅ GREEN

### When Build Fails

1. Check TypeScript errors first
2. Verify all imports are correct
3. Check for missing dependencies
4. Validate environment variables
5. Clear .next cache if needed

Remember: This is production code - quality and reliability are paramount!