@caddis/cli 0.0.0 → 0.1.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.
Files changed (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -1
  3. package/bundles/antigravity-plugin/agents/code-reviewer.md +47 -0
  4. package/bundles/antigravity-plugin/agents/preflight.md +53 -0
  5. package/bundles/antigravity-plugin/guard_agy.py +338 -0
  6. package/bundles/antigravity-plugin/hooks.json +36 -0
  7. package/bundles/antigravity-plugin/mcp_config.json +8 -0
  8. package/bundles/antigravity-plugin/mcp_ping_server.py +55 -0
  9. package/bundles/antigravity-plugin/plugin.json +5 -0
  10. package/bundles/antigravity-plugin/session_end_agy.py +57 -0
  11. package/bundles/antigravity-plugin/skills/_registry.md +115 -0
  12. package/bundles/antigravity-plugin/skills/add-rules/SKILL.md +45 -0
  13. package/bundles/antigravity-plugin/skills/api-design/SKILL.md +249 -0
  14. package/bundles/antigravity-plugin/skills/backend-development/SKILL.md +305 -0
  15. package/bundles/antigravity-plugin/skills/best-practices/SKILL.md +500 -0
  16. package/bundles/antigravity-plugin/skills/best-practices/agents/best-practices-referencer.md +263 -0
  17. package/bundles/antigravity-plugin/skills/best-practices/agents/codebase-context-builder.md +326 -0
  18. package/bundles/antigravity-plugin/skills/best-practices/agents/task-intent-analyzer.md +245 -0
  19. package/bundles/antigravity-plugin/skills/best-practices/references/anti-patterns.md +571 -0
  20. package/bundles/antigravity-plugin/skills/best-practices/references/before-after-examples.md +1114 -0
  21. package/bundles/antigravity-plugin/skills/best-practices/references/best-practices-guide.md +513 -0
  22. package/bundles/antigravity-plugin/skills/best-practices/references/common-workflows.md +692 -0
  23. package/bundles/antigravity-plugin/skills/best-practices/references/prompt-patterns.md +547 -0
  24. package/bundles/antigravity-plugin/skills/brainstorming/SKILL.md +57 -0
  25. package/bundles/antigravity-plugin/skills/ci-cd-pipeline/SKILL.md +315 -0
  26. package/bundles/antigravity-plugin/skills/code-documentation/SKILL.md +271 -0
  27. package/bundles/antigravity-plugin/skills/code-review/SKILL.md +122 -0
  28. package/bundles/antigravity-plugin/skills/codebase-audit/SKILL.md +204 -0
  29. package/bundles/antigravity-plugin/skills/context-curator/SKILL.md +157 -0
  30. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +40 -0
  31. package/bundles/antigravity-plugin/skills/css-architecture/SKILL.md +305 -0
  32. package/bundles/antigravity-plugin/skills/css-architecture/references/RESPONSIVE-DESIGN.md +604 -0
  33. package/bundles/antigravity-plugin/skills/database-design/SKILL.md +177 -0
  34. package/bundles/antigravity-plugin/skills/db-diagram/SKILL.md +148 -0
  35. package/bundles/antigravity-plugin/skills/db-diagram/scripts/sql_to_graph.py +1212 -0
  36. package/bundles/antigravity-plugin/skills/digress/SKILL.md +61 -0
  37. package/bundles/antigravity-plugin/skills/draw-io/SKILL.md +162 -0
  38. package/bundles/antigravity-plugin/skills/draw-io/references/aws-icons.md +677 -0
  39. package/bundles/antigravity-plugin/skills/draw-io/references/layout-guidelines.md +142 -0
  40. package/bundles/antigravity-plugin/skills/draw-io/references/troubleshooting.md +118 -0
  41. package/bundles/antigravity-plugin/skills/draw-io/references/workflows.md +103 -0
  42. package/bundles/antigravity-plugin/skills/draw-io/scripts/convert-drawio-to-png.sh +25 -0
  43. package/bundles/antigravity-plugin/skills/draw-io/scripts/find_aws_icon.py +79 -0
  44. package/bundles/antigravity-plugin/skills/error-handling/SKILL.md +260 -0
  45. package/bundles/antigravity-plugin/skills/excalidraw-db/SKILL.md +38 -0
  46. package/bundles/antigravity-plugin/skills/fastapi-dev/SKILL.md +300 -0
  47. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +198 -0
  48. package/bundles/antigravity-plugin/skills/frontend-design/SKILL.md +193 -0
  49. package/bundles/antigravity-plugin/skills/frontend-design/references/my-tech-stack.md +127 -0
  50. package/bundles/antigravity-plugin/skills/gh-cli/SKILL.md +195 -0
  51. package/bundles/antigravity-plugin/skills/git-commit/SKILL.md +285 -0
  52. package/bundles/antigravity-plugin/skills/golden-plan/SKILL.md +577 -0
  53. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +100 -0
  54. package/bundles/antigravity-plugin/skills/implement/SKILL.md +114 -0
  55. package/bundles/antigravity-plugin/skills/javascript-typescript/SKILL.md +142 -0
  56. package/bundles/antigravity-plugin/skills/kb/SKILL.md +60 -0
  57. package/bundles/antigravity-plugin/skills/mermaid-db/SKILL.md +33 -0
  58. package/bundles/antigravity-plugin/skills/mermaid-diagrams/SKILL.md +236 -0
  59. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/ENHANCEMENTS.md +264 -0
  60. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/MERMAID-SUMMARY.md +137 -0
  61. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/advanced-features.md +556 -0
  62. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/architecture-diagrams.md +192 -0
  63. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/c4-diagrams.md +410 -0
  64. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/class-diagrams.md +361 -0
  65. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/erd-diagrams.md +510 -0
  66. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/flowcharts.md +450 -0
  67. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/sequence-diagrams.md +394 -0
  68. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/troubleshooting.md +335 -0
  69. package/bundles/antigravity-plugin/skills/mermaid-diagrams/references/workflows.md +418 -0
  70. package/bundles/antigravity-plugin/skills/migrate-dir/SKILL.md +68 -0
  71. package/bundles/antigravity-plugin/skills/mockup/SKILL.md +242 -0
  72. package/bundles/antigravity-plugin/skills/particle-art/SKILL.md +243 -0
  73. package/bundles/antigravity-plugin/skills/particle-art/references/canvas-utils.ts +171 -0
  74. package/bundles/antigravity-plugin/skills/particle-art/references/dot-field.template.tsx +203 -0
  75. package/bundles/antigravity-plugin/skills/particle-art/references/flow-field.template.tsx +263 -0
  76. package/bundles/antigravity-plugin/skills/particle-art/references/node-shape.template.tsx +261 -0
  77. package/bundles/antigravity-plugin/skills/particle-art/references/shape-sampler.ts +281 -0
  78. package/bundles/antigravity-plugin/skills/particle-art/references/stipple-morph.template.tsx +167 -0
  79. package/bundles/antigravity-plugin/skills/particle-art/references/stipple.template.tsx +175 -0
  80. package/bundles/antigravity-plugin/skills/particle-art/references/trail-ghost.template.tsx +266 -0
  81. package/bundles/antigravity-plugin/skills/particle-art/references/usage-examples.md +320 -0
  82. package/bundles/antigravity-plugin/skills/playwright/API_REFERENCE.md +653 -0
  83. package/bundles/antigravity-plugin/skills/playwright/SKILL.md +454 -0
  84. package/bundles/antigravity-plugin/skills/playwright/lib/helpers.js +441 -0
  85. package/bundles/antigravity-plugin/skills/playwright/package.json +26 -0
  86. package/bundles/antigravity-plugin/skills/playwright/run.js +228 -0
  87. package/bundles/antigravity-plugin/skills/prd/SKILL.md +107 -0
  88. package/bundles/antigravity-plugin/skills/preflight/SKILL.md +435 -0
  89. package/bundles/antigravity-plugin/skills/python/SKILL.md +388 -0
  90. package/bundles/antigravity-plugin/skills/react-best-practices/SKILL.md +269 -0
  91. package/bundles/antigravity-plugin/skills/react-dev/README.md +404 -0
  92. package/bundles/antigravity-plugin/skills/react-dev/SKILL.md +459 -0
  93. package/bundles/antigravity-plugin/skills/react-dev/examples/generic-components.md +579 -0
  94. package/bundles/antigravity-plugin/skills/react-dev/examples/server-components.md +579 -0
  95. package/bundles/antigravity-plugin/skills/react-dev/references/event-handlers.md +574 -0
  96. package/bundles/antigravity-plugin/skills/react-dev/references/hooks.md +456 -0
  97. package/bundles/antigravity-plugin/skills/react-dev/references/react-19-patterns.md +638 -0
  98. package/bundles/antigravity-plugin/skills/react-dev/references/react-router.md +1002 -0
  99. package/bundles/antigravity-plugin/skills/react-dev/references/tanstack-router.md +587 -0
  100. package/bundles/antigravity-plugin/skills/refactoring/SKILL.md +486 -0
  101. package/bundles/antigravity-plugin/skills/resume/SKILL.md +36 -0
  102. package/bundles/antigravity-plugin/skills/security-review/SKILL.md +196 -0
  103. package/bundles/antigravity-plugin/skills/setup-project-ai/SKILL.md +61 -0
  104. package/bundles/antigravity-plugin/skills/ship/SKILL.md +107 -0
  105. package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +103 -0
  106. package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +102 -0
  107. package/bundles/antigravity-plugin/skills/skill-creator/LICENSE.txt +202 -0
  108. package/bundles/antigravity-plugin/skills/skill-creator/SKILL.md +491 -0
  109. package/bundles/antigravity-plugin/skills/skill-creator/agents/analyzer.md +274 -0
  110. package/bundles/antigravity-plugin/skills/skill-creator/agents/comparator.md +202 -0
  111. package/bundles/antigravity-plugin/skills/skill-creator/agents/grader.md +223 -0
  112. package/bundles/antigravity-plugin/skills/skill-creator/assets/eval_review.html +146 -0
  113. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  114. package/bundles/antigravity-plugin/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  115. package/bundles/antigravity-plugin/skills/skill-creator/references/schemas.md +430 -0
  116. package/bundles/antigravity-plugin/skills/skill-creator/scripts/__init__.py +0 -0
  117. package/bundles/antigravity-plugin/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  118. package/bundles/antigravity-plugin/skills/skill-creator/scripts/generate_report.py +326 -0
  119. package/bundles/antigravity-plugin/skills/skill-creator/scripts/improve_description.py +247 -0
  120. package/bundles/antigravity-plugin/skills/skill-creator/scripts/package_skill.py +136 -0
  121. package/bundles/antigravity-plugin/skills/skill-creator/scripts/quick_validate.py +103 -0
  122. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_eval.py +310 -0
  123. package/bundles/antigravity-plugin/skills/skill-creator/scripts/run_loop.py +328 -0
  124. package/bundles/antigravity-plugin/skills/skill-creator/scripts/utils.py +47 -0
  125. package/bundles/antigravity-plugin/skills/sql/SKILL.md +321 -0
  126. package/bundles/antigravity-plugin/skills/tdd/SKILL.md +37 -0
  127. package/bundles/antigravity-plugin/skills/tdd-workflow/SKILL.md +188 -0
  128. package/bundles/antigravity-plugin/skills/technical-writing/SKILL.md +286 -0
  129. package/bundles/antigravity-plugin/skills/test-strategy/SKILL.md +155 -0
  130. package/bundles/antigravity-plugin/skills/ui-brief/SKILL.md +84 -0
  131. package/bundles/antigravity-plugin/skills/ui-review/SKILL.md +176 -0
  132. package/bundles/antigravity-plugin/skills/ui-review/references/framework-fixes.md +471 -0
  133. package/bundles/antigravity-plugin/skills/ui-review/references/visual-checklist.md +236 -0
  134. package/bundles/antigravity-plugin/skills/usage-review/SKILL.md +77 -0
  135. package/bundles/antigravity-plugin/skills/use-model/SKILL.md +64 -0
  136. package/bundles/antigravity-plugin/skills/using-git-worktrees/SKILL.md +217 -0
  137. package/bundles/antigravity-plugin/skills/version/SKILL.md +18 -0
  138. package/bundles/antigravity-plugin/skills/warm-editorial-ui/DESIGN_TOKENS.md +487 -0
  139. package/bundles/antigravity-plugin/skills/warm-editorial-ui/IMPLEMENTATION_GUIDE.md +177 -0
  140. package/bundles/antigravity-plugin/skills/warm-editorial-ui/SKILL.md +732 -0
  141. package/bundles/antigravity-plugin/skills/webapp-testing/LICENSE.txt +202 -0
  142. package/bundles/antigravity-plugin/skills/webapp-testing/SKILL.md +97 -0
  143. package/bundles/antigravity-plugin/skills/webapp-testing/examples/console_logging.py +35 -0
  144. package/bundles/antigravity-plugin/skills/webapp-testing/examples/element_discovery.py +40 -0
  145. package/bundles/antigravity-plugin/skills/webapp-testing/examples/static_html_automation.py +33 -0
  146. package/bundles/antigravity-plugin/skills/webapp-testing/scripts/with_server.py +106 -0
  147. package/bundles/antigravity-plugin/skills/windows-deployment/SKILL.md +880 -0
  148. package/bundles/antigravity-plugin/skills/writing-plans/SKILL.md +384 -0
  149. package/bundles/antigravity-plugin/statusline-command-agy.sh +91 -0
  150. package/bundles/antigravity-plugin/warm_start_agy.py +149 -0
  151. package/bundles/manifest.json +6 -0
  152. package/dist/cli.js +5363 -0
  153. package/package.json +61 -4
@@ -0,0 +1,404 @@
1
+ # React TypeScript Development Skill
2
+
3
+ ## Purpose
4
+
5
+ The `react-dev` skill provides comprehensive TypeScript patterns and best practices for building type-safe React applications. It serves as a complete reference for modern React development with TypeScript, covering React 18-19 features, including Server Components, type-safe routing, and proper event handling.
6
+
7
+ This skill exists to eliminate TypeScript guesswork in React development by providing compile-time guarantees, confident refactoring, and production-ready patterns that catch bugs before runtime.
8
+
9
+ ## When to Use
10
+
11
+ Activate this skill when working on:
12
+
13
+ - **Building typed React components** - Creating new components with proper TypeScript types
14
+ - **Implementing generic components** - Tables, lists, modals, form fields that work with any data type
15
+ - **Typing event handlers and forms** - Mouse events, form submissions, input changes, keyboard events
16
+ - **Using React 19 features** - Actions, Server Components, `use()` hook, `useActionState`
17
+ - **Router integration** - TanStack Router or React Router v7 with type safety
18
+ - **Custom hooks with proper typing** - Creating reusable hooks with correct return types
19
+ - **Migrating to React 19** - Understanding breaking changes and new patterns
20
+
21
+ **Trigger phrases:**
22
+ - "Build a typed React component"
23
+ - "Type this event handler"
24
+ - "Create a generic Table/List/Modal"
25
+ - "Use React 19 Server Components"
26
+ - "Type-safe routing with TanStack/React Router"
27
+ - "How do I type this hook?"
28
+ - "React TypeScript best practices"
29
+
30
+ **Not for:**
31
+ - Non-React TypeScript projects
32
+ - Vanilla JavaScript React (without TypeScript)
33
+ - React Native-specific patterns
34
+
35
+ ## How It Works
36
+
37
+ The skill provides progressive disclosure of React TypeScript knowledge:
38
+
39
+ 1. **Core patterns loaded immediately** - Component props, event handlers, hooks typing
40
+ 2. **Advanced patterns referenced on-demand** - Generic components, Server Components, routing
41
+ 3. **Reference files for deep dives** - Detailed examples and edge cases only loaded when needed
42
+ 4. **React 19 migration guidance** - Breaking changes and new APIs clearly marked
43
+
44
+ The skill is structured around:
45
+ - **Quick reference sections** - Common patterns you can copy immediately
46
+ - **Detailed reference files** - In-depth examples and explanations
47
+ - **Rules and anti-patterns** - What to always do and what to never do
48
+ - **Version-specific guidance** - React 18 vs React 19 differences highlighted
49
+
50
+ ## Key Features
51
+
52
+ ### 1. React 19 Breaking Changes
53
+
54
+ Covers all major breaking changes in React 19:
55
+
56
+ - **ref as prop** - No more `forwardRef`, refs are regular props now
57
+ - **useActionState** - Replaces deprecated `useFormState`
58
+ - **use() hook** - Unwraps promises and context in components
59
+ - **Migration patterns** - Step-by-step guides for updating existing code
60
+
61
+ ### 2. Component Patterns
62
+
63
+ Type-safe patterns for common component scenarios:
64
+
65
+ - **Props typing** - Extending native HTML elements with `ComponentPropsWithoutRef`
66
+ - **Children typing** - `ReactNode`, `ReactElement`, render props
67
+ - **Discriminated unions** - Type-safe variant props (e.g., button vs link)
68
+ - **Generic components** - Reusable components that infer types from data
69
+
70
+ ### 3. Event Handler Typing
71
+
72
+ Specific event types for accurate TypeScript inference:
73
+
74
+ - Mouse events (`MouseEvent<HTMLButtonElement>`)
75
+ - Form events (`FormEvent<HTMLFormElement>`)
76
+ - Input changes (`ChangeEvent<HTMLInputElement>`)
77
+ - Keyboard events (`KeyboardEvent<HTMLInputElement>`)
78
+ - Focus, drag, clipboard, touch, wheel events (in reference docs)
79
+
80
+ ### 4. Hooks Typing
81
+
82
+ Proper TypeScript patterns for all React hooks:
83
+
84
+ - `useState` - Explicit types for unions and nullable values
85
+ - `useRef` - DOM refs (null) vs mutable refs (direct access)
86
+ - `useReducer` - Discriminated union actions
87
+ - `useContext` - Null guard patterns
88
+ - Custom hooks - Tuple returns with `as const`
89
+
90
+ ### 5. Server Components (React 19)
91
+
92
+ Modern patterns for Server Components and Server Actions:
93
+
94
+ - Async components with direct data fetching
95
+ - Server Actions with `'use server'` directive
96
+ - Client components consuming Server Actions
97
+ - Promise handoff with `use()` hook
98
+ - Parallel fetching and streaming
99
+
100
+ ### 6. Type-Safe Routing
101
+
102
+ Comprehensive routing patterns for both major routers:
103
+
104
+ - **TanStack Router** - Compile-time type safety with Zod validation
105
+ - **React Router v7** - Auto-generated types with Framework Mode
106
+ - Type-safe params, search params, loaders, actions
107
+
108
+ ### 7. Generic Components
109
+
110
+ Reusable components that work with any data type:
111
+
112
+ - Tables with type-safe columns
113
+ - Lists with constrained generics
114
+ - Modals, selects, form fields
115
+ - Render props and keyof patterns
116
+
117
+ ## Prerequisites
118
+
119
+ - **React 18 or 19** - Patterns are optimized for modern React
120
+ - **TypeScript 5.0+** - Uses latest TypeScript features
121
+ - **Router (optional)** - TanStack Router or React Router v7 for routing patterns
122
+ - **Zod (optional)** - For TanStack Router search param validation
123
+
124
+ ## Usage Examples
125
+
126
+ ### Example 1: Type-Safe Button Component
127
+
128
+ ```typescript
129
+ type ButtonProps = {
130
+ variant: 'primary' | 'secondary';
131
+ } & React.ComponentPropsWithoutRef<'button'>;
132
+
133
+ function Button({ variant, children, ...props }: ButtonProps) {
134
+ return (
135
+ <button
136
+ className={variant}
137
+ {...props}
138
+ >
139
+ {children}
140
+ </button>
141
+ );
142
+ }
143
+
144
+ // Usage
145
+ <Button variant="primary" onClick={(e) => console.log(e.currentTarget.disabled)}>
146
+ Click me
147
+ </Button>
148
+ ```
149
+
150
+ ### Example 2: Generic Table Component
151
+
152
+ ```typescript
153
+ type Column<T> = {
154
+ key: keyof T;
155
+ header: string;
156
+ render?: (value: T[keyof T], item: T) => React.ReactNode;
157
+ };
158
+
159
+ type TableProps<T> = {
160
+ data: T[];
161
+ columns: Column<T>[];
162
+ keyExtractor: (item: T) => string | number;
163
+ };
164
+
165
+ function Table<T>({ data, columns, keyExtractor }: TableProps<T>) {
166
+ return (
167
+ <table>
168
+ <thead>
169
+ <tr>{columns.map(col => <th key={String(col.key)}>{col.header}</th>)}</tr>
170
+ </thead>
171
+ <tbody>
172
+ {data.map(item => (
173
+ <tr key={keyExtractor(item)}>
174
+ {columns.map(col => (
175
+ <td key={String(col.key)}>
176
+ {col.render ? col.render(item[col.key], item) : String(item[col.key])}
177
+ </td>
178
+ ))}
179
+ </tr>
180
+ ))}
181
+ </tbody>
182
+ </table>
183
+ );
184
+ }
185
+
186
+ // Usage - types are inferred!
187
+ type User = { id: number; name: string; email: string };
188
+ const users: User[] = [...];
189
+
190
+ <Table
191
+ data={users}
192
+ columns={[
193
+ { key: 'name', header: 'Name' },
194
+ { key: 'email', header: 'Email' }
195
+ ]}
196
+ keyExtractor={user => user.id}
197
+ />
198
+ ```
199
+
200
+ ### Example 3: React 19 Server Action with Form
201
+
202
+ ```typescript
203
+ // actions/user.ts
204
+ 'use server';
205
+
206
+ export async function updateUser(userId: string, formData: FormData) {
207
+ const name = formData.get('name') as string;
208
+ await db.user.update({
209
+ where: { id: userId },
210
+ data: { name }
211
+ });
212
+ revalidatePath(`/users/${userId}`);
213
+ return { success: true };
214
+ }
215
+
216
+ // UserForm.tsx
217
+ 'use client';
218
+
219
+ import { useActionState } from 'react';
220
+ import { updateUser } from '@/actions/user';
221
+
222
+ function UserForm({ userId }: { userId: string }) {
223
+ const [state, formAction, isPending] = useActionState(
224
+ (prev, formData) => updateUser(userId, formData),
225
+ {}
226
+ );
227
+
228
+ return (
229
+ <form action={formAction}>
230
+ <input name="name" />
231
+ <button disabled={isPending}>
232
+ {isPending ? 'Saving...' : 'Save'}
233
+ </button>
234
+ {state.success && <p>Saved!</p>}
235
+ </form>
236
+ );
237
+ }
238
+ ```
239
+
240
+ ### Example 4: Type-Safe Event Handlers
241
+
242
+ ```typescript
243
+ function Form() {
244
+ const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
245
+ e.preventDefault();
246
+ const formData = new FormData(e.currentTarget);
247
+ console.log(Object.fromEntries(formData));
248
+ };
249
+
250
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
251
+ console.log(e.target.value); // Typed correctly!
252
+ };
253
+
254
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
255
+ if (e.key === 'Enter') {
256
+ e.currentTarget.blur(); // currentTarget is typed as HTMLInputElement
257
+ }
258
+ };
259
+
260
+ return (
261
+ <form onSubmit={handleSubmit}>
262
+ <input
263
+ onChange={handleChange}
264
+ onKeyDown={handleKeyDown}
265
+ />
266
+ </form>
267
+ );
268
+ }
269
+ ```
270
+
271
+ ### Example 5: Custom Hook with Proper Typing
272
+
273
+ ```typescript
274
+ function useToggle(initial = false) {
275
+ const [value, setValue] = useState(initial);
276
+ const toggle = () => setValue(v => !v);
277
+ return [value, toggle] as const; // Tuple type preserved!
278
+ }
279
+
280
+ // Usage
281
+ const [isOpen, toggleOpen] = useToggle(false);
282
+ // isOpen is boolean, toggleOpen is () => void
283
+ ```
284
+
285
+ ### Example 6: TanStack Router Type-Safe Route
286
+
287
+ ```typescript
288
+ import { createRoute } from '@tanstack/react-router';
289
+ import { z } from 'zod';
290
+
291
+ const userRoute = createRoute({
292
+ path: '/users/$userId',
293
+ component: UserPage,
294
+ loader: async ({ params }) => ({
295
+ user: await fetchUser(params.userId)
296
+ }),
297
+ validateSearch: z.object({
298
+ tab: z.enum(['profile', 'settings']).optional(),
299
+ page: z.number().int().positive().default(1),
300
+ }),
301
+ });
302
+
303
+ function UserPage() {
304
+ // All fully typed from the route definition!
305
+ const { user } = useLoaderData({ from: userRoute.id });
306
+ const { tab, page } = useSearch({ from: userRoute.id });
307
+ const { userId } = useParams({ from: userRoute.id });
308
+
309
+ return <div>{user.name} - {tab} - Page {page}</div>;
310
+ }
311
+ ```
312
+
313
+ ## Output
314
+
315
+ The skill provides:
316
+
317
+ 1. **Code examples** - Copy-paste ready TypeScript code
318
+ 2. **Type definitions** - Exact types to use for your scenarios
319
+ 3. **Pattern explanations** - Why patterns work and when to use them
320
+ 4. **Migration guides** - Step-by-step updates for React 19
321
+ 5. **Reference links** - Pointers to detailed documentation when needed
322
+
323
+ ## Best Practices
324
+
325
+ ### Always Do
326
+
327
+ ✅ **Use specific event types** - `MouseEvent<HTMLButtonElement>` not `React.MouseEvent`
328
+ ✅ **Explicit `useState` for unions/null** - `useState<User | null>(null)`
329
+ ✅ **Extend native elements** - `ComponentPropsWithoutRef<'button'>`
330
+ ✅ **Discriminated unions for variants** - Type-safe props based on variant
331
+ ✅ **`as const` for tuple returns** - Preserve tuple types in custom hooks
332
+ ✅ **`ref` as prop in React 19** - No `forwardRef` needed
333
+ ✅ **`useActionState` for forms** - Not deprecated `useFormState`
334
+ ✅ **Type-safe routing patterns** - Use provided router patterns
335
+
336
+ ### Never Do
337
+
338
+ ❌ **Use `any` for event handlers** - Defeats TypeScript's purpose
339
+ ❌ **Use `JSX.Element` for children** - Use `ReactNode` instead
340
+ ❌ **Use `forwardRef` in React 19+** - It's deprecated
341
+ ❌ **Use `useFormState`** - Deprecated in React 19
342
+ ❌ **Forget null handling for DOM refs** - Always use `ref?.current`
343
+ ❌ **Mix Server/Client in same file** - Will cause hydration errors
344
+ ❌ **Await promises before `use()`** - Defeats streaming/Suspense
345
+
346
+ ### Progressive Enhancement
347
+
348
+ 1. **Start simple** - Basic component props and event handlers
349
+ 2. **Add constraints** - Discriminated unions, generic constraints
350
+ 3. **Leverage inference** - Let TypeScript infer types from usage
351
+ 4. **Reference docs when stuck** - Deep dive into specific patterns
352
+
353
+ ### Reference File Organization
354
+
355
+ The skill includes detailed reference files:
356
+
357
+ - **hooks.md** - `useState`, `useRef`, `useReducer`, `useContext`, custom hooks
358
+ - **event-handlers.md** - All event types, generic handlers, edge cases
359
+ - **react-19-patterns.md** - `useActionState`, `use()`, `useOptimistic`, migration
360
+ - **generic-components.md** - Table, Select, List, Modal, FormField patterns
361
+ - **server-components.md** - Async components, Server Actions, streaming
362
+ - **tanstack-router.md** - TanStack Router typed routes, search params, navigation
363
+ - **react-router.md** - React Router v7 loaders, actions, type generation
364
+
365
+ These files are loaded on-demand to keep context efficient. The skill will reference them when deeper knowledge is needed.
366
+
367
+ ## Context Efficiency
368
+
369
+ This skill follows progressive disclosure principles:
370
+
371
+ - **Core patterns in SKILL.md** - Most common use cases immediately available
372
+ - **Reference files on-demand** - Deep dives only when needed
373
+ - **Script-free design** - Pure knowledge, no executable scripts needed
374
+ - **Single-level references** - Direct links, no nested includes
375
+
376
+ This keeps the skill's context footprint minimal while providing comprehensive coverage when needed.
377
+
378
+ ## Version Compatibility
379
+
380
+ - **React 18** - All patterns work, ignore React 19-specific sections
381
+ - **React 19** - Full support including Server Components, `use()`, `useActionState`
382
+ - **TypeScript 5.0+** - Recommended for best type inference
383
+ - **TanStack Router** - Any version supporting `createRoute`
384
+ - **React Router v7+** - Framework Mode for auto-generated types
385
+
386
+ ## Getting Started
387
+
388
+ 1. **Install the skill** in Claude Code or add to claude.ai project knowledge
389
+ 2. **Mention React TypeScript** in your conversation or request
390
+ 3. **Reference specific patterns** - "How do I type this event handler?"
391
+ 4. **Let Claude suggest patterns** - Describe what you're building
392
+ 5. **Explore reference docs** - Ask for deep dives when needed
393
+
394
+ ## Related Skills
395
+
396
+ - **typescript-patterns** - General TypeScript patterns beyond React
397
+ - **frontend-testing** - Testing typed React components
398
+ - **component-library** - Building design systems with TypeScript
399
+
400
+ ---
401
+
402
+ **Version:** 1.0.0
403
+ **Last Updated:** 2026-01-20
404
+ **Maintained by:** Softaworks Agent Skills