@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.
Files changed (51) hide show
  1. package/dist/chunk-M7BBX56R.js +340 -0
  2. package/dist/chunk-M7BBX56R.js.map +1 -0
  3. package/dist/{chunk-SWXTFHC7.js → chunk-Z5D2QZY6.js} +3 -3
  4. package/dist/chunk-Z5D2QZY6.js.map +1 -0
  5. package/dist/chunk-Z6ZWNWWR.js +34 -0
  6. package/dist/index.d.ts +2717 -188
  7. package/dist/index.js +16178 -7949
  8. package/dist/index.js.map +1 -1
  9. package/dist/self-extend-47LWSK3E.js +52 -0
  10. package/dist/self-extend-47LWSK3E.js.map +1 -0
  11. package/dist/skills/builtin/api-and-interface-design/SKILL.md +300 -0
  12. package/dist/skills/builtin/browser-testing-with-devtools/SKILL.md +307 -0
  13. package/dist/skills/builtin/ci-cd-and-automation/SKILL.md +391 -0
  14. package/dist/skills/builtin/code-review-and-quality/SKILL.md +353 -0
  15. package/dist/skills/builtin/code-simplification/SKILL.md +340 -0
  16. package/dist/skills/builtin/context-engineering/SKILL.md +301 -0
  17. package/dist/skills/builtin/daemon-operations/SKILL.md +55 -0
  18. package/dist/skills/builtin/debugging-and-error-recovery/SKILL.md +306 -0
  19. package/dist/skills/builtin/deprecation-and-migration/SKILL.md +207 -0
  20. package/dist/skills/builtin/documentation-and-adrs/SKILL.md +295 -0
  21. package/dist/skills/builtin/frontend-ui-engineering/SKILL.md +333 -0
  22. package/dist/skills/builtin/git-workflow-and-versioning/SKILL.md +303 -0
  23. package/dist/skills/builtin/github-collaboration/SKILL.md +215 -0
  24. package/dist/skills/builtin/godmode-operations/SKILL.md +68 -0
  25. package/dist/skills/builtin/idea-refine/SKILL.md +186 -0
  26. package/dist/skills/builtin/idea-refine/examples.md +244 -0
  27. package/dist/skills/builtin/idea-refine/frameworks.md +101 -0
  28. package/dist/skills/builtin/idea-refine/refinement-criteria.md +126 -0
  29. package/dist/skills/builtin/idea-refine/scripts/idea-refine.sh +15 -0
  30. package/dist/skills/builtin/incremental-implementation/SKILL.md +243 -0
  31. package/dist/skills/builtin/memory-init/SKILL.md +54 -0
  32. package/dist/skills/builtin/memory-reflection/SKILL.md +59 -0
  33. package/dist/skills/builtin/multi-model-routing/SKILL.md +56 -0
  34. package/dist/skills/builtin/performance-optimization/SKILL.md +291 -0
  35. package/dist/skills/builtin/planning-and-task-breakdown/SKILL.md +240 -0
  36. package/dist/skills/builtin/security-and-hardening/SKILL.md +368 -0
  37. package/dist/skills/builtin/shipping-and-launch/SKILL.md +310 -0
  38. package/dist/skills/builtin/spec-driven-development/SKILL.md +212 -0
  39. package/dist/skills/builtin/test-driven-development/SKILL.md +376 -0
  40. package/dist/skills/builtin/using-agent-skills/SKILL.md +173 -0
  41. package/dist/trajectory-analyzer-ZAI2XUAI.js +14 -0
  42. package/dist/{trajectory-capture-RF7TUN6I.js → trajectory-capture-ERPIVYQJ.js} +3 -3
  43. package/package.json +14 -11
  44. package/dist/chunk-OU3NPQBH.js +0 -87
  45. package/dist/chunk-OU3NPQBH.js.map +0 -1
  46. package/dist/chunk-PZ5AY32C.js +0 -10
  47. package/dist/chunk-SWXTFHC7.js.map +0 -1
  48. package/dist/trajectory-MOCIJBV6.js +0 -8
  49. /package/dist/{chunk-PZ5AY32C.js.map → chunk-Z6ZWNWWR.js.map} +0 -0
  50. /package/dist/{trajectory-MOCIJBV6.js.map → trajectory-analyzer-ZAI2XUAI.js.map} +0 -0
  51. /package/dist/{trajectory-capture-RF7TUN6I.js.map → trajectory-capture-ERPIVYQJ.js.map} +0 -0
@@ -0,0 +1,333 @@
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" : ""}>
69
+ {task.title}
70
+ </span>
71
+ <Button variant="ghost" size="sm" onClick={() => onDelete(task.id)}>
72
+ <TrashIcon />
73
+ </Button>
74
+ </li>
75
+ );
76
+ }
77
+ ```
78
+
79
+ **Separate data fetching from presentation:**
80
+
81
+ ```tsx
82
+ // Container: handles data
83
+ export function TaskListContainer() {
84
+ const { tasks, isLoading, error } = useTasks();
85
+
86
+ if (isLoading) return <TaskListSkeleton />;
87
+ if (error)
88
+ return <ErrorState message="Failed to load tasks" retry={refetch} />;
89
+ if (tasks.length === 0) return <EmptyState message="No tasks yet" />;
90
+
91
+ return <TaskList tasks={tasks} />;
92
+ }
93
+
94
+ // Presentation: handles rendering
95
+ export function TaskList({ tasks }: { tasks: Task[] }) {
96
+ return (
97
+ <ul role="list" className="divide-y">
98
+ {tasks.map((task) => (
99
+ <TaskItem key={task.id} task={task} />
100
+ ))}
101
+ </ul>
102
+ );
103
+ }
104
+ ```
105
+
106
+ ## State Management
107
+
108
+ **Choose the simplest approach that works:**
109
+
110
+ ```
111
+ Local state (useState) → Component-specific UI state
112
+ Lifted state → Shared between 2-3 sibling components
113
+ Context → Theme, auth, locale (read-heavy, write-rare)
114
+ URL state (searchParams) → Filters, pagination, shareable UI state
115
+ Server state (React Query, SWR) → Remote data with caching
116
+ Global store (Zustand, Redux) → Complex client state shared app-wide
117
+ ```
118
+
119
+ **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.
120
+
121
+ ## Design System Adherence
122
+
123
+ ### Avoid the AI Aesthetic
124
+
125
+ AI-generated UI has recognizable patterns. Avoid all of them:
126
+
127
+ | AI Default | Why It Is a Problem | Production Quality |
128
+ | -------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
129
+ | Purple/indigo everything | Models default to visually "safe" palettes, making every app look identical | Use the project's actual color palette |
130
+ | Excessive gradients | Gradients add visual noise and clash with most design systems | Flat or subtle gradients matching the design system |
131
+ | 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 |
132
+ | Generic hero sections | Template-driven layout with no connection to the actual content or user need | Content-first layouts |
133
+ | Lorem ipsum-style copy | Placeholder text hides layout problems that real content reveals (length, wrapping, overflow) | Realistic placeholder content |
134
+ | Oversized padding everywhere | Equal generous padding destroys visual hierarchy and wastes screen space | Consistent spacing scale |
135
+ | Stock card grids | Uniform grids are a layout shortcut that ignores information priority and scanning patterns | Purpose-driven layouts |
136
+ | 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 |
137
+
138
+ ### Spacing and Layout
139
+
140
+ Use a consistent spacing scale. Don't invent values:
141
+
142
+ ```css
143
+ /* Use the scale: 0.25rem increments (or whatever the project uses) */
144
+ /* Good */
145
+ padding: 1rem; /* 16px */
146
+ /* Good */
147
+ gap: 0.75rem; /* 12px */
148
+ /* Bad */
149
+ padding: 13px; /* Not on any scale */
150
+ /* Bad */
151
+ margin-top: 2.3rem; /* Not on any scale */
152
+ ```
153
+
154
+ ### Typography
155
+
156
+ Respect the type hierarchy:
157
+
158
+ ```
159
+ h1 → Page title (one per page)
160
+ h2 → Section title
161
+ h3 → Subsection title
162
+ body → Default text
163
+ small → Secondary/helper text
164
+ ```
165
+
166
+ Don't skip heading levels. Don't use heading styles for non-heading content.
167
+
168
+ ### Color
169
+
170
+ - Use semantic color tokens: `text-primary`, `bg-surface`, `border-default` — not raw hex values
171
+ - Ensure sufficient contrast (4.5:1 for normal text, 3:1 for large text)
172
+ - Don't rely solely on color to convey information (use icons, text, or patterns too)
173
+
174
+ ## Accessibility (WCAG 2.1 AA)
175
+
176
+ Every component must meet these standards:
177
+
178
+ ### Keyboard Navigation
179
+
180
+ ```tsx
181
+ // Every interactive element must be keyboard accessible
182
+ <button onClick={handleClick}>Click me</button> // ✓ Focusable by default
183
+ <div onClick={handleClick}>Click me</div> // ✗ Not focusable
184
+ <div role="button" tabIndex={0} onClick={handleClick} // ✓ But prefer <button>
185
+ onKeyDown={e => e.key === 'Enter' && handleClick()}>
186
+ Click me
187
+ </div>
188
+ ```
189
+
190
+ ### ARIA Labels
191
+
192
+ ```tsx
193
+ // Label interactive elements that lack visible text
194
+ <button aria-label="Close dialog"><XIcon /></button>
195
+
196
+ // Label form inputs
197
+ <label htmlFor="email">Email</label>
198
+ <input id="email" type="email" />
199
+
200
+ // Or use aria-label when no visible label exists
201
+ <input aria-label="Search tasks" type="search" />
202
+ ```
203
+
204
+ ### Focus Management
205
+
206
+ ```tsx
207
+ // Move focus when content changes
208
+ function Dialog({ isOpen, onClose }: DialogProps) {
209
+ const closeRef = useRef<HTMLButtonElement>(null);
210
+
211
+ useEffect(() => {
212
+ if (isOpen) closeRef.current?.focus();
213
+ }, [isOpen]);
214
+
215
+ // Trap focus inside dialog when open
216
+ return (
217
+ <dialog open={isOpen}>
218
+ <button ref={closeRef} onClick={onClose}>
219
+ Close
220
+ </button>
221
+ {/* dialog content */}
222
+ </dialog>
223
+ );
224
+ }
225
+ ```
226
+
227
+ ### Meaningful Empty and Error States
228
+
229
+ ```tsx
230
+ // Don't show blank screens
231
+ function TaskList({ tasks }: { tasks: Task[] }) {
232
+ if (tasks.length === 0) {
233
+ return (
234
+ <div role="status" className="text-center py-12">
235
+ <TasksEmptyIcon className="mx-auto h-12 w-12 text-muted" />
236
+ <h3 className="mt-2 text-sm font-medium">No tasks</h3>
237
+ <p className="mt-1 text-sm text-muted">
238
+ Get started by creating a new task.
239
+ </p>
240
+ <Button className="mt-4" onClick={onCreateTask}>
241
+ Create Task
242
+ </Button>
243
+ </div>
244
+ );
245
+ }
246
+
247
+ return <ul role="list">...</ul>;
248
+ }
249
+ ```
250
+
251
+ ## Responsive Design
252
+
253
+ Design for mobile first, then expand:
254
+
255
+ ```tsx
256
+ // Tailwind: mobile-first responsive
257
+ <div className="
258
+ grid grid-cols-1 /* Mobile: single column */
259
+ sm:grid-cols-2 /* Small: 2 columns */
260
+ lg:grid-cols-3 /* Large: 3 columns */
261
+ gap-4
262
+ ">
263
+ ```
264
+
265
+ Test at these breakpoints: 320px, 768px, 1024px, 1440px.
266
+
267
+ ## Loading and Transitions
268
+
269
+ ```tsx
270
+ // Skeleton loading (not spinners for content)
271
+ function TaskListSkeleton() {
272
+ return (
273
+ <div className="space-y-3" aria-busy="true" aria-label="Loading tasks">
274
+ {Array.from({ length: 3 }).map((_, i) => (
275
+ <div key={i} className="h-12 bg-muted animate-pulse rounded" />
276
+ ))}
277
+ </div>
278
+ );
279
+ }
280
+
281
+ // Optimistic updates for perceived speed
282
+ function useToggleTask() {
283
+ const queryClient = useQueryClient();
284
+
285
+ return useMutation({
286
+ mutationFn: toggleTask,
287
+ onMutate: async (taskId) => {
288
+ await queryClient.cancelQueries({ queryKey: ["tasks"] });
289
+ const previous = queryClient.getQueryData(["tasks"]);
290
+
291
+ queryClient.setQueryData(["tasks"], (old: Task[]) =>
292
+ old.map((t) => (t.id === taskId ? { ...t, done: !t.done } : t)),
293
+ );
294
+
295
+ return { previous };
296
+ },
297
+ onError: (_err, _taskId, context) => {
298
+ queryClient.setQueryData(["tasks"], context?.previous);
299
+ },
300
+ });
301
+ }
302
+ ```
303
+
304
+ ## Common Rationalizations
305
+
306
+ | Rationalization | Reality |
307
+ | ---------------------------------------------- | -------------------------------------------------------------------------------------------- |
308
+ | "Accessibility is a nice-to-have" | It's a legal requirement in many jurisdictions and an engineering quality standard. |
309
+ | "We'll make it responsive later" | Retrofitting responsive design is 3x harder than building it from the start. |
310
+ | "The design isn't final, so I'll skip styling" | Use the design system defaults. Unstyled UI creates a broken first impression for reviewers. |
311
+ | "This is just a prototype" | Prototypes become production code. Build the foundation right. |
312
+ | "The AI aesthetic is fine for now" | It signals low quality. Use the project's actual design system from the start. |
313
+
314
+ ## Red Flags
315
+
316
+ - Components with more than 200 lines (split them)
317
+ - Inline styles or arbitrary pixel values
318
+ - Missing error states, loading states, or empty states
319
+ - No keyboard navigation testing
320
+ - Color as the sole indicator of state (red/green without text or icons)
321
+ - Generic "AI look" (purple gradients, oversized cards, stock layouts)
322
+
323
+ ## Verification
324
+
325
+ After building UI:
326
+
327
+ - [ ] Component renders without console errors
328
+ - [ ] All interactive elements are keyboard accessible (Tab through the page)
329
+ - [ ] Screen reader can convey the page's content and structure
330
+ - [ ] Responsive: works at 320px, 768px, 1024px, 1440px
331
+ - [ ] Loading, error, and empty states all handled
332
+ - [ ] Follows the project's design system (spacing, colors, typography)
333
+ - [ ] No accessibility warnings in dev tools or axe-core
@@ -0,0 +1,303 @@
1
+ ---
2
+ name: git-workflow-and-versioning
3
+ description: Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.
4
+ ---
5
+
6
+ # Git Workflow and Versioning
7
+
8
+ ## Overview
9
+
10
+ Git is your safety net. Treat commits as save points, branches as sandboxes, and history as documentation. With AI agents generating code at high speed, disciplined version control is the mechanism that keeps changes manageable, reviewable, and reversible.
11
+
12
+ ## When to Use
13
+
14
+ Always. Every code change flows through git.
15
+
16
+ ## Core Principles
17
+
18
+ ### Trunk-Based Development (Recommended)
19
+
20
+ Keep `main` always deployable. Work in short-lived feature branches that merge back within 1-3 days. Long-lived development branches are hidden costs — they diverge, create merge conflicts, and delay integration. DORA research consistently shows trunk-based development correlates with high-performing engineering teams.
21
+
22
+ ```
23
+ main ──●──●──●──●──●──●──●──●──●── (always deployable)
24
+ ╲ ╱ ╲ ╱
25
+ ●──●─╱ ●──╱ ← short-lived feature branches (1-3 days)
26
+ ```
27
+
28
+ This is the recommended default. Teams using gitflow or long-lived branches can adapt the principles (atomic commits, small changes, descriptive messages) to their branching model — the commit discipline matters more than the specific branching strategy.
29
+
30
+ - **Dev branches are costs.** Every day a branch lives, it accumulates merge risk.
31
+ - **Release branches are acceptable.** When you need to stabilize a release while main moves forward.
32
+ - **Feature flags > long branches.** Prefer deploying incomplete work behind flags rather than keeping it on a branch for weeks.
33
+
34
+ ### 1. Commit Early, Commit Often
35
+
36
+ Each successful increment gets its own commit. Don't accumulate large uncommitted changes.
37
+
38
+ ```
39
+ Work pattern:
40
+ Implement slice → Test → Verify → Commit → Next slice
41
+
42
+ Not this:
43
+ Implement everything → Hope it works → Giant commit
44
+ ```
45
+
46
+ Commits are save points. If the next change breaks something, you can revert to the last known-good state instantly.
47
+
48
+ ### 2. Atomic Commits
49
+
50
+ Each commit does one logical thing:
51
+
52
+ ```
53
+ # Good: Each commit is self-contained
54
+ git log --oneline
55
+ a1b2c3d Add task creation endpoint with validation
56
+ d4e5f6g Add task creation form component
57
+ h7i8j9k Connect form to API and add loading state
58
+ m1n2o3p Add task creation tests (unit + integration)
59
+
60
+ # Bad: Everything mixed together
61
+ git log --oneline
62
+ x1y2z3a Add task feature, fix sidebar, update deps, refactor utils
63
+ ```
64
+
65
+ ### 3. Descriptive Messages
66
+
67
+ Commit messages explain the _why_, not just the _what_:
68
+
69
+ ```
70
+ # Good: Explains intent
71
+ feat: add email validation to registration endpoint
72
+
73
+ Prevents invalid email formats from reaching the database.
74
+ Uses Zod schema validation at the route handler level,
75
+ consistent with existing validation patterns in auth.ts.
76
+
77
+ # Bad: Describes what's obvious from the diff
78
+ update auth.ts
79
+ ```
80
+
81
+ **Format:**
82
+
83
+ ```
84
+ <type>: <short description>
85
+
86
+ <optional body explaining why, not what>
87
+ ```
88
+
89
+ **Types:**
90
+
91
+ - `feat` — New feature
92
+ - `fix` — Bug fix
93
+ - `refactor` — Code change that neither fixes a bug nor adds a feature
94
+ - `test` — Adding or updating tests
95
+ - `docs` — Documentation only
96
+ - `chore` — Tooling, dependencies, config
97
+
98
+ ### 4. Keep Concerns Separate
99
+
100
+ Don't combine formatting changes with behavior changes. Don't combine refactors with features. Each type of change should be a separate commit — and ideally a separate PR:
101
+
102
+ ```
103
+ # Good: Separate concerns
104
+ git commit -m "refactor: extract validation logic to shared utility"
105
+ git commit -m "feat: add phone number validation to registration"
106
+
107
+ # Bad: Mixed concerns
108
+ git commit -m "refactor validation and add phone number field"
109
+ ```
110
+
111
+ **Separate refactoring from feature work.** A refactoring change and a feature change are two different changes — submit them separately. This makes each change easier to review, revert, and understand in history. Small cleanups (renaming a variable) can be included in a feature commit at reviewer discretion.
112
+
113
+ ### 5. Size Your Changes
114
+
115
+ Target ~100 lines per commit/PR. Changes over ~1000 lines should be split. See the splitting strategies in `code-review-and-quality` for how to break down large changes.
116
+
117
+ ```
118
+ ~100 lines → Easy to review, easy to revert
119
+ ~300 lines → Acceptable for a single logical change
120
+ ~1000 lines → Split into smaller changes
121
+ ```
122
+
123
+ ## Branching Strategy
124
+
125
+ ### Feature Branches
126
+
127
+ ```
128
+ main (always deployable)
129
+
130
+ ├── feature/task-creation ← One feature per branch
131
+ ├── feature/user-settings ← Parallel work
132
+ └── fix/duplicate-tasks ← Bug fixes
133
+ ```
134
+
135
+ - Branch from `main` (or the team's default branch)
136
+ - Keep branches short-lived (merge within 1-3 days) — long-lived branches are hidden costs
137
+ - Delete branches after merge
138
+ - Prefer feature flags over long-lived branches for incomplete features
139
+
140
+ ### Branch Naming
141
+
142
+ ```
143
+ feature/<short-description> → feature/task-creation
144
+ fix/<short-description> → fix/duplicate-tasks
145
+ chore/<short-description> → chore/update-deps
146
+ refactor/<short-description> → refactor/auth-module
147
+ ```
148
+
149
+ ## Working with Worktrees
150
+
151
+ For parallel AI agent work, use git worktrees to run multiple branches simultaneously:
152
+
153
+ ```bash
154
+ # Create a worktree for a feature branch
155
+ git worktree add ../project-feature-a feature/task-creation
156
+ git worktree add ../project-feature-b feature/user-settings
157
+
158
+ # Each worktree is a separate directory with its own branch
159
+ # Agents can work in parallel without interfering
160
+ ls ../
161
+ project/ ← main branch
162
+ project-feature-a/ ← task-creation branch
163
+ project-feature-b/ ← user-settings branch
164
+
165
+ # When done, merge and clean up
166
+ git worktree remove ../project-feature-a
167
+ ```
168
+
169
+ Benefits:
170
+
171
+ - Multiple agents can work on different features simultaneously
172
+ - No branch switching needed (each directory has its own branch)
173
+ - If one experiment fails, delete the worktree — nothing is lost
174
+ - Changes are isolated until explicitly merged
175
+
176
+ ## The Save Point Pattern
177
+
178
+ ```
179
+ Agent starts work
180
+
181
+ ├── Makes a change
182
+ │ ├── Test passes? → Commit → Continue
183
+ │ └── Test fails? → Revert to last commit → Investigate
184
+
185
+ ├── Makes another change
186
+ │ ├── Test passes? → Commit → Continue
187
+ │ └── Test fails? → Revert to last commit → Investigate
188
+
189
+ └── Feature complete → All commits form a clean history
190
+ ```
191
+
192
+ This pattern means you never lose more than one increment of work. If an agent goes off the rails, `git reset --hard HEAD` takes you back to the last successful state.
193
+
194
+ ## Change Summaries
195
+
196
+ After any modification, provide a structured summary. This makes review easier, documents scope discipline, and surfaces unintended changes:
197
+
198
+ ```
199
+ CHANGES MADE:
200
+ - src/routes/tasks.ts: Added validation middleware to POST endpoint
201
+ - src/lib/validation.ts: Added TaskCreateSchema using Zod
202
+
203
+ THINGS I DIDN'T TOUCH (intentionally):
204
+ - src/routes/auth.ts: Has similar validation gap but out of scope
205
+ - src/middleware/error.ts: Error format could be improved (separate task)
206
+
207
+ POTENTIAL CONCERNS:
208
+ - The Zod schema is strict — rejects extra fields. Confirm this is desired.
209
+ - Added zod as a dependency (72KB gzipped) — already in package.json
210
+ ```
211
+
212
+ This pattern catches wrong assumptions early and gives reviewers a clear map of the change. The "DIDN'T TOUCH" section is especially important — it shows you exercised scope discipline and didn't go on an unsolicited renovation.
213
+
214
+ ## Pre-Commit Hygiene
215
+
216
+ Before every commit:
217
+
218
+ ```bash
219
+ # 1. Check what you're about to commit
220
+ git diff --staged
221
+
222
+ # 2. Ensure no secrets
223
+ git diff --staged | grep -i "password\|secret\|api_key\|token"
224
+
225
+ # 3. Run tests
226
+ npm test
227
+
228
+ # 4. Run linting
229
+ npm run lint
230
+
231
+ # 5. Run type checking
232
+ npx tsc --noEmit
233
+ ```
234
+
235
+ Automate this with git hooks:
236
+
237
+ ```json
238
+ // package.json (using lint-staged + husky)
239
+ {
240
+ "lint-staged": {
241
+ "*.{ts,tsx}": ["eslint --fix", "prettier --write"],
242
+ "*.{json,md}": ["prettier --write"]
243
+ }
244
+ }
245
+ ```
246
+
247
+ ## Handling Generated Files
248
+
249
+ - **Commit generated files** only if the project expects them (e.g., `package-lock.json`, Prisma migrations)
250
+ - **Don't commit** build output (`dist/`, `.next/`), environment files (`.env`), or IDE config (`.vscode/settings.json` unless shared)
251
+ - **Have a `.gitignore`** that covers: `node_modules/`, `dist/`, `.env`, `.env.local`, `*.pem`
252
+
253
+ ## Using Git for Debugging
254
+
255
+ ```bash
256
+ # Find which commit introduced a bug
257
+ git bisect start
258
+ git bisect bad HEAD
259
+ git bisect good <known-good-commit>
260
+ # Git checkouts midpoints; run your test at each to narrow down
261
+
262
+ # View what changed recently
263
+ git log --oneline -20
264
+ git diff HEAD~5..HEAD -- src/
265
+
266
+ # Find who last changed a specific line
267
+ git blame src/services/task.ts
268
+
269
+ # Search commit messages for a keyword
270
+ git log --grep="validation" --oneline
271
+ ```
272
+
273
+ ## Common Rationalizations
274
+
275
+ | Rationalization | Reality |
276
+ | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
277
+ | "I'll commit when the feature is done" | One giant commit is impossible to review, debug, or revert. Commit each slice. |
278
+ | "The message doesn't matter" | Messages are documentation. Future you (and future agents) will need to understand what changed and why. |
279
+ | "I'll squash it all later" | Squashing destroys the development narrative. Prefer clean incremental commits from the start. |
280
+ | "Branches add overhead" | Short-lived branches are free and prevent conflicting work from colliding. Long-lived branches are the problem — merge within 1-3 days. |
281
+ | "I'll split this change later" | Large changes are harder to review, riskier to deploy, and harder to revert. Split before submitting, not after. |
282
+ | "I don't need a .gitignore" | Until `.env` with production secrets gets committed. Set it up immediately. |
283
+
284
+ ## Red Flags
285
+
286
+ - Large uncommitted changes accumulating
287
+ - Commit messages like "fix", "update", "misc"
288
+ - Formatting changes mixed with behavior changes
289
+ - No `.gitignore` in the project
290
+ - Committing `node_modules/`, `.env`, or build artifacts
291
+ - Long-lived branches that diverge significantly from main
292
+ - Force-pushing to shared branches
293
+
294
+ ## Verification
295
+
296
+ For every commit:
297
+
298
+ - [ ] Commit does one logical thing
299
+ - [ ] Message explains the why, follows type conventions
300
+ - [ ] Tests pass before committing
301
+ - [ ] No secrets in the diff
302
+ - [ ] No formatting-only changes mixed with behavior changes
303
+ - [ ] `.gitignore` covers standard exclusions