agentic-team-templates 0.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.
- package/README.md +280 -0
- package/bin/cli.js +5 -0
- package/package.json +47 -0
- package/src/index.js +521 -0
- package/templates/_shared/code-quality.md +162 -0
- package/templates/_shared/communication.md +114 -0
- package/templates/_shared/core-principles.md +62 -0
- package/templates/_shared/git-workflow.md +165 -0
- package/templates/_shared/security-fundamentals.md +173 -0
- package/templates/blockchain/.cursorrules/defi-patterns.md +520 -0
- package/templates/blockchain/.cursorrules/gas-optimization.md +339 -0
- package/templates/blockchain/.cursorrules/overview.md +130 -0
- package/templates/blockchain/.cursorrules/security.md +318 -0
- package/templates/blockchain/.cursorrules/smart-contracts.md +364 -0
- package/templates/blockchain/.cursorrules/testing.md +415 -0
- package/templates/blockchain/.cursorrules/web3-integration.md +538 -0
- package/templates/blockchain/CLAUDE.md +389 -0
- package/templates/cli-tools/.cursorrules/architecture.md +412 -0
- package/templates/cli-tools/.cursorrules/arguments.md +406 -0
- package/templates/cli-tools/.cursorrules/distribution.md +546 -0
- package/templates/cli-tools/.cursorrules/error-handling.md +455 -0
- package/templates/cli-tools/.cursorrules/overview.md +136 -0
- package/templates/cli-tools/.cursorrules/testing.md +537 -0
- package/templates/cli-tools/.cursorrules/user-experience.md +545 -0
- package/templates/cli-tools/CLAUDE.md +356 -0
- package/templates/data-engineering/.cursorrules/data-modeling.md +367 -0
- package/templates/data-engineering/.cursorrules/data-quality.md +455 -0
- package/templates/data-engineering/.cursorrules/overview.md +85 -0
- package/templates/data-engineering/.cursorrules/performance.md +339 -0
- package/templates/data-engineering/.cursorrules/pipeline-design.md +280 -0
- package/templates/data-engineering/.cursorrules/security.md +460 -0
- package/templates/data-engineering/.cursorrules/testing.md +452 -0
- package/templates/data-engineering/CLAUDE.md +974 -0
- package/templates/devops-sre/.cursorrules/capacity-planning.md +653 -0
- package/templates/devops-sre/.cursorrules/change-management.md +584 -0
- package/templates/devops-sre/.cursorrules/chaos-engineering.md +651 -0
- package/templates/devops-sre/.cursorrules/disaster-recovery.md +641 -0
- package/templates/devops-sre/.cursorrules/incident-management.md +565 -0
- package/templates/devops-sre/.cursorrules/observability.md +714 -0
- package/templates/devops-sre/.cursorrules/overview.md +230 -0
- package/templates/devops-sre/.cursorrules/postmortems.md +588 -0
- package/templates/devops-sre/.cursorrules/runbooks.md +760 -0
- package/templates/devops-sre/.cursorrules/slo-sli.md +617 -0
- package/templates/devops-sre/.cursorrules/toil-reduction.md +567 -0
- package/templates/devops-sre/CLAUDE.md +1007 -0
- package/templates/documentation/.cursorrules/adr.md +277 -0
- package/templates/documentation/.cursorrules/api-documentation.md +411 -0
- package/templates/documentation/.cursorrules/code-comments.md +253 -0
- package/templates/documentation/.cursorrules/maintenance.md +260 -0
- package/templates/documentation/.cursorrules/overview.md +82 -0
- package/templates/documentation/.cursorrules/readme-standards.md +306 -0
- package/templates/documentation/CLAUDE.md +120 -0
- package/templates/fullstack/.cursorrules/api-contracts.md +331 -0
- package/templates/fullstack/.cursorrules/architecture.md +298 -0
- package/templates/fullstack/.cursorrules/overview.md +109 -0
- package/templates/fullstack/.cursorrules/shared-types.md +348 -0
- package/templates/fullstack/.cursorrules/testing.md +386 -0
- package/templates/fullstack/CLAUDE.md +349 -0
- package/templates/ml-ai/.cursorrules/data-engineering.md +483 -0
- package/templates/ml-ai/.cursorrules/deployment.md +601 -0
- package/templates/ml-ai/.cursorrules/model-development.md +538 -0
- package/templates/ml-ai/.cursorrules/monitoring.md +658 -0
- package/templates/ml-ai/.cursorrules/overview.md +131 -0
- package/templates/ml-ai/.cursorrules/security.md +637 -0
- package/templates/ml-ai/.cursorrules/testing.md +678 -0
- package/templates/ml-ai/CLAUDE.md +1136 -0
- package/templates/mobile/.cursorrules/navigation.md +246 -0
- package/templates/mobile/.cursorrules/offline-first.md +302 -0
- package/templates/mobile/.cursorrules/overview.md +71 -0
- package/templates/mobile/.cursorrules/performance.md +345 -0
- package/templates/mobile/.cursorrules/testing.md +339 -0
- package/templates/mobile/CLAUDE.md +233 -0
- package/templates/platform-engineering/.cursorrules/ci-cd.md +778 -0
- package/templates/platform-engineering/.cursorrules/developer-experience.md +632 -0
- package/templates/platform-engineering/.cursorrules/infrastructure-as-code.md +600 -0
- package/templates/platform-engineering/.cursorrules/kubernetes.md +710 -0
- package/templates/platform-engineering/.cursorrules/observability.md +747 -0
- package/templates/platform-engineering/.cursorrules/overview.md +215 -0
- package/templates/platform-engineering/.cursorrules/security.md +855 -0
- package/templates/platform-engineering/.cursorrules/testing.md +878 -0
- package/templates/platform-engineering/CLAUDE.md +850 -0
- package/templates/utility-agent/.cursorrules/action-control.md +284 -0
- package/templates/utility-agent/.cursorrules/context-management.md +186 -0
- package/templates/utility-agent/.cursorrules/hallucination-prevention.md +253 -0
- package/templates/utility-agent/.cursorrules/overview.md +78 -0
- package/templates/utility-agent/.cursorrules/token-optimization.md +369 -0
- package/templates/utility-agent/CLAUDE.md +513 -0
- package/templates/web-backend/.cursorrules/api-design.md +255 -0
- package/templates/web-backend/.cursorrules/authentication.md +309 -0
- package/templates/web-backend/.cursorrules/database-patterns.md +298 -0
- package/templates/web-backend/.cursorrules/error-handling.md +366 -0
- package/templates/web-backend/.cursorrules/overview.md +69 -0
- package/templates/web-backend/.cursorrules/security.md +358 -0
- package/templates/web-backend/.cursorrules/testing.md +395 -0
- package/templates/web-backend/CLAUDE.md +366 -0
- package/templates/web-frontend/.cursorrules/accessibility.md +296 -0
- package/templates/web-frontend/.cursorrules/component-patterns.md +204 -0
- package/templates/web-frontend/.cursorrules/overview.md +72 -0
- package/templates/web-frontend/.cursorrules/performance.md +325 -0
- package/templates/web-frontend/.cursorrules/state-management.md +227 -0
- package/templates/web-frontend/.cursorrules/styling.md +271 -0
- package/templates/web-frontend/.cursorrules/testing.md +311 -0
- package/templates/web-frontend/CLAUDE.md +399 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# Fullstack Development Guide
|
|
2
|
+
|
|
3
|
+
Comprehensive guidelines for building cohesive full-stack web applications.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This guide applies to:
|
|
10
|
+
- Monolithic full-stack applications
|
|
11
|
+
- Full-stack frameworks (Next.js, Nuxt, SvelteKit, Remix)
|
|
12
|
+
- Separate frontend/backend codebases sharing types
|
|
13
|
+
- JAMstack with serverless backends
|
|
14
|
+
|
|
15
|
+
### Key Principles
|
|
16
|
+
|
|
17
|
+
1. **Unified Type System** - Share types between frontend and backend
|
|
18
|
+
2. **Clear Boundaries** - Maintain separation between client and server
|
|
19
|
+
3. **API-First Thinking** - Design the contract first
|
|
20
|
+
4. **End-to-End Testing** - Test the full user journey
|
|
21
|
+
|
|
22
|
+
### Project Structure
|
|
23
|
+
|
|
24
|
+
**Monorepo:**
|
|
25
|
+
```
|
|
26
|
+
packages/
|
|
27
|
+
├── shared/ # Shared types, validation, utilities
|
|
28
|
+
├── web/ # Frontend application
|
|
29
|
+
├── api/ # Backend API
|
|
30
|
+
└── e2e/ # End-to-end tests
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Full-Stack Framework:**
|
|
34
|
+
```
|
|
35
|
+
src/
|
|
36
|
+
├── app/ # Pages and routing
|
|
37
|
+
├── components/ # React components
|
|
38
|
+
├── lib/
|
|
39
|
+
│ ├── client/ # Client-only code
|
|
40
|
+
│ ├── server/ # Server-only code
|
|
41
|
+
│ └── shared/ # Isomorphic code
|
|
42
|
+
└── types/ # TypeScript definitions
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Architecture
|
|
48
|
+
|
|
49
|
+
### Architectural Layers
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
Presentation → Application → Domain ← Infrastructure
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- **Presentation**: Components, pages, UI
|
|
56
|
+
- **Application**: Route handlers, request validation
|
|
57
|
+
- **Domain**: Business rules, pure functions
|
|
58
|
+
- **Infrastructure**: Database, external APIs
|
|
59
|
+
|
|
60
|
+
### Server vs Client Components
|
|
61
|
+
|
|
62
|
+
**Server Components** (default):
|
|
63
|
+
```tsx
|
|
64
|
+
// Direct database access, no interactivity
|
|
65
|
+
export default async function UsersPage() {
|
|
66
|
+
const users = await db.user.findMany();
|
|
67
|
+
return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Client Components**:
|
|
72
|
+
```tsx
|
|
73
|
+
'use client';
|
|
74
|
+
// Interactivity, hooks, browser APIs
|
|
75
|
+
export function UserForm({ onSubmit }) {
|
|
76
|
+
const [name, setName] = useState('');
|
|
77
|
+
return <form onSubmit={...}>...</form>;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Data Flow
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
User Action → Component → API Request → Server Handler
|
|
85
|
+
↓ ↓
|
|
86
|
+
UI Update ← State ← API Response ← Database
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## API Contracts
|
|
92
|
+
|
|
93
|
+
### Schema-Driven Development
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
// shared/schemas/user.ts
|
|
97
|
+
import { z } from 'zod';
|
|
98
|
+
|
|
99
|
+
export const CreateUserSchema = z.object({
|
|
100
|
+
email: z.string().email(),
|
|
101
|
+
name: z.string().min(1).max(100),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const UserResponseSchema = z.object({
|
|
105
|
+
id: z.string(),
|
|
106
|
+
email: z.string(),
|
|
107
|
+
name: z.string(),
|
|
108
|
+
createdAt: z.string().datetime(),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export type CreateUserRequest = z.infer<typeof CreateUserSchema>;
|
|
112
|
+
export type UserResponse = z.infer<typeof UserResponseSchema>;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Use on Backend
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
app.post('/users', async (req, res) => {
|
|
119
|
+
const result = CreateUserSchema.safeParse(req.body);
|
|
120
|
+
if (!result.success) {
|
|
121
|
+
return res.status(422).json({ error: result.error });
|
|
122
|
+
}
|
|
123
|
+
const user = await createUser(result.data);
|
|
124
|
+
res.status(201).json({ data: user });
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Use on Frontend
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
export const usersApi = {
|
|
132
|
+
async create(data: CreateUserRequest): Promise<UserResponse> {
|
|
133
|
+
const validated = CreateUserSchema.parse(data);
|
|
134
|
+
const response = await fetch('/api/users', {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
body: JSON.stringify(validated),
|
|
137
|
+
});
|
|
138
|
+
return (await response.json()).data;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Shared Types
|
|
146
|
+
|
|
147
|
+
### Monorepo Setup
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// packages/shared/src/types/user.ts
|
|
151
|
+
export interface User {
|
|
152
|
+
id: string;
|
|
153
|
+
email: string;
|
|
154
|
+
name: string;
|
|
155
|
+
createdAt: Date;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type CreateUserInput = Omit<User, 'id' | 'createdAt'>;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Using Shared Types
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// In API
|
|
165
|
+
import { User, CreateUserInput } from '@myapp/shared';
|
|
166
|
+
|
|
167
|
+
// In Web
|
|
168
|
+
import { User, CreateUserInput } from '@myapp/shared';
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Validation Schemas
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// shared/validation/user.ts
|
|
175
|
+
export const CreateUserSchema = z.object({
|
|
176
|
+
email: z.string().email(),
|
|
177
|
+
name: z.string().min(1),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export type CreateUserInput = z.infer<typeof CreateUserSchema>;
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Error Types
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
export const ErrorCode = {
|
|
187
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
188
|
+
NOT_FOUND: 'NOT_FOUND',
|
|
189
|
+
UNAUTHORIZED: 'UNAUTHORIZED',
|
|
190
|
+
} as const;
|
|
191
|
+
|
|
192
|
+
export type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## State Synchronization
|
|
198
|
+
|
|
199
|
+
### Optimistic Updates
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
'use client';
|
|
203
|
+
import { useOptimistic } from 'react';
|
|
204
|
+
|
|
205
|
+
export function TodoList({ todos, addTodo }) {
|
|
206
|
+
const [optimisticTodos, addOptimisticTodo] = useOptimistic(
|
|
207
|
+
todos,
|
|
208
|
+
(state, newTodo) => [...state, newTodo]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
async function handleAdd(formData) {
|
|
212
|
+
addOptimisticTodo({ id: 'temp', title: formData.get('title') });
|
|
213
|
+
await addTodo(formData);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Cache Invalidation
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import { revalidatePath, revalidateTag } from 'next/cache';
|
|
222
|
+
|
|
223
|
+
export async function updateUser(id: string, data) {
|
|
224
|
+
await db.user.update({ where: { id }, data });
|
|
225
|
+
revalidatePath(`/users/${id}`);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Testing
|
|
232
|
+
|
|
233
|
+
### Testing Pyramid
|
|
234
|
+
|
|
235
|
+
1. **E2E Tests**: Critical user flows
|
|
236
|
+
2. **Integration Tests**: API + DB, components + API
|
|
237
|
+
3. **Unit Tests**: Pure functions, isolated logic
|
|
238
|
+
|
|
239
|
+
### E2E Tests
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
test('user can sign up and access dashboard', async ({ page }) => {
|
|
243
|
+
await page.goto('/signup');
|
|
244
|
+
await page.fill('[name="email"]', 'test@example.com');
|
|
245
|
+
await page.fill('[name="password"]', 'SecurePass123!');
|
|
246
|
+
await page.click('button[type="submit"]');
|
|
247
|
+
|
|
248
|
+
await expect(page).toHaveURL('/dashboard');
|
|
249
|
+
await expect(page.locator('text=Welcome')).toBeVisible();
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Integration Tests
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
describe('User Management', () => {
|
|
257
|
+
it('creates user and returns in list', async () => {
|
|
258
|
+
const createRes = await request(app)
|
|
259
|
+
.post('/api/users')
|
|
260
|
+
.send({ email: 'new@example.com', name: 'New User' });
|
|
261
|
+
|
|
262
|
+
expect(createRes.status).toBe(201);
|
|
263
|
+
|
|
264
|
+
const listRes = await request(app).get('/api/users');
|
|
265
|
+
expect(listRes.body.data).toContainEqual(
|
|
266
|
+
expect.objectContaining({ email: 'new@example.com' })
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Contract Tests
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
describe('User API Contract', () => {
|
|
276
|
+
it('returns valid UserResponse', async () => {
|
|
277
|
+
const response = await request(app).get('/api/users');
|
|
278
|
+
|
|
279
|
+
for (const user of response.body.data) {
|
|
280
|
+
const result = UserResponseSchema.safeParse(user);
|
|
281
|
+
expect(result.success).toBe(true);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Test Data Factories
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import { faker } from '@faker-js/faker';
|
|
291
|
+
|
|
292
|
+
export const createUserInput = (overrides?) => ({
|
|
293
|
+
email: faker.internet.email(),
|
|
294
|
+
name: faker.person.fullName(),
|
|
295
|
+
...overrides,
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Error Handling
|
|
302
|
+
|
|
303
|
+
### Server-Side
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
export async function GET(request, { params }) {
|
|
307
|
+
const user = await db.user.findUnique({ where: { id: params.id } });
|
|
308
|
+
|
|
309
|
+
if (!user) {
|
|
310
|
+
return NextResponse.json(
|
|
311
|
+
{ error: { code: 'NOT_FOUND', message: 'User not found' } },
|
|
312
|
+
{ status: 404 }
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return NextResponse.json({ data: user });
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Client-Side
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
export function UserProfile({ userId }) {
|
|
324
|
+
const { data, error, isLoading } = useQuery(['user', userId], () =>
|
|
325
|
+
fetch(`/api/users/${userId}`).then(res => res.json())
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
if (isLoading) return <Skeleton />;
|
|
329
|
+
if (error) return <ErrorMessage error={error} />;
|
|
330
|
+
return <UserCard user={data.data} />;
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Definition of Done
|
|
337
|
+
|
|
338
|
+
A fullstack feature is complete when:
|
|
339
|
+
|
|
340
|
+
- [ ] Types shared between frontend and backend
|
|
341
|
+
- [ ] API contract documented
|
|
342
|
+
- [ ] Frontend renders correctly
|
|
343
|
+
- [ ] Backend handles all edge cases
|
|
344
|
+
- [ ] Validation consistent on both sides
|
|
345
|
+
- [ ] Loading and error states handled
|
|
346
|
+
- [ ] E2E tests cover critical paths
|
|
347
|
+
- [ ] No TypeScript errors
|
|
348
|
+
- [ ] Performance acceptable
|
|
349
|
+
- [ ] Code reviewed and approved
|