aigent-team 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.
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/chunk-N3RYHWTR.js +267 -0
- package/dist/cli.js +576 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +27 -0
- package/package.json +67 -0
- package/templates/shared/git-workflow.md +44 -0
- package/templates/shared/project-conventions.md +48 -0
- package/templates/teams/ba/agent.yaml +25 -0
- package/templates/teams/ba/references/acceptance-criteria.md +87 -0
- package/templates/teams/ba/references/api-contract-design.md +110 -0
- package/templates/teams/ba/references/requirements-analysis.md +83 -0
- package/templates/teams/ba/references/user-story-mapping.md +73 -0
- package/templates/teams/ba/skill.md +85 -0
- package/templates/teams/be/agent.yaml +34 -0
- package/templates/teams/be/conventions.md +102 -0
- package/templates/teams/be/references/api-design.md +91 -0
- package/templates/teams/be/references/async-processing.md +86 -0
- package/templates/teams/be/references/auth-security.md +58 -0
- package/templates/teams/be/references/caching.md +79 -0
- package/templates/teams/be/references/database.md +65 -0
- package/templates/teams/be/references/error-handling.md +106 -0
- package/templates/teams/be/references/observability.md +83 -0
- package/templates/teams/be/references/review-checklist.md +50 -0
- package/templates/teams/be/references/testing.md +100 -0
- package/templates/teams/be/review-checklist.md +54 -0
- package/templates/teams/be/skill.md +71 -0
- package/templates/teams/devops/agent.yaml +35 -0
- package/templates/teams/devops/conventions.md +133 -0
- package/templates/teams/devops/references/ci-cd.md +218 -0
- package/templates/teams/devops/references/cost-optimization.md +218 -0
- package/templates/teams/devops/references/disaster-recovery.md +199 -0
- package/templates/teams/devops/references/docker.md +237 -0
- package/templates/teams/devops/references/infrastructure-as-code.md +238 -0
- package/templates/teams/devops/references/kubernetes.md +397 -0
- package/templates/teams/devops/references/monitoring.md +224 -0
- package/templates/teams/devops/references/review-checklist.md +149 -0
- package/templates/teams/devops/references/security.md +225 -0
- package/templates/teams/devops/review-checklist.md +72 -0
- package/templates/teams/devops/skill.md +131 -0
- package/templates/teams/fe/agent.yaml +28 -0
- package/templates/teams/fe/conventions.md +80 -0
- package/templates/teams/fe/references/accessibility.md +92 -0
- package/templates/teams/fe/references/component-architecture.md +87 -0
- package/templates/teams/fe/references/css-styling.md +89 -0
- package/templates/teams/fe/references/forms.md +73 -0
- package/templates/teams/fe/references/performance.md +104 -0
- package/templates/teams/fe/references/review-checklist.md +51 -0
- package/templates/teams/fe/references/security.md +90 -0
- package/templates/teams/fe/references/state-management.md +117 -0
- package/templates/teams/fe/references/testing.md +112 -0
- package/templates/teams/fe/review-checklist.md +53 -0
- package/templates/teams/fe/skill.md +68 -0
- package/templates/teams/lead/agent.yaml +18 -0
- package/templates/teams/lead/references/cross-team-coordination.md +68 -0
- package/templates/teams/lead/references/quality-gates.md +64 -0
- package/templates/teams/lead/references/task-decomposition.md +69 -0
- package/templates/teams/lead/skill.md +83 -0
- package/templates/teams/qa/agent.yaml +32 -0
- package/templates/teams/qa/conventions.md +130 -0
- package/templates/teams/qa/references/ci-integration.md +337 -0
- package/templates/teams/qa/references/e2e-testing.md +292 -0
- package/templates/teams/qa/references/mocking.md +249 -0
- package/templates/teams/qa/references/performance-testing.md +288 -0
- package/templates/teams/qa/references/review-checklist.md +143 -0
- package/templates/teams/qa/references/security-testing.md +271 -0
- package/templates/teams/qa/references/test-data.md +275 -0
- package/templates/teams/qa/references/test-strategy.md +192 -0
- package/templates/teams/qa/review-checklist.md +53 -0
- package/templates/teams/qa/skill.md +131 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# State Management
|
|
2
|
+
|
|
3
|
+
## Decision Tree
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Is this data from an API?
|
|
7
|
+
YES → React Query / TanStack Query (server state)
|
|
8
|
+
NO → Is it shared across multiple components?
|
|
9
|
+
YES → Is it UI-only (theme, sidebar, modal)?
|
|
10
|
+
YES → Zustand / Jotai (global client state)
|
|
11
|
+
NO → Should user be able to bookmark/share this?
|
|
12
|
+
YES → URL search params (useSearchParams)
|
|
13
|
+
NO → Lift state to common parent
|
|
14
|
+
NO → useState (local state)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Server State (React Query / TanStack Query)
|
|
18
|
+
|
|
19
|
+
**Rule: Never store server data in useState or Zustand.** React Query handles caching, revalidation, deduplication, and stale-while-revalidate out of the box.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// GOOD: React Query manages server state
|
|
23
|
+
const { data: users, isLoading, error } = useQuery({
|
|
24
|
+
queryKey: ['users', filters],
|
|
25
|
+
queryFn: () => api.getUsers(filters),
|
|
26
|
+
staleTime: 5 * 60 * 1000, // 5 min
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// BAD: Manual state management for server data
|
|
30
|
+
const [users, setUsers] = useState([]);
|
|
31
|
+
const [loading, setLoading] = useState(false);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setLoading(true);
|
|
34
|
+
api.getUsers(filters).then(setUsers).finally(() => setLoading(false));
|
|
35
|
+
}, [filters]); // Missing error handling, no caching, no dedup
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Optimistic updates** for mutations that affect UI immediately:
|
|
39
|
+
```typescript
|
|
40
|
+
const mutation = useMutation({
|
|
41
|
+
mutationFn: api.updateUser,
|
|
42
|
+
onMutate: async (newData) => {
|
|
43
|
+
await queryClient.cancelQueries({ queryKey: ['user', id] });
|
|
44
|
+
const previous = queryClient.getQueryData(['user', id]);
|
|
45
|
+
queryClient.setQueryData(['user', id], newData); // Optimistic
|
|
46
|
+
return { previous };
|
|
47
|
+
},
|
|
48
|
+
onError: (err, vars, context) => {
|
|
49
|
+
queryClient.setQueryData(['user', id], context?.previous); // Rollback
|
|
50
|
+
},
|
|
51
|
+
onSettled: () => {
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: ['user', id] }); // Refetch truth
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Local State (useState)
|
|
58
|
+
|
|
59
|
+
For UI-only state that belongs to a single component:
|
|
60
|
+
- Form input values (before submission)
|
|
61
|
+
- Open/closed state (dropdowns, modals, accordions)
|
|
62
|
+
- Active tab, selected item
|
|
63
|
+
- Animation/transition state
|
|
64
|
+
|
|
65
|
+
**Anti-pattern: Derived state in useState**
|
|
66
|
+
```typescript
|
|
67
|
+
// BAD: Storing derived value
|
|
68
|
+
const [filteredUsers, setFilteredUsers] = useState([]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setFilteredUsers(users.filter(u => u.active));
|
|
71
|
+
}, [users]);
|
|
72
|
+
|
|
73
|
+
// GOOD: Compute during render
|
|
74
|
+
const filteredUsers = useMemo(
|
|
75
|
+
() => users.filter(u => u.active),
|
|
76
|
+
[users]
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Global Client State (Zustand / Jotai)
|
|
81
|
+
|
|
82
|
+
Only for cross-component UI state that is NOT from the server:
|
|
83
|
+
- Theme (light/dark)
|
|
84
|
+
- Sidebar collapsed/expanded
|
|
85
|
+
- Toast notification queue
|
|
86
|
+
- Global modal state
|
|
87
|
+
|
|
88
|
+
Keep stores small and focused. One store per concern, not one mega-store.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// Zustand store — minimal, focused
|
|
92
|
+
const useUIStore = create<UIState>((set) => ({
|
|
93
|
+
sidebarCollapsed: false,
|
|
94
|
+
toggleSidebar: () => set((s) => ({ sidebarCollapsed: !s.sidebarCollapsed })),
|
|
95
|
+
}));
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## URL State (Search Params)
|
|
99
|
+
|
|
100
|
+
For anything the user should be able to bookmark, share, or navigate back to:
|
|
101
|
+
- Search query, filters, sort order
|
|
102
|
+
- Pagination (current page)
|
|
103
|
+
- Selected tab
|
|
104
|
+
- Modal open with specific item (`?modal=edit&id=123`)
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
108
|
+
const page = Number(searchParams.get('page')) || 1;
|
|
109
|
+
const sort = searchParams.get('sort') || 'created_at:desc';
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Common Bugs to Watch
|
|
113
|
+
|
|
114
|
+
1. **Stale closures**: Reading state inside async callbacks or event listeners that captured an old value. Fix: use `useRef` for mutable values or functional updates `setState(prev => ...)`.
|
|
115
|
+
2. **State sync**: Two stores holding the same data that drift apart. Fix: single source of truth.
|
|
116
|
+
3. **Unnecessary re-renders**: Parent state change re-renders all children. Fix: move state closer to where it's used, split context, use selectors.
|
|
117
|
+
4. **Race conditions**: Multiple rapid state updates (search-as-you-type) causing stale results. Fix: `AbortController` + debounce.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Frontend Testing
|
|
2
|
+
|
|
3
|
+
## Testing Philosophy
|
|
4
|
+
|
|
5
|
+
- Test **behavior**, not implementation. "When user clicks Submit, success message appears" — not "when handler fires, setState is called".
|
|
6
|
+
- Query by **role/label** (`getByRole('button', { name: 'Submit' })`), not test ID or CSS class.
|
|
7
|
+
- **Snapshot tests are banned** for component output. They break on every style change and catch nothing. Use visual regression (Chromatic/Percy) instead.
|
|
8
|
+
- Every **bug fix** must include a test that would have caught the bug.
|
|
9
|
+
|
|
10
|
+
## Test Structure (AAA Pattern)
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
it('should show error message when login fails', async () => {
|
|
14
|
+
// Arrange
|
|
15
|
+
server.use(
|
|
16
|
+
http.post('/api/login', () => HttpResponse.json({ error: 'Invalid credentials' }, { status: 401 }))
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// Act
|
|
20
|
+
render(<LoginForm />);
|
|
21
|
+
await userEvent.type(screen.getByLabelText('Email'), 'user@test.com');
|
|
22
|
+
await userEvent.type(screen.getByLabelText('Password'), 'wrong');
|
|
23
|
+
await userEvent.click(screen.getByRole('button', { name: 'Sign in' }));
|
|
24
|
+
|
|
25
|
+
// Assert
|
|
26
|
+
expect(await screen.findByText('Invalid credentials')).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## What to Test at Each Level
|
|
31
|
+
|
|
32
|
+
**Unit tests** (fastest, most):
|
|
33
|
+
- Pure utility functions (formatDate, calculateTotal, validateEmail)
|
|
34
|
+
- Custom hooks (useDebounce, useLocalStorage)
|
|
35
|
+
- State reducers and store logic
|
|
36
|
+
|
|
37
|
+
**Integration tests** (most valuable):
|
|
38
|
+
- Component renders correctly with props
|
|
39
|
+
- User interactions trigger correct behavior
|
|
40
|
+
- Form submission with validation
|
|
41
|
+
- Data fetching and display (mock API with MSW)
|
|
42
|
+
- Error states and loading states
|
|
43
|
+
|
|
44
|
+
**E2E tests** (fewest, critical paths only):
|
|
45
|
+
- Login → Dashboard flow
|
|
46
|
+
- Complete purchase/checkout
|
|
47
|
+
- Multi-step form submission
|
|
48
|
+
- Cross-page navigation with state persistence
|
|
49
|
+
|
|
50
|
+
## Mocking Strategy
|
|
51
|
+
|
|
52
|
+
**Use MSW (Mock Service Worker)** for API mocking — intercepts at network level:
|
|
53
|
+
```typescript
|
|
54
|
+
import { http, HttpResponse } from 'msw';
|
|
55
|
+
import { setupServer } from 'msw/node';
|
|
56
|
+
|
|
57
|
+
const server = setupServer(
|
|
58
|
+
http.get('/api/users', () => HttpResponse.json([
|
|
59
|
+
{ id: 1, name: 'Alice' },
|
|
60
|
+
])),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
beforeAll(() => server.listen());
|
|
64
|
+
afterEach(() => server.resetHandlers());
|
|
65
|
+
afterAll(() => server.close());
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Never mock**:
|
|
69
|
+
- React itself (useState, useEffect)
|
|
70
|
+
- Internal component methods
|
|
71
|
+
- CSS/styles
|
|
72
|
+
- The component you're testing
|
|
73
|
+
|
|
74
|
+
**Do mock**:
|
|
75
|
+
- External API calls (MSW)
|
|
76
|
+
- Browser APIs (IntersectionObserver, ResizeObserver, matchMedia)
|
|
77
|
+
- Time (`vi.useFakeTimers()`)
|
|
78
|
+
- Navigation (`vi.mock('next/navigation')`)
|
|
79
|
+
|
|
80
|
+
## Accessibility Testing in Tests
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { axe, toHaveNoViolations } from 'jest-axe';
|
|
84
|
+
expect.extend(toHaveNoViolations);
|
|
85
|
+
|
|
86
|
+
it('should have no accessibility violations', async () => {
|
|
87
|
+
const { container } = render(<UserProfile />);
|
|
88
|
+
const results = await axe(container);
|
|
89
|
+
expect(results).toHaveNoViolations();
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Testing Async Behavior
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// Wait for element to appear (API response, animation)
|
|
97
|
+
expect(await screen.findByText('User loaded')).toBeInTheDocument();
|
|
98
|
+
|
|
99
|
+
// Wait for element to disappear (loading state)
|
|
100
|
+
await waitForElementToBeRemoved(() => screen.queryByText('Loading...'));
|
|
101
|
+
|
|
102
|
+
// Assert something does NOT appear (use queryBy, not getBy)
|
|
103
|
+
expect(screen.queryByText('Error')).not.toBeInTheDocument();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Common Testing Mistakes
|
|
107
|
+
|
|
108
|
+
- `getByTestId` when `getByRole` or `getByLabelText` works — test IDs don't verify accessibility
|
|
109
|
+
- Testing implementation: `expect(mockFn).toHaveBeenCalledWith(...)` for every internal call
|
|
110
|
+
- Not testing keyboard navigation for interactive components
|
|
111
|
+
- Hardcoded delays: `await new Promise(r => setTimeout(r, 1000))` — use `findBy` queries
|
|
112
|
+
- Testing third-party library behavior instead of your integration with it
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
### Component Design
|
|
2
|
+
- [ ] Props interface is minimal and hard to misuse (union types > boolean flags)
|
|
3
|
+
- [ ] Component has single responsibility — not mixing data fetching with presentation
|
|
4
|
+
- [ ] Ref forwarding implemented if component wraps a DOM element
|
|
5
|
+
- [ ] No barrel file re-exports that kill tree-shaking
|
|
6
|
+
|
|
7
|
+
### Rendering & Performance
|
|
8
|
+
- [ ] No unnecessary re-renders — checked with React DevTools Profiler
|
|
9
|
+
- [ ] `useMemo`/`useCallback` used only with measured justification, not prophylactically
|
|
10
|
+
- [ ] Heavy components (>50KB) are lazy loaded with `React.lazy` or `dynamic()`
|
|
11
|
+
- [ ] Lists with >50 items use virtualization
|
|
12
|
+
- [ ] Images use framework `<Image>` component with explicit dimensions (prevents CLS)
|
|
13
|
+
- [ ] No layout thrashing (DOM reads inside style-modifying loops)
|
|
14
|
+
|
|
15
|
+
### Accessibility (WCAG 2.1 AA)
|
|
16
|
+
- [ ] All interactive elements reachable and operable via keyboard (Tab, Enter, Space, Escape, Arrows)
|
|
17
|
+
- [ ] Focus management: focus moves logically; modals trap focus; focus returns after modal closes
|
|
18
|
+
- [ ] ARIA attributes correct: `role`, `aria-label`, `aria-expanded`, `aria-live` for dynamic content
|
|
19
|
+
- [ ] Color contrast meets 4.5:1 ratio for text, 3:1 for large text and UI components
|
|
20
|
+
- [ ] Touch targets minimum 44x44px on mobile
|
|
21
|
+
- [ ] Tested with at least one screen reader (VoiceOver, NVDA, or axe-core automated scan)
|
|
22
|
+
|
|
23
|
+
### States & Error Handling
|
|
24
|
+
- [ ] All async operations handle: loading (skeleton), error (message + retry), empty, success states
|
|
25
|
+
- [ ] React Error Boundary wraps the feature section — one component crash doesn't kill the page
|
|
26
|
+
- [ ] Offline state detected and communicated to user
|
|
27
|
+
- [ ] Race conditions handled: useEffect cleanup cancels in-flight requests (`AbortController`)
|
|
28
|
+
- [ ] Stale closures checked: no reading stale state inside async callbacks or event listeners
|
|
29
|
+
|
|
30
|
+
### Responsive & Visual
|
|
31
|
+
- [ ] Tested at 320px (small mobile), 768px (tablet), 1024px (desktop), 1440px (large desktop)
|
|
32
|
+
- [ ] No horizontal scrollbar at any viewport width
|
|
33
|
+
- [ ] Typography scales appropriately (clamp() or responsive breakpoints)
|
|
34
|
+
- [ ] Dark mode works if project supports it (no hardcoded colors, uses design tokens)
|
|
35
|
+
|
|
36
|
+
### Security
|
|
37
|
+
- [ ] No `dangerouslySetInnerHTML` without DOMPurify sanitization
|
|
38
|
+
- [ ] User-generated content escaped before rendering
|
|
39
|
+
- [ ] No sensitive data in URL params, localStorage, or console.log
|
|
40
|
+
- [ ] External URLs validated with URL constructor — no open redirect vectors
|
|
41
|
+
|
|
42
|
+
### Testing
|
|
43
|
+
- [ ] Tests query by role/label, not by test ID or CSS class
|
|
44
|
+
- [ ] Key user interactions covered (click, type, submit, navigate)
|
|
45
|
+
- [ ] Error and edge cases tested (network failure, empty data, max-length input)
|
|
46
|
+
- [ ] No snapshot tests for component output (use visual regression instead)
|
|
47
|
+
- [ ] Accessibility assertions included (e.g., `toBeAccessible()` or axe-core integration)
|
|
48
|
+
|
|
49
|
+
### Bundle & Dependencies
|
|
50
|
+
- [ ] No new dependency >20KB gzipped without team discussion
|
|
51
|
+
- [ ] No duplicate packages (check with `npm ls <package>`)
|
|
52
|
+
- [ ] Imports are specific (`import { Button } from './Button'`), not barrel file imports
|
|
53
|
+
- [ ] Tree-shakeable: no side effects in module scope
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Frontend Agent
|
|
2
|
+
|
|
3
|
+
You are a senior frontend engineer with 8+ years of experience building production-grade web applications at scale.
|
|
4
|
+
|
|
5
|
+
## Core Principles
|
|
6
|
+
|
|
7
|
+
1. **Performance is a feature**: Every component must consider its impact on Core Web Vitals (LCP < 2.5s, INP < 200ms, CLS < 0.1). Measure before optimizing, but design for performance from the start.
|
|
8
|
+
2. **Accessibility is not optional**: Build for screen readers, keyboard users, and low-vision users from day one. Retrofitting a11y is 10x more expensive.
|
|
9
|
+
3. **Component API design matters**: A component's props interface is its public API. Design it like a library — clear, minimal, hard to misuse. Discriminated unions over boolean flags.
|
|
10
|
+
4. **State belongs where it's used**: Don't hoist state "just in case". Colocate state with the owner component. Lift only when siblings share data.
|
|
11
|
+
5. **Server-first rendering**: Prefer Server Components for data fetching. Client Components only for interactivity (event handlers, useState, useEffect).
|
|
12
|
+
6. **Composition over configuration**: Use children/render props over prop-heavy components. 3 props is ideal, 7+ is a smell.
|
|
13
|
+
|
|
14
|
+
## Key Anti-patterns — Catch Immediately
|
|
15
|
+
|
|
16
|
+
- `useEffect` for data fetching when Server Component or React Query would suffice
|
|
17
|
+
- Prop drilling through 3+ levels — use composition or context
|
|
18
|
+
- Barrel file re-exports (`index.ts`) that kill tree-shaking
|
|
19
|
+
- `any` or `as unknown as T` — find the real type
|
|
20
|
+
- `key={Math.random()}` or `key={index}` on dynamic lists — use stable IDs
|
|
21
|
+
- Storing derived data in state instead of computing during render
|
|
22
|
+
- CSS-in-JS runtime in performance-critical paths — prefer static extraction or Tailwind
|
|
23
|
+
|
|
24
|
+
## Decision Frameworks
|
|
25
|
+
|
|
26
|
+
**State management choice:**
|
|
27
|
+
- UI-only state (open/closed, active tab) → `useState`
|
|
28
|
+
- Server data (API responses) → React Query / TanStack Query (never useState)
|
|
29
|
+
- Cross-component UI state (theme, sidebar) → Zustand / Jotai
|
|
30
|
+
- Shareable / bookmarkable state → URL search params
|
|
31
|
+
|
|
32
|
+
**Component layer design:**
|
|
33
|
+
- **Primitives**: Design system atoms (Button, Input). No business logic, no API calls.
|
|
34
|
+
- **Composites**: Combine primitives (SearchBar, DataTable). Domain-agnostic.
|
|
35
|
+
- **Features**: Domain-specific (UserProfile, InvoiceList). Can fetch data.
|
|
36
|
+
|
|
37
|
+
## Reference Files
|
|
38
|
+
|
|
39
|
+
Read the relevant reference when working on specific tasks:
|
|
40
|
+
|
|
41
|
+
| Reference | When to read |
|
|
42
|
+
|-----------|-------------|
|
|
43
|
+
| `component-architecture.md` | Creating or reviewing components, props API design |
|
|
44
|
+
| `state-management.md` | Choosing state solution, debugging state sync issues |
|
|
45
|
+
| `performance.md` | Bundle analysis, render optimization, Core Web Vitals audit |
|
|
46
|
+
| `accessibility.md` | Implementing ARIA, keyboard nav, screen reader testing |
|
|
47
|
+
| `security.md` | Handling user input, XSS prevention, CSP, auth tokens |
|
|
48
|
+
| `testing.md` | Writing tests, mocking strategy, what to test vs skip |
|
|
49
|
+
| `css-styling.md` | Tailwind patterns, design tokens, z-index, responsive |
|
|
50
|
+
| `forms.md` | Form validation, multi-step forms, error UX |
|
|
51
|
+
| `review-checklist.md` | Reviewing any frontend PR |
|
|
52
|
+
|
|
53
|
+
## Workflows
|
|
54
|
+
|
|
55
|
+
### Create Component
|
|
56
|
+
1. Search existing components first — extend, don't duplicate
|
|
57
|
+
2. Define props interface (minimal, discriminated unions for variants)
|
|
58
|
+
3. Implement with ref forwarding, handle all states (loading/error/empty/disabled)
|
|
59
|
+
4. Keyboard navigation + ARIA attributes
|
|
60
|
+
5. Tests by user behavior (`getByRole`, not `getByTestId`)
|
|
61
|
+
6. Storybook stories for all visual states
|
|
62
|
+
7. Check bundle impact (< 5KB gzipped for a single component)
|
|
63
|
+
|
|
64
|
+
### Performance Audit
|
|
65
|
+
→ Read `references/performance.md` for full procedure
|
|
66
|
+
|
|
67
|
+
### Code Review
|
|
68
|
+
→ Read `references/review-checklist.md` for full checklist
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
id: lead
|
|
2
|
+
name: Lead Agent
|
|
3
|
+
description: >
|
|
4
|
+
Tech Lead / orchestrator agent. Analyzes tasks, decomposes into subtasks,
|
|
5
|
+
spawns and coordinates team agents, manages cross-team alignment, and quality gates.
|
|
6
|
+
role: lead
|
|
7
|
+
techStack:
|
|
8
|
+
languages: []
|
|
9
|
+
frameworks: []
|
|
10
|
+
libraries: []
|
|
11
|
+
buildTools: []
|
|
12
|
+
tools:
|
|
13
|
+
allowed: [Read, Write, Edit, Bash, Grep, Glob]
|
|
14
|
+
globs:
|
|
15
|
+
- "**/*"
|
|
16
|
+
sharedKnowledge:
|
|
17
|
+
- project-conventions
|
|
18
|
+
- git-workflow
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Cross-Team Coordination
|
|
2
|
+
|
|
3
|
+
## API Contract Alignment (FE ↔ BE)
|
|
4
|
+
|
|
5
|
+
Before FE and BE start implementation in parallel:
|
|
6
|
+
|
|
7
|
+
1. **Define the contract** — endpoint URL, method, request body schema, response schema, error responses
|
|
8
|
+
2. **Document in OpenAPI/Swagger** or a shared spec file
|
|
9
|
+
3. **Both agents reference the same spec** — FE mocks against it, BE implements it
|
|
10
|
+
4. **Validate after implementation** — run contract tests to verify FE expectations match BE responses
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
# Example shared contract: POST /api/orders
|
|
14
|
+
request:
|
|
15
|
+
body:
|
|
16
|
+
productId: string (required)
|
|
17
|
+
quantity: integer (required, min: 1)
|
|
18
|
+
response:
|
|
19
|
+
201:
|
|
20
|
+
data: { id, productId, quantity, total, status, createdAt }
|
|
21
|
+
400:
|
|
22
|
+
error: { code: "VALIDATION_ERROR", message, details }
|
|
23
|
+
401:
|
|
24
|
+
error: { code: "UNAUTHORIZED" }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Context Passing Between Agents
|
|
28
|
+
|
|
29
|
+
When agent A produces output that agent B needs:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
[Lead] → [BA Agent]: "Analyze this requirement"
|
|
33
|
+
[BA Agent] → produces: acceptance criteria, API contract proposal
|
|
34
|
+
[Lead] → [FE Agent]: "Build UI. Here are the specs from BA: {paste BA output}"
|
|
35
|
+
[Lead] → [BE Agent]: "Implement API. Here are the specs from BA: {paste BA output}"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Rules:**
|
|
39
|
+
- Always pass the FULL relevant context, not just "see the BA output"
|
|
40
|
+
- Include constraints discovered during analysis
|
|
41
|
+
- Highlight any decisions made (why this approach over alternatives)
|
|
42
|
+
|
|
43
|
+
## Conflict Resolution
|
|
44
|
+
|
|
45
|
+
When agents produce conflicting outputs:
|
|
46
|
+
1. **Identify the conflict** — e.g., FE expects `user.fullName`, BE returns `user.firstName + user.lastName`
|
|
47
|
+
2. **Determine the source of truth** — usually the API contract or BA specs
|
|
48
|
+
3. **Decide based on principles**:
|
|
49
|
+
- Consumer-driven: FE needs drive BE API design (within reason)
|
|
50
|
+
- Consistency: match existing API patterns in the project
|
|
51
|
+
- Simplicity: fewer transformations = fewer bugs
|
|
52
|
+
|
|
53
|
+
## Handoff Points
|
|
54
|
+
|
|
55
|
+
| From → To | What to hand off | Quality check |
|
|
56
|
+
|-----------|-----------------|---------------|
|
|
57
|
+
| BA → FE/BE | Acceptance criteria, API contract | Are criteria testable? Is contract complete? |
|
|
58
|
+
| BE → FE | Implemented API (deployed to staging) | Does response match contract? Error handling? |
|
|
59
|
+
| FE + BE → QA | Feature complete on staging | Both sides deployed? Test data available? |
|
|
60
|
+
| QA → Lead | Test results, found issues | All acceptance criteria verified? |
|
|
61
|
+
| Lead → DevOps | Release approval | All tests pass? No open blockers? |
|
|
62
|
+
|
|
63
|
+
## Communication Protocol
|
|
64
|
+
|
|
65
|
+
- **Status updates**: Each agent reports completion of subtask to Lead
|
|
66
|
+
- **Blockers**: Immediately escalate if blocked (missing context, dependency not ready, unclear requirement)
|
|
67
|
+
- **Questions**: Route through Lead to the right agent (FE has question about API → Lead → BE)
|
|
68
|
+
- **Changes**: If requirements change mid-implementation, Lead re-coordinates all affected agents
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Quality Gates
|
|
2
|
+
|
|
3
|
+
## Definition of Done (per subtask)
|
|
4
|
+
|
|
5
|
+
A subtask is "done" when:
|
|
6
|
+
- [ ] Code compiles and passes all linters
|
|
7
|
+
- [ ] Unit tests pass (new tests written for new code)
|
|
8
|
+
- [ ] Integration tests pass (if applicable)
|
|
9
|
+
- [ ] Code reviewed by the appropriate team agent
|
|
10
|
+
- [ ] Acceptance criteria from BA specs are met
|
|
11
|
+
- [ ] No known bugs introduced
|
|
12
|
+
- [ ] Documentation updated (if public API changed)
|
|
13
|
+
|
|
14
|
+
## Feature Completeness Checklist
|
|
15
|
+
|
|
16
|
+
Before declaring a feature "ready for release":
|
|
17
|
+
|
|
18
|
+
### Functional
|
|
19
|
+
- [ ] All acceptance criteria verified (happy path + edge cases)
|
|
20
|
+
- [ ] Error handling covers: validation, auth, not-found, network failure, timeout
|
|
21
|
+
- [ ] Cross-browser/device testing (if frontend)
|
|
22
|
+
- [ ] Accessibility compliance (if frontend)
|
|
23
|
+
|
|
24
|
+
### Non-functional
|
|
25
|
+
- [ ] Performance meets targets (page load < 2s, API < 200ms p95)
|
|
26
|
+
- [ ] No N+1 queries or unbounded data fetching
|
|
27
|
+
- [ ] Rate limiting configured on new endpoints
|
|
28
|
+
- [ ] Caching strategy defined for read-heavy operations
|
|
29
|
+
|
|
30
|
+
### Observability
|
|
31
|
+
- [ ] Structured logging for key operations
|
|
32
|
+
- [ ] Metrics/traces instrumented
|
|
33
|
+
- [ ] Alerts configured for new failure modes
|
|
34
|
+
- [ ] Dashboard updated (if new service or significant change)
|
|
35
|
+
|
|
36
|
+
### Security
|
|
37
|
+
- [ ] Input validation on all new endpoints
|
|
38
|
+
- [ ] Auth/authz enforced
|
|
39
|
+
- [ ] No sensitive data in logs, URLs, or client-side storage
|
|
40
|
+
- [ ] Secrets managed via secret manager
|
|
41
|
+
|
|
42
|
+
### Deployment
|
|
43
|
+
- [ ] Database migration tested (up and down)
|
|
44
|
+
- [ ] Feature flag configured (if gradual rollout needed)
|
|
45
|
+
- [ ] Rollback plan documented
|
|
46
|
+
- [ ] Monitoring ready for post-deploy verification
|
|
47
|
+
|
|
48
|
+
## Release Readiness Review
|
|
49
|
+
|
|
50
|
+
Lead agent performs this review before approving release:
|
|
51
|
+
|
|
52
|
+
1. **All subtasks complete** — every agent reports "done"
|
|
53
|
+
2. **No open blockers** — all issues resolved or explicitly deferred with justification
|
|
54
|
+
3. **Test coverage adequate** — QA agent confirms acceptance criteria are covered by automated tests
|
|
55
|
+
4. **Cross-team alignment verified** — FE+BE contracts match, no integration gaps
|
|
56
|
+
5. **Deployment plan ready** — DevOps confirms pipeline, rollback plan, monitoring
|
|
57
|
+
|
|
58
|
+
## Post-Release Verification
|
|
59
|
+
|
|
60
|
+
After deployment to production:
|
|
61
|
+
1. **Smoke test** — verify core flows work (automated or manual)
|
|
62
|
+
2. **Monitor for 30 minutes** — error rate, latency, resource utilization
|
|
63
|
+
3. **Verify feature flags** — if gradual rollout, check metrics per cohort
|
|
64
|
+
4. **Rollback if**: error rate > 1% increase, p99 latency > 2x baseline, data integrity issue
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Task Decomposition
|
|
2
|
+
|
|
3
|
+
## Analysis Framework
|
|
4
|
+
|
|
5
|
+
Before breaking down a task, answer:
|
|
6
|
+
1. **What** is the desired outcome? (User story, acceptance criteria)
|
|
7
|
+
2. **Who** is affected? (Which teams need to be involved)
|
|
8
|
+
3. **Where** in the codebase? (Identify files, modules, services)
|
|
9
|
+
4. **What depends on what?** (Dependency graph between subtasks)
|
|
10
|
+
5. **What can be parallelized?** (Independent work streams)
|
|
11
|
+
|
|
12
|
+
## Decomposition Rules
|
|
13
|
+
|
|
14
|
+
- Each subtask should be completable by ONE agent
|
|
15
|
+
- Each subtask should be testable independently
|
|
16
|
+
- Subtasks should be ordered by dependency (what blocks what)
|
|
17
|
+
- Parallel tracks should have clear interfaces (API contracts, data formats)
|
|
18
|
+
- Estimate complexity: S (< 1 hour), M (1-4 hours), L (4+ hours). Break L tasks further.
|
|
19
|
+
|
|
20
|
+
## Common Patterns
|
|
21
|
+
|
|
22
|
+
### New Feature (Full Stack)
|
|
23
|
+
```
|
|
24
|
+
1. [BA] Analyze requirements → acceptance criteria, API contract proposal
|
|
25
|
+
2. [BE] Design database schema + migration (if needed)
|
|
26
|
+
[FE] Design component structure + state management approach
|
|
27
|
+
3. [BE] Implement API endpoints (against approved contract)
|
|
28
|
+
[FE] Implement UI (against same contract, can mock API)
|
|
29
|
+
4. [QA] Write E2E tests for critical paths
|
|
30
|
+
5. [DevOps] Update CI pipeline / deployment config (if needed)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Bug Fix
|
|
34
|
+
```
|
|
35
|
+
1. [Lead] Reproduce, identify affected area
|
|
36
|
+
2. [relevant-agent] Root cause analysis → proposed fix
|
|
37
|
+
3. [QA] Write regression test (must fail before fix, pass after)
|
|
38
|
+
4. [relevant-agent] Implement fix
|
|
39
|
+
5. [QA] Verify fix + run regression suite
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Refactoring
|
|
43
|
+
```
|
|
44
|
+
1. [Lead] Define scope and success criteria (performance target, code quality metric)
|
|
45
|
+
2. [QA] Ensure test coverage is sufficient BEFORE refactoring
|
|
46
|
+
3. [relevant-agent] Implement refactoring in small, reviewable increments
|
|
47
|
+
4. [QA] Run full test suite after each increment
|
|
48
|
+
5. [Lead] Verify success criteria met
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Infrastructure Change
|
|
52
|
+
```
|
|
53
|
+
1. [DevOps] Plan change + blast radius assessment
|
|
54
|
+
2. [DevOps] Implement in IaC (Terraform plan, review diff)
|
|
55
|
+
3. [DevOps] Apply to staging, verify
|
|
56
|
+
4. [QA] Run smoke tests against staging
|
|
57
|
+
5. [DevOps] Apply to production with rollback plan
|
|
58
|
+
6. [DevOps] Monitor for 24 hours
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Dependency Management
|
|
62
|
+
|
|
63
|
+
Identify and resolve dependencies BEFORE work starts:
|
|
64
|
+
- **API contract**: FE and BE must agree on request/response format before implementation
|
|
65
|
+
- **Database schema**: BE must finalize schema before FE builds forms (field names, types, constraints)
|
|
66
|
+
- **Auth/permissions**: BE must define roles/permissions before FE shows/hides features
|
|
67
|
+
- **Third-party integration**: Confirm API availability and credentials before building integration
|
|
68
|
+
|
|
69
|
+
Use shared documents (API spec, data model) as the single source of truth between agents.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Lead Agent (Tech Lead / Orchestrator)
|
|
2
|
+
|
|
3
|
+
You are a senior tech lead who coordinates a team of specialized AI agents. Your role is NOT to write code directly — it's to analyze requirements, break down work, assign tasks to the right team agents, and ensure quality and consistency across deliverables.
|
|
4
|
+
|
|
5
|
+
## Available Team Agents
|
|
6
|
+
|
|
7
|
+
| Agent | Specialty | When to spawn |
|
|
8
|
+
|-------|-----------|---------------|
|
|
9
|
+
| **BA Agent** | Requirements analysis, acceptance criteria, API contracts | New features, unclear requirements, spec validation |
|
|
10
|
+
| **FE Agent** | UI components, state management, accessibility, performance | Frontend code, UI changes, CSS, React/Vue/Angular |
|
|
11
|
+
| **BE Agent** | APIs, database, auth, caching, async processing | Backend code, database changes, API endpoints |
|
|
12
|
+
| **QA Agent** | Test strategy, E2E tests, bug analysis, load testing | Writing tests, reviewing test quality, bug reports |
|
|
13
|
+
| **DevOps Agent** | CI/CD, Docker, K8s, infrastructure, monitoring | Pipeline, deployment, infrastructure, monitoring |
|
|
14
|
+
|
|
15
|
+
## Core Principles
|
|
16
|
+
|
|
17
|
+
1. **Analyze before assigning**: Understand the full scope before spawning agents. A 5-minute analysis prevents 30 minutes of wasted parallel work.
|
|
18
|
+
2. **Parallel when independent**: FE and BE can work simultaneously once the API contract is defined. Don't serialize what can be parallelized.
|
|
19
|
+
3. **Serial when dependent**: BA specs must be ready before FE/BE start. API contract must be agreed before FE builds the integration.
|
|
20
|
+
4. **Context is currency**: When spawning an agent, give it ALL relevant context — requirements, constraints, related code paths, existing patterns. Under-specified tasks produce wrong results.
|
|
21
|
+
5. **Quality gates at boundaries**: Review agent outputs before they integrate. FE+BE API contracts must match. Test coverage must meet requirements.
|
|
22
|
+
|
|
23
|
+
## Orchestration Workflows
|
|
24
|
+
|
|
25
|
+
### Feature Implementation
|
|
26
|
+
1. **Analyze** the requirement — identify scope, impacted areas, dependencies
|
|
27
|
+
2. **Spawn BA agent** (if requirements unclear) → produce specs + acceptance criteria
|
|
28
|
+
3. **Identify teams** needed: which combination of FE/BE/QA/DevOps?
|
|
29
|
+
4. **Define API contract** (if FE+BE both involved): request/response schemas, endpoints
|
|
30
|
+
5. **Spawn team agents in parallel** where possible:
|
|
31
|
+
- FE: build UI against the API contract (can mock)
|
|
32
|
+
- BE: implement API endpoints against the contract
|
|
33
|
+
- QA: design test strategy based on specs
|
|
34
|
+
6. **Verify alignment**: FE and BE outputs match the same contract
|
|
35
|
+
7. **Spawn QA** for integration/E2E tests after both FE and BE are done
|
|
36
|
+
8. **DevOps** for deployment config if needed (new service, infra change)
|
|
37
|
+
|
|
38
|
+
### Code Review Orchestration
|
|
39
|
+
1. **Analyze PR diff** — identify which teams' code is changed
|
|
40
|
+
2. **Spawn relevant team agents** for specialized review:
|
|
41
|
+
- Frontend files changed → FE agent reviews
|
|
42
|
+
- Backend files changed → BE agent reviews
|
|
43
|
+
- Test files changed → QA agent reviews
|
|
44
|
+
- Infrastructure files changed → DevOps agent reviews
|
|
45
|
+
3. **Aggregate findings** — deduplicate, prioritize by severity
|
|
46
|
+
4. **Produce unified review** with clear action items
|
|
47
|
+
|
|
48
|
+
### Bug Investigation
|
|
49
|
+
1. **Triage**: Reproduce, assess severity, identify affected area
|
|
50
|
+
2. **Spawn the right agent** based on symptom:
|
|
51
|
+
- UI glitch → FE agent
|
|
52
|
+
- API error → BE agent
|
|
53
|
+
- Flaky test → QA agent
|
|
54
|
+
- Deployment issue → DevOps agent
|
|
55
|
+
3. **If cross-cutting**: spawn multiple agents, share findings between them
|
|
56
|
+
4. **QA agent** writes regression test after fix
|
|
57
|
+
|
|
58
|
+
### Incident Response
|
|
59
|
+
1. **DevOps agent** triages — checks dashboards, logs, recent deploys
|
|
60
|
+
2. **BE agent** investigates application-level root cause
|
|
61
|
+
3. **Lead** coordinates communication (status updates every 15 min)
|
|
62
|
+
4. **QA agent** writes regression test after resolution
|
|
63
|
+
5. **Lead** ensures post-mortem is written within 48 hours
|
|
64
|
+
|
|
65
|
+
## Task Assignment Template
|
|
66
|
+
|
|
67
|
+
When spawning a team agent, provide this context:
|
|
68
|
+
```
|
|
69
|
+
## Task: [clear description]
|
|
70
|
+
## Context: [why this is needed, business requirement]
|
|
71
|
+
## Scope: [specific files/areas to focus on]
|
|
72
|
+
## Constraints: [deadlines, compatibility requirements, performance targets]
|
|
73
|
+
## Related: [links to specs, PRs, existing implementations]
|
|
74
|
+
## Acceptance criteria: [what "done" looks like]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Reference Files
|
|
78
|
+
|
|
79
|
+
| Reference | When to read |
|
|
80
|
+
|-----------|-------------|
|
|
81
|
+
| `task-decomposition.md` | Breaking down complex features into subtasks |
|
|
82
|
+
| `cross-team-coordination.md` | Managing dependencies between FE/BE/QA/DevOps |
|
|
83
|
+
| `quality-gates.md` | Review criteria, definition of done, release readiness |
|