specialist-agent 1.0.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/LICENSE +21 -0
- package/README.md +346 -0
- package/agents/cloud-lite.md +44 -0
- package/agents/cloud.md +122 -0
- package/agents/data-lite.md +44 -0
- package/agents/data.md +136 -0
- package/agents/designer-lite.md +44 -0
- package/agents/designer.md +126 -0
- package/agents/devops-lite.md +44 -0
- package/agents/devops.md +131 -0
- package/agents/finance-lite.md +43 -0
- package/agents/finance.md +108 -0
- package/agents/security-lite.md +43 -0
- package/agents/security.md +123 -0
- package/agents/starter-lite.md +49 -0
- package/agents/starter.md +200 -0
- package/agents/tester-lite.md +48 -0
- package/agents/tester.md +142 -0
- package/cli/index.mjs +232 -0
- package/package.json +45 -0
- package/packs/nextjs/ARCHITECTURE.md +1033 -0
- package/packs/nextjs/CLAUDE.md +70 -0
- package/packs/nextjs/agents/builder.md +145 -0
- package/packs/nextjs/agents/doctor.md +152 -0
- package/packs/nextjs/agents/migrator.md +203 -0
- package/packs/nextjs/agents/reviewer.md +141 -0
- package/packs/nextjs/agents-lite/builder.md +51 -0
- package/packs/nextjs/agents-lite/doctor.md +51 -0
- package/packs/nextjs/agents-lite/migrator.md +52 -0
- package/packs/nextjs/agents-lite/reviewer.md +51 -0
- package/packs/nextjs/skills/dev-create-component/SKILL.md +82 -0
- package/packs/nextjs/skills/dev-create-hook/SKILL.md +90 -0
- package/packs/nextjs/skills/dev-create-module/SKILL.md +63 -0
- package/packs/nextjs/skills/dev-create-service/SKILL.md +35 -0
- package/packs/nextjs/skills/dev-create-test/SKILL.md +106 -0
- package/packs/nextjs/skills/dev-generate-types/SKILL.md +37 -0
- package/packs/nextjs/skills/docs-onboard/SKILL.md +55 -0
- package/packs/nextjs/skills/migration-migrate-component/SKILL.md +58 -0
- package/packs/nextjs/skills/migration-migrate-module/SKILL.md +25 -0
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +101 -0
- package/packs/nextjs/skills/review-fix-violations/SKILL.md +48 -0
- package/packs/nextjs/skills/review-review/SKILL.md +46 -0
- package/packs/react/ARCHITECTURE.md +991 -0
- package/packs/react/CLAUDE.md +66 -0
- package/packs/react/agents/builder.md +74 -0
- package/packs/react/agents/doctor.md +100 -0
- package/packs/react/agents/migrator.md +114 -0
- package/packs/react/agents/reviewer.md +116 -0
- package/packs/react/agents-lite/builder.md +42 -0
- package/packs/react/agents-lite/doctor.md +41 -0
- package/packs/react/agents-lite/migrator.md +51 -0
- package/packs/react/agents-lite/reviewer.md +47 -0
- package/packs/react/skills/dev-create-component/SKILL.md +53 -0
- package/packs/react/skills/dev-create-hook/SKILL.md +78 -0
- package/packs/react/skills/dev-create-module/SKILL.md +51 -0
- package/packs/react/skills/dev-create-service/SKILL.md +34 -0
- package/packs/react/skills/dev-create-test/SKILL.md +92 -0
- package/packs/react/skills/dev-generate-types/SKILL.md +37 -0
- package/packs/react/skills/docs-onboard/SKILL.md +42 -0
- package/packs/react/skills/migration-migrate-component/SKILL.md +44 -0
- package/packs/react/skills/migration-migrate-module/SKILL.md +25 -0
- package/packs/react/skills/review-check-architecture/SKILL.md +73 -0
- package/packs/react/skills/review-fix-violations/SKILL.md +45 -0
- package/packs/react/skills/review-review/SKILL.md +43 -0
- package/packs/svelte/ARCHITECTURE.md +975 -0
- package/packs/svelte/CLAUDE.md +66 -0
- package/packs/svelte/agents/builder.md +80 -0
- package/packs/svelte/agents/doctor.md +100 -0
- package/packs/svelte/agents/migrator.md +128 -0
- package/packs/svelte/agents/reviewer.md +104 -0
- package/packs/svelte/agents-lite/builder.md +43 -0
- package/packs/svelte/agents-lite/doctor.md +44 -0
- package/packs/svelte/agents-lite/migrator.md +59 -0
- package/packs/svelte/agents-lite/reviewer.md +48 -0
- package/packs/svelte/skills/dev-create-component/SKILL.md +77 -0
- package/packs/svelte/skills/dev-create-module/SKILL.md +59 -0
- package/packs/svelte/skills/dev-create-service/SKILL.md +35 -0
- package/packs/svelte/skills/dev-create-store/SKILL.md +94 -0
- package/packs/svelte/skills/dev-create-test/SKILL.md +98 -0
- package/packs/svelte/skills/dev-generate-types/SKILL.md +37 -0
- package/packs/svelte/skills/docs-onboard/SKILL.md +47 -0
- package/packs/svelte/skills/migration-migrate-component/SKILL.md +51 -0
- package/packs/svelte/skills/migration-migrate-module/SKILL.md +25 -0
- package/packs/svelte/skills/review-check-architecture/SKILL.md +79 -0
- package/packs/svelte/skills/review-fix-violations/SKILL.md +47 -0
- package/packs/svelte/skills/review-review/SKILL.md +44 -0
- package/packs/vue/ARCHITECTURE.md +798 -0
- package/packs/vue/CLAUDE.md +66 -0
- package/packs/vue/agents/builder.md +73 -0
- package/packs/vue/agents/doctor.md +82 -0
- package/packs/vue/agents/migrator.md +101 -0
- package/packs/vue/agents/reviewer.md +92 -0
- package/packs/vue/agents-lite/builder.md +42 -0
- package/packs/vue/agents-lite/doctor.md +40 -0
- package/packs/vue/agents-lite/migrator.md +50 -0
- package/packs/vue/agents-lite/reviewer.md +46 -0
- package/packs/vue/skills/dev-create-component/SKILL.md +58 -0
- package/packs/vue/skills/dev-create-composable/SKILL.md +31 -0
- package/packs/vue/skills/dev-create-module/SKILL.md +50 -0
- package/packs/vue/skills/dev-create-service/SKILL.md +34 -0
- package/packs/vue/skills/dev-create-test/SKILL.md +62 -0
- package/packs/vue/skills/dev-generate-types/SKILL.md +37 -0
- package/packs/vue/skills/docs-onboard/SKILL.md +42 -0
- package/packs/vue/skills/migration-migrate-component/SKILL.md +41 -0
- package/packs/vue/skills/migration-migrate-module/SKILL.md +25 -0
- package/packs/vue/skills/review-check-architecture/SKILL.md +73 -0
- package/packs/vue/skills/review-fix-violations/SKILL.md +42 -0
- package/packs/vue/skills/review-review/SKILL.md +42 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-create-component
|
|
3
|
+
description: "Create a React functional component with TypeScript following ARCHITECTURE.md"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[ComponentName]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Create a React component following `docs/ARCHITECTURE.md` section 5.
|
|
10
|
+
|
|
11
|
+
Component: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Read `docs/ARCHITECTURE.md` section 5.
|
|
16
|
+
|
|
17
|
+
2. Determine the type:
|
|
18
|
+
- **Feature component** -> `src/modules/[module]/components/ComponentName.tsx`
|
|
19
|
+
- **Shared component** -> `src/shared/components/ComponentName.tsx`
|
|
20
|
+
- **Page** -> `src/modules/[module]/pages/PageName.tsx`
|
|
21
|
+
|
|
22
|
+
3. Create the component with the standard template:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { useState, useMemo, useCallback } from 'react'
|
|
26
|
+
|
|
27
|
+
interface ComponentNameProps {
|
|
28
|
+
// type all props
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function ComponentName({ /* destructure props */ }: ComponentNameProps) {
|
|
32
|
+
// 1. Stores (selectors)
|
|
33
|
+
// 2. Hooks
|
|
34
|
+
// 3. Local state (useState)
|
|
35
|
+
// 4. Derived state (useMemo)
|
|
36
|
+
// 5. Handlers (useCallback)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
{/* clean JSX, < 100 lines */}
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
4. Checklist:
|
|
47
|
+
- Functional component (no class)
|
|
48
|
+
- TypeScript props interface
|
|
49
|
+
- Callback props typed (onSelect, onChange)
|
|
50
|
+
- < 200 lines
|
|
51
|
+
- PascalCase.tsx
|
|
52
|
+
|
|
53
|
+
5. Validate: `npx tsc --noEmit`
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-create-hook
|
|
3
|
+
description: "Create a custom React hook with React Query integration following ARCHITECTURE.md"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[hook-name]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Create a custom hook following `docs/ARCHITECTURE.md` section 4.4.
|
|
10
|
+
|
|
11
|
+
Hook: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Read `docs/ARCHITECTURE.md` section 4.4.
|
|
16
|
+
|
|
17
|
+
2. Determine the type:
|
|
18
|
+
- **Query** (data reading) -> `useQuery` + service + adapter
|
|
19
|
+
- **Mutation** (write/delete) -> `useMutation` + query invalidation
|
|
20
|
+
- **Pure logic** (no API) -> useState + useMemo + useEffect
|
|
21
|
+
|
|
22
|
+
3. Create the hook in `hooks/use[Name].ts`:
|
|
23
|
+
|
|
24
|
+
### Query Hook Template
|
|
25
|
+
```typescript
|
|
26
|
+
import { useQuery, keepPreviousData } from '@tanstack/react-query'
|
|
27
|
+
import { xxxService } from '../services/xxx-service'
|
|
28
|
+
import { xxxAdapter } from '../adapters/xxx-adapter'
|
|
29
|
+
|
|
30
|
+
interface UseXxxOptions {
|
|
31
|
+
page: number
|
|
32
|
+
pageSize?: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useXxx(options: UseXxxOptions) {
|
|
36
|
+
const { page, pageSize = 20 } = options
|
|
37
|
+
|
|
38
|
+
const { data, isLoading, isFetching, error, refetch } = useQuery({
|
|
39
|
+
queryKey: ['xxx', { page, pageSize }],
|
|
40
|
+
queryFn: async () => {
|
|
41
|
+
const response = await xxxService.list({ page, pageSize })
|
|
42
|
+
return xxxAdapter.toXxxList(response.data)
|
|
43
|
+
},
|
|
44
|
+
staleTime: 5 * 60 * 1000,
|
|
45
|
+
placeholderData: keepPreviousData,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return { data, isLoading, isFetching, error, refetch }
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Mutation Hook Template
|
|
53
|
+
```typescript
|
|
54
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
55
|
+
import { xxxService } from '../services/xxx-service'
|
|
56
|
+
import { xxxAdapter } from '../adapters/xxx-adapter'
|
|
57
|
+
|
|
58
|
+
export function useCreateXxx() {
|
|
59
|
+
const queryClient = useQueryClient()
|
|
60
|
+
|
|
61
|
+
return useMutation({
|
|
62
|
+
mutationFn: async (input: CreateXxxInput) => {
|
|
63
|
+
const payload = xxxAdapter.toCreatePayload(input)
|
|
64
|
+
const response = await xxxService.create(payload)
|
|
65
|
+
return xxxAdapter.toXxx(response.data)
|
|
66
|
+
},
|
|
67
|
+
onSuccess: () => {
|
|
68
|
+
queryClient.invalidateQueries({ queryKey: ['xxx'] })
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
4. Required: `use` prefix, staleTime for queries, queryKey as array, adapter in queryFn.
|
|
75
|
+
|
|
76
|
+
5. Connect the layers: service -> adapter -> React Query
|
|
77
|
+
|
|
78
|
+
6. Validate: `npx tsc --noEmit`
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-create-module
|
|
3
|
+
description: "Create a new complete feature module with CRUD following ARCHITECTURE.md"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[module-name]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Create a new complete feature module following `docs/ARCHITECTURE.md`.
|
|
10
|
+
|
|
11
|
+
Module name: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Read `docs/ARCHITECTURE.md` sections 2, 3 and 4.
|
|
16
|
+
|
|
17
|
+
2. Create the directory structure:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
src/modules/[kebab-case-name]/
|
|
21
|
+
+-- components/
|
|
22
|
+
+-- hooks/
|
|
23
|
+
+-- services/
|
|
24
|
+
+-- adapters/
|
|
25
|
+
+-- stores/
|
|
26
|
+
+-- types/
|
|
27
|
+
+-- pages/
|
|
28
|
+
+-- __tests__/
|
|
29
|
+
+-- index.ts
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
3. Create `index.ts` with empty barrel export:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// src/modules/[name]/index.ts
|
|
36
|
+
// Public API for this module
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
4. Ask the user:
|
|
40
|
+
- Which API endpoints does this module consume?
|
|
41
|
+
- What UI type? (list with CRUD, dashboard, form, detail)
|
|
42
|
+
|
|
43
|
+
5. Use `@builder` to create bottom-up:
|
|
44
|
+
- Types + contracts + adapter + service
|
|
45
|
+
- Hooks with React Query
|
|
46
|
+
- Components with typed props
|
|
47
|
+
- Page composing components
|
|
48
|
+
|
|
49
|
+
6. Register the route in the router using React.lazy() + Suspense.
|
|
50
|
+
|
|
51
|
+
7. Validate: `npx tsc --noEmit && npx vite build`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-create-service
|
|
3
|
+
description: "Create the complete data layer (types + adapter + service) for a resource"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[resource-name]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Create the complete data layer for a resource following `docs/ARCHITECTURE.md` sections 4.1-4.3.
|
|
10
|
+
|
|
11
|
+
Resource: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Read `docs/ARCHITECTURE.md` sections 4.1 (Services), 4.2 (Adapters), 4.3 (Types).
|
|
16
|
+
|
|
17
|
+
2. Ask the user:
|
|
18
|
+
- What is the endpoint base URL? (e.g. `/v4/marketplace`)
|
|
19
|
+
- What is the response JSON format? (ask for an example or describe the fields)
|
|
20
|
+
- Which operations? (GET list, GET by ID, POST, PATCH, DELETE)
|
|
21
|
+
|
|
22
|
+
3. Create in order:
|
|
23
|
+
|
|
24
|
+
a. `types/[resource].types.ts` -- mirrors API exactly (snake_case)
|
|
25
|
+
b. `types/[resource].contracts.ts` -- app contract (camelCase, correct types)
|
|
26
|
+
c. `adapters/[resource]-adapter.ts` -- inbound (API->App) + outbound (App->API)
|
|
27
|
+
d. `services/[resource]-service.ts` -- HTTP only, no try/catch, no transformation
|
|
28
|
+
|
|
29
|
+
4. Required rules:
|
|
30
|
+
- Service: **NO try/catch**, **NO .map()/.filter()/new Date()**
|
|
31
|
+
- Adapter: **pure functions**, no side effects
|
|
32
|
+
- Types separated: .types.ts (API) != .contracts.ts (App)
|
|
33
|
+
|
|
34
|
+
5. Validate: `npx tsc --noEmit`
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-create-test
|
|
3
|
+
description: "Create tests for adapters, hooks, or components using Vitest and React Testing Library"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[file-path]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Create tests for the specified file or module.
|
|
10
|
+
|
|
11
|
+
Target: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Analyze the file to understand what to test.
|
|
16
|
+
|
|
17
|
+
2. Determine the test type:
|
|
18
|
+
|
|
19
|
+
### Adapter (high priority -- pure functions, easy to test)
|
|
20
|
+
```typescript
|
|
21
|
+
import { describe, it, expect } from 'vitest'
|
|
22
|
+
import { xxxAdapter } from '../adapters/xxx-adapter'
|
|
23
|
+
|
|
24
|
+
describe('xxxAdapter', () => {
|
|
25
|
+
describe('toXxx', () => {
|
|
26
|
+
it('should convert API response to app contract', () => {
|
|
27
|
+
const response = { uuid: '123', field_name: 'test', created_at: '2024-01-01T00:00:00Z' }
|
|
28
|
+
const result = xxxAdapter.toXxx(response)
|
|
29
|
+
expect(result.id).toBe('123')
|
|
30
|
+
expect(result.fieldName).toBe('test')
|
|
31
|
+
expect(result.createdAt).toBeInstanceOf(Date)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Hook (medium priority -- mock service, use renderHook)
|
|
38
|
+
```typescript
|
|
39
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
40
|
+
import { renderHook, waitFor } from '@testing-library/react'
|
|
41
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
42
|
+
import { useXxxList } from '../hooks/useXxxList'
|
|
43
|
+
import type { ReactNode } from 'react'
|
|
44
|
+
|
|
45
|
+
// Mock service
|
|
46
|
+
vi.mock('../services/xxx-service')
|
|
47
|
+
|
|
48
|
+
function createWrapper() {
|
|
49
|
+
const queryClient = new QueryClient({
|
|
50
|
+
defaultOptions: { queries: { retry: false } },
|
|
51
|
+
})
|
|
52
|
+
return ({ children }: { children: ReactNode }) => (
|
|
53
|
+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe('useXxxList', () => {
|
|
58
|
+
it('should return items', async () => {
|
|
59
|
+
const { result } = renderHook(() => useXxxList({ page: 1 }), {
|
|
60
|
+
wrapper: createWrapper(),
|
|
61
|
+
})
|
|
62
|
+
await waitFor(() => expect(result.current.isLoading).toBe(false))
|
|
63
|
+
expect(result.current.items).toBeDefined()
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Component (medium-low priority -- React Testing Library)
|
|
69
|
+
```typescript
|
|
70
|
+
import { describe, it, expect } from 'vitest'
|
|
71
|
+
import { render, screen } from '@testing-library/react'
|
|
72
|
+
import userEvent from '@testing-library/user-event'
|
|
73
|
+
import { XxxComponent } from '../components/XxxComponent'
|
|
74
|
+
|
|
75
|
+
describe('XxxComponent', () => {
|
|
76
|
+
it('should render', () => {
|
|
77
|
+
render(<XxxComponent name="Test" onSelect={vi.fn()} />)
|
|
78
|
+
expect(screen.getByText('Test')).toBeInTheDocument()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('should call onSelect when clicked', async () => {
|
|
82
|
+
const onSelect = vi.fn()
|
|
83
|
+
render(<XxxComponent name="Test" onSelect={onSelect} />)
|
|
84
|
+
await userEvent.click(screen.getByRole('button'))
|
|
85
|
+
expect(onSelect).toHaveBeenCalledOnce()
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
3. Create the test in `__tests__/OriginalName.spec.ts(x)`.
|
|
91
|
+
|
|
92
|
+
4. Run: `npx vitest run --reporter=verbose`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-generate-types
|
|
3
|
+
description: "Generate types, contracts and adapter from an API endpoint or JSON example"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[endpoint-or-json]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Generate types, contracts and adapter for an API endpoint following `docs/ARCHITECTURE.md` sections 4.2-4.3.
|
|
10
|
+
|
|
11
|
+
Endpoint or example JSON: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Read `docs/ARCHITECTURE.md` sections 4.2 and 4.3.
|
|
16
|
+
|
|
17
|
+
2. If the user provided an example JSON, use it. If they provided an endpoint:
|
|
18
|
+
- Search existing code for calls to that endpoint
|
|
19
|
+
- Ask the user for an example response JSON
|
|
20
|
+
|
|
21
|
+
3. From the JSON, create:
|
|
22
|
+
|
|
23
|
+
a. **`[resource].types.ts`** -- types that mirror the API exactly:
|
|
24
|
+
- snake_case, string dates, IDs as string
|
|
25
|
+
- Include request payloads and list response (with pagination)
|
|
26
|
+
|
|
27
|
+
b. **`[resource].contracts.ts`** -- clean app contracts:
|
|
28
|
+
- camelCase, Date objects, derived booleans
|
|
29
|
+
- No internal API fields (tokens, metadata)
|
|
30
|
+
|
|
31
|
+
c. **`[resource]-adapter.ts`** -- pure functions:
|
|
32
|
+
- `toXxx(response)` -- inbound (API -> App)
|
|
33
|
+
- `toXxxList(response)` -- inbound for list
|
|
34
|
+
- `toCreatePayload(input)` -- outbound (App -> API)
|
|
35
|
+
- Conversions: snake->camel, string->Date, cents->decimal
|
|
36
|
+
|
|
37
|
+
4. Validate: `npx tsc --noEmit`
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docs-onboard
|
|
3
|
+
description: "Create a quick module summary for onboarding new developers"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[module-name]"
|
|
6
|
+
allowed-tools: Read, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Create a quick summary of a module for onboarding.
|
|
10
|
+
|
|
11
|
+
Module: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Map the structure:
|
|
16
|
+
```bash
|
|
17
|
+
find src/modules/$ARGUMENTS -type f | head -40
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. Summarize in quick format:
|
|
21
|
+
|
|
22
|
+
### Endpoints
|
|
23
|
+
List the consumed endpoints (grep in services).
|
|
24
|
+
|
|
25
|
+
### Main Components
|
|
26
|
+
List components and their responsibilities (1 line each).
|
|
27
|
+
|
|
28
|
+
### State
|
|
29
|
+
- What is in Zustand? (client state)
|
|
30
|
+
- What is in React Query? (server state)
|
|
31
|
+
|
|
32
|
+
### Data Flow
|
|
33
|
+
```
|
|
34
|
+
Service (HTTP) -> Adapter (parse) -> Hook (React Query) -> Component (TSX)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Points of Attention
|
|
38
|
+
- Anything outside the ARCHITECTURE.md pattern?
|
|
39
|
+
- Components > 200 lines?
|
|
40
|
+
- Legacy code not yet migrated? (class components, Redux, PropTypes)
|
|
41
|
+
|
|
42
|
+
3. Output: concise summary that a new developer can understand the module in 2 minutes.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migration-migrate-component
|
|
3
|
+
description: "Migrate a React class component to a functional component with TypeScript and hooks"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[component-file]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Migrate a React component from class to functional with TypeScript following `docs/ARCHITECTURE.md` section 5.
|
|
10
|
+
|
|
11
|
+
Component: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Read `docs/ARCHITECTURE.md` section 5.
|
|
16
|
+
|
|
17
|
+
2. Analyze the component:
|
|
18
|
+
- Count lines
|
|
19
|
+
- List: props (PropTypes or TS), state, lifecycle methods, handlers, HOCs, Redux connections
|
|
20
|
+
- Map who imports this component
|
|
21
|
+
|
|
22
|
+
3. Convert to functional component with TypeScript:
|
|
23
|
+
- `class X extends Component` -> `function X(props: XProps)`
|
|
24
|
+
- `this.state` / `this.setState` -> `useState()`
|
|
25
|
+
- `this.props` -> destructured props parameter
|
|
26
|
+
- `PropTypes` -> TypeScript interface
|
|
27
|
+
- `componentDidMount` -> `useEffect(() => {}, [])`
|
|
28
|
+
- `componentDidUpdate` -> `useEffect(() => {}, [deps])`
|
|
29
|
+
- `componentWillUnmount` -> `useEffect` cleanup function
|
|
30
|
+
- `shouldComponentUpdate` -> `React.memo()`
|
|
31
|
+
- `this.handleX.bind(this)` -> `useCallback`
|
|
32
|
+
- HOCs (`connect`, `withRouter`) -> custom hooks (`useStore`, `useNavigate`)
|
|
33
|
+
- Redux `connect(mapState, mapDispatch)` -> Zustand selectors
|
|
34
|
+
|
|
35
|
+
4. Apply composition pattern if there is prop drilling.
|
|
36
|
+
|
|
37
|
+
5. Decompose if > 200 lines.
|
|
38
|
+
|
|
39
|
+
6. Validate:
|
|
40
|
+
```bash
|
|
41
|
+
npx tsc --noEmit
|
|
42
|
+
npx vite build
|
|
43
|
+
npx vitest run --passWithNoTests
|
|
44
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migration-migrate-module
|
|
3
|
+
description: "Migrate an entire module to the target architecture in 6 phases"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[module-path]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Migrate an entire module to the target architecture from `docs/ARCHITECTURE.md`.
|
|
10
|
+
|
|
11
|
+
Module/Path: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
Use `@migrator` to coordinate the full migration in phases:
|
|
16
|
+
|
|
17
|
+
1. **Phase 0 -- Analysis**: Map the module (files, patterns, dependencies, class vs functional, Redux, HOCs)
|
|
18
|
+
2. **Phase 1 -- Structure**: Create `src/modules/[name]/` and move files
|
|
19
|
+
3. **Phase 2 -- Types**: Create `.types.ts` + `.contracts.ts` + adapter
|
|
20
|
+
4. **Phase 3 -- Services**: Migrate to pure service (no try/catch)
|
|
21
|
+
5. **Phase 4 -- State**: Server state -> React Query, Client state -> Zustand. Remove Redux
|
|
22
|
+
6. **Phase 5 -- Components**: Class -> functional, typed props, hooks, useCallback/useMemo
|
|
23
|
+
7. **Phase 6 -- Review**: Validate conformance
|
|
24
|
+
|
|
25
|
+
Validate build/tsc/tests after each phase. Ask for approval before each phase.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-check-architecture
|
|
3
|
+
description: "Validate project conformance against ARCHITECTURE.md with automated checks"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[module]"
|
|
6
|
+
allowed-tools: Read, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Validate the entire project (or a specific module) against `docs/ARCHITECTURE.md`.
|
|
10
|
+
|
|
11
|
+
Scope: $ARGUMENTS (if empty, validate all src/modules/)
|
|
12
|
+
|
|
13
|
+
## Automated Checks
|
|
14
|
+
|
|
15
|
+
Run all checks and report a summary:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
echo "=== 1. Services with try/catch ==="
|
|
19
|
+
grep -rn "try {" src/modules/*/services/ --include="*.ts" 2>/dev/null || echo "OK None"
|
|
20
|
+
|
|
21
|
+
echo "=== 2. Services with transformation ==="
|
|
22
|
+
grep -rn "\.map(\|\.filter(\|new Date\|\.reduce(" src/modules/*/services/ --include="*.ts" 2>/dev/null || echo "OK None"
|
|
23
|
+
|
|
24
|
+
echo "=== 3. Class components ==="
|
|
25
|
+
grep -rn "class.*extends.*Component" src/modules/ --include="*.tsx" 2>/dev/null || echo "OK None"
|
|
26
|
+
|
|
27
|
+
echo "=== 4. PropTypes usage ==="
|
|
28
|
+
grep -rn "PropTypes\." src/modules/ --include="*.tsx" --include="*.ts" 2>/dev/null || echo "OK None"
|
|
29
|
+
|
|
30
|
+
echo "=== 5. Redux usage ==="
|
|
31
|
+
grep -rn "useSelector\|useDispatch\|createSlice\|createStore\|connect(" src/modules/ --include="*.ts" --include="*.tsx" 2>/dev/null || echo "OK None"
|
|
32
|
+
|
|
33
|
+
echo "=== 6. Server state in Zustand ==="
|
|
34
|
+
grep -rn "async.*fetch\|axios\|api\.\|\.get(\|\.post(" src/modules/*/stores/ --include="*.ts" 2>/dev/null || echo "OK None"
|
|
35
|
+
|
|
36
|
+
echo "=== 7. Full Zustand destructure (should use selectors) ==="
|
|
37
|
+
grep -rn "} = use.*Store()" src/ --include="*.tsx" 2>/dev/null || echo "OK None"
|
|
38
|
+
|
|
39
|
+
echo "=== 8. any types ==="
|
|
40
|
+
grep -rn ": any\| any;\|as any\|<any>" src/modules/ --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l
|
|
41
|
+
|
|
42
|
+
echo "=== 9. Cross-module imports ==="
|
|
43
|
+
for module in src/modules/*/; do
|
|
44
|
+
name=$(basename "$module")
|
|
45
|
+
grep -rn "from.*modules/" "$module" --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v "modules/${name}" || true
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
echo "=== 10. dangerouslySetInnerHTML ==="
|
|
49
|
+
grep -rn "dangerouslySetInnerHTML" src/ --include="*.tsx" 2>/dev/null || echo "OK None"
|
|
50
|
+
|
|
51
|
+
echo "=== 11. Debug artifacts ==="
|
|
52
|
+
grep -rn "console\.\|debugger" src/modules/ --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l
|
|
53
|
+
|
|
54
|
+
echo "=== 12. Queries without staleTime ==="
|
|
55
|
+
grep -rn "useQuery" src/ --include="*.ts" -l 2>/dev/null | while read f; do
|
|
56
|
+
grep -L "staleTime" "$f" 2>/dev/null
|
|
57
|
+
done
|
|
58
|
+
|
|
59
|
+
echo "=== 13. Components > 200 lines ==="
|
|
60
|
+
find src/modules -name "*.tsx" -exec sh -c 'lines=$(wc -l < "$1"); [ "$lines" -gt 200 ] && echo "$1: $lines lines"' _ {} \;
|
|
61
|
+
|
|
62
|
+
echo "=== 14. Inline style objects in JSX ==="
|
|
63
|
+
grep -rn "style={{" src/modules/ --include="*.tsx" 2>/dev/null || echo "OK None"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Produce a summary table:
|
|
67
|
+
|
|
68
|
+
| Check | Status | Occurrences |
|
|
69
|
+
|-------|--------|-------------|
|
|
70
|
+
| Services without try/catch | OK/FAIL | X |
|
|
71
|
+
| ... | ... | ... |
|
|
72
|
+
|
|
73
|
+
Overall score: X/14 checks passing.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-fix-violations
|
|
3
|
+
description: "Find and auto-fix ARCHITECTURE.md violations in a module"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[module]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Identify and fix `docs/ARCHITECTURE.md` violations in the specified module.
|
|
10
|
+
|
|
11
|
+
Module: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Run `/review-check-architecture` to find violations.
|
|
16
|
+
|
|
17
|
+
2. For each violation found, fix in priority order:
|
|
18
|
+
|
|
19
|
+
**Critical (fix first):**
|
|
20
|
+
- try/catch in services -> remove, move error handling to hook (onError)
|
|
21
|
+
- Transformation in services -> move to adapter
|
|
22
|
+
- dangerouslySetInnerHTML without sanitization -> remove or sanitize
|
|
23
|
+
- Hardcoded secrets -> move to env vars
|
|
24
|
+
|
|
25
|
+
**Important:**
|
|
26
|
+
- Class components -> convert to functional (`/migration-migrate-component`)
|
|
27
|
+
- PropTypes -> replace with TypeScript interface
|
|
28
|
+
- Redux -> migrate to Zustand store
|
|
29
|
+
- Server state in Zustand -> migrate to React Query hook
|
|
30
|
+
- any types -> type correctly
|
|
31
|
+
- Full Zustand destructure -> use selectors
|
|
32
|
+
- Queries without staleTime -> add staleTime
|
|
33
|
+
|
|
34
|
+
**Improvements:**
|
|
35
|
+
- Components > 200 lines -> decompose
|
|
36
|
+
- Console.log -> remove
|
|
37
|
+
- Inline style objects -> extract to const or CSS
|
|
38
|
+
- TODO/FIXME -> resolve or create issue
|
|
39
|
+
|
|
40
|
+
3. Validate after each fix:
|
|
41
|
+
```bash
|
|
42
|
+
npx tsc --noEmit && npx vite build && npx vitest run --passWithNoTests
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
4. Report what was fixed and what remains.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-review
|
|
3
|
+
description: "Perform a full code review validating against ARCHITECTURE.md"
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[scope]"
|
|
6
|
+
allowed-tools: Read, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Perform a full code review of changed files, validating against `docs/ARCHITECTURE.md`.
|
|
10
|
+
|
|
11
|
+
Scope: $ARGUMENTS (if empty, review files changed in git)
|
|
12
|
+
|
|
13
|
+
## Steps
|
|
14
|
+
|
|
15
|
+
1. Identify changed files:
|
|
16
|
+
```bash
|
|
17
|
+
git diff --name-only HEAD~1 2>/dev/null || git diff --name-only --cached 2>/dev/null || echo "Please specify the files"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. Run automated checks:
|
|
21
|
+
```bash
|
|
22
|
+
npx tsc --noEmit
|
|
23
|
+
npx eslint --ext .ts,.tsx src/ --max-warnings 0
|
|
24
|
+
npx vitest run --passWithNoTests
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
3. Check ARCHITECTURE.md patterns:
|
|
28
|
+
- Services: no try/catch, no transformation
|
|
29
|
+
- Adapters: pure functions
|
|
30
|
+
- Hooks: use service+adapter, staleTime defined
|
|
31
|
+
- Stores: client state only, selectors in components
|
|
32
|
+
- Components: functional TSX, typed props, < 200 lines
|
|
33
|
+
- No class components, no PropTypes, no Redux
|
|
34
|
+
- Naming: correct conventions
|
|
35
|
+
- Boundaries: no cross-module imports
|
|
36
|
+
|
|
37
|
+
4. Classify:
|
|
38
|
+
- VIOLATION -- ARCHITECTURE.md violation
|
|
39
|
+
- ATTENTION -- Recommended improvement
|
|
40
|
+
- COMPLIANT -- Correct
|
|
41
|
+
- HIGHLIGHT -- Positive highlight
|
|
42
|
+
|
|
43
|
+
5. Produce report with verdict: Approved | With caveats | Requires changes
|