@brainst0rm/core 0.13.0 → 0.14.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/dist/chunk-M7BBX56R.js +340 -0
- package/dist/chunk-M7BBX56R.js.map +1 -0
- package/dist/{chunk-SWXTFHC7.js → chunk-Z5D2QZY6.js} +3 -3
- package/dist/chunk-Z5D2QZY6.js.map +1 -0
- package/dist/chunk-Z6ZWNWWR.js +34 -0
- package/dist/index.d.ts +2717 -188
- package/dist/index.js +16178 -7949
- package/dist/index.js.map +1 -1
- package/dist/self-extend-47LWSK3E.js +52 -0
- package/dist/self-extend-47LWSK3E.js.map +1 -0
- package/dist/skills/builtin/api-and-interface-design/SKILL.md +300 -0
- package/dist/skills/builtin/browser-testing-with-devtools/SKILL.md +307 -0
- package/dist/skills/builtin/ci-cd-and-automation/SKILL.md +391 -0
- package/dist/skills/builtin/code-review-and-quality/SKILL.md +353 -0
- package/dist/skills/builtin/code-simplification/SKILL.md +340 -0
- package/dist/skills/builtin/context-engineering/SKILL.md +301 -0
- package/dist/skills/builtin/daemon-operations/SKILL.md +55 -0
- package/dist/skills/builtin/debugging-and-error-recovery/SKILL.md +306 -0
- package/dist/skills/builtin/deprecation-and-migration/SKILL.md +207 -0
- package/dist/skills/builtin/documentation-and-adrs/SKILL.md +295 -0
- package/dist/skills/builtin/frontend-ui-engineering/SKILL.md +333 -0
- package/dist/skills/builtin/git-workflow-and-versioning/SKILL.md +303 -0
- package/dist/skills/builtin/github-collaboration/SKILL.md +215 -0
- package/dist/skills/builtin/godmode-operations/SKILL.md +68 -0
- package/dist/skills/builtin/idea-refine/SKILL.md +186 -0
- package/dist/skills/builtin/idea-refine/examples.md +244 -0
- package/dist/skills/builtin/idea-refine/frameworks.md +101 -0
- package/dist/skills/builtin/idea-refine/refinement-criteria.md +126 -0
- package/dist/skills/builtin/idea-refine/scripts/idea-refine.sh +15 -0
- package/dist/skills/builtin/incremental-implementation/SKILL.md +243 -0
- package/dist/skills/builtin/memory-init/SKILL.md +54 -0
- package/dist/skills/builtin/memory-reflection/SKILL.md +59 -0
- package/dist/skills/builtin/multi-model-routing/SKILL.md +56 -0
- package/dist/skills/builtin/performance-optimization/SKILL.md +291 -0
- package/dist/skills/builtin/planning-and-task-breakdown/SKILL.md +240 -0
- package/dist/skills/builtin/security-and-hardening/SKILL.md +368 -0
- package/dist/skills/builtin/shipping-and-launch/SKILL.md +310 -0
- package/dist/skills/builtin/spec-driven-development/SKILL.md +212 -0
- package/dist/skills/builtin/test-driven-development/SKILL.md +376 -0
- package/dist/skills/builtin/using-agent-skills/SKILL.md +173 -0
- package/dist/trajectory-analyzer-ZAI2XUAI.js +14 -0
- package/dist/{trajectory-capture-RF7TUN6I.js → trajectory-capture-ERPIVYQJ.js} +3 -3
- package/package.json +14 -11
- package/dist/chunk-OU3NPQBH.js +0 -87
- package/dist/chunk-OU3NPQBH.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-SWXTFHC7.js.map +0 -1
- package/dist/trajectory-MOCIJBV6.js +0 -8
- /package/dist/{chunk-PZ5AY32C.js.map → chunk-Z6ZWNWWR.js.map} +0 -0
- /package/dist/{trajectory-MOCIJBV6.js.map → trajectory-analyzer-ZAI2XUAI.js.map} +0 -0
- /package/dist/{trajectory-capture-RF7TUN6I.js.map → trajectory-capture-ERPIVYQJ.js.map} +0 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance-optimization
|
|
3
|
+
description: Optimizes application performance. Use when performance requirements exist, when you suspect performance regressions, or when Core Web Vitals or load times need improvement. Use when profiling reveals bottlenecks that need fixing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Performance Optimization
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Measure before optimizing. Performance work without measurement is guessing — and guessing leads to premature optimization that adds complexity without improving what matters. Profile first, identify the actual bottleneck, fix it, measure again. Optimize only what measurements prove matters.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Performance requirements exist in the spec (load time budgets, response time SLAs)
|
|
15
|
+
- Users or monitoring report slow behavior
|
|
16
|
+
- Core Web Vitals scores are below thresholds
|
|
17
|
+
- You suspect a change introduced a regression
|
|
18
|
+
- Building features that handle large datasets or high traffic
|
|
19
|
+
|
|
20
|
+
**When NOT to use:** Don't optimize before you have evidence of a problem. Premature optimization adds complexity that costs more than the performance it gains.
|
|
21
|
+
|
|
22
|
+
## Core Web Vitals Targets
|
|
23
|
+
|
|
24
|
+
| Metric | Good | Needs Improvement | Poor |
|
|
25
|
+
| ----------------------------------- | ------- | ----------------- | ------- |
|
|
26
|
+
| **LCP** (Largest Contentful Paint) | ≤ 2.5s | ≤ 4.0s | > 4.0s |
|
|
27
|
+
| **INP** (Interaction to Next Paint) | ≤ 200ms | ≤ 500ms | > 500ms |
|
|
28
|
+
| **CLS** (Cumulative Layout Shift) | ≤ 0.1 | ≤ 0.25 | > 0.25 |
|
|
29
|
+
|
|
30
|
+
## The Optimization Workflow
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
1. MEASURE → Establish baseline with real data
|
|
34
|
+
2. IDENTIFY → Find the actual bottleneck (not assumed)
|
|
35
|
+
3. FIX → Address the specific bottleneck
|
|
36
|
+
4. VERIFY → Measure again, confirm improvement
|
|
37
|
+
5. GUARD → Add monitoring or tests to prevent regression
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step 1: Measure
|
|
41
|
+
|
|
42
|
+
**Frontend:**
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Lighthouse in Chrome DevTools (or CI)
|
|
46
|
+
# Chrome DevTools → Performance tab → Record
|
|
47
|
+
# Chrome DevTools MCP → Performance trace
|
|
48
|
+
|
|
49
|
+
# Web Vitals library in code
|
|
50
|
+
import { onLCP, onINP, onCLS } from 'web-vitals';
|
|
51
|
+
|
|
52
|
+
onLCP(console.log);
|
|
53
|
+
onINP(console.log);
|
|
54
|
+
onCLS(console.log);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Backend:**
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Response time logging
|
|
61
|
+
# Application Performance Monitoring (APM)
|
|
62
|
+
# Database query logging with timing
|
|
63
|
+
|
|
64
|
+
# Simple timing
|
|
65
|
+
console.time('db-query');
|
|
66
|
+
const result = await db.query(...);
|
|
67
|
+
console.timeEnd('db-query');
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Where to Start Measuring
|
|
71
|
+
|
|
72
|
+
Use the symptom to decide what to measure first:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
What is slow?
|
|
76
|
+
├── First page load
|
|
77
|
+
│ ├── Large bundle? --> Measure bundle size, check code splitting
|
|
78
|
+
│ ├── Slow server response? --> Measure TTFB, check API/database
|
|
79
|
+
│ └── Render-blocking resources? --> Check network waterfall for CSS/JS blocking
|
|
80
|
+
├── Interaction feels sluggish
|
|
81
|
+
│ ├── UI freezes on click? --> Profile main thread, look for long tasks (>50ms)
|
|
82
|
+
│ ├── Form input lag? --> Check re-renders, controlled component overhead
|
|
83
|
+
│ └── Animation jank? --> Check layout thrashing, forced reflows
|
|
84
|
+
├── Page after navigation
|
|
85
|
+
│ ├── Data loading? --> Measure API response times, check for waterfalls
|
|
86
|
+
│ └── Client rendering? --> Profile component render time, check for N+1 fetches
|
|
87
|
+
└── Backend / API
|
|
88
|
+
├── Single endpoint slow? --> Profile database queries, check indexes
|
|
89
|
+
├── All endpoints slow? --> Check connection pool, memory, CPU
|
|
90
|
+
└── Intermittent slowness? --> Check for lock contention, GC pauses, external deps
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Step 2: Identify the Bottleneck
|
|
94
|
+
|
|
95
|
+
Common bottlenecks by category:
|
|
96
|
+
|
|
97
|
+
**Frontend:**
|
|
98
|
+
|
|
99
|
+
| Symptom | Likely Cause | Investigation |
|
|
100
|
+
| ----------------- | ------------------------------------------------------------ | ------------------------------------- |
|
|
101
|
+
| Slow LCP | Large images, render-blocking resources, slow server | Check network waterfall, image sizes |
|
|
102
|
+
| High CLS | Images without dimensions, late-loading content, font shifts | Check layout shift attribution |
|
|
103
|
+
| Poor INP | Heavy JavaScript on main thread, large DOM updates | Check long tasks in Performance trace |
|
|
104
|
+
| Slow initial load | Large bundle, many network requests | Check bundle size, code splitting |
|
|
105
|
+
|
|
106
|
+
**Backend:**
|
|
107
|
+
|
|
108
|
+
| Symptom | Likely Cause | Investigation |
|
|
109
|
+
| ------------------ | ---------------------------------------------------- | -------------------------------- |
|
|
110
|
+
| Slow API responses | N+1 queries, missing indexes, unoptimized queries | Check database query log |
|
|
111
|
+
| Memory growth | Leaked references, unbounded caches, large payloads | Heap snapshot analysis |
|
|
112
|
+
| CPU spikes | Synchronous heavy computation, regex backtracking | CPU profiling |
|
|
113
|
+
| High latency | Missing caching, redundant computation, network hops | Trace requests through the stack |
|
|
114
|
+
|
|
115
|
+
### Step 3: Fix Common Anti-Patterns
|
|
116
|
+
|
|
117
|
+
#### N+1 Queries (Backend)
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// BAD: N+1 — one query per task for the owner
|
|
121
|
+
const tasks = await db.tasks.findMany();
|
|
122
|
+
for (const task of tasks) {
|
|
123
|
+
task.owner = await db.users.findUnique({ where: { id: task.ownerId } });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// GOOD: Single query with join/include
|
|
127
|
+
const tasks = await db.tasks.findMany({
|
|
128
|
+
include: { owner: true },
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Unbounded Data Fetching
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// BAD: Fetching all records
|
|
136
|
+
const allTasks = await db.tasks.findMany();
|
|
137
|
+
|
|
138
|
+
// GOOD: Paginated with limits
|
|
139
|
+
const tasks = await db.tasks.findMany({
|
|
140
|
+
take: 20,
|
|
141
|
+
skip: (page - 1) * 20,
|
|
142
|
+
orderBy: { createdAt: "desc" },
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Missing Image Optimization (Frontend)
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<!-- BAD: No dimensions, no lazy loading, no responsive sizes -->
|
|
150
|
+
<img src="/hero.jpg" />
|
|
151
|
+
|
|
152
|
+
<!-- GOOD: Responsive, lazy-loaded, properly sized -->
|
|
153
|
+
<img
|
|
154
|
+
src="/hero.jpg"
|
|
155
|
+
srcset="/hero-400.webp 400w, /hero-800.webp 800w, /hero-1200.webp 1200w"
|
|
156
|
+
sizes="(max-width: 768px) 100vw, 50vw"
|
|
157
|
+
width="1200"
|
|
158
|
+
height="600"
|
|
159
|
+
loading="lazy"
|
|
160
|
+
alt="Hero image description"
|
|
161
|
+
/>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Unnecessary Re-renders (React)
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
// BAD: Creates new object on every render, causing children to re-render
|
|
168
|
+
function TaskList() {
|
|
169
|
+
return <TaskFilters options={{ sortBy: "date", order: "desc" }} />;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// GOOD: Stable reference
|
|
173
|
+
const DEFAULT_OPTIONS = { sortBy: "date", order: "desc" } as const;
|
|
174
|
+
function TaskList() {
|
|
175
|
+
return <TaskFilters options={DEFAULT_OPTIONS} />;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Use React.memo for expensive components
|
|
179
|
+
const TaskItem = React.memo(function TaskItem({ task }: Props) {
|
|
180
|
+
return <div>{/* expensive render */}</div>;
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Use useMemo for expensive computations
|
|
184
|
+
function TaskStats({ tasks }: Props) {
|
|
185
|
+
const stats = useMemo(() => calculateStats(tasks), [tasks]);
|
|
186
|
+
return (
|
|
187
|
+
<div>
|
|
188
|
+
{stats.completed} / {stats.total}
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Large Bundle Size
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// BAD: Importing entire library
|
|
198
|
+
import { format } from "date-fns";
|
|
199
|
+
|
|
200
|
+
// GOOD: Tree-shakable import (if the library supports it)
|
|
201
|
+
import { format } from "date-fns/format";
|
|
202
|
+
|
|
203
|
+
// GOOD: Dynamic import for heavy, rarely-used features
|
|
204
|
+
const ChartLibrary = lazy(() => import("./ChartLibrary"));
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### Missing Caching (Backend)
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// Cache frequently-read, rarely-changed data
|
|
211
|
+
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
212
|
+
let cachedConfig: AppConfig | null = null;
|
|
213
|
+
let cacheExpiry = 0;
|
|
214
|
+
|
|
215
|
+
async function getAppConfig(): Promise<AppConfig> {
|
|
216
|
+
if (cachedConfig && Date.now() < cacheExpiry) {
|
|
217
|
+
return cachedConfig;
|
|
218
|
+
}
|
|
219
|
+
cachedConfig = await db.config.findFirst();
|
|
220
|
+
cacheExpiry = Date.now() + CACHE_TTL;
|
|
221
|
+
return cachedConfig;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// HTTP caching headers for static assets
|
|
225
|
+
app.use(
|
|
226
|
+
"/static",
|
|
227
|
+
express.static("public", {
|
|
228
|
+
maxAge: "1y", // Cache for 1 year
|
|
229
|
+
immutable: true, // Never revalidate (use content hashing in filenames)
|
|
230
|
+
}),
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// Cache-Control for API responses
|
|
234
|
+
res.set("Cache-Control", "public, max-age=300"); // 5 minutes
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Performance Budget
|
|
238
|
+
|
|
239
|
+
Set budgets and enforce them:
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
JavaScript bundle: < 200KB gzipped (initial load)
|
|
243
|
+
CSS: < 50KB gzipped
|
|
244
|
+
Images: < 200KB per image (above the fold)
|
|
245
|
+
Fonts: < 100KB total
|
|
246
|
+
API response time: < 200ms (p95)
|
|
247
|
+
Time to Interactive: < 3.5s on 4G
|
|
248
|
+
Lighthouse Performance score: ≥ 90
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Enforce in CI:**
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Bundle size check
|
|
255
|
+
npx bundlesize --config bundlesize.config.json
|
|
256
|
+
|
|
257
|
+
# Lighthouse CI
|
|
258
|
+
npx lhci autorun
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Common Rationalizations
|
|
262
|
+
|
|
263
|
+
| Rationalization | Reality |
|
|
264
|
+
| ----------------------------------- | -------------------------------------------------------------------------------------- |
|
|
265
|
+
| "We'll optimize later" | Performance debt compounds. Fix obvious anti-patterns now, defer micro-optimizations. |
|
|
266
|
+
| "It's fast on my machine" | Your machine isn't the user's. Profile on representative hardware and networks. |
|
|
267
|
+
| "This optimization is obvious" | If you didn't measure, you don't know. Profile first. |
|
|
268
|
+
| "Users won't notice 100ms" | Research shows 100ms delays impact conversion rates. Users notice more than you think. |
|
|
269
|
+
| "The framework handles performance" | Frameworks prevent some issues but can't fix N+1 queries or oversized bundles. |
|
|
270
|
+
|
|
271
|
+
## Red Flags
|
|
272
|
+
|
|
273
|
+
- Optimization without profiling data to justify it
|
|
274
|
+
- N+1 query patterns in data fetching
|
|
275
|
+
- List endpoints without pagination
|
|
276
|
+
- Images without dimensions, lazy loading, or responsive sizes
|
|
277
|
+
- Bundle size growing without review
|
|
278
|
+
- No performance monitoring in production
|
|
279
|
+
- `React.memo` and `useMemo` everywhere (overusing is as bad as underusing)
|
|
280
|
+
|
|
281
|
+
## Verification
|
|
282
|
+
|
|
283
|
+
After any performance-related change:
|
|
284
|
+
|
|
285
|
+
- [ ] Before and after measurements exist (specific numbers)
|
|
286
|
+
- [ ] The specific bottleneck is identified and addressed
|
|
287
|
+
- [ ] Core Web Vitals are within "Good" thresholds
|
|
288
|
+
- [ ] Bundle size hasn't increased significantly
|
|
289
|
+
- [ ] No N+1 queries in new data fetching code
|
|
290
|
+
- [ ] Performance budget passes in CI (if configured)
|
|
291
|
+
- [ ] Existing tests still pass (optimization didn't break behavior)
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planning-and-task-breakdown
|
|
3
|
+
description: Breaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Planning and Task Breakdown
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Decompose work into small, verifiable tasks with explicit acceptance criteria. Good task breakdown is the difference between an agent that completes work reliably and one that produces a tangled mess. Every task should be small enough to implement, test, and verify in a single focused session.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- You have a spec and need to break it into implementable units
|
|
15
|
+
- A task feels too large or vague to start
|
|
16
|
+
- Work needs to be parallelized across multiple agents or sessions
|
|
17
|
+
- You need to communicate scope to a human
|
|
18
|
+
- The implementation order isn't obvious
|
|
19
|
+
|
|
20
|
+
**When NOT to use:** Single-file changes with obvious scope, or when the spec already contains well-defined tasks.
|
|
21
|
+
|
|
22
|
+
## The Planning Process
|
|
23
|
+
|
|
24
|
+
### Step 1: Enter Plan Mode
|
|
25
|
+
|
|
26
|
+
Before writing any code, operate in read-only mode:
|
|
27
|
+
|
|
28
|
+
- Read the spec and relevant codebase sections
|
|
29
|
+
- Identify existing patterns and conventions
|
|
30
|
+
- Map dependencies between components
|
|
31
|
+
- Note risks and unknowns
|
|
32
|
+
|
|
33
|
+
**Do NOT write code during planning.** The output is a plan document, not implementation.
|
|
34
|
+
|
|
35
|
+
### Step 2: Identify the Dependency Graph
|
|
36
|
+
|
|
37
|
+
Map what depends on what:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Database schema
|
|
41
|
+
│
|
|
42
|
+
├── API models/types
|
|
43
|
+
│ │
|
|
44
|
+
│ ├── API endpoints
|
|
45
|
+
│ │ │
|
|
46
|
+
│ │ └── Frontend API client
|
|
47
|
+
│ │ │
|
|
48
|
+
│ │ └── UI components
|
|
49
|
+
│ │
|
|
50
|
+
│ └── Validation logic
|
|
51
|
+
│
|
|
52
|
+
└── Seed data / migrations
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Implementation order follows the dependency graph bottom-up: build foundations first.
|
|
56
|
+
|
|
57
|
+
### Step 3: Slice Vertically
|
|
58
|
+
|
|
59
|
+
Instead of building all the database, then all the API, then all the UI — build one complete feature path at a time:
|
|
60
|
+
|
|
61
|
+
**Bad (horizontal slicing):**
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
Task 1: Build entire database schema
|
|
65
|
+
Task 2: Build all API endpoints
|
|
66
|
+
Task 3: Build all UI components
|
|
67
|
+
Task 4: Connect everything
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Good (vertical slicing):**
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Task 1: User can create an account (schema + API + UI for registration)
|
|
74
|
+
Task 2: User can log in (auth schema + API + UI for login)
|
|
75
|
+
Task 3: User can create a task (task schema + API + UI for creation)
|
|
76
|
+
Task 4: User can view task list (query + API + UI for list view)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Each vertical slice delivers working, testable functionality.
|
|
80
|
+
|
|
81
|
+
### Step 4: Write Tasks
|
|
82
|
+
|
|
83
|
+
Each task follows this structure:
|
|
84
|
+
|
|
85
|
+
```markdown
|
|
86
|
+
## Task [N]: [Short descriptive title]
|
|
87
|
+
|
|
88
|
+
**Description:** One paragraph explaining what this task accomplishes.
|
|
89
|
+
|
|
90
|
+
**Acceptance criteria:**
|
|
91
|
+
|
|
92
|
+
- [ ] [Specific, testable condition]
|
|
93
|
+
- [ ] [Specific, testable condition]
|
|
94
|
+
|
|
95
|
+
**Verification:**
|
|
96
|
+
|
|
97
|
+
- [ ] Tests pass: `npm test -- --grep "feature-name"`
|
|
98
|
+
- [ ] Build succeeds: `npm run build`
|
|
99
|
+
- [ ] Manual check: [description of what to verify]
|
|
100
|
+
|
|
101
|
+
**Dependencies:** [Task numbers this depends on, or "None"]
|
|
102
|
+
|
|
103
|
+
**Files likely touched:**
|
|
104
|
+
|
|
105
|
+
- `src/path/to/file.ts`
|
|
106
|
+
- `tests/path/to/test.ts`
|
|
107
|
+
|
|
108
|
+
**Estimated scope:** [Small: 1-2 files | Medium: 3-5 files | Large: 5+ files]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Step 5: Order and Checkpoint
|
|
112
|
+
|
|
113
|
+
Arrange tasks so that:
|
|
114
|
+
|
|
115
|
+
1. Dependencies are satisfied (build foundation first)
|
|
116
|
+
2. Each task leaves the system in a working state
|
|
117
|
+
3. Verification checkpoints occur after every 2-3 tasks
|
|
118
|
+
4. High-risk tasks are early (fail fast)
|
|
119
|
+
|
|
120
|
+
Add explicit checkpoints:
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
## Checkpoint: After Tasks 1-3
|
|
124
|
+
|
|
125
|
+
- [ ] All tests pass
|
|
126
|
+
- [ ] Application builds without errors
|
|
127
|
+
- [ ] Core user flow works end-to-end
|
|
128
|
+
- [ ] Review with human before proceeding
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Task Sizing Guidelines
|
|
132
|
+
|
|
133
|
+
| Size | Files | Scope | Example |
|
|
134
|
+
| ------ | ----- | ------------------------------------- | ------------------------------------ |
|
|
135
|
+
| **XS** | 1 | Single function or config change | Add a validation rule |
|
|
136
|
+
| **S** | 1-2 | One component or endpoint | Add a new API endpoint |
|
|
137
|
+
| **M** | 3-5 | One feature slice | User registration flow |
|
|
138
|
+
| **L** | 5-8 | Multi-component feature | Search with filtering and pagination |
|
|
139
|
+
| **XL** | 8+ | **Too large — break it down further** | — |
|
|
140
|
+
|
|
141
|
+
If a task is L or larger, it should be broken into smaller tasks. An agent performs best on S and M tasks.
|
|
142
|
+
|
|
143
|
+
**When to break a task down further:**
|
|
144
|
+
|
|
145
|
+
- It would take more than one focused session (roughly 2+ hours of agent work)
|
|
146
|
+
- You cannot describe the acceptance criteria in 3 or fewer bullet points
|
|
147
|
+
- It touches two or more independent subsystems (e.g., auth and billing)
|
|
148
|
+
- You find yourself writing "and" in the task title (a sign it is two tasks)
|
|
149
|
+
|
|
150
|
+
## Plan Document Template
|
|
151
|
+
|
|
152
|
+
```markdown
|
|
153
|
+
# Implementation Plan: [Feature/Project Name]
|
|
154
|
+
|
|
155
|
+
## Overview
|
|
156
|
+
|
|
157
|
+
[One paragraph summary of what we're building]
|
|
158
|
+
|
|
159
|
+
## Architecture Decisions
|
|
160
|
+
|
|
161
|
+
- [Key decision 1 and rationale]
|
|
162
|
+
- [Key decision 2 and rationale]
|
|
163
|
+
|
|
164
|
+
## Task List
|
|
165
|
+
|
|
166
|
+
### Phase 1: Foundation
|
|
167
|
+
|
|
168
|
+
- [ ] Task 1: ...
|
|
169
|
+
- [ ] Task 2: ...
|
|
170
|
+
|
|
171
|
+
### Checkpoint: Foundation
|
|
172
|
+
|
|
173
|
+
- [ ] Tests pass, builds clean
|
|
174
|
+
|
|
175
|
+
### Phase 2: Core Features
|
|
176
|
+
|
|
177
|
+
- [ ] Task 3: ...
|
|
178
|
+
- [ ] Task 4: ...
|
|
179
|
+
|
|
180
|
+
### Checkpoint: Core Features
|
|
181
|
+
|
|
182
|
+
- [ ] End-to-end flow works
|
|
183
|
+
|
|
184
|
+
### Phase 3: Polish
|
|
185
|
+
|
|
186
|
+
- [ ] Task 5: ...
|
|
187
|
+
- [ ] Task 6: ...
|
|
188
|
+
|
|
189
|
+
### Checkpoint: Complete
|
|
190
|
+
|
|
191
|
+
- [ ] All acceptance criteria met
|
|
192
|
+
- [ ] Ready for review
|
|
193
|
+
|
|
194
|
+
## Risks and Mitigations
|
|
195
|
+
|
|
196
|
+
| Risk | Impact | Mitigation |
|
|
197
|
+
| ------ | -------------- | ---------- |
|
|
198
|
+
| [Risk] | [High/Med/Low] | [Strategy] |
|
|
199
|
+
|
|
200
|
+
## Open Questions
|
|
201
|
+
|
|
202
|
+
- [Question needing human input]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Parallelization Opportunities
|
|
206
|
+
|
|
207
|
+
When multiple agents or sessions are available:
|
|
208
|
+
|
|
209
|
+
- **Safe to parallelize:** Independent feature slices, tests for already-implemented features, documentation
|
|
210
|
+
- **Must be sequential:** Database migrations, shared state changes, dependency chains
|
|
211
|
+
- **Needs coordination:** Features that share an API contract (define the contract first, then parallelize)
|
|
212
|
+
|
|
213
|
+
## Common Rationalizations
|
|
214
|
+
|
|
215
|
+
| Rationalization | Reality |
|
|
216
|
+
| ------------------------------ | -------------------------------------------------------------------------------------------- |
|
|
217
|
+
| "I'll figure it out as I go" | That's how you end up with a tangled mess and rework. 10 minutes of planning saves hours. |
|
|
218
|
+
| "The tasks are obvious" | Write them down anyway. Explicit tasks surface hidden dependencies and forgotten edge cases. |
|
|
219
|
+
| "Planning is overhead" | Planning is the task. Implementation without a plan is just typing. |
|
|
220
|
+
| "I can hold it all in my head" | Context windows are finite. Written plans survive session boundaries and compaction. |
|
|
221
|
+
|
|
222
|
+
## Red Flags
|
|
223
|
+
|
|
224
|
+
- Starting implementation without a written task list
|
|
225
|
+
- Tasks that say "implement the feature" without acceptance criteria
|
|
226
|
+
- No verification steps in the plan
|
|
227
|
+
- All tasks are XL-sized
|
|
228
|
+
- No checkpoints between tasks
|
|
229
|
+
- Dependency order isn't considered
|
|
230
|
+
|
|
231
|
+
## Verification
|
|
232
|
+
|
|
233
|
+
Before starting implementation, confirm:
|
|
234
|
+
|
|
235
|
+
- [ ] Every task has acceptance criteria
|
|
236
|
+
- [ ] Every task has a verification step
|
|
237
|
+
- [ ] Task dependencies are identified and ordered correctly
|
|
238
|
+
- [ ] No task touches more than ~5 files
|
|
239
|
+
- [ ] Checkpoints exist between major phases
|
|
240
|
+
- [ ] The human has reviewed and approved the plan
|