agcel 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/workflows/api-gen.md +59 -0
- package/.agent/workflows/architect.md +44 -0
- package/.agent/workflows/brainstorm.md +223 -0
- package/.agent/workflows/build.md +38 -0
- package/.agent/workflows/changelog.md +51 -0
- package/.agent/workflows/checkpoint.md +138 -0
- package/.agent/workflows/commit.md +223 -0
- package/.agent/workflows/debug.md +57 -0
- package/.agent/workflows/deploy.md +76 -0
- package/.agent/workflows/doc.md +247 -0
- package/.agent/workflows/execute-plan.md +225 -0
- package/.agent/workflows/feature.md +255 -0
- package/.agent/workflows/fix.md +323 -0
- package/.agent/workflows/help.md +63 -0
- package/.agent/workflows/index.md +148 -0
- package/.agent/workflows/load.md +112 -0
- package/.agent/workflows/mode.md +170 -0
- package/.agent/workflows/optimize.md +53 -0
- package/.agent/workflows/plan.md +337 -0
- package/.agent/workflows/pr.md +74 -0
- package/.agent/workflows/product-plan.md +36 -0
- package/.agent/workflows/production-deploy.md +39 -0
- package/.agent/workflows/refactor.md +63 -0
- package/.agent/workflows/research.md +116 -0
- package/.agent/workflows/review.md +344 -0
- package/.agent/workflows/security-scan.md +56 -0
- package/.agent/workflows/ship.md +221 -0
- package/.agent/workflows/spawn.md +177 -0
- package/.agent/workflows/status.md +59 -0
- package/.agent/workflows/tdd.md +139 -0
- package/.agent/workflows/test.md +340 -0
- package/.agent/workflows/verify.md +35 -0
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/commands/init.js +142 -0
- package/dist/commands/install.js +98 -0
- package/dist/commands/list.js +49 -0
- package/dist/commands/restart.js +17 -0
- package/dist/commands/start.js +41 -0
- package/dist/commands/status.js +24 -0
- package/dist/commands/stop.js +29 -0
- package/dist/commands/uninstall.js +78 -0
- package/dist/index.js +58 -0
- package/dist/server/index.js +174 -0
- package/dist/utils/index.js +63 -0
- package/package.json +54 -0
- package/skills/api-security-best-practices/SKILL.md +291 -0
- package/skills/api-security-best-practices/references/examples.md +617 -0
- package/skills/architecture/SKILL.md +59 -0
- package/skills/architecture/context-discovery.md +43 -0
- package/skills/architecture/examples.md +94 -0
- package/skills/architecture/pattern-selection.md +68 -0
- package/skills/architecture/patterns-reference.md +50 -0
- package/skills/architecture/trade-off-analysis.md +77 -0
- package/skills/aws-serverless/SKILL.md +327 -0
- package/skills/brainstorming/SKILL.md +234 -0
- package/skills/c4-context/SKILL.md +154 -0
- package/skills/ci-cd-engineer/SKILL.md +50 -0
- package/skills/code-auditing/SKILL.md +55 -0
- package/skills/copywriting/SKILL.md +248 -0
- package/skills/database-engineer/SKILL.md +47 -0
- package/skills/doc-coauthoring/SKILL.md +379 -0
- package/skills/docker-expert/SKILL.md +412 -0
- package/skills/langgraph/SKILL.md +291 -0
- package/skills/postgresql/SKILL.md +73 -0
- package/skills/pricing-strategy/SKILL.md +360 -0
- package/skills/product-manager/SKILL.md +57 -0
- package/skills/prompt-engineer/README.md +659 -0
- package/skills/prompt-engineer/SKILL.md +256 -0
- package/skills/python-patterns/SKILL.md +445 -0
- package/skills/qa-engineer/SKILL.md +42 -0
- package/skills/rag-engineer/SKILL.md +94 -0
- package/skills/react-patterns/SKILL.md +202 -0
- package/skills/secure-refactoring/SKILL.md +54 -0
- package/skills/security-documentation/SKILL.md +53 -0
- package/skills/senior-architect/SKILL.md +213 -0
- package/skills/senior-architect/references/architecture_patterns.md +103 -0
- package/skills/senior-architect/references/system_design_workflows.md +103 -0
- package/skills/senior-architect/references/tech_decision_guide.md +103 -0
- package/skills/senior-architect/scripts/architecture_diagram_generator.py +114 -0
- package/skills/senior-architect/scripts/dependency_analyzer.py +114 -0
- package/skills/senior-architect/scripts/project_architect.py +114 -0
- package/skills/seo-audit/SKILL.md +491 -0
- package/skills/sql-injection-testing/SKILL.md +452 -0
- package/skills/test-driven-development/SKILL.md +375 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/test-fixing/SKILL.md +123 -0
- package/skills/testing-patterns/SKILL.md +263 -0
- package/skills/typescript-expert/SKILL.md +202 -0
- package/skills/typescript-expert/references/advanced-topics.md +252 -0
- package/skills/typescript-expert/references/tsconfig-strict.json +92 -0
- package/skills/typescript-expert/references/typescript-cheatsheet.md +383 -0
- package/skills/typescript-expert/references/utility-types.ts +335 -0
- package/skills/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/skills/ui-ux-designer/SKILL.md +46 -0
- package/skills/vercel-deployment/SKILL.md +83 -0
- package/skills/vulnerability-scanner/SKILL.md +280 -0
- package/skills/vulnerability-scanner/checklists.md +121 -0
- package/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/skills/writing-plans/SKILL.md +120 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-fixing
|
|
3
|
+
description: Run tests and systematically fix all failing tests using smart error grouping. Use when user asks to fix failing tests, mentions test failures, runs test suite and failures occur, or requests to make tests pass.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test Fixing
|
|
7
|
+
|
|
8
|
+
Systematically identify and fix all failing tests using smart grouping strategies.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- Explicitly asks to fix tests ("fix these tests", "make tests pass")
|
|
13
|
+
- Reports test failures ("tests are failing", "test suite is broken")
|
|
14
|
+
- Completes implementation and wants tests passing
|
|
15
|
+
- Mentions CI/CD failures due to tests
|
|
16
|
+
|
|
17
|
+
## Systematic Approach
|
|
18
|
+
|
|
19
|
+
### 1. Initial Test Run
|
|
20
|
+
|
|
21
|
+
Run `make test` to identify all failing tests.
|
|
22
|
+
|
|
23
|
+
Analyze output for:
|
|
24
|
+
|
|
25
|
+
- Total number of failures
|
|
26
|
+
- Error types and patterns
|
|
27
|
+
- Affected modules/files
|
|
28
|
+
|
|
29
|
+
### 2. Smart Error Grouping
|
|
30
|
+
|
|
31
|
+
Group similar failures by:
|
|
32
|
+
|
|
33
|
+
- **Error type**: ImportError, AttributeError, AssertionError, etc.
|
|
34
|
+
- **Module/file**: Same file causing multiple test failure
|
|
35
|
+
- **Root cause**: Missing dependencies, API changes, refactoring impacts
|
|
36
|
+
|
|
37
|
+
Prioritize groups by:
|
|
38
|
+
|
|
39
|
+
- Number of affected tests (highest impact first)
|
|
40
|
+
- Dependency order (fix infrastructure before functionality)
|
|
41
|
+
|
|
42
|
+
### 3. Systematic Fixing Process
|
|
43
|
+
|
|
44
|
+
For each group (starting with highest impact):
|
|
45
|
+
|
|
46
|
+
1. **Identify root cause**
|
|
47
|
+
|
|
48
|
+
- Read relevant code
|
|
49
|
+
- Check recent changes with `git diff`
|
|
50
|
+
- Understand the error pattern
|
|
51
|
+
|
|
52
|
+
2. **Implement fix**
|
|
53
|
+
|
|
54
|
+
- Use Edit tool for code changes
|
|
55
|
+
- Follow project conventions (see CLAUDE.md)
|
|
56
|
+
- Make minimal, focused changes
|
|
57
|
+
|
|
58
|
+
3. **Verify fix**
|
|
59
|
+
|
|
60
|
+
- Run subset of tests for this group
|
|
61
|
+
- Use pytest markers or file patterns:
|
|
62
|
+
```bash
|
|
63
|
+
uv run pytest tests/path/to/test_file.py -v
|
|
64
|
+
uv run pytest -k "pattern" -v
|
|
65
|
+
```
|
|
66
|
+
- Ensure group passes before moving on
|
|
67
|
+
|
|
68
|
+
4. **Move to next group**
|
|
69
|
+
|
|
70
|
+
### 4. Fix Order Strategy
|
|
71
|
+
|
|
72
|
+
**Infrastructure first:**
|
|
73
|
+
|
|
74
|
+
- Import errors
|
|
75
|
+
- Missing dependencies
|
|
76
|
+
- Configuration issues
|
|
77
|
+
|
|
78
|
+
**Then API changes:**
|
|
79
|
+
|
|
80
|
+
- Function signature changes
|
|
81
|
+
- Module reorganization
|
|
82
|
+
- Renamed variables/functions
|
|
83
|
+
|
|
84
|
+
**Finally, logic issues:**
|
|
85
|
+
|
|
86
|
+
- Assertion failures
|
|
87
|
+
- Business logic bugs
|
|
88
|
+
- Edge case handling
|
|
89
|
+
|
|
90
|
+
### 5. Final Verification
|
|
91
|
+
|
|
92
|
+
After all groups fixed:
|
|
93
|
+
|
|
94
|
+
- Run complete test suite: `make test`
|
|
95
|
+
- Verify no regressions
|
|
96
|
+
- Check test coverage remains intact
|
|
97
|
+
|
|
98
|
+
## Best Practices
|
|
99
|
+
|
|
100
|
+
- Fix one group at a time
|
|
101
|
+
- Run focused tests after each fix
|
|
102
|
+
- Use `git diff` to understand recent changes
|
|
103
|
+
- Look for patterns in failures
|
|
104
|
+
- Don't move to next group until current passes
|
|
105
|
+
- Keep changes minimal and focused
|
|
106
|
+
|
|
107
|
+
## Example Workflow
|
|
108
|
+
|
|
109
|
+
User: "The tests are failing after my refactor"
|
|
110
|
+
|
|
111
|
+
1. Run `make test` → 15 failures identified
|
|
112
|
+
2. Group errors:
|
|
113
|
+
- 8 ImportErrors (module renamed)
|
|
114
|
+
- 5 AttributeErrors (function signature changed)
|
|
115
|
+
- 2 AssertionErrors (logic bugs)
|
|
116
|
+
3. Fix ImportErrors first → Run subset → Verify
|
|
117
|
+
4. Fix AttributeErrors → Run subset → Verify
|
|
118
|
+
5. Fix AssertionErrors → Run subset → Verify
|
|
119
|
+
6. Run full suite → All pass ✓
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Gap Analysis Rule
|
|
123
|
+
Always identify gaps and suggest next steps to users. In case there is no gaps anymore, then AI should clearly state that there is no gap left.
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testing-patterns
|
|
3
|
+
description: Jest testing patterns, factory functions, mocking strategies, and TDD workflow. Use when writing unit tests, creating test factories, or following TDD red-green-refactor cycle.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Testing Patterns and Utilities
|
|
7
|
+
|
|
8
|
+
## Testing Philosophy
|
|
9
|
+
|
|
10
|
+
**Test-Driven Development (TDD):**
|
|
11
|
+
- Write failing test FIRST
|
|
12
|
+
- Implement minimal code to pass
|
|
13
|
+
- Refactor after green
|
|
14
|
+
- Never write production code without a failing test
|
|
15
|
+
|
|
16
|
+
**Behavior-Driven Testing:**
|
|
17
|
+
- Test behavior, not implementation
|
|
18
|
+
- Focus on public APIs and business requirements
|
|
19
|
+
- Avoid testing implementation details
|
|
20
|
+
- Use descriptive test names that describe behavior
|
|
21
|
+
|
|
22
|
+
**Factory Pattern:**
|
|
23
|
+
- Create `getMockX(overrides?: Partial<X>)` functions
|
|
24
|
+
- Provide sensible defaults
|
|
25
|
+
- Allow overriding specific properties
|
|
26
|
+
- Keep tests DRY and maintainable
|
|
27
|
+
|
|
28
|
+
## Test Utilities
|
|
29
|
+
|
|
30
|
+
### Custom Render Function
|
|
31
|
+
|
|
32
|
+
Create a custom render that wraps components with required providers:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// src/utils/testUtils.tsx
|
|
36
|
+
import { render } from '@testing-library/react-native';
|
|
37
|
+
import { ThemeProvider } from './theme';
|
|
38
|
+
|
|
39
|
+
export const renderWithTheme = (ui: React.ReactElement) => {
|
|
40
|
+
return render(
|
|
41
|
+
<ThemeProvider>{ui}</ThemeProvider>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Usage:**
|
|
47
|
+
```typescript
|
|
48
|
+
import { renderWithTheme } from 'utils/testUtils';
|
|
49
|
+
import { screen } from '@testing-library/react-native';
|
|
50
|
+
|
|
51
|
+
it('should render component', () => {
|
|
52
|
+
renderWithTheme(<MyComponent />);
|
|
53
|
+
expect(screen.getByText('Hello')).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Factory Pattern
|
|
58
|
+
|
|
59
|
+
### Component Props Factory
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { ComponentProps } from 'react';
|
|
63
|
+
|
|
64
|
+
const getMockMyComponentProps = (
|
|
65
|
+
overrides?: Partial<ComponentProps<typeof MyComponent>>
|
|
66
|
+
) => {
|
|
67
|
+
return {
|
|
68
|
+
title: 'Default Title',
|
|
69
|
+
count: 0,
|
|
70
|
+
onPress: jest.fn(),
|
|
71
|
+
isLoading: false,
|
|
72
|
+
...overrides,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Usage in tests
|
|
77
|
+
it('should render with custom title', () => {
|
|
78
|
+
const props = getMockMyComponentProps({ title: 'Custom Title' });
|
|
79
|
+
renderWithTheme(<MyComponent {...props} />);
|
|
80
|
+
expect(screen.getByText('Custom Title')).toBeTruthy();
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Data Factory
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
interface User {
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
email: string;
|
|
91
|
+
role: 'admin' | 'user';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const getMockUser = (overrides?: Partial<User>): User => {
|
|
95
|
+
return {
|
|
96
|
+
id: '123',
|
|
97
|
+
name: 'John Doe',
|
|
98
|
+
email: 'john@example.com',
|
|
99
|
+
role: 'user',
|
|
100
|
+
...overrides,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Usage
|
|
105
|
+
it('should display admin badge for admin users', () => {
|
|
106
|
+
const user = getMockUser({ role: 'admin' });
|
|
107
|
+
renderWithTheme(<UserCard user={user} />);
|
|
108
|
+
expect(screen.getByText('Admin')).toBeTruthy();
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Mocking Patterns
|
|
113
|
+
|
|
114
|
+
### Mocking Modules
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Mock entire module
|
|
118
|
+
jest.mock('utils/analytics');
|
|
119
|
+
|
|
120
|
+
// Mock with factory function
|
|
121
|
+
jest.mock('utils/analytics', () => ({
|
|
122
|
+
Analytics: {
|
|
123
|
+
logEvent: jest.fn(),
|
|
124
|
+
},
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
// Access mock in test
|
|
128
|
+
const mockLogEvent = jest.requireMock('utils/analytics').Analytics.logEvent;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Mocking GraphQL Hooks
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
jest.mock('./GetItems.generated', () => ({
|
|
135
|
+
useGetItemsQuery: jest.fn(),
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
const mockUseGetItemsQuery = jest.requireMock(
|
|
139
|
+
'./GetItems.generated'
|
|
140
|
+
).useGetItemsQuery as jest.Mock;
|
|
141
|
+
|
|
142
|
+
// In test
|
|
143
|
+
mockUseGetItemsQuery.mockReturnValue({
|
|
144
|
+
data: { items: [] },
|
|
145
|
+
loading: false,
|
|
146
|
+
error: undefined,
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Test Structure
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
describe('ComponentName', () => {
|
|
154
|
+
beforeEach(() => {
|
|
155
|
+
jest.clearAllMocks();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('Rendering', () => {
|
|
159
|
+
it('should render component with default props', () => {});
|
|
160
|
+
it('should render loading state when loading', () => {});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('User interactions', () => {
|
|
164
|
+
it('should call onPress when button is clicked', async () => {});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('Edge cases', () => {
|
|
168
|
+
it('should handle empty data gracefully', () => {});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Query Patterns
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// Element must exist
|
|
177
|
+
expect(screen.getByText('Hello')).toBeTruthy();
|
|
178
|
+
|
|
179
|
+
// Element should not exist
|
|
180
|
+
expect(screen.queryByText('Goodbye')).toBeNull();
|
|
181
|
+
|
|
182
|
+
// Element appears asynchronously
|
|
183
|
+
await waitFor(() => {
|
|
184
|
+
expect(screen.findByText('Loaded')).toBeTruthy();
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## User Interaction Patterns
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { fireEvent, screen } from '@testing-library/react-native';
|
|
192
|
+
|
|
193
|
+
it('should submit form on button click', async () => {
|
|
194
|
+
const onSubmit = jest.fn();
|
|
195
|
+
renderWithTheme(<LoginForm onSubmit={onSubmit} />);
|
|
196
|
+
|
|
197
|
+
fireEvent.changeText(screen.getByLabelText('Email'), 'user@example.com');
|
|
198
|
+
fireEvent.changeText(screen.getByLabelText('Password'), 'password123');
|
|
199
|
+
fireEvent.press(screen.getByTestId('login-button'));
|
|
200
|
+
|
|
201
|
+
await waitFor(() => {
|
|
202
|
+
expect(onSubmit).toHaveBeenCalled();
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Anti-Patterns to Avoid
|
|
208
|
+
|
|
209
|
+
### Testing Mock Behavior Instead of Real Behavior
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
// Bad - testing the mock
|
|
213
|
+
expect(mockFetchData).toHaveBeenCalled();
|
|
214
|
+
|
|
215
|
+
// Good - testing actual behavior
|
|
216
|
+
expect(screen.getByText('John Doe')).toBeTruthy();
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Not Using Factories
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
// Bad - duplicated, inconsistent test data
|
|
223
|
+
it('test 1', () => {
|
|
224
|
+
const user = { id: '1', name: 'John', email: 'john@test.com', role: 'user' };
|
|
225
|
+
});
|
|
226
|
+
it('test 2', () => {
|
|
227
|
+
const user = { id: '2', name: 'Jane', email: 'jane@test.com' }; // Missing role!
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Good - reusable factory
|
|
231
|
+
const user = getMockUser({ name: 'Custom Name' });
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Best Practices
|
|
235
|
+
|
|
236
|
+
1. **Always use factory functions** for props and data
|
|
237
|
+
2. **Test behavior, not implementation**
|
|
238
|
+
3. **Use descriptive test names**
|
|
239
|
+
4. **Organize with describe blocks**
|
|
240
|
+
5. **Clear mocks between tests**
|
|
241
|
+
6. **Keep tests focused** - one behavior per test
|
|
242
|
+
|
|
243
|
+
## Running Tests
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Run all tests
|
|
247
|
+
npm test
|
|
248
|
+
|
|
249
|
+
# Run with coverage
|
|
250
|
+
npm run test:coverage
|
|
251
|
+
|
|
252
|
+
# Run specific file
|
|
253
|
+
npm test ComponentName.test.tsx
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Integration with Other Skills
|
|
257
|
+
|
|
258
|
+
- **react-ui-patterns**: Test all UI states (loading, error, empty, success)
|
|
259
|
+
- **systematic-debugging**: Write test that reproduces bug before fixing
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
## Gap Analysis Rule
|
|
263
|
+
Always identify gaps and suggest next steps to users. In case there is no gaps anymore, then AI should clearly state that there is no gap left.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typescript-expert
|
|
3
|
+
description: >-
|
|
4
|
+
TypeScript and JavaScript expert with deep knowledge of type-level
|
|
5
|
+
programming, performance optimization, monorepo management, migration
|
|
6
|
+
strategies, and modern tooling. Use PROACTIVELY for any TypeScript/JavaScript
|
|
7
|
+
issues including complex type gymnastics, build performance, debugging, and
|
|
8
|
+
architectural decisions. If a specialized expert is a better fit, I will
|
|
9
|
+
recommend switching and stop.
|
|
10
|
+
category: framework
|
|
11
|
+
bundle: [typescript-type-expert, typescript-build-expert]
|
|
12
|
+
displayName: TypeScript
|
|
13
|
+
color: blue
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# TypeScript Expert
|
|
17
|
+
|
|
18
|
+
You are an advanced TypeScript expert with deep, practical knowledge of type-level programming, performance optimization, and real-world problem solving based on current best practices.
|
|
19
|
+
|
|
20
|
+
## When invoked:
|
|
21
|
+
|
|
22
|
+
0. If the issue requires ultra-specific expertise, recommend switching and stop:
|
|
23
|
+
- Deep webpack/vite/rollup bundler internals → typescript-build-expert
|
|
24
|
+
- Complex ESM/CJS migration or circular dependency analysis → typescript-module-expert
|
|
25
|
+
- Type performance profiling or compiler internals → typescript-type-expert
|
|
26
|
+
|
|
27
|
+
Example to output:
|
|
28
|
+
"This requires deep bundler expertise. Please invoke: 'Use the typescript-build-expert subagent.' Stopping here."
|
|
29
|
+
|
|
30
|
+
1. Analyze project setup comprehensively:
|
|
31
|
+
|
|
32
|
+
**Use internal tools first (Read, Grep, Glob) for better performance. Shell commands are fallbacks.**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Core versions and configuration
|
|
36
|
+
npx tsc --version
|
|
37
|
+
node -v
|
|
38
|
+
# Detect tooling ecosystem (prefer parsing package.json)
|
|
39
|
+
node -e "const p=require('./package.json');console.log(Object.keys({...p.devDependencies,...p.dependencies}||{}).join('\n'))" 2>/dev/null | grep -E 'biome|eslint|prettier|vitest|jest|turborepo|nx' || echo "No tooling detected"
|
|
40
|
+
# Check for monorepo (fixed precedence)
|
|
41
|
+
(test -f pnpm-workspace.yaml || test -f lerna.json || test -f nx.json || test -f turbo.json) && echo "Monorepo detected"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**After detection, adapt approach:**
|
|
45
|
+
- Match import style (absolute vs relative)
|
|
46
|
+
- Respect existing baseUrl/paths configuration
|
|
47
|
+
- Prefer existing project scripts over raw tools
|
|
48
|
+
- In monorepos, consider project references before broad tsconfig changes
|
|
49
|
+
|
|
50
|
+
2. Identify the specific problem category and complexity level
|
|
51
|
+
|
|
52
|
+
3. Apply the appropriate solution strategy from my expertise
|
|
53
|
+
|
|
54
|
+
4. Validate thoroughly:
|
|
55
|
+
```bash
|
|
56
|
+
# Fast fail approach (avoid long-lived processes)
|
|
57
|
+
npm run -s typecheck || npx tsc --noEmit
|
|
58
|
+
npm test -s || npx vitest run --reporter=basic --no-watch
|
|
59
|
+
# Only if needed and build affects outputs/config
|
|
60
|
+
npm run -s build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Safety note:** Avoid watch/serve processes in validation. Use one-shot diagnostics only.
|
|
64
|
+
|
|
65
|
+
## Advanced Topics
|
|
66
|
+
|
|
67
|
+
Deep dives into **Type-Level Programming**, **Performance Optimization**, **Real-World Problem Resolution**, **Modern Tooling**, and **Debugging** are available in the references:
|
|
68
|
+
|
|
69
|
+
[View Advanced Topics](references/advanced-topics.md)
|
|
70
|
+
|
|
71
|
+
## Current Best Practices
|
|
72
|
+
|
|
73
|
+
### Strict by Default
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"compilerOptions": {
|
|
77
|
+
"strict": true,
|
|
78
|
+
"noUncheckedIndexedAccess": true,
|
|
79
|
+
"noImplicitOverride": true,
|
|
80
|
+
"exactOptionalPropertyTypes": true,
|
|
81
|
+
"noPropertyAccessFromIndexSignature": true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### ESM-First Approach
|
|
87
|
+
- Set `"type": "module"` in package.json
|
|
88
|
+
- Use `.mts` for TypeScript ESM files if needed
|
|
89
|
+
- Configure `"moduleResolution": "bundler"` for modern tools
|
|
90
|
+
- Use dynamic imports for CJS: `const pkg = await import('cjs-package')`
|
|
91
|
+
- Note: `await import()` requires async function or top-level await in ESM
|
|
92
|
+
- For CJS packages in ESM: May need `(await import('pkg')).default` depending on the package's export structure and your compiler settings
|
|
93
|
+
|
|
94
|
+
### AI-Assisted Development
|
|
95
|
+
- GitHub Copilot excels at TypeScript generics
|
|
96
|
+
- Use AI for boilerplate type definitions
|
|
97
|
+
- Validate AI-generated types with type tests
|
|
98
|
+
- Document complex types for AI context
|
|
99
|
+
|
|
100
|
+
## Code Review Checklist
|
|
101
|
+
|
|
102
|
+
When reviewing TypeScript/JavaScript code, focus on these domain-specific aspects:
|
|
103
|
+
|
|
104
|
+
### Type Safety
|
|
105
|
+
- [ ] No implicit `any` types (use `unknown` or proper types)
|
|
106
|
+
- [ ] Strict null checks enabled and properly handled
|
|
107
|
+
- [ ] Type assertions (`as`) justified and minimal
|
|
108
|
+
- [ ] Generic constraints properly defined
|
|
109
|
+
- [ ] Discriminated unions for error handling
|
|
110
|
+
- [ ] Return types explicitly declared for public APIs
|
|
111
|
+
|
|
112
|
+
### TypeScript Best Practices
|
|
113
|
+
- [ ] Prefer `interface` over `type` for object shapes (better error messages)
|
|
114
|
+
- [ ] Use const assertions for literal types
|
|
115
|
+
- [ ] Leverage type guards and predicates
|
|
116
|
+
- [ ] Avoid type gymnastics when simpler solution exists
|
|
117
|
+
- [ ] Template literal types used appropriately
|
|
118
|
+
- [ ] Branded types for domain primitives
|
|
119
|
+
|
|
120
|
+
### Performance Considerations
|
|
121
|
+
- [ ] Type complexity doesn't cause slow compilation
|
|
122
|
+
- [ ] No excessive type instantiation depth
|
|
123
|
+
- [ ] Avoid complex mapped types in hot paths
|
|
124
|
+
- [ ] Use `skipLibCheck: true` in tsconfig
|
|
125
|
+
- [ ] Project references configured for monorepos
|
|
126
|
+
|
|
127
|
+
### Module System
|
|
128
|
+
- [ ] Consistent import/export patterns
|
|
129
|
+
- [ ] No circular dependencies
|
|
130
|
+
- [ ] Proper use of barrel exports (avoid over-bundling)
|
|
131
|
+
- [ ] ESM/CJS compatibility handled correctly
|
|
132
|
+
- [ ] Dynamic imports for code splitting
|
|
133
|
+
|
|
134
|
+
### Error Handling Patterns
|
|
135
|
+
- [ ] Result types or discriminated unions for errors
|
|
136
|
+
- [ ] Custom error classes with proper inheritance
|
|
137
|
+
- [ ] Type-safe error boundaries
|
|
138
|
+
- [ ] Exhaustive switch cases with `never` type
|
|
139
|
+
|
|
140
|
+
### Code Organization
|
|
141
|
+
- [ ] Types co-located with implementation
|
|
142
|
+
- [ ] Shared types in dedicated modules
|
|
143
|
+
- [ ] Avoid global type augmentation when possible
|
|
144
|
+
- [ ] Proper use of declaration files (.d.ts)
|
|
145
|
+
|
|
146
|
+
## Quick Decision Trees
|
|
147
|
+
|
|
148
|
+
### "Which tool should I use?"
|
|
149
|
+
```
|
|
150
|
+
Type checking only? → tsc
|
|
151
|
+
Type checking + linting speed critical? → Biome
|
|
152
|
+
Type checking + comprehensive linting? → ESLint + typescript-eslint
|
|
153
|
+
Type testing? → Vitest expectTypeOf
|
|
154
|
+
Build tool? → Project size <10 packages? Turborepo. Else? Nx
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### "How do I fix this performance issue?"
|
|
158
|
+
```
|
|
159
|
+
Slow type checking? → skipLibCheck, incremental, project references
|
|
160
|
+
Slow builds? → Check bundler config, enable caching
|
|
161
|
+
Slow tests? → Vitest with threads, avoid type checking in tests
|
|
162
|
+
Slow language server? → Exclude node_modules, limit files in tsconfig
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Anti-Patterns
|
|
166
|
+
|
|
167
|
+
### ❌ The `any` Trap
|
|
168
|
+
- Using `any` disables all type checking. Use `unknown` or specific types instead.
|
|
169
|
+
|
|
170
|
+
### ❌ Enum Overuse
|
|
171
|
+
- Prefer string union types (`type Role = 'admin' | 'user'`) over numeric enums.
|
|
172
|
+
|
|
173
|
+
### ❌ `IInterface` Naming
|
|
174
|
+
- Don't prefix interfaces with `I`. It's a C# convention, not TypeScript.
|
|
175
|
+
|
|
176
|
+
### ❌ Default Exports
|
|
177
|
+
- Prefer named exports for better refactoring support.
|
|
178
|
+
|
|
179
|
+
## Expert Resources
|
|
180
|
+
|
|
181
|
+
### Performance
|
|
182
|
+
- [TypeScript Wiki Performance](https://github.com/microsoft/TypeScript/wiki/Performance)
|
|
183
|
+
- [Type instantiation tracking](https://github.com/microsoft/TypeScript/pull/48077)
|
|
184
|
+
|
|
185
|
+
### Advanced Patterns
|
|
186
|
+
- [Type Challenges](https://github.com/type-challenges/type-challenges)
|
|
187
|
+
- [Type-Level TypeScript Course](https://type-level-typescript.com)
|
|
188
|
+
|
|
189
|
+
### Tools
|
|
190
|
+
- [Biome](https://biomejs.dev) - Fast linter/formatter
|
|
191
|
+
- [TypeStat](https://github.com/JoshuaKGoldberg/TypeStat) - Auto-fix TypeScript types
|
|
192
|
+
- [ts-migrate](https://github.com/airbnb/ts-migrate) - Migration toolkit
|
|
193
|
+
|
|
194
|
+
### Testing
|
|
195
|
+
- [Vitest Type Testing](https://vitest.dev/guide/testing-types)
|
|
196
|
+
- [tsd](https://github.com/tsdjs/tsd) - Standalone type testing
|
|
197
|
+
|
|
198
|
+
Always validate changes don't break existing functionality before considering the issue resolved.
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## Gap Analysis Rule
|
|
202
|
+
Always identify gaps and suggest next steps to users. In case there is no gaps anymore, then AI should clearly state that there is no gap left.
|