ai-flow-dev 1.0.1
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/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +791 -0
- package/dist/cli.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +46 -0
- package/dist/fs-utils.js.map +1 -0
- package/package.json +71 -0
- package/prompts/backend/flow-dev-feature.md +1318 -0
- package/prompts/backend/flow-dev-fix.md +903 -0
- package/prompts/backend/flow-dev-refactor.md +715 -0
- package/prompts/backend/flow-dev-review.md +401 -0
- package/prompts/backend/flow-dev-work.md +1129 -0
- package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
- package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
- package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
- package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
- package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
- package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
- package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
- package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
- package/prompts/backend/flow-docs-gen.md +820 -0
- package/prompts/backend/flow-docs-sync.md +526 -0
- package/prompts/backend/flow-project-init.md +248 -0
- package/prompts/backend/flow-project-roadmap.md +1159 -0
- package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
- package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
- package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
- package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
- package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
- package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
- package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
- package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
- package/prompts/frontend/flow-docs-gen.md +413 -0
- package/prompts/frontend/flow-docs-sync.md +561 -0
- package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
- package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
- package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
- package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
- package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
- package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
- package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
- package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
- package/prompts/mobile/flow-docs-gen.md +430 -0
- package/prompts/mobile/flow-docs-sync.md +634 -0
- package/templates/backend/.clauderules.template +111 -0
- package/templates/backend/.cursorrules.template +102 -0
- package/templates/backend/.env.example.template +122 -0
- package/templates/backend/README.template.md +200 -0
- package/templates/backend/ai-instructions.template.md +354 -0
- package/templates/backend/copilot-instructions.template.md +160 -0
- package/templates/backend/docs/api.template.md +251 -0
- package/templates/backend/docs/architecture.template.md +612 -0
- package/templates/backend/docs/business-flows.template.md +109 -0
- package/templates/backend/docs/code-standards.template.md +828 -0
- package/templates/backend/docs/contributing.template.md +163 -0
- package/templates/backend/docs/data-model.template.md +416 -0
- package/templates/backend/docs/operations.template.md +591 -0
- package/templates/backend/docs/testing.template.md +762 -0
- package/templates/backend/project-brief.template.md +176 -0
- package/templates/backend/specs/configuration.template.md +133 -0
- package/templates/backend/specs/security.template.md +422 -0
- package/templates/frontend/README.template.md +121 -0
- package/templates/frontend/ai-instructions.template.md +368 -0
- package/templates/frontend/docs/api-integration.template.md +390 -0
- package/templates/frontend/docs/components.template.md +567 -0
- package/templates/frontend/docs/error-handling.template.md +385 -0
- package/templates/frontend/docs/operations.template.md +123 -0
- package/templates/frontend/docs/performance.template.md +140 -0
- package/templates/frontend/docs/pwa.template.md +135 -0
- package/templates/frontend/docs/state-management.template.md +394 -0
- package/templates/frontend/docs/styling.template.md +779 -0
- package/templates/frontend/docs/testing.template.md +736 -0
- package/templates/frontend/project-brief.template.md +55 -0
- package/templates/frontend/specs/accessibility.template.md +111 -0
- package/templates/frontend/specs/configuration.template.md +520 -0
- package/templates/frontend/specs/security.template.md +197 -0
- package/templates/fullstack/README.template.md +282 -0
- package/templates/fullstack/ai-instructions.template.md +487 -0
- package/templates/fullstack/project-brief.template.md +197 -0
- package/templates/fullstack/specs/configuration.template.md +380 -0
- package/templates/mobile/AGENT.template.md +251 -0
- package/templates/mobile/README.template.md +195 -0
- package/templates/mobile/ai-instructions.template.md +221 -0
- package/templates/mobile/docs/app-store.template.md +163 -0
- package/templates/mobile/docs/architecture.template.md +100 -0
- package/templates/mobile/docs/native-features.template.md +137 -0
- package/templates/mobile/docs/navigation.template.md +81 -0
- package/templates/mobile/docs/offline-strategy.template.md +90 -0
- package/templates/mobile/docs/permissions.template.md +70 -0
- package/templates/mobile/docs/state-management.template.md +116 -0
- package/templates/mobile/docs/testing.template.md +146 -0
- package/templates/mobile/project-brief.template.md +97 -0
- package/templates/mobile/specs/build-configuration.template.md +116 -0
- package/templates/mobile/specs/deployment.template.md +114 -0
- package/templates/shared/AGENT.template.md +252 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
# Code Standards
|
|
2
|
+
|
|
3
|
+
> Coding conventions, quality rules, and best practices for {{PROJECT_NAME}}
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎨 Code Style
|
|
8
|
+
|
|
9
|
+
### Formatting
|
|
10
|
+
|
|
11
|
+
**Indentation:** {{INDENTATION}}
|
|
12
|
+
|
|
13
|
+
**Quote Style:** {{QUOTE_STYLE}}
|
|
14
|
+
|
|
15
|
+
**Line Length:** {{LINE_LENGTH}} characters max
|
|
16
|
+
|
|
17
|
+
**Semicolons:** {{SEMICOLON_POLICY}}
|
|
18
|
+
|
|
19
|
+
**Trailing Commas:** {{TRAILING_COMMA_POLICY}}
|
|
20
|
+
|
|
21
|
+
### Formatter
|
|
22
|
+
|
|
23
|
+
**Tool:** {{FORMATTER}}
|
|
24
|
+
|
|
25
|
+
**Configuration:** `{{FORMATTER_CONFIG_FILE}}`
|
|
26
|
+
|
|
27
|
+
**Auto-format:** {{AUTO_FORMAT_POLICY}}
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Format code
|
|
31
|
+
{{FORMAT_COMMAND}}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 📝 Naming Conventions
|
|
37
|
+
|
|
38
|
+
### Files
|
|
39
|
+
|
|
40
|
+
**Style:** {{FILE_NAMING_STYLE}}
|
|
41
|
+
|
|
42
|
+
**Examples:**
|
|
43
|
+
```
|
|
44
|
+
{{FILE_NAMING_EXAMPLES}}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Classes and Interfaces
|
|
48
|
+
|
|
49
|
+
**Style:** PascalCase
|
|
50
|
+
|
|
51
|
+
**Examples:**
|
|
52
|
+
```{{LANGUAGE}}
|
|
53
|
+
class UserService {}
|
|
54
|
+
class OrderRepository {}
|
|
55
|
+
interface {{INTERFACE_EXAMPLE}} {}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
{{#IF TYPESCRIPT}}
|
|
59
|
+
### Interfaces
|
|
60
|
+
|
|
61
|
+
**Convention:** {{INTERFACE_NAMING_CONVENTION}}
|
|
62
|
+
|
|
63
|
+
**Examples:**
|
|
64
|
+
```typescript
|
|
65
|
+
{{#IF I_PREFIX}}
|
|
66
|
+
interface IUserService {}
|
|
67
|
+
interface IRepository<T> {}
|
|
68
|
+
{{ELSE}}
|
|
69
|
+
interface UserService {}
|
|
70
|
+
interface Repository<T> {}
|
|
71
|
+
{{/IF}}
|
|
72
|
+
```
|
|
73
|
+
{{/IF}}
|
|
74
|
+
|
|
75
|
+
### Functions and Methods
|
|
76
|
+
|
|
77
|
+
**Style:** camelCase
|
|
78
|
+
|
|
79
|
+
**Examples:**
|
|
80
|
+
```{{LANGUAGE}}
|
|
81
|
+
function getUserById(id: string) {}
|
|
82
|
+
async function createOrder(data: OrderDto) {}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Variables
|
|
86
|
+
|
|
87
|
+
**Style:** camelCase
|
|
88
|
+
|
|
89
|
+
**Examples:**
|
|
90
|
+
```{{LANGUAGE}}
|
|
91
|
+
const userName = 'John';
|
|
92
|
+
let orderTotal = 0;
|
|
93
|
+
const activeUsers = [];
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Constants
|
|
97
|
+
|
|
98
|
+
**Style:** UPPER_SNAKE_CASE
|
|
99
|
+
|
|
100
|
+
**Examples:**
|
|
101
|
+
```{{LANGUAGE}}
|
|
102
|
+
const MAX_RETRY_ATTEMPTS = 3;
|
|
103
|
+
const API_BASE_URL = 'https://api.example.com';
|
|
104
|
+
const DEFAULT_PAGE_SIZE = 20;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Boolean Variables
|
|
108
|
+
|
|
109
|
+
**Convention:** Use is/has/can/should prefix
|
|
110
|
+
|
|
111
|
+
**Examples:**
|
|
112
|
+
```{{LANGUAGE}}
|
|
113
|
+
const isActive = true;
|
|
114
|
+
const hasPermission = false;
|
|
115
|
+
const canEdit = checkPermissions();
|
|
116
|
+
const shouldRefresh = false;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🏗️ Code Organization
|
|
122
|
+
|
|
123
|
+
### File Structure
|
|
124
|
+
|
|
125
|
+
**Strategy:** {{FILE_ORGANIZATION_STRATEGY}}
|
|
126
|
+
|
|
127
|
+
{{#IF FEATURE_BASED}}
|
|
128
|
+
### Feature-Based Example
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
src/
|
|
132
|
+
users/
|
|
133
|
+
user.controller.ts
|
|
134
|
+
user.service.ts
|
|
135
|
+
user.repository.ts
|
|
136
|
+
user.dto.ts
|
|
137
|
+
user.entity.ts
|
|
138
|
+
user.spec.ts
|
|
139
|
+
index.ts
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Benefits:**
|
|
143
|
+
- Clear feature boundaries
|
|
144
|
+
- Easy to locate related code
|
|
145
|
+
- Supports team ownership
|
|
146
|
+
- Facilitates modular architecture
|
|
147
|
+
|
|
148
|
+
{{/IF}}
|
|
149
|
+
|
|
150
|
+
{{#IF LAYER_BASED}}
|
|
151
|
+
### Layer-Based Example
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
src/
|
|
155
|
+
controllers/
|
|
156
|
+
user.controller.ts
|
|
157
|
+
order.controller.ts
|
|
158
|
+
services/
|
|
159
|
+
user.service.ts
|
|
160
|
+
order.service.ts
|
|
161
|
+
repositories/
|
|
162
|
+
user.repository.ts
|
|
163
|
+
order.repository.ts
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
{{/IF}}
|
|
167
|
+
|
|
168
|
+
### Import Organization
|
|
169
|
+
|
|
170
|
+
**Order:**
|
|
171
|
+
{{#EACH IMPORT_ORDER}}
|
|
172
|
+
{{INDEX}}. {{IMPORT_GROUP_DESCRIPTION}}
|
|
173
|
+
{{/EACH}}
|
|
174
|
+
|
|
175
|
+
**Example:**
|
|
176
|
+
```{{LANGUAGE}}
|
|
177
|
+
{{IMPORT_ORDER_EXAMPLE}}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
{{#IF PATH_ALIASES}}
|
|
181
|
+
### Path Aliases
|
|
182
|
+
|
|
183
|
+
**Enabled:** Yes
|
|
184
|
+
|
|
185
|
+
**Configuration:**
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"paths": {
|
|
189
|
+
"@/*": ["src/*"],
|
|
190
|
+
"@/controllers/*": ["src/controllers/*"],
|
|
191
|
+
"@/services/*": ["src/services/*"],
|
|
192
|
+
"@/utils/*": ["src/utils/*"]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Usage:**
|
|
198
|
+
```{{LANGUAGE}}
|
|
199
|
+
import { UserService } from '@/services/user.service';
|
|
200
|
+
import { validateEmail } from '@/utils/validation';
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
{{/IF}}
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## {{#IF TYPESCRIPT}}📘 TypeScript Rules{{ELSE}}📘 Type System{{/IF}}
|
|
208
|
+
|
|
209
|
+
{{#IF TYPESCRIPT}}
|
|
210
|
+
### Strict Mode
|
|
211
|
+
|
|
212
|
+
**Enabled:** {{STRICT_MODE}}
|
|
213
|
+
|
|
214
|
+
**Strict Checks:**
|
|
215
|
+
- `strict`: {{STRICT}}
|
|
216
|
+
- `noImplicitAny`: {{NO_IMPLICIT_ANY}}
|
|
217
|
+
- `strictNullChecks`: {{STRICT_NULL_CHECKS}}
|
|
218
|
+
- `strictFunctionTypes`: {{STRICT_FUNCTION_TYPES}}
|
|
219
|
+
- `strictPropertyInitialization`: {{STRICT_PROPERTY_INIT}}
|
|
220
|
+
|
|
221
|
+
### Type Rules
|
|
222
|
+
|
|
223
|
+
- ✅ **Always** specify return types for functions
|
|
224
|
+
- ✅ **Always** use interfaces for object shapes
|
|
225
|
+
- ✅ **Always** use proper types (never `any`)
|
|
226
|
+
- ❌ **Never** use `any` - use `unknown` if type is truly unknown
|
|
227
|
+
- ❌ **Never** disable TypeScript errors with `@ts-ignore`
|
|
228
|
+
- ✅ **Use** `@ts-expect-error` with comment if absolutely necessary
|
|
229
|
+
|
|
230
|
+
### Type Preferences
|
|
231
|
+
|
|
232
|
+
**Interfaces vs Types:**
|
|
233
|
+
{{TYPE_VS_INTERFACE_PREFERENCE}}
|
|
234
|
+
|
|
235
|
+
**Example:**
|
|
236
|
+
```typescript
|
|
237
|
+
// Interfaces for object shapes
|
|
238
|
+
interface User {
|
|
239
|
+
id: string;
|
|
240
|
+
email: string;
|
|
241
|
+
name: string;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Types for unions, intersections
|
|
245
|
+
type Status = 'pending' | 'active' | 'suspended';
|
|
246
|
+
type UserWithStatus = User & { status: Status };
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Generics
|
|
250
|
+
|
|
251
|
+
**When to use:**
|
|
252
|
+
- Reusable components
|
|
253
|
+
- Type-safe collections
|
|
254
|
+
- Abstract data structures
|
|
255
|
+
|
|
256
|
+
**Example:**
|
|
257
|
+
```typescript
|
|
258
|
+
class Repository<T> {
|
|
259
|
+
async findById(id: string): Promise<T | null> {
|
|
260
|
+
// implementation
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async findAll(): Promise<T[]> {
|
|
264
|
+
// implementation
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
{{/IF}}
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 🚨 Error Handling
|
|
274
|
+
|
|
275
|
+
### Strategy
|
|
276
|
+
|
|
277
|
+
{{ERROR_HANDLING_STRATEGY}}
|
|
278
|
+
|
|
279
|
+
### Custom Error Classes
|
|
280
|
+
|
|
281
|
+
```{{LANGUAGE}}
|
|
282
|
+
{{ERROR_CLASS_EXAMPLE}}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Try-Catch Pattern
|
|
286
|
+
|
|
287
|
+
```{{LANGUAGE}}
|
|
288
|
+
{{TRY_CATCH_EXAMPLE}}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Error Response Format
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{{ERROR_RESPONSE_FORMAT}}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Logging Errors
|
|
298
|
+
|
|
299
|
+
```{{LANGUAGE}}
|
|
300
|
+
{{ERROR_LOGGING_EXAMPLE}}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 📝 Logging Standards
|
|
306
|
+
|
|
307
|
+
### Log Levels
|
|
308
|
+
|
|
309
|
+
**Hierarchy:** DEBUG < INFO < WARN < ERROR < FATAL
|
|
310
|
+
|
|
311
|
+
**Usage Guidelines:**
|
|
312
|
+
- **DEBUG**: Detailed information for debugging (development only)
|
|
313
|
+
- **INFO**: General informational messages (request start, successful operations)
|
|
314
|
+
- **WARN**: Warning messages (deprecated features, recoverable errors)
|
|
315
|
+
- **ERROR**: Error messages (failed operations, exceptions)
|
|
316
|
+
- **FATAL**: Critical errors (system failures, unrecoverable errors)
|
|
317
|
+
|
|
318
|
+
**Default Level:** {{LOG_LEVEL}} ({{LOG_LEVEL_ENVIRONMENT}})
|
|
319
|
+
|
|
320
|
+
### Log Format
|
|
321
|
+
|
|
322
|
+
**Format:** {{LOG_FORMAT}} ({{#IF JSON_LOGS}}Structured JSON{{ELSE}}Plain Text{{/IF}})
|
|
323
|
+
|
|
324
|
+
**Structured Logging Example:**
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"timestamp": "2024-01-20T10:30:00Z",
|
|
328
|
+
"level": "info",
|
|
329
|
+
"message": "User logged in successfully",
|
|
330
|
+
"context": {
|
|
331
|
+
"userId": "123",
|
|
332
|
+
"ip": "192.168.1.1",
|
|
333
|
+
"userAgent": "Mozilla/5.0..."
|
|
334
|
+
},
|
|
335
|
+
"requestId": "req-abc123",
|
|
336
|
+
"duration": 45
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Implementation:**
|
|
341
|
+
```{{LANGUAGE}}
|
|
342
|
+
{{LOGGING_IMPLEMENTATION_EXAMPLE}}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Log Context
|
|
346
|
+
|
|
347
|
+
**Always Include:**
|
|
348
|
+
- Request ID (for tracing)
|
|
349
|
+
- User ID (if authenticated)
|
|
350
|
+
- Timestamp
|
|
351
|
+
- Log level
|
|
352
|
+
- Message
|
|
353
|
+
|
|
354
|
+
**Optional Context:**
|
|
355
|
+
- IP address
|
|
356
|
+
- User agent
|
|
357
|
+
- Request path
|
|
358
|
+
- Response status
|
|
359
|
+
- Duration
|
|
360
|
+
- Error stack traces
|
|
361
|
+
|
|
362
|
+
### Logging Best Practices
|
|
363
|
+
|
|
364
|
+
✅ **DO:**
|
|
365
|
+
- Use structured logging (JSON format)
|
|
366
|
+
- Include request ID for tracing
|
|
367
|
+
- Log at appropriate levels
|
|
368
|
+
- Include relevant context
|
|
369
|
+
- Sanitize sensitive data (passwords, tokens, PII)
|
|
370
|
+
- Use correlation IDs across services
|
|
371
|
+
|
|
372
|
+
❌ **DON'T:**
|
|
373
|
+
- Log sensitive information (passwords, API keys, tokens)
|
|
374
|
+
- Log excessive data (full request/response bodies)
|
|
375
|
+
- Use console.log in production
|
|
376
|
+
- Log in tight loops
|
|
377
|
+
- Log PII without consent
|
|
378
|
+
|
|
379
|
+
### Log Aggregation
|
|
380
|
+
|
|
381
|
+
**Tool:** {{LOG_AGGREGATION_TOOL}}
|
|
382
|
+
|
|
383
|
+
**Retention:** {{LOG_RETENTION}} days
|
|
384
|
+
|
|
385
|
+
**Search:** {{LOG_SEARCH_TOOL}}
|
|
386
|
+
|
|
387
|
+
**Example Queries:**
|
|
388
|
+
```bash
|
|
389
|
+
# Find errors in last hour
|
|
390
|
+
{{LOG_ERROR_QUERY}}
|
|
391
|
+
|
|
392
|
+
# Find slow requests
|
|
393
|
+
{{LOG_SLOW_QUERY}}
|
|
394
|
+
|
|
395
|
+
# Find by request ID
|
|
396
|
+
{{LOG_REQUEST_ID_QUERY}}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 📝 Comments and Documentation
|
|
402
|
+
|
|
403
|
+
### When to Comment
|
|
404
|
+
|
|
405
|
+
✅ **DO comment:**
|
|
406
|
+
- Complex business logic
|
|
407
|
+
- Non-obvious algorithms
|
|
408
|
+
- Workarounds for bugs/limitations
|
|
409
|
+
- TODOs and FIXMEs
|
|
410
|
+
- Public API documentation
|
|
411
|
+
|
|
412
|
+
❌ **DON'T comment:**
|
|
413
|
+
- Obvious code
|
|
414
|
+
- What the code does (code should be self-explanatory)
|
|
415
|
+
- Outdated information
|
|
416
|
+
|
|
417
|
+
### Documentation Comments
|
|
418
|
+
|
|
419
|
+
**Format:** {{DOC_COMMENT_FORMAT}}
|
|
420
|
+
|
|
421
|
+
{{#IF JSDOC}}
|
|
422
|
+
**JSDoc Example:**
|
|
423
|
+
```typescript
|
|
424
|
+
/**
|
|
425
|
+
* Calculates the total price for an order including tax and discounts
|
|
426
|
+
*
|
|
427
|
+
* @param items - Array of order items
|
|
428
|
+
* @param taxRate - Tax rate as decimal (e.g., 0.15 for 15%)
|
|
429
|
+
* @param discountCode - Optional discount code
|
|
430
|
+
* @returns Total price in cents
|
|
431
|
+
* @throws {InvalidDiscountError} If discount code is invalid
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const total = calculateOrderTotal(items, 0.15, 'SAVE10');
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
async function calculateOrderTotal(
|
|
439
|
+
items: OrderItem[],
|
|
440
|
+
taxRate: number,
|
|
441
|
+
discountCode?: string
|
|
442
|
+
): Promise<number> {
|
|
443
|
+
// implementation
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
{{/IF}}
|
|
447
|
+
|
|
448
|
+
{{#IF PYTHON_DOCSTRING}}
|
|
449
|
+
**Python Docstring Example:**
|
|
450
|
+
```python
|
|
451
|
+
def calculate_order_total(
|
|
452
|
+
items: List[OrderItem],
|
|
453
|
+
tax_rate: float,
|
|
454
|
+
discount_code: Optional[str] = None
|
|
455
|
+
) -> int:
|
|
456
|
+
"""
|
|
457
|
+
Calculate the total price for an order including tax and discounts.
|
|
458
|
+
|
|
459
|
+
Args:
|
|
460
|
+
items: List of order items
|
|
461
|
+
tax_rate: Tax rate as decimal (e.g., 0.15 for 15%)
|
|
462
|
+
discount_code: Optional discount code
|
|
463
|
+
|
|
464
|
+
Returns:
|
|
465
|
+
Total price in cents
|
|
466
|
+
|
|
467
|
+
Raises:
|
|
468
|
+
InvalidDiscountError: If discount code is invalid
|
|
469
|
+
|
|
470
|
+
Example:
|
|
471
|
+
>>> total = calculate_order_total(items, 0.15, 'SAVE10')
|
|
472
|
+
>>> print(total)
|
|
473
|
+
1599
|
|
474
|
+
"""
|
|
475
|
+
# implementation
|
|
476
|
+
```
|
|
477
|
+
{{/IF}}
|
|
478
|
+
|
|
479
|
+
### Inline Comments
|
|
480
|
+
|
|
481
|
+
```{{LANGUAGE}}
|
|
482
|
+
// GOOD: Explains WHY
|
|
483
|
+
// Using exponential backoff to avoid overwhelming the API
|
|
484
|
+
await retryWithBackoff(apiCall, { maxAttempts: 3 });
|
|
485
|
+
|
|
486
|
+
// BAD: Explains WHAT (obvious from code)
|
|
487
|
+
// Loop through users
|
|
488
|
+
for (const user of users) {
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### TODO Comments
|
|
492
|
+
|
|
493
|
+
**Format:**
|
|
494
|
+
```{{LANGUAGE}}
|
|
495
|
+
// TODO(username): Description of what needs to be done
|
|
496
|
+
// FIXME(username): Description of bug that needs fixing
|
|
497
|
+
// HACK(username): Explanation of why this hack exists
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## 🧪 Code Quality Metrics
|
|
503
|
+
|
|
504
|
+
### Function Complexity
|
|
505
|
+
|
|
506
|
+
**Maximum Cyclomatic Complexity:** {{MAX_COMPLEXITY}}
|
|
507
|
+
|
|
508
|
+
**Maximum Function Length:** {{MAX_FUNCTION_LENGTH}} lines
|
|
509
|
+
|
|
510
|
+
**Maximum Parameters:** {{MAX_PARAMETERS}}
|
|
511
|
+
|
|
512
|
+
**Maximum Nesting Depth:** {{MAX_NESTING_DEPTH}} levels
|
|
513
|
+
|
|
514
|
+
### Class Complexity
|
|
515
|
+
|
|
516
|
+
**Maximum Class Length:** {{MAX_CLASS_LENGTH}} lines
|
|
517
|
+
|
|
518
|
+
**Maximum Methods per Class:** {{MAX_METHODS_PER_CLASS}}
|
|
519
|
+
|
|
520
|
+
### File Size
|
|
521
|
+
|
|
522
|
+
**Maximum File Length:** {{MAX_FILE_LENGTH}} lines
|
|
523
|
+
|
|
524
|
+
**When to split:** If file exceeds limit or has multiple responsibilities
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## ✅ Code Quality Rules
|
|
529
|
+
|
|
530
|
+
### Functions
|
|
531
|
+
|
|
532
|
+
- ✅ Functions should do ONE thing
|
|
533
|
+
- ✅ Use descriptive names (no abbreviations)
|
|
534
|
+
- ✅ Keep parameters to minimum (max {{MAX_PARAMETERS}})
|
|
535
|
+
- ✅ Use parameter objects for 4+ parameters
|
|
536
|
+
- ✅ Return early to avoid nesting
|
|
537
|
+
- ❌ No side effects in getters
|
|
538
|
+
- ❌ No Boolean parameters (use enums or separate methods)
|
|
539
|
+
|
|
540
|
+
**Example:**
|
|
541
|
+
```{{LANGUAGE}}
|
|
542
|
+
{{FUNCTION_QUALITY_EXAMPLE}}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Classes
|
|
546
|
+
|
|
547
|
+
- ✅ Single Responsibility Principle
|
|
548
|
+
- ✅ Open/Closed Principle
|
|
549
|
+
- ✅ Liskov Substitution Principle
|
|
550
|
+
- ✅ Interface Segregation Principle
|
|
551
|
+
- ✅ Dependency Inversion Principle
|
|
552
|
+
|
|
553
|
+
### DRY (Don't Repeat Yourself)
|
|
554
|
+
|
|
555
|
+
- ✅ Extract repeated code into functions
|
|
556
|
+
- ✅ Use loops instead of copy-paste
|
|
557
|
+
- ✅ Create utilities for common operations
|
|
558
|
+
- ❌ Copy-paste is a code smell
|
|
559
|
+
|
|
560
|
+
### KISS (Keep It Simple, Stupid)
|
|
561
|
+
|
|
562
|
+
- ✅ Simplest solution that works
|
|
563
|
+
- ✅ Avoid premature optimization
|
|
564
|
+
- ✅ Readable over clever
|
|
565
|
+
- ❌ Don't over-engineer
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
## 🔒 Security Coding Standards
|
|
570
|
+
|
|
571
|
+
### Input Validation
|
|
572
|
+
|
|
573
|
+
```{{LANGUAGE}}
|
|
574
|
+
{{INPUT_VALIDATION_EXAMPLE}}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### SQL Injection Prevention
|
|
578
|
+
|
|
579
|
+
```{{LANGUAGE}}
|
|
580
|
+
{{SQL_INJECTION_PREVENTION_EXAMPLE}}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### XSS Prevention
|
|
584
|
+
|
|
585
|
+
```{{LANGUAGE}}
|
|
586
|
+
{{XSS_PREVENTION_EXAMPLE}}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Secrets Management
|
|
590
|
+
|
|
591
|
+
```{{LANGUAGE}}
|
|
592
|
+
{{SECRETS_EXAMPLE}}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
## 🧹 Code Smell Detection
|
|
598
|
+
|
|
599
|
+
### Common Code Smells
|
|
600
|
+
|
|
601
|
+
| Smell | Description | Solution |
|
|
602
|
+
|-------|-------------|----------|
|
|
603
|
+
| Long Method | Function over {{MAX_FUNCTION_LENGTH}} lines | Extract methods |
|
|
604
|
+
| Large Class | Class over {{MAX_CLASS_LENGTH}} lines | Split responsibilities |
|
|
605
|
+
| Long Parameter List | More than {{MAX_PARAMETERS}} parameters | Use parameter object |
|
|
606
|
+
| Duplicate Code | Same code in multiple places | Extract to function/class |
|
|
607
|
+
| Dead Code | Unused code | Delete it |
|
|
608
|
+
| Magic Numbers | Unexplained constants | Use named constants |
|
|
609
|
+
| Nested Conditionals | Deep if/else nesting | Use early returns, guard clauses |
|
|
610
|
+
|
|
611
|
+
---
|
|
612
|
+
|
|
613
|
+
## 📦 Dependency Management
|
|
614
|
+
|
|
615
|
+
### Rules
|
|
616
|
+
|
|
617
|
+
- ✅ Keep dependencies up to date
|
|
618
|
+
- ✅ Review security vulnerabilities regularly
|
|
619
|
+
- ✅ Use exact versions in production
|
|
620
|
+
- ❌ Don't add dependencies for simple utilities
|
|
621
|
+
- ❌ Don't use deprecated packages
|
|
622
|
+
|
|
623
|
+
### Checking for Updates
|
|
624
|
+
|
|
625
|
+
```bash
|
|
626
|
+
{{DEPENDENCY_CHECK_COMMAND}}
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
### Security Audit
|
|
630
|
+
|
|
631
|
+
```bash
|
|
632
|
+
{{SECURITY_AUDIT_COMMAND}}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
---
|
|
636
|
+
|
|
637
|
+
## 🔧 Linting
|
|
638
|
+
|
|
639
|
+
**Tool:** {{LINTER}}
|
|
640
|
+
|
|
641
|
+
**Configuration:** `{{LINTER_CONFIG_FILE}}`
|
|
642
|
+
|
|
643
|
+
### Running Linter
|
|
644
|
+
|
|
645
|
+
```bash
|
|
646
|
+
# Check for issues
|
|
647
|
+
{{LINT_COMMAND}}
|
|
648
|
+
|
|
649
|
+
# Auto-fix issues
|
|
650
|
+
{{LINT_FIX_COMMAND}}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### Critical Rules
|
|
654
|
+
|
|
655
|
+
{{#EACH LINT_RULE}}
|
|
656
|
+
- **{{RULE_NAME}}**: {{RULE_DESCRIPTION}}
|
|
657
|
+
{{/EACH}}
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
## ✍️ Git Commit Standards
|
|
662
|
+
|
|
663
|
+
### Commit Message Format
|
|
664
|
+
|
|
665
|
+
**Standard:** {{COMMIT_STANDARD}}
|
|
666
|
+
|
|
667
|
+
{{#IF CONVENTIONAL_COMMITS}}
|
|
668
|
+
### Conventional Commits
|
|
669
|
+
|
|
670
|
+
**Format:**
|
|
671
|
+
```
|
|
672
|
+
<type>(<scope>): <subject>
|
|
673
|
+
|
|
674
|
+
<body>
|
|
675
|
+
|
|
676
|
+
<footer>
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
**Types:**
|
|
680
|
+
- `feat`: New feature
|
|
681
|
+
- `fix`: Bug fix
|
|
682
|
+
- `docs`: Documentation changes
|
|
683
|
+
- `style`: Code style changes (formatting, etc.)
|
|
684
|
+
- `refactor`: Code refactoring
|
|
685
|
+
- `test`: Adding/updating tests
|
|
686
|
+
- `chore`: Maintenance tasks
|
|
687
|
+
|
|
688
|
+
**Example:**
|
|
689
|
+
```
|
|
690
|
+
feat(auth): add JWT refresh token rotation
|
|
691
|
+
|
|
692
|
+
- Implement token rotation on every refresh request
|
|
693
|
+
- Store refresh tokens in Redis with expiration
|
|
694
|
+
- Add cleanup job for expired tokens
|
|
695
|
+
|
|
696
|
+
Closes #123
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
{{/IF}}
|
|
700
|
+
|
|
701
|
+
### Branch Naming
|
|
702
|
+
|
|
703
|
+
**Convention:** {{BRANCH_NAMING_CONVENTION}}
|
|
704
|
+
|
|
705
|
+
**Examples:**
|
|
706
|
+
```
|
|
707
|
+
{{BRANCH_NAMING_EXAMPLES}}
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
### Commit Size
|
|
711
|
+
|
|
712
|
+
- ✅ Small, focused commits
|
|
713
|
+
- ✅ One logical change per commit
|
|
714
|
+
- ❌ Don't mix refactoring with feature changes
|
|
715
|
+
- ❌ Don't commit broken code
|
|
716
|
+
|
|
717
|
+
---
|
|
718
|
+
|
|
719
|
+
## 📋 Code Review Checklist
|
|
720
|
+
|
|
721
|
+
### Before Requesting Review
|
|
722
|
+
|
|
723
|
+
- [ ] Code follows all standards in this document
|
|
724
|
+
- [ ] Tests written and passing ({{MIN_COVERAGE}}%+ coverage)
|
|
725
|
+
- [ ] No linting errors
|
|
726
|
+
- [ ] No console.logs or debugger statements
|
|
727
|
+
- [ ] Documentation updated (if needed)
|
|
728
|
+
- [ ] Self-reviewed the changes
|
|
729
|
+
- [ ] Commit messages follow standard
|
|
730
|
+
|
|
731
|
+
### Reviewer Checklist
|
|
732
|
+
|
|
733
|
+
- [ ] Code is understandable
|
|
734
|
+
- [ ] Logic is correct
|
|
735
|
+
- [ ] Edge cases are handled
|
|
736
|
+
- [ ] Error handling is appropriate
|
|
737
|
+
- [ ] Tests are comprehensive
|
|
738
|
+
- [ ] No security vulnerabilities
|
|
739
|
+
- [ ] Performance is acceptable
|
|
740
|
+
- [ ] Follows architecture patterns
|
|
741
|
+
|
|
742
|
+
---
|
|
743
|
+
|
|
744
|
+
## 🎯 Code Examples
|
|
745
|
+
|
|
746
|
+
### Controller Example
|
|
747
|
+
|
|
748
|
+
```{{LANGUAGE}}
|
|
749
|
+
{{CONTROLLER_EXAMPLE}}
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
### Service Example
|
|
753
|
+
|
|
754
|
+
```{{LANGUAGE}}
|
|
755
|
+
{{SERVICE_EXAMPLE}}
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### Repository Example
|
|
759
|
+
|
|
760
|
+
```{{LANGUAGE}}
|
|
761
|
+
{{REPOSITORY_EXAMPLE}}
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
### DTO Example
|
|
765
|
+
|
|
766
|
+
```{{LANGUAGE}}
|
|
767
|
+
{{DTO_EXAMPLE}}
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
### Test Example
|
|
771
|
+
|
|
772
|
+
```{{LANGUAGE}}
|
|
773
|
+
{{TEST_EXAMPLE}}
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
---
|
|
777
|
+
|
|
778
|
+
## 🚀 Performance Guidelines
|
|
779
|
+
|
|
780
|
+
### Database
|
|
781
|
+
|
|
782
|
+
- ✅ Use indexes on foreign keys and frequently queried columns
|
|
783
|
+
- ✅ Use `select` to specify columns, not `SELECT *`
|
|
784
|
+
- ✅ Use pagination for large result sets
|
|
785
|
+
- ✅ Use database transactions for multi-step operations
|
|
786
|
+
- ❌ Avoid N+1 queries (use joins or batch queries)
|
|
787
|
+
- ❌ Don't query in loops
|
|
788
|
+
|
|
789
|
+
### API
|
|
790
|
+
|
|
791
|
+
- ✅ Implement caching for expensive operations
|
|
792
|
+
- ✅ Use compression for large responses
|
|
793
|
+
- ✅ Implement rate limiting
|
|
794
|
+
- ✅ Use async/await for I/O operations
|
|
795
|
+
- ❌ Don't block the event loop (Node.js)
|
|
796
|
+
- ❌ Don't return excessive data
|
|
797
|
+
|
|
798
|
+
### Memory
|
|
799
|
+
|
|
800
|
+
- ✅ Clean up event listeners
|
|
801
|
+
- ✅ Close database connections
|
|
802
|
+
- ✅ Stream large files
|
|
803
|
+
- ❌ Don't load entire files into memory
|
|
804
|
+
- ❌ Don't create memory leaks
|
|
805
|
+
|
|
806
|
+
---
|
|
807
|
+
|
|
808
|
+
## 📚 Resources
|
|
809
|
+
|
|
810
|
+
### Official Docs
|
|
811
|
+
|
|
812
|
+
{{#EACH OFFICIAL_DOC}}
|
|
813
|
+
- [{{DOC_NAME}}]({{DOC_URL}})
|
|
814
|
+
{{/EACH}}
|
|
815
|
+
|
|
816
|
+
### Style Guides
|
|
817
|
+
|
|
818
|
+
{{#EACH STYLE_GUIDE}}
|
|
819
|
+
- [{{GUIDE_NAME}}]({{GUIDE_URL}})
|
|
820
|
+
{{/EACH}}
|
|
821
|
+
|
|
822
|
+
---
|
|
823
|
+
|
|
824
|
+
**Document Version:** 1.0
|
|
825
|
+
|
|
826
|
+
**Last Updated:** {{GENERATION_DATE}}
|
|
827
|
+
|
|
828
|
+
**Generated by:** AI Flow v1.0.0
|