spec-lite 1.0.0 → 1.0.2
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 +85 -0
- package/package.json +1 -1
- package/skills/build/SKILL.md +116 -0
- package/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/skills/frontend-design/SKILL.md +42 -0
- package/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/skills/incremental-implementation/SKILL.md +241 -0
- package/skills/{spec-plan → plan}/SKILL.md +15 -88
- package/skills/planning-and-task-breakdown/SKILL.md +29 -99
- package/skills/scaffold/SKILL.md +2 -2
- package/skills/spec-new/SKILL.md +6 -2
- package/skills/spec-tech/SKILL.md +13 -7
- package/templates/integrations/plan-template.md +62 -13
- package/templates/integrations/spec-template.md +15 -9
- package/templates/integrations/todo-template.md +1 -1
- package/templates/main/feature/frd-template.md +18 -14
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend-ui-engineering
|
|
3
|
+
description: Builds production-quality UIs. Use when building or modifying user-facing interfaces. Use when creating components, implementing layouts, managing state, or when the output needs to look and feel production-quality rather than AI-generated.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Frontend UI Engineering
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Build production-quality user interfaces that are accessible, performant, and visually polished. The goal is UI that looks like it was built by a design-aware engineer at a top company — not like it was generated by an AI. This means real design system adherence, proper accessibility, thoughtful interaction patterns, and no generic "AI aesthetic."
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Building new UI components or pages
|
|
15
|
+
- Modifying existing user-facing interfaces
|
|
16
|
+
- Implementing responsive layouts
|
|
17
|
+
- Adding interactivity or state management
|
|
18
|
+
- Fixing visual or UX issues
|
|
19
|
+
|
|
20
|
+
## Component Architecture
|
|
21
|
+
|
|
22
|
+
### File Structure
|
|
23
|
+
|
|
24
|
+
Colocate everything related to a component:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
src/components/
|
|
28
|
+
TaskList/
|
|
29
|
+
TaskList.tsx # Component implementation
|
|
30
|
+
TaskList.test.tsx # Tests
|
|
31
|
+
TaskList.stories.tsx # Storybook stories (if using)
|
|
32
|
+
use-task-list.ts # Custom hook (if complex state)
|
|
33
|
+
types.ts # Component-specific types (if needed)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Component Patterns
|
|
37
|
+
|
|
38
|
+
**Prefer composition over configuration:**
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
// Good: Composable
|
|
42
|
+
<Card>
|
|
43
|
+
<CardHeader>
|
|
44
|
+
<CardTitle>Tasks</CardTitle>
|
|
45
|
+
</CardHeader>
|
|
46
|
+
<CardBody>
|
|
47
|
+
<TaskList tasks={tasks} />
|
|
48
|
+
</CardBody>
|
|
49
|
+
</Card>
|
|
50
|
+
|
|
51
|
+
// Avoid: Over-configured
|
|
52
|
+
<Card
|
|
53
|
+
title="Tasks"
|
|
54
|
+
headerVariant="large"
|
|
55
|
+
bodyPadding="md"
|
|
56
|
+
content={<TaskList tasks={tasks} />}
|
|
57
|
+
/>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Keep components focused:**
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// Good: Does one thing
|
|
64
|
+
export function TaskItem({ task, onToggle, onDelete }: TaskItemProps) {
|
|
65
|
+
return (
|
|
66
|
+
<li className="flex items-center gap-3 p-3">
|
|
67
|
+
<Checkbox checked={task.done} onChange={() => onToggle(task.id)} />
|
|
68
|
+
<span className={task.done ? 'line-through text-muted' : ''}>{task.title}</span>
|
|
69
|
+
<Button variant="ghost" size="sm" onClick={() => onDelete(task.id)}>
|
|
70
|
+
<TrashIcon />
|
|
71
|
+
</Button>
|
|
72
|
+
</li>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Separate data fetching from presentation:**
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
// Container: handles data
|
|
81
|
+
export function TaskListContainer() {
|
|
82
|
+
const { tasks, isLoading, error } = useTasks();
|
|
83
|
+
|
|
84
|
+
if (isLoading) return <TaskListSkeleton />;
|
|
85
|
+
if (error) return <ErrorState message="Failed to load tasks" retry={refetch} />;
|
|
86
|
+
if (tasks.length === 0) return <EmptyState message="No tasks yet" />;
|
|
87
|
+
|
|
88
|
+
return <TaskList tasks={tasks} />;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Presentation: handles rendering
|
|
92
|
+
export function TaskList({ tasks }: { tasks: Task[] }) {
|
|
93
|
+
return (
|
|
94
|
+
<ul role="list" className="divide-y">
|
|
95
|
+
{tasks.map(task => <TaskItem key={task.id} task={task} />)}
|
|
96
|
+
</ul>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## State Management
|
|
102
|
+
|
|
103
|
+
**Choose the simplest approach that works:**
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Local state (useState) → Component-specific UI state
|
|
107
|
+
Lifted state → Shared between 2-3 sibling components
|
|
108
|
+
Context → Theme, auth, locale (read-heavy, write-rare)
|
|
109
|
+
URL state (searchParams) → Filters, pagination, shareable UI state
|
|
110
|
+
Server state (React Query, SWR) → Remote data with caching
|
|
111
|
+
Global store (Zustand, Redux) → Complex client state shared app-wide
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Avoid prop drilling deeper than 3 levels.** If you're passing props through components that don't use them, introduce context or restructure the component tree.
|
|
115
|
+
|
|
116
|
+
## Design System Adherence
|
|
117
|
+
|
|
118
|
+
### Avoid the AI Aesthetic
|
|
119
|
+
|
|
120
|
+
AI-generated UI has recognizable patterns. Avoid all of them:
|
|
121
|
+
|
|
122
|
+
| AI Default | Why It Is a Problem | Production Quality |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| Purple/indigo everything | Models default to visually "safe" palettes, making every app look identical | Use the project's actual color palette |
|
|
125
|
+
| Excessive gradients | Gradients add visual noise and clash with most design systems | Flat or subtle gradients matching the design system |
|
|
126
|
+
| Rounded everything (rounded-2xl) | Maximum rounding signals "friendly" but ignores the hierarchy of corner radii in real designs | Consistent border-radius from the design system |
|
|
127
|
+
| Generic hero sections | Template-driven layout with no connection to the actual content or user need | Content-first layouts |
|
|
128
|
+
| Lorem ipsum-style copy | Placeholder text hides layout problems that real content reveals (length, wrapping, overflow) | Realistic placeholder content |
|
|
129
|
+
| Oversized padding everywhere | Equal generous padding destroys visual hierarchy and wastes screen space | Consistent spacing scale |
|
|
130
|
+
| Stock card grids | Uniform grids are a layout shortcut that ignores information priority and scanning patterns | Purpose-driven layouts |
|
|
131
|
+
| Shadow-heavy design | Layered shadows add depth that competes with content and slows rendering on low-end devices | Subtle or no shadows unless the design system specifies |
|
|
132
|
+
|
|
133
|
+
### Spacing and Layout
|
|
134
|
+
|
|
135
|
+
Use a consistent spacing scale. Don't invent values:
|
|
136
|
+
|
|
137
|
+
```css
|
|
138
|
+
/* Use the scale: 0.25rem increments (or whatever the project uses) */
|
|
139
|
+
/* Good */ padding: 1rem; /* 16px */
|
|
140
|
+
/* Good */ gap: 0.75rem; /* 12px */
|
|
141
|
+
/* Bad */ padding: 13px; /* Not on any scale */
|
|
142
|
+
/* Bad */ margin-top: 2.3rem; /* Not on any scale */
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Typography
|
|
146
|
+
|
|
147
|
+
Respect the type hierarchy:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
h1 → Page title (one per page)
|
|
151
|
+
h2 → Section title
|
|
152
|
+
h3 → Subsection title
|
|
153
|
+
body → Default text
|
|
154
|
+
small → Secondary/helper text
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Don't skip heading levels. Don't use heading styles for non-heading content.
|
|
158
|
+
|
|
159
|
+
### Color
|
|
160
|
+
|
|
161
|
+
- Use semantic color tokens: `text-primary`, `bg-surface`, `border-default` — not raw hex values
|
|
162
|
+
- Ensure sufficient contrast (4.5:1 for normal text, 3:1 for large text)
|
|
163
|
+
- Don't rely solely on color to convey information (use icons, text, or patterns too)
|
|
164
|
+
|
|
165
|
+
## Accessibility (WCAG 2.1 AA)
|
|
166
|
+
|
|
167
|
+
Every component must meet these standards:
|
|
168
|
+
|
|
169
|
+
### Keyboard Navigation
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
// Every interactive element must be keyboard accessible
|
|
173
|
+
<button onClick={handleClick}>Click me</button> // ✓ Focusable by default
|
|
174
|
+
<div onClick={handleClick}>Click me</div> // ✗ Not focusable
|
|
175
|
+
<div role="button" tabIndex={0} onClick={handleClick} // ✓ But prefer <button>
|
|
176
|
+
onKeyDown={e => {
|
|
177
|
+
if (e.key === 'Enter') handleClick();
|
|
178
|
+
if (e.key === ' ') e.preventDefault();
|
|
179
|
+
}}
|
|
180
|
+
onKeyUp={e => {
|
|
181
|
+
if (e.key === ' ') handleClick();
|
|
182
|
+
}}>
|
|
183
|
+
Click me
|
|
184
|
+
</div>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### ARIA Labels
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
// Label interactive elements that lack visible text
|
|
191
|
+
<button aria-label="Close dialog"><XIcon /></button>
|
|
192
|
+
|
|
193
|
+
// Label form inputs
|
|
194
|
+
<label htmlFor="email">Email</label>
|
|
195
|
+
<input id="email" type="email" />
|
|
196
|
+
|
|
197
|
+
// Or use aria-label when no visible label exists
|
|
198
|
+
<input aria-label="Search tasks" type="search" />
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Focus Management
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
// Move focus when content changes
|
|
205
|
+
function Dialog({ isOpen, onClose }: DialogProps) {
|
|
206
|
+
const closeRef = useRef<HTMLButtonElement>(null);
|
|
207
|
+
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (isOpen) closeRef.current?.focus();
|
|
210
|
+
}, [isOpen]);
|
|
211
|
+
|
|
212
|
+
// Trap focus inside dialog when open
|
|
213
|
+
return (
|
|
214
|
+
<dialog open={isOpen}>
|
|
215
|
+
<button ref={closeRef} onClick={onClose}>Close</button>
|
|
216
|
+
{/* dialog content */}
|
|
217
|
+
</dialog>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Meaningful Empty and Error States
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
// Don't show blank screens
|
|
226
|
+
function TaskList({ tasks }: { tasks: Task[] }) {
|
|
227
|
+
if (tasks.length === 0) {
|
|
228
|
+
return (
|
|
229
|
+
<div role="status" className="text-center py-12">
|
|
230
|
+
<TasksEmptyIcon className="mx-auto h-12 w-12 text-muted" />
|
|
231
|
+
<h3 className="mt-2 text-sm font-medium">No tasks</h3>
|
|
232
|
+
<p className="mt-1 text-sm text-muted">Get started by creating a new task.</p>
|
|
233
|
+
<Button className="mt-4" onClick={onCreateTask}>Create Task</Button>
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return <ul role="list">...</ul>;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Responsive Design
|
|
243
|
+
|
|
244
|
+
Design for mobile first, then expand:
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
// Tailwind: mobile-first responsive
|
|
248
|
+
<div className="
|
|
249
|
+
grid grid-cols-1 /* Mobile: single column */
|
|
250
|
+
sm:grid-cols-2 /* Small: 2 columns */
|
|
251
|
+
lg:grid-cols-3 /* Large: 3 columns */
|
|
252
|
+
gap-4
|
|
253
|
+
">
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Test at these breakpoints: 320px, 768px, 1024px, 1440px.
|
|
257
|
+
|
|
258
|
+
## Loading and Transitions
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
// Skeleton loading (not spinners for content)
|
|
262
|
+
function TaskListSkeleton() {
|
|
263
|
+
return (
|
|
264
|
+
<div className="space-y-3" aria-busy="true" aria-label="Loading tasks">
|
|
265
|
+
{Array.from({ length: 3 }).map((_, i) => (
|
|
266
|
+
<div key={i} className="h-12 bg-muted animate-pulse rounded" />
|
|
267
|
+
))}
|
|
268
|
+
</div>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Optimistic updates for perceived speed
|
|
273
|
+
function useToggleTask() {
|
|
274
|
+
const queryClient = useQueryClient();
|
|
275
|
+
|
|
276
|
+
return useMutation({
|
|
277
|
+
mutationFn: toggleTask,
|
|
278
|
+
onMutate: async (taskId) => {
|
|
279
|
+
await queryClient.cancelQueries({ queryKey: ['tasks'] });
|
|
280
|
+
const previous = queryClient.getQueryData(['tasks']);
|
|
281
|
+
|
|
282
|
+
queryClient.setQueryData(['tasks'], (old: Task[]) =>
|
|
283
|
+
old.map(t => t.id === taskId ? { ...t, done: !t.done } : t)
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
return { previous };
|
|
287
|
+
},
|
|
288
|
+
onError: (_err, _taskId, context) => {
|
|
289
|
+
queryClient.setQueryData(['tasks'], context?.previous);
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## See Also
|
|
296
|
+
|
|
297
|
+
For detailed accessibility requirements and testing tools, see `references/accessibility-checklist.md`.
|
|
298
|
+
|
|
299
|
+
## Common Rationalizations
|
|
300
|
+
|
|
301
|
+
| Rationalization | Reality |
|
|
302
|
+
|---|---|
|
|
303
|
+
| "Accessibility is a nice-to-have" | It's a legal requirement in many jurisdictions and an engineering quality standard. |
|
|
304
|
+
| "We'll make it responsive later" | Retrofitting responsive design is 3x harder than building it from the start. |
|
|
305
|
+
| "The design isn't final, so I'll skip styling" | Use the design system defaults. Unstyled UI creates a broken first impression for reviewers. |
|
|
306
|
+
| "This is just a prototype" | Prototypes become production code. Build the foundation right. |
|
|
307
|
+
| "The AI aesthetic is fine for now" | It signals low quality. Use the project's actual design system from the start. |
|
|
308
|
+
|
|
309
|
+
## Red Flags
|
|
310
|
+
|
|
311
|
+
- Components with more than 200 lines (split them)
|
|
312
|
+
- Inline styles or arbitrary pixel values
|
|
313
|
+
- Missing error states, loading states, or empty states
|
|
314
|
+
- No keyboard navigation testing
|
|
315
|
+
- Color as the sole indicator of state (red/green without text or icons)
|
|
316
|
+
- Generic "AI look" (purple gradients, oversized cards, stock layouts)
|
|
317
|
+
|
|
318
|
+
## Verification
|
|
319
|
+
|
|
320
|
+
After building UI:
|
|
321
|
+
|
|
322
|
+
- [ ] Component renders without console errors
|
|
323
|
+
- [ ] All interactive elements are keyboard accessible (Tab through the page)
|
|
324
|
+
- [ ] Screen reader can convey the page's content and structure
|
|
325
|
+
- [ ] Responsive: works at 320px, 768px, 1024px, 1440px
|
|
326
|
+
- [ ] Loading, error, and empty states all handled
|
|
327
|
+
- [ ] Follows the project's design system (spacing, colors, typography)
|
|
328
|
+
- [ ] No accessibility warnings in dev tools or axe-core
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: incremental-implementation
|
|
3
|
+
description: Delivers changes incrementally. Use when implementing any feature or change that touches more than one file. Use when you're about to write a large amount of code at once, or when a task feels too big to land in one step.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Incremental Implementation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Build in thin vertical slices — implement one piece, test it, verify it, then expand. Avoid implementing an entire feature in one pass. Each increment should leave the system in a working, testable state. This is the execution discipline that makes large features manageable.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Implementing any multi-file change
|
|
15
|
+
- Building a new feature from a task breakdown
|
|
16
|
+
- Refactoring existing code
|
|
17
|
+
- Any time you're tempted to write more than ~100 lines before testing
|
|
18
|
+
|
|
19
|
+
**When NOT to use:** Single-file, single-function changes where the scope is already minimal.
|
|
20
|
+
|
|
21
|
+
## The Increment Cycle
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌──────────────────────────────────────┐
|
|
25
|
+
│ │
|
|
26
|
+
│ Implement ──→ Test ──→ Verify ──┐ │
|
|
27
|
+
│ ▲ │ │
|
|
28
|
+
│ └───── Commit ◄─────────────┘ │
|
|
29
|
+
│ │ │
|
|
30
|
+
│ ▼ │
|
|
31
|
+
│ Next slice │
|
|
32
|
+
│ │
|
|
33
|
+
└──────────────────────────────────────┘
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For each slice:
|
|
37
|
+
|
|
38
|
+
1. **Implement** the smallest complete piece of functionality
|
|
39
|
+
2. **Test** — run the test suite (or write a test if none exists)
|
|
40
|
+
3. **Verify** — confirm the slice works as expected (tests pass, build succeeds, manual check)
|
|
41
|
+
4. **Commit** -- save your progress with a descriptive message (see `git-workflow-and-versioning` for atomic commit guidance)
|
|
42
|
+
5. **Move to the next slice** — carry forward, don't restart
|
|
43
|
+
|
|
44
|
+
## Slicing Strategies
|
|
45
|
+
|
|
46
|
+
### Vertical Slices (Preferred)
|
|
47
|
+
|
|
48
|
+
Build one complete path through the stack:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Slice 1: Create a task (DB + API + basic UI)
|
|
52
|
+
→ Tests pass, user can create a task via the UI
|
|
53
|
+
|
|
54
|
+
Slice 2: List tasks (query + API + UI)
|
|
55
|
+
→ Tests pass, user can see their tasks
|
|
56
|
+
|
|
57
|
+
Slice 3: Edit a task (update + API + UI)
|
|
58
|
+
→ Tests pass, user can modify tasks
|
|
59
|
+
|
|
60
|
+
Slice 4: Delete a task (delete + API + UI + confirmation)
|
|
61
|
+
→ Tests pass, full CRUD complete
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Each slice delivers working end-to-end functionality.
|
|
65
|
+
|
|
66
|
+
### Contract-First Slicing
|
|
67
|
+
|
|
68
|
+
When backend and frontend need to develop in parallel:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Slice 0: Define the API contract (types, interfaces, OpenAPI spec)
|
|
72
|
+
Slice 1a: Implement backend against the contract + API tests
|
|
73
|
+
Slice 1b: Implement frontend against mock data matching the contract
|
|
74
|
+
Slice 2: Integrate and test end-to-end
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Risk-First Slicing
|
|
78
|
+
|
|
79
|
+
Tackle the riskiest or most uncertain piece first:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Slice 1: Prove the WebSocket connection works (highest risk)
|
|
83
|
+
Slice 2: Build real-time task updates on the proven connection
|
|
84
|
+
Slice 3: Add offline support and reconnection
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If Slice 1 fails, you discover it before investing in Slices 2 and 3.
|
|
88
|
+
|
|
89
|
+
## Implementation Rules
|
|
90
|
+
|
|
91
|
+
### Rule 0: Simplicity First
|
|
92
|
+
|
|
93
|
+
Before writing any code, ask: "What is the simplest thing that could work?"
|
|
94
|
+
|
|
95
|
+
After writing code, review it against these checks:
|
|
96
|
+
- Can this be done in fewer lines?
|
|
97
|
+
- Are these abstractions earning their complexity?
|
|
98
|
+
- Would a staff engineer look at this and say "why didn't you just..."?
|
|
99
|
+
- Am I building for hypothetical future requirements, or the current task?
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
SIMPLICITY CHECK:
|
|
103
|
+
✗ Generic EventBus with middleware pipeline for one notification
|
|
104
|
+
✓ Simple function call
|
|
105
|
+
|
|
106
|
+
✗ Abstract factory pattern for two similar components
|
|
107
|
+
✓ Two straightforward components with shared utilities
|
|
108
|
+
|
|
109
|
+
✗ Config-driven form builder for three forms
|
|
110
|
+
✓ Three form components
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Three similar lines of code is better than a premature abstraction. Implement the naive, obviously-correct version first. Optimize only after correctness is proven with tests.
|
|
114
|
+
|
|
115
|
+
### Rule 0.5: Scope Discipline
|
|
116
|
+
|
|
117
|
+
Touch only what the task requires.
|
|
118
|
+
|
|
119
|
+
Do NOT:
|
|
120
|
+
- "Clean up" code adjacent to your change
|
|
121
|
+
- Refactor imports in files you're not modifying
|
|
122
|
+
- Remove comments you don't fully understand
|
|
123
|
+
- Add features not in the spec because they "seem useful"
|
|
124
|
+
- Modernize syntax in files you're only reading
|
|
125
|
+
|
|
126
|
+
If you notice something worth improving outside your task scope, note it — don't fix it:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
NOTICED BUT NOT TOUCHING:
|
|
130
|
+
- src/utils/format.ts has an unused import (unrelated to this task)
|
|
131
|
+
- The auth middleware could use better error messages (separate task)
|
|
132
|
+
→ Want me to create tasks for these?
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Rule 1: One Thing at a Time
|
|
136
|
+
|
|
137
|
+
Each increment changes one logical thing. Don't mix concerns:
|
|
138
|
+
|
|
139
|
+
**Bad:** One commit that adds a new component, refactors an existing one, and updates the build config.
|
|
140
|
+
|
|
141
|
+
**Good:** Three separate commits — one for each change.
|
|
142
|
+
|
|
143
|
+
### Rule 2: Keep It Compilable
|
|
144
|
+
|
|
145
|
+
After each increment, the project must build and existing tests must pass. Don't leave the codebase in a broken state between slices.
|
|
146
|
+
|
|
147
|
+
### Rule 3: Feature Flags for Incomplete Features
|
|
148
|
+
|
|
149
|
+
If a feature isn't ready for users but you need to merge increments:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Feature flag for work-in-progress
|
|
153
|
+
const ENABLE_TASK_SHARING = process.env.FEATURE_TASK_SHARING === 'true';
|
|
154
|
+
|
|
155
|
+
if (ENABLE_TASK_SHARING) {
|
|
156
|
+
// New sharing UI
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
This lets you merge small increments to the main branch without exposing incomplete work.
|
|
161
|
+
|
|
162
|
+
### Rule 4: Safe Defaults
|
|
163
|
+
|
|
164
|
+
New code should default to safe, conservative behavior:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// Safe: disabled by default, opt-in
|
|
168
|
+
export function createTask(data: TaskInput, options?: { notify?: boolean }) {
|
|
169
|
+
const shouldNotify = options?.notify ?? false;
|
|
170
|
+
// ...
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Rule 5: Rollback-Friendly
|
|
175
|
+
|
|
176
|
+
Each increment should be independently revertable:
|
|
177
|
+
|
|
178
|
+
- Additive changes (new files, new functions) are easy to revert
|
|
179
|
+
- Modifications to existing code should be minimal and focused
|
|
180
|
+
- Database migrations should have corresponding rollback migrations
|
|
181
|
+
- Avoid deleting something in one commit and replacing it in the same commit — separate them
|
|
182
|
+
|
|
183
|
+
## Working with Agents
|
|
184
|
+
|
|
185
|
+
When directing an agent to implement incrementally:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
"Let's implement Task 3 from the plan.
|
|
189
|
+
|
|
190
|
+
Start with just the database schema change and the API endpoint.
|
|
191
|
+
Don't touch the UI yet — we'll do that in the next increment.
|
|
192
|
+
|
|
193
|
+
After implementing, run `npm test` and `npm run build` to verify
|
|
194
|
+
nothing is broken."
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Be explicit about what's in scope and what's NOT in scope for each increment.
|
|
198
|
+
|
|
199
|
+
## Increment Checklist
|
|
200
|
+
|
|
201
|
+
After each increment, verify:
|
|
202
|
+
|
|
203
|
+
- [ ] The change does one thing and does it completely
|
|
204
|
+
- [ ] All existing tests still pass (`npm test`)
|
|
205
|
+
- [ ] The build succeeds (`npm run build`)
|
|
206
|
+
- [ ] Type checking passes (`npx tsc --noEmit`)
|
|
207
|
+
- [ ] Linting passes (`npm run lint`)
|
|
208
|
+
- [ ] The new functionality works as expected
|
|
209
|
+
- [ ] The change is committed with a descriptive message
|
|
210
|
+
|
|
211
|
+
## Common Rationalizations
|
|
212
|
+
|
|
213
|
+
| Rationalization | Reality |
|
|
214
|
+
|---|---|
|
|
215
|
+
| "I'll test it all at the end" | Bugs compound. A bug in Slice 1 makes Slices 2-5 wrong. Test each slice. |
|
|
216
|
+
| "It's faster to do it all at once" | It *feels* faster until something breaks and you can't find which of 500 changed lines caused it. |
|
|
217
|
+
| "These changes are too small to commit separately" | Small commits are free. Large commits hide bugs and make rollbacks painful. |
|
|
218
|
+
| "I'll add the feature flag later" | If the feature isn't complete, it shouldn't be user-visible. Add the flag now. |
|
|
219
|
+
| "This refactor is small enough to include" | Refactors mixed with features make both harder to review and debug. Separate them. |
|
|
220
|
+
|
|
221
|
+
## Red Flags
|
|
222
|
+
|
|
223
|
+
- More than 100 lines of code written without running tests
|
|
224
|
+
- Multiple unrelated changes in a single increment
|
|
225
|
+
- "Let me just quickly add this too" scope expansion
|
|
226
|
+
- Skipping the test/verify step to move faster
|
|
227
|
+
- Build or tests broken between increments
|
|
228
|
+
- Large uncommitted changes accumulating
|
|
229
|
+
- Building abstractions before the third use case demands it
|
|
230
|
+
- Touching files outside the task scope "while I'm here"
|
|
231
|
+
- Creating new utility files for one-time operations
|
|
232
|
+
|
|
233
|
+
## Verification
|
|
234
|
+
|
|
235
|
+
After completing all increments for a task:
|
|
236
|
+
|
|
237
|
+
- [ ] Each increment was individually tested and committed
|
|
238
|
+
- [ ] The full test suite passes
|
|
239
|
+
- [ ] The build is clean
|
|
240
|
+
- [ ] The feature works end-to-end as specified
|
|
241
|
+
- [ ] No uncommitted changes remain
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: plan
|
|
3
3
|
description: Tạo plan.md và todo.md cho một integration — phân rã tasks từ spec.md và tech.md. SDD wrapper quanh planning-and-task-breakdown — chỉ làm context loading, delegate toàn bộ breakdown cho planning-and-task-breakdown.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# plan
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
@@ -27,22 +27,28 @@ Mọi quyết định về sizing, slicing đều thuộc về `planning-and-tas
|
|
|
27
27
|
|
|
28
28
|
### Bước 1: Xác định integration
|
|
29
29
|
|
|
30
|
+
**Nếu có ARGUMENT:**
|
|
31
|
+
- Parse argument: có thể là số thứ tự (`2`, `002`) hoặc slug (`002-implement-todo`)
|
|
32
|
+
- Quét `specs/integrations/*/`, tìm integration khớp với argument
|
|
33
|
+
- Nếu không tìm thấy → báo lỗi:
|
|
34
|
+
> Không tìm thấy integration khớp với "{argument}". Kiểm tra lại tên hoặc số thứ tự.
|
|
35
|
+
- Nếu tìm thấy → dùng integration đó, bắt đầu luôn
|
|
36
|
+
|
|
37
|
+
**Nếu không có ARGUMENT:**
|
|
38
|
+
|
|
30
39
|
Quét `specs/integrations/`. Liệt kê tất cả integrations:
|
|
31
40
|
|
|
32
41
|
```
|
|
33
42
|
Integrations:
|
|
34
43
|
|
|
35
|
-
[1]
|
|
36
|
-
[2]
|
|
37
|
-
[3] f004-credit-system — Credit System spec—
|
|
44
|
+
[1] 001-implement-auth — Implement Auth spec✓ tech✓ plan✓
|
|
45
|
+
[2] 002-implement-todo — Implement Todo Management spec✓ tech✓ plan—
|
|
38
46
|
|
|
39
47
|
Chọn số integration:
|
|
40
48
|
```
|
|
41
49
|
|
|
42
50
|
Legend: `✓` = có, `—` = chưa có
|
|
43
51
|
|
|
44
|
-
Nếu có ARGUMENT → chọn luôn, không hiển thị danh sách.
|
|
45
|
-
|
|
46
52
|
Nếu plan.md / todo.md đã tồn tại → hỏi trước khi ghi đè.
|
|
47
53
|
|
|
48
54
|
---
|
|
@@ -84,77 +90,7 @@ Invoke `planning-and-task-breakdown` với context đã load. Skill đó sẽ th
|
|
|
84
90
|
|
|
85
91
|
### plan.md
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
id: "{slug}"
|
|
90
|
-
slug: "{slug}"
|
|
91
|
-
title: "{title} — Implementation Plan"
|
|
92
|
-
features: ["{F-XXX}"]
|
|
93
|
-
status: draft
|
|
94
|
-
created: {YYYY-MM-DD}
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## Summary
|
|
98
|
-
|
|
99
|
-
[2-3 sentences on what will be implemented]
|
|
100
|
-
|
|
101
|
-
## Dependency Graph
|
|
102
|
-
|
|
103
|
-
[ASCII diagram — bottom = foundations, top = UI. Ví dụ:]
|
|
104
|
-
|
|
105
|
-
UI Components
|
|
106
|
-
│
|
|
107
|
-
API Routes ──── Middleware
|
|
108
|
-
│
|
|
109
|
-
Services
|
|
110
|
-
│
|
|
111
|
-
Prisma Schema
|
|
112
|
-
|
|
113
|
-
## Tasks
|
|
114
|
-
|
|
115
|
-
### Phase 1: [Phase name]
|
|
116
|
-
|
|
117
|
-
#### T001 · [task title — starts with a verb]
|
|
118
|
-
|
|
119
|
-
**Mục tiêu:** [One sentence: what this task delivers]
|
|
120
|
-
|
|
121
|
-
**depends:** — (hoặc T-IDs)
|
|
122
|
-
|
|
123
|
-
**Các bước:**
|
|
124
|
-
1. [Concrete implementation step]
|
|
125
|
-
2. [Concrete implementation step]
|
|
126
|
-
|
|
127
|
-
**Verification:**
|
|
128
|
-
- [ ] [AC-F-001] [specific test case]
|
|
129
|
-
- [ ] [smoke check or observable result]
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
### Phase N: Verification
|
|
134
|
-
|
|
135
|
-
#### T00N · Integration tests — [flow name]
|
|
136
|
-
|
|
137
|
-
**Mục tiêu:** [End-to-end flow being tested]
|
|
138
|
-
|
|
139
|
-
**depends:** T001, T002, ...
|
|
140
|
-
|
|
141
|
-
**Các bước:**
|
|
142
|
-
1. [Test setup / seed data]
|
|
143
|
-
2. [Execute happy path]
|
|
144
|
-
3. [Execute error cases]
|
|
145
|
-
|
|
146
|
-
**Verification:**
|
|
147
|
-
- [ ] Happy path: [description]
|
|
148
|
-
- [ ] Error case: [description]
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## Definition of Done
|
|
153
|
-
|
|
154
|
-
- [ ] [AC-F-001 / AC-S-001] [AC description — concise, preserve intent]
|
|
155
|
-
- [ ] All unit tests pass
|
|
156
|
-
- [ ] All integration tests pass
|
|
157
|
-
```
|
|
93
|
+
Dùng `.claude/templates/integrations/plan-template.md` làm skeleton, điền nội dung từ breakdown vào từng section.
|
|
158
94
|
|
|
159
95
|
**Lưu ý format:**
|
|
160
96
|
- Task ID dùng `·` (middle dot), không dùng `—`
|
|
@@ -164,16 +100,7 @@ created: {YYYY-MM-DD}
|
|
|
164
100
|
|
|
165
101
|
### todo.md
|
|
166
102
|
|
|
167
|
-
|
|
168
|
-
# [title] — Todo
|
|
169
|
-
|
|
170
|
-
### Phase 1: [Phase name]
|
|
171
|
-
- [ ] T001 · [task title]
|
|
172
|
-
- [ ] T002 · [task title]
|
|
173
|
-
|
|
174
|
-
### Phase N: Verification
|
|
175
|
-
- [ ] T00N · Integration tests — [flow name]
|
|
176
|
-
```
|
|
103
|
+
Dùng `.claude/templates/integrations/todo-template.md` làm skeleton, điền nội dung từ breakdown vào từng section.
|
|
177
104
|
|
|
178
105
|
---
|
|
179
106
|
|