@smicolon/ai-kit 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/CLAUDE.md +7 -0
- package/.claude-plugin/marketplace.json +373 -0
- package/README.md +26 -16
- package/dist/index.js +146 -38
- package/package.json +4 -3
- package/packs/architect/CHANGELOG.md +17 -0
- package/packs/architect/README.md +58 -0
- package/packs/architect/agents/system-architect.md +768 -0
- package/packs/architect/commands/diagram-create.md +300 -0
- package/packs/better-auth/.claude-plugin/plugin.json +14 -0
- package/packs/better-auth/.mcp.json +14 -0
- package/packs/better-auth/CHANGELOG.md +26 -0
- package/packs/better-auth/README.md +125 -0
- package/packs/better-auth/agents/auth-architect.md +278 -0
- package/packs/better-auth/commands/auth-provider-add.md +265 -0
- package/packs/better-auth/commands/auth-setup.md +298 -0
- package/packs/better-auth/skills/auth-security/SKILL.md +425 -0
- package/packs/better-auth/skills/better-auth-patterns/SKILL.md +455 -0
- package/packs/dev-loop/.claude-plugin/plugin.json +10 -0
- package/packs/dev-loop/CHANGELOG.md +69 -0
- package/packs/dev-loop/README.md +155 -0
- package/packs/dev-loop/commands/cancel-dev.md +21 -0
- package/packs/dev-loop/commands/dev-loop.md +72 -0
- package/packs/dev-loop/commands/dev-plan.md +351 -0
- package/packs/dev-loop/hooks/hooks.json +15 -0
- package/packs/dev-loop/hooks/stop-hook.sh +178 -0
- package/packs/dev-loop/scripts/setup-dev-loop.sh +194 -0
- package/packs/dev-loop/skills/tdd-planner/SKILL.md +249 -0
- package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +874 -0
- package/packs/dev-loop/skills/tdd-planner/references/good-example.md +260 -0
- package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +275 -0
- package/packs/django/CHANGELOG.md +39 -0
- package/packs/django/README.md +92 -0
- package/packs/django/agents/django-architect.md +182 -0
- package/packs/django/agents/django-builder.md +250 -0
- package/packs/django/agents/django-feature-based.md +420 -0
- package/packs/django/agents/django-reviewer.md +253 -0
- package/packs/django/agents/django-tester.md +230 -0
- package/packs/django/commands/api-endpoint.md +285 -0
- package/packs/django/commands/model-create.md +178 -0
- package/packs/django/commands/test-generate.md +325 -0
- package/packs/django/rules/migrations.md +138 -0
- package/packs/django/rules/models.md +167 -0
- package/packs/django/rules/serializers.md +126 -0
- package/packs/django/rules/services.md +131 -0
- package/packs/django/rules/tests.md +140 -0
- package/packs/django/rules/views.md +102 -0
- package/packs/django/skills/import-convention-enforcer/SKILL.md +226 -0
- package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +343 -0
- package/packs/django/skills/migration-safety-checker/SKILL.md +375 -0
- package/packs/django/skills/model-entity-validator/SKILL.md +298 -0
- package/packs/django/skills/performance-optimizer/SKILL.md +447 -0
- package/packs/django/skills/red-phase-verifier/SKILL.md +180 -0
- package/packs/django/skills/security-first-validator/SKILL.md +435 -0
- package/packs/django/skills/test-coverage-advisor/SKILL.md +394 -0
- package/packs/django/skills/test-validity-checker/SKILL.md +194 -0
- package/packs/failure-log/.claude-plugin/plugin.json +14 -0
- package/packs/failure-log/CHANGELOG.md +20 -0
- package/packs/failure-log/README.md +168 -0
- package/packs/failure-log/commands/failure-add.md +106 -0
- package/packs/failure-log/commands/failure-list.md +89 -0
- package/packs/failure-log/hooks/hooks.json +16 -0
- package/packs/failure-log/hooks/scripts/inject-failures.sh +64 -0
- package/packs/failure-log/skills/failure-log-manager/SKILL.md +164 -0
- package/packs/flutter/.claude-plugin/plugin.json +10 -0
- package/packs/flutter/CHANGELOG.md +19 -0
- package/packs/flutter/README.md +170 -0
- package/packs/flutter/agents/flutter-architect.md +166 -0
- package/packs/flutter/agents/flutter-builder.md +303 -0
- package/packs/flutter/agents/release-manager.md +355 -0
- package/packs/flutter/commands/fastlane-setup.md +188 -0
- package/packs/flutter/commands/flutter-build.md +90 -0
- package/packs/flutter/commands/flutter-deploy.md +133 -0
- package/packs/flutter/commands/flutter-test.md +117 -0
- package/packs/flutter/commands/signing-setup.md +209 -0
- package/packs/flutter/hooks/hooks.json +17 -0
- package/packs/flutter/skills/fastlane-knowledge/SKILL.md +193 -0
- package/packs/flutter/skills/flutter-architecture/SKILL.md +127 -0
- package/packs/flutter/skills/store-publishing/SKILL.md +163 -0
- package/packs/hono/.claude-plugin/plugin.json +19 -0
- package/packs/hono/CHANGELOG.md +19 -0
- package/packs/hono/README.md +143 -0
- package/packs/hono/agents/hono-architect.md +240 -0
- package/packs/hono/agents/hono-builder.md +285 -0
- package/packs/hono/agents/hono-reviewer.md +279 -0
- package/packs/hono/agents/hono-tester.md +346 -0
- package/packs/hono/commands/middleware-create.md +223 -0
- package/packs/hono/commands/project-init.md +306 -0
- package/packs/hono/commands/route-create.md +153 -0
- package/packs/hono/commands/rpc-client.md +263 -0
- package/packs/hono/hooks/hooks.json +4 -0
- package/packs/hono/skills/cloudflare-bindings/SKILL.md +408 -0
- package/packs/hono/skills/hono-patterns/SKILL.md +309 -0
- package/packs/hono/skills/rpc-typesafe/SKILL.md +388 -0
- package/packs/hono/skills/zod-validation/SKILL.md +332 -0
- package/packs/nestjs/CHANGELOG.md +29 -0
- package/packs/nestjs/README.md +75 -0
- package/packs/nestjs/agents/nestjs-architect.md +402 -0
- package/packs/nestjs/agents/nestjs-builder.md +301 -0
- package/packs/nestjs/agents/nestjs-tester.md +437 -0
- package/packs/nestjs/commands/module-create.md +369 -0
- package/packs/nestjs/rules/controllers.md +92 -0
- package/packs/nestjs/rules/dto.md +124 -0
- package/packs/nestjs/rules/entities.md +102 -0
- package/packs/nestjs/rules/services.md +106 -0
- package/packs/nestjs/skills/barrel-export-manager/SKILL.md +389 -0
- package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +365 -0
- package/packs/nextjs/CHANGELOG.md +36 -0
- package/packs/nextjs/README.md +76 -0
- package/packs/nextjs/agents/frontend-tester.md +680 -0
- package/packs/nextjs/agents/frontend-visual.md +820 -0
- package/packs/nextjs/agents/nextjs-architect.md +331 -0
- package/packs/nextjs/agents/nextjs-modular.md +433 -0
- package/packs/nextjs/commands/component-create.md +398 -0
- package/packs/nextjs/rules/api-routes.md +129 -0
- package/packs/nextjs/rules/components.md +106 -0
- package/packs/nextjs/rules/hooks.md +132 -0
- package/packs/nextjs/skills/accessibility-validator/SKILL.md +445 -0
- package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +399 -0
- package/packs/nextjs/skills/react-form-validator/SKILL.md +569 -0
- package/packs/nuxtjs/CHANGELOG.md +30 -0
- package/packs/nuxtjs/README.md +56 -0
- package/packs/nuxtjs/agents/frontend-tester.md +680 -0
- package/packs/nuxtjs/agents/frontend-visual.md +820 -0
- package/packs/nuxtjs/agents/nuxtjs-architect.md +537 -0
- package/packs/nuxtjs/commands/component-create.md +223 -0
- package/packs/nuxtjs/rules/components.md +101 -0
- package/packs/nuxtjs/rules/composables.md +118 -0
- package/packs/nuxtjs/rules/server-routes.md +127 -0
- package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +183 -0
- package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +196 -0
- package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +190 -0
- package/packs/onboard/CHANGELOG.md +22 -0
- package/packs/onboard/README.md +103 -0
- package/packs/onboard/agents/onboard-guide.md +118 -0
- package/packs/onboard/commands/onboard.md +313 -0
- package/packs/onboard/skills/onboard-context-provider/SKILL.md +98 -0
- package/packs/tanstack-router/.claude-plugin/plugin.json +14 -0
- package/packs/tanstack-router/CHANGELOG.md +30 -0
- package/packs/tanstack-router/README.md +113 -0
- package/packs/tanstack-router/agents/tanstack-architect.md +173 -0
- package/packs/tanstack-router/agents/tanstack-builder.md +360 -0
- package/packs/tanstack-router/agents/tanstack-tester.md +454 -0
- package/packs/tanstack-router/commands/form-create.md +313 -0
- package/packs/tanstack-router/commands/query-create.md +263 -0
- package/packs/tanstack-router/commands/route-create.md +190 -0
- package/packs/tanstack-router/commands/table-create.md +413 -0
- package/packs/tanstack-router/skills/ai-patterns/SKILL.md +370 -0
- package/packs/tanstack-router/skills/db-patterns/SKILL.md +346 -0
- package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +415 -0
- package/packs/tanstack-router/skills/form-patterns/SKILL.md +425 -0
- package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +341 -0
- package/packs/tanstack-router/skills/query-patterns/SKILL.md +359 -0
- package/packs/tanstack-router/skills/router-patterns/SKILL.md +285 -0
- package/packs/tanstack-router/skills/store-patterns/SKILL.md +351 -0
- package/packs/tanstack-router/skills/table-patterns/SKILL.md +531 -0
- package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +428 -0
- package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +490 -0
- package/packs/worktree/.claude-plugin/plugin.json +19 -0
- package/packs/worktree/CHANGELOG.md +24 -0
- package/packs/worktree/README.md +110 -0
- package/packs/worktree/commands/wt.md +73 -0
- package/packs/worktree/scripts/wt.sh +396 -0
- package/packs/worktree/skills/worktree-manager/SKILL.md +68 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: TanStack DevTools Patterns
|
|
3
|
+
description: >-
|
|
4
|
+
TanStack DevTools patterns for debugging and development. Activates when
|
|
5
|
+
setting up development tools, debugging queries, or configuring developer
|
|
6
|
+
experience in React applications.
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# TanStack DevTools Patterns
|
|
11
|
+
|
|
12
|
+
This skill covers TanStack DevTools setup and usage for debugging React applications.
|
|
13
|
+
|
|
14
|
+
## React Query DevTools
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
```bash
|
|
18
|
+
bun add -D @tanstack/react-query-devtools
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Basic Setup
|
|
22
|
+
```typescript
|
|
23
|
+
// main.tsx
|
|
24
|
+
import { QueryClientProvider } from '@tanstack/react-query'
|
|
25
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
26
|
+
import { createQueryClient } from '@/lib/query-client'
|
|
27
|
+
|
|
28
|
+
const queryClient = createQueryClient()
|
|
29
|
+
|
|
30
|
+
function App() {
|
|
31
|
+
return (
|
|
32
|
+
<QueryClientProvider client={queryClient}>
|
|
33
|
+
<RouterProvider router={router} />
|
|
34
|
+
<ReactQueryDevtools initialIsOpen={false} />
|
|
35
|
+
</QueryClientProvider>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Production Lazy Loading
|
|
41
|
+
```typescript
|
|
42
|
+
// Only load devtools in development
|
|
43
|
+
import { lazy, Suspense } from 'react'
|
|
44
|
+
|
|
45
|
+
const ReactQueryDevtools = lazy(() =>
|
|
46
|
+
import('@tanstack/react-query-devtools').then((d) => ({
|
|
47
|
+
default: d.ReactQueryDevtools,
|
|
48
|
+
}))
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
function App() {
|
|
52
|
+
return (
|
|
53
|
+
<QueryClientProvider client={queryClient}>
|
|
54
|
+
<RouterProvider router={router} />
|
|
55
|
+
{import.meta.env.DEV && (
|
|
56
|
+
<Suspense fallback={null}>
|
|
57
|
+
<ReactQueryDevtools />
|
|
58
|
+
</Suspense>
|
|
59
|
+
)}
|
|
60
|
+
</QueryClientProvider>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### DevTools Configuration
|
|
66
|
+
```typescript
|
|
67
|
+
<ReactQueryDevtools
|
|
68
|
+
initialIsOpen={false}
|
|
69
|
+
position="bottom-right"
|
|
70
|
+
buttonPosition="bottom-right"
|
|
71
|
+
toggleButtonProps={{
|
|
72
|
+
style: {
|
|
73
|
+
marginBottom: '4rem', // Avoid overlapping with other UI
|
|
74
|
+
},
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Embedded DevTools
|
|
80
|
+
```typescript
|
|
81
|
+
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
|
|
82
|
+
|
|
83
|
+
function AdminDashboard() {
|
|
84
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<button onClick={() => setIsOpen(!isOpen)}>
|
|
89
|
+
Toggle Query Inspector
|
|
90
|
+
</button>
|
|
91
|
+
{isOpen && (
|
|
92
|
+
<div className="devtools-panel">
|
|
93
|
+
<ReactQueryDevtoolsPanel />
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Router DevTools
|
|
102
|
+
|
|
103
|
+
### Installation
|
|
104
|
+
```bash
|
|
105
|
+
bun add -D @tanstack/router-devtools
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Setup
|
|
109
|
+
```typescript
|
|
110
|
+
// routes/__root.tsx
|
|
111
|
+
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
|
|
112
|
+
|
|
113
|
+
export const Route = createRootRouteWithContext<RouterContext>()({
|
|
114
|
+
component: () => (
|
|
115
|
+
<>
|
|
116
|
+
<Outlet />
|
|
117
|
+
{import.meta.env.DEV && <TanStackRouterDevtools position="bottom-left" />}
|
|
118
|
+
</>
|
|
119
|
+
),
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Lazy Loading Router DevTools
|
|
124
|
+
```typescript
|
|
125
|
+
import { lazy, Suspense } from 'react'
|
|
126
|
+
|
|
127
|
+
const TanStackRouterDevtools = import.meta.env.DEV
|
|
128
|
+
? lazy(() =>
|
|
129
|
+
import('@tanstack/router-devtools').then((d) => ({
|
|
130
|
+
default: d.TanStackRouterDevtools,
|
|
131
|
+
}))
|
|
132
|
+
)
|
|
133
|
+
: () => null
|
|
134
|
+
|
|
135
|
+
export const Route = createRootRouteWithContext<RouterContext>()({
|
|
136
|
+
component: () => (
|
|
137
|
+
<>
|
|
138
|
+
<Outlet />
|
|
139
|
+
<Suspense fallback={null}>
|
|
140
|
+
<TanStackRouterDevtools />
|
|
141
|
+
</Suspense>
|
|
142
|
+
</>
|
|
143
|
+
),
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Combined DevTools Layout
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// routes/__root.tsx
|
|
151
|
+
import { lazy, Suspense } from 'react'
|
|
152
|
+
|
|
153
|
+
const ReactQueryDevtools = lazy(() =>
|
|
154
|
+
import('@tanstack/react-query-devtools').then((d) => ({
|
|
155
|
+
default: d.ReactQueryDevtools,
|
|
156
|
+
}))
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const TanStackRouterDevtools = lazy(() =>
|
|
160
|
+
import('@tanstack/router-devtools').then((d) => ({
|
|
161
|
+
default: d.TanStackRouterDevtools,
|
|
162
|
+
}))
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
export const Route = createRootRouteWithContext<RouterContext>()({
|
|
166
|
+
component: () => (
|
|
167
|
+
<>
|
|
168
|
+
<Outlet />
|
|
169
|
+
{import.meta.env.DEV && (
|
|
170
|
+
<Suspense fallback={null}>
|
|
171
|
+
<ReactQueryDevtools position="bottom-right" />
|
|
172
|
+
<TanStackRouterDevtools position="bottom-left" />
|
|
173
|
+
</Suspense>
|
|
174
|
+
)}
|
|
175
|
+
</>
|
|
176
|
+
),
|
|
177
|
+
})
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Query Logging
|
|
181
|
+
|
|
182
|
+
### Development Logger
|
|
183
|
+
```typescript
|
|
184
|
+
// lib/query-client.ts
|
|
185
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
186
|
+
|
|
187
|
+
export function createQueryClient() {
|
|
188
|
+
return new QueryClient({
|
|
189
|
+
defaultOptions: {
|
|
190
|
+
queries: {
|
|
191
|
+
// ... other options
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
...(import.meta.env.DEV && {
|
|
195
|
+
logger: {
|
|
196
|
+
log: console.log,
|
|
197
|
+
warn: console.warn,
|
|
198
|
+
error: console.error,
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Custom Query Logger
|
|
206
|
+
```typescript
|
|
207
|
+
const queryClient = new QueryClient({
|
|
208
|
+
queryCache: new QueryCache({
|
|
209
|
+
onError: (error, query) => {
|
|
210
|
+
if (import.meta.env.DEV) {
|
|
211
|
+
console.error(`Query Error [${query.queryKey}]:`, error)
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
onSuccess: (data, query) => {
|
|
215
|
+
if (import.meta.env.DEV) {
|
|
216
|
+
console.log(`Query Success [${query.queryKey}]:`, data)
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
}),
|
|
220
|
+
mutationCache: new MutationCache({
|
|
221
|
+
onError: (error, variables, context, mutation) => {
|
|
222
|
+
if (import.meta.env.DEV) {
|
|
223
|
+
console.error(`Mutation Error:`, error, variables)
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
}),
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Performance Monitoring
|
|
231
|
+
|
|
232
|
+
### Query Timing
|
|
233
|
+
```typescript
|
|
234
|
+
const queryClient = new QueryClient({
|
|
235
|
+
queryCache: new QueryCache({
|
|
236
|
+
onSuccess: (data, query) => {
|
|
237
|
+
if (import.meta.env.DEV) {
|
|
238
|
+
const timing = query.state.dataUpdatedAt - query.state.fetchFailureCount
|
|
239
|
+
console.log(`[${query.queryKey}] fetched in ${timing}ms`)
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
}),
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### React Profiler Integration
|
|
247
|
+
```typescript
|
|
248
|
+
import { Profiler } from 'react'
|
|
249
|
+
|
|
250
|
+
function App() {
|
|
251
|
+
const onRender = (
|
|
252
|
+
id: string,
|
|
253
|
+
phase: 'mount' | 'update',
|
|
254
|
+
actualDuration: number
|
|
255
|
+
) => {
|
|
256
|
+
if (import.meta.env.DEV && actualDuration > 16) {
|
|
257
|
+
console.warn(`Slow render: ${id} (${phase}) - ${actualDuration.toFixed(2)}ms`)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<Profiler id="App" onRender={onRender}>
|
|
263
|
+
<QueryClientProvider client={queryClient}>
|
|
264
|
+
<RouterProvider router={router} />
|
|
265
|
+
</QueryClientProvider>
|
|
266
|
+
</Profiler>
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Debug Utilities
|
|
272
|
+
|
|
273
|
+
### Query State Inspector Hook
|
|
274
|
+
```typescript
|
|
275
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
276
|
+
|
|
277
|
+
function useQueryInspector() {
|
|
278
|
+
const queryClient = useQueryClient()
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
getQueryState: (queryKey: unknown[]) =>
|
|
282
|
+
queryClient.getQueryState(queryKey),
|
|
283
|
+
|
|
284
|
+
getQueriesData: () =>
|
|
285
|
+
queryClient.getQueriesData({ type: 'all' }),
|
|
286
|
+
|
|
287
|
+
invalidateAll: () =>
|
|
288
|
+
queryClient.invalidateQueries(),
|
|
289
|
+
|
|
290
|
+
clearAll: () =>
|
|
291
|
+
queryClient.clear(),
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Usage in development
|
|
296
|
+
function DevPanel() {
|
|
297
|
+
const inspector = useQueryInspector()
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<div>
|
|
301
|
+
<button onClick={() => console.log(inspector.getQueriesData())}>
|
|
302
|
+
Log All Queries
|
|
303
|
+
</button>
|
|
304
|
+
<button onClick={inspector.invalidateAll}>
|
|
305
|
+
Invalidate All
|
|
306
|
+
</button>
|
|
307
|
+
<button onClick={inspector.clearAll}>
|
|
308
|
+
Clear Cache
|
|
309
|
+
</button>
|
|
310
|
+
</div>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Route State Inspector
|
|
316
|
+
```typescript
|
|
317
|
+
import { useRouter, useMatches } from '@tanstack/react-router'
|
|
318
|
+
|
|
319
|
+
function RouteInspector() {
|
|
320
|
+
const router = useRouter()
|
|
321
|
+
const matches = useMatches()
|
|
322
|
+
|
|
323
|
+
if (!import.meta.env.DEV) return null
|
|
324
|
+
|
|
325
|
+
return (
|
|
326
|
+
<div className="fixed bottom-20 left-4 bg-black/90 text-white p-4 rounded text-xs">
|
|
327
|
+
<pre>
|
|
328
|
+
{JSON.stringify(
|
|
329
|
+
{
|
|
330
|
+
pathname: router.state.location.pathname,
|
|
331
|
+
search: router.state.location.search,
|
|
332
|
+
matches: matches.map((m) => m.routeId),
|
|
333
|
+
},
|
|
334
|
+
null,
|
|
335
|
+
2
|
|
336
|
+
)}
|
|
337
|
+
</pre>
|
|
338
|
+
</div>
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Vite Configuration
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
// vite.config.ts
|
|
347
|
+
import { defineConfig } from 'vite'
|
|
348
|
+
|
|
349
|
+
export default defineConfig({
|
|
350
|
+
define: {
|
|
351
|
+
// Strip devtools from production
|
|
352
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
353
|
+
},
|
|
354
|
+
build: {
|
|
355
|
+
rollupOptions: {
|
|
356
|
+
// Exclude devtools from production bundle
|
|
357
|
+
external: import.meta.env.PROD
|
|
358
|
+
? ['@tanstack/react-query-devtools', '@tanstack/router-devtools']
|
|
359
|
+
: [],
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
})
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Conventions
|
|
366
|
+
|
|
367
|
+
1. **Lazy load devtools** - Always lazy load to reduce bundle size
|
|
368
|
+
2. **Environment check** - Only render in development
|
|
369
|
+
3. **Position wisely** - Avoid overlapping with app UI
|
|
370
|
+
4. **Production strip** - Ensure devtools are excluded from prod
|
|
371
|
+
5. **Custom logging** - Add meaningful logging in development
|
|
372
|
+
|
|
373
|
+
## Anti-Patterns
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// ❌ WRONG: DevTools in production bundle
|
|
377
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
378
|
+
|
|
379
|
+
function App() {
|
|
380
|
+
return (
|
|
381
|
+
<>
|
|
382
|
+
<Main />
|
|
383
|
+
<ReactQueryDevtools /> {/* Always included! */}
|
|
384
|
+
</>
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// ✅ CORRECT: Conditional and lazy loaded
|
|
389
|
+
const ReactQueryDevtools = lazy(() =>
|
|
390
|
+
import('@tanstack/react-query-devtools').then((d) => ({
|
|
391
|
+
default: d.ReactQueryDevtools,
|
|
392
|
+
}))
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
function App() {
|
|
396
|
+
return (
|
|
397
|
+
<>
|
|
398
|
+
<Main />
|
|
399
|
+
{import.meta.env.DEV && (
|
|
400
|
+
<Suspense fallback={null}>
|
|
401
|
+
<ReactQueryDevtools />
|
|
402
|
+
</Suspense>
|
|
403
|
+
)}
|
|
404
|
+
</>
|
|
405
|
+
)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ❌ WRONG: No position configuration (overlapping)
|
|
409
|
+
<ReactQueryDevtools />
|
|
410
|
+
<TanStackRouterDevtools />
|
|
411
|
+
|
|
412
|
+
// ✅ CORRECT: Different positions
|
|
413
|
+
<ReactQueryDevtools position="bottom-right" />
|
|
414
|
+
<TanStackRouterDevtools position="bottom-left" />
|
|
415
|
+
```
|