claude-code-pilot 3.0.0 → 3.1.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/README.md +76 -97
- package/bin/install.js +14 -14
- package/manifest.json +1 -1
- package/package.json +17 -5
- package/src/agents/doc-updater.md +1 -1
- package/src/agents/gan-evaluator.md +209 -0
- package/src/agents/gan-generator.md +131 -0
- package/src/agents/gan-planner.md +99 -0
- package/src/agents/harness-optimizer.md +35 -0
- package/src/agents/loop-operator.md +36 -0
- package/src/agents/opensource-forker.md +198 -0
- package/src/agents/opensource-packager.md +249 -0
- package/src/agents/opensource-sanitizer.md +188 -0
- package/src/agents/performance-optimizer.md +446 -0
- package/src/available-rules/README.md +1 -1
- package/src/commands/{aside.md → ccp/aside.md} +14 -13
- package/src/commands/{build-fix.md → ccp/build-fix.md} +5 -0
- package/src/commands/{checkpoint.md → ccp/checkpoint.md} +12 -7
- package/src/commands/{code-review.md → ccp/code-review.md} +5 -0
- package/src/commands/{context-budget.md → ccp/context-budget.md} +2 -1
- package/src/commands/{cpp-build.md → ccp/cpp-build.md} +6 -5
- package/src/commands/{cpp-review.md → ccp/cpp-review.md} +7 -6
- package/src/commands/{cpp-test.md → ccp/cpp-test.md} +6 -5
- package/src/commands/ccp/docs-update.md +48 -0
- package/src/commands/{docs.md → ccp/docs.md} +4 -3
- package/src/commands/{e2e.md → ccp/e2e.md} +7 -6
- package/src/commands/{eval.md → ccp/eval.md} +10 -5
- package/src/commands/{evolve.md → ccp/evolve.md} +3 -3
- package/src/commands/{go-build.md → ccp/go-build.md} +6 -5
- package/src/commands/{go-review.md → ccp/go-review.md} +7 -6
- package/src/commands/{go-test.md → ccp/go-test.md} +6 -5
- package/src/commands/{gradle-build.md → ccp/gradle-build.md} +1 -0
- package/src/commands/{harness-audit.md → ccp/harness-audit.md} +6 -1
- package/src/commands/{kotlin-build.md → ccp/kotlin-build.md} +6 -5
- package/src/commands/{kotlin-review.md → ccp/kotlin-review.md} +7 -6
- package/src/commands/{kotlin-test.md → ccp/kotlin-test.md} +6 -5
- package/src/commands/{learn.md → ccp/learn.md} +7 -2
- package/src/commands/{model-route.md → ccp/model-route.md} +6 -1
- package/src/commands/{orchestrate.md → ccp/orchestrate.md} +4 -3
- package/src/commands/{plan.md → ccp/plan.md} +6 -5
- package/src/commands/ccp/profile-user.md +46 -0
- package/src/commands/{prompt-optimize.md → ccp/prompt-optimize.md} +3 -2
- package/src/commands/{prune.md → ccp/prune.md} +4 -4
- package/src/commands/{python-review.md → ccp/python-review.md} +7 -6
- package/src/commands/{quality-gate.md → ccp/quality-gate.md} +6 -1
- package/src/commands/{refactor-clean.md → ccp/refactor-clean.md} +5 -0
- package/src/commands/{resume-session.md → ccp/resume-session.md} +9 -8
- package/src/commands/ccp/review.md +37 -0
- package/src/commands/{rules-distill.md → ccp/rules-distill.md} +2 -1
- package/src/commands/{rust-build.md → ccp/rust-build.md} +6 -5
- package/src/commands/{rust-review.md → ccp/rust-review.md} +7 -6
- package/src/commands/{rust-test.md → ccp/rust-test.md} +6 -5
- package/src/commands/{save-session.md → ccp/save-session.md} +2 -1
- package/src/commands/ccp/secure-phase.md +35 -0
- package/src/commands/{sessions.md → ccp/sessions.md} +29 -24
- package/src/commands/{setup-pm.md → ccp/setup-pm.md} +1 -0
- package/src/commands/{setup-refresh.md → ccp/setup-refresh.md} +4 -3
- package/src/commands/{setup.md → ccp/setup.md} +24 -23
- package/src/commands/{skill-create.md → ccp/skill-create.md} +8 -8
- package/src/commands/{skill-health.md → ccp/skill-health.md} +5 -5
- package/src/commands/{tdd.md → ccp/tdd.md} +9 -8
- package/src/commands/{test-coverage.md → ccp/test-coverage.md} +5 -0
- package/src/commands/{tool-guide.md → ccp/tool-guide.md} +2 -1
- package/src/commands/{update-codemaps.md → ccp/update-codemaps.md} +5 -0
- package/src/commands/{update-docs.md → ccp/update-docs.md} +5 -0
- package/src/commands/{verify.md → ccp/verify.md} +5 -0
- package/src/commands/ccp/workstreams.md +68 -0
- package/src/examples/CLAUDE.md +4 -4
- package/src/examples/django-api-CLAUDE.md +5 -5
- package/src/examples/go-microservice-CLAUDE.md +6 -6
- package/src/examples/rust-api-CLAUDE.md +4 -4
- package/src/examples/saas-nextjs-CLAUDE.md +8 -8
- package/src/hooks/session-start.js +1 -1
- package/src/pilot/references/mcp-servers.json +1 -1
- package/src/pilot/workflows/docs-update.md +1165 -0
- package/src/pilot/workflows/help.md +48 -56
- package/src/pilot/workflows/profile-user.md +452 -0
- package/src/pilot/workflows/review.md +244 -0
- package/src/pilot/workflows/secure-phase.md +164 -0
- package/src/rules/common/code-review.md +124 -0
- package/src/rules/zh/README.md +108 -0
- package/src/rules/zh/agents.md +50 -0
- package/src/rules/zh/code-review.md +124 -0
- package/src/rules/zh/coding-style.md +48 -0
- package/src/rules/zh/development-workflow.md +44 -0
- package/src/rules/zh/git-workflow.md +24 -0
- package/src/rules/zh/hooks.md +30 -0
- package/src/rules/zh/patterns.md +31 -0
- package/src/rules/zh/performance.md +55 -0
- package/src/rules/zh/security.md +29 -0
- package/src/rules/zh/testing.md +29 -0
- package/src/skills/autonomous-agent-harness/SKILL.md +267 -0
- package/src/skills/autonomous-loops/SKILL.md +610 -0
- package/src/skills/bun-runtime/SKILL.md +84 -0
- package/src/skills/content-hash-cache-pattern/SKILL.md +161 -0
- package/src/skills/context-budget/SKILL.md +3 -3
- package/src/skills/continuous-learning-v2/SKILL.md +4 -4
- package/src/skills/continuous-learning-v2/agents/observer.md +1 -1
- package/src/skills/cost-aware-llm-pipeline/SKILL.md +183 -0
- package/src/skills/design-system/SKILL.md +82 -0
- package/src/skills/eval-harness/SKILL.md +270 -0
- package/src/skills/flutter-dart-code-review/SKILL.md +435 -0
- package/src/skills/gan-style-harness/SKILL.md +278 -0
- package/src/skills/git-workflow/SKILL.md +715 -0
- package/src/skills/hexagonal-architecture/SKILL.md +276 -0
- package/src/skills/iterative-retrieval/SKILL.md +211 -0
- package/src/skills/laravel-plugin-discovery/SKILL.md +229 -0
- package/src/skills/nextjs-turbopack/SKILL.md +44 -0
- package/src/skills/nuxt4-patterns/SKILL.md +100 -0
- package/src/skills/opensource-pipeline/SKILL.md +255 -0
- package/src/skills/perl-security/SKILL.md +503 -0
- package/src/skills/project-flow-ops/SKILL.md +111 -0
- package/src/skills/project-guidelines-example/SKILL.md +349 -0
- package/src/skills/prompt-optimizer/SKILL.md +38 -38
- package/src/skills/pytorch-patterns/SKILL.md +396 -0
- package/src/skills/regex-vs-llm-structured-text/SKILL.md +220 -0
- package/src/skills/repo-scan/SKILL.md +78 -0
- package/src/skills/rules-distill/SKILL.md +264 -0
- package/src/skills/rules-distill/scripts/scan-rules.sh +58 -0
- package/src/skills/rules-distill/scripts/scan-skills.sh +129 -0
- package/src/skills/swift-concurrency-6-2/SKILL.md +216 -0
- package/src/skills/token-budget-advisor/SKILL.md +133 -0
- package/src/skills/verification-loop/SKILL.md +1 -1
- package/src/skills/workspace-surface-audit/SKILL.md +125 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance-optimizer
|
|
3
|
+
description: Performance analysis and optimization specialist. Use PROACTIVELY for identifying bottlenecks, optimizing slow code, reducing bundle sizes, and improving runtime performance. Profiling, memory leaks, render optimization, and algorithmic improvements.
|
|
4
|
+
tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"]
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Performance Optimizer
|
|
9
|
+
|
|
10
|
+
You are an expert performance specialist focused on identifying bottlenecks and optimizing application speed, memory usage, and efficiency. Your mission is to make code faster, lighter, and more responsive.
|
|
11
|
+
|
|
12
|
+
## Core Responsibilities
|
|
13
|
+
|
|
14
|
+
1. **Performance Profiling** — Identify slow code paths, memory leaks, and bottlenecks
|
|
15
|
+
2. **Bundle Optimization** — Reduce JavaScript bundle sizes, lazy loading, code splitting
|
|
16
|
+
3. **Runtime Optimization** — Improve algorithmic efficiency, reduce unnecessary computations
|
|
17
|
+
4. **React/Rendering Optimization** — Prevent unnecessary re-renders, optimize component trees
|
|
18
|
+
5. **Database & Network** — Optimize queries, reduce API calls, implement caching
|
|
19
|
+
6. **Memory Management** — Detect leaks, optimize memory usage, cleanup resources
|
|
20
|
+
|
|
21
|
+
## Analysis Commands
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Bundle analysis
|
|
25
|
+
npx bundle-analyzer
|
|
26
|
+
npx source-map-explorer build/static/js/*.js
|
|
27
|
+
|
|
28
|
+
# Lighthouse performance audit
|
|
29
|
+
npx lighthouse https://your-app.com --view
|
|
30
|
+
|
|
31
|
+
# Node.js profiling
|
|
32
|
+
node --prof your-app.js
|
|
33
|
+
node --prof-process isolate-*.log
|
|
34
|
+
|
|
35
|
+
# Memory analysis
|
|
36
|
+
node --inspect your-app.js # Then use Chrome DevTools
|
|
37
|
+
|
|
38
|
+
# React profiling (in browser)
|
|
39
|
+
# React DevTools > Profiler tab
|
|
40
|
+
|
|
41
|
+
# Network analysis
|
|
42
|
+
npx webpack-bundle-analyzer
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Performance Review Workflow
|
|
46
|
+
|
|
47
|
+
### 1. Identify Performance Issues
|
|
48
|
+
|
|
49
|
+
**Critical Performance Indicators:**
|
|
50
|
+
|
|
51
|
+
| Metric | Target | Action if Exceeded |
|
|
52
|
+
|--------|--------|-------------------|
|
|
53
|
+
| First Contentful Paint | < 1.8s | Optimize critical path, inline critical CSS |
|
|
54
|
+
| Largest Contentful Paint | < 2.5s | Lazy load images, optimize server response |
|
|
55
|
+
| Time to Interactive | < 3.8s | Code splitting, reduce JavaScript |
|
|
56
|
+
| Cumulative Layout Shift | < 0.1 | Reserve space for images, avoid layout thrashing |
|
|
57
|
+
| Total Blocking Time | < 200ms | Break up long tasks, use web workers |
|
|
58
|
+
| Bundle Size (gzipped) | < 200KB | Tree shaking, lazy loading, code splitting |
|
|
59
|
+
|
|
60
|
+
### 2. Algorithmic Analysis
|
|
61
|
+
|
|
62
|
+
Check for inefficient algorithms:
|
|
63
|
+
|
|
64
|
+
| Pattern | Complexity | Better Alternative |
|
|
65
|
+
|---------|------------|-------------------|
|
|
66
|
+
| Nested loops on same data | O(n²) | Use Map/Set for O(1) lookups |
|
|
67
|
+
| Repeated array searches | O(n) per search | Convert to Map for O(1) |
|
|
68
|
+
| Sorting inside loop | O(n² log n) | Sort once outside loop |
|
|
69
|
+
| String concatenation in loop | O(n²) | Use array.join() |
|
|
70
|
+
| Deep cloning large objects | O(n) each time | Use shallow copy or immer |
|
|
71
|
+
| Recursion without memoization | O(2^n) | Add memoization |
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// BAD: O(n²) - searching array in loop
|
|
75
|
+
for (const user of users) {
|
|
76
|
+
const posts = allPosts.filter(p => p.userId === user.id); // O(n) per user
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// GOOD: O(n) - group once with Map
|
|
80
|
+
const postsByUser = new Map<number, Post[]>();
|
|
81
|
+
for (const post of allPosts) {
|
|
82
|
+
const userPosts = postsByUser.get(post.userId) || [];
|
|
83
|
+
userPosts.push(post);
|
|
84
|
+
postsByUser.set(post.userId, userPosts);
|
|
85
|
+
}
|
|
86
|
+
// Now O(1) lookup per user
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. React Performance Optimization
|
|
90
|
+
|
|
91
|
+
**Common React Anti-patterns:**
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
// BAD: Inline function creation in render
|
|
95
|
+
<Button onClick={() => handleClick(id)}>Submit</Button>
|
|
96
|
+
|
|
97
|
+
// GOOD: Stable callback with useCallback
|
|
98
|
+
const handleButtonClick = useCallback(() => handleClick(id), [handleClick, id]);
|
|
99
|
+
<Button onClick={handleButtonClick}>Submit</Button>
|
|
100
|
+
|
|
101
|
+
// BAD: Object creation in render
|
|
102
|
+
<Child style={{ color: 'red' }} />
|
|
103
|
+
|
|
104
|
+
// GOOD: Stable object reference
|
|
105
|
+
const style = useMemo(() => ({ color: 'red' }), []);
|
|
106
|
+
<Child style={style} />
|
|
107
|
+
|
|
108
|
+
// BAD: Expensive computation on every render
|
|
109
|
+
const sortedItems = items.sort((a, b) => a.name.localeCompare(b.name));
|
|
110
|
+
|
|
111
|
+
// GOOD: Memoize expensive computations
|
|
112
|
+
const sortedItems = useMemo(
|
|
113
|
+
() => [...items].sort((a, b) => a.name.localeCompare(b.name)),
|
|
114
|
+
[items]
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// BAD: List without keys or with index
|
|
118
|
+
{items.map((item, index) => <Item key={index} />)}
|
|
119
|
+
|
|
120
|
+
// GOOD: Stable unique keys
|
|
121
|
+
{items.map(item => <Item key={item.id} item={item} />)}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**React Performance Checklist:**
|
|
125
|
+
|
|
126
|
+
- [ ] `useMemo` for expensive computations
|
|
127
|
+
- [ ] `useCallback` for functions passed to children
|
|
128
|
+
- [ ] `React.memo` for frequently re-rendered components
|
|
129
|
+
- [ ] Proper dependency arrays in hooks
|
|
130
|
+
- [ ] Virtualization for long lists (react-window, react-virtualized)
|
|
131
|
+
- [ ] Lazy loading for heavy components (`React.lazy`)
|
|
132
|
+
- [ ] Code splitting at route level
|
|
133
|
+
|
|
134
|
+
### 4. Bundle Size Optimization
|
|
135
|
+
|
|
136
|
+
**Bundle Analysis Checklist:**
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Analyze bundle composition
|
|
140
|
+
npx webpack-bundle-analyzer build/static/js/*.js
|
|
141
|
+
|
|
142
|
+
# Check for duplicate dependencies
|
|
143
|
+
npx duplicate-package-checker-analyzer
|
|
144
|
+
|
|
145
|
+
# Find largest files
|
|
146
|
+
du -sh node_modules/* | sort -hr | head -20
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Optimization Strategies:**
|
|
150
|
+
|
|
151
|
+
| Issue | Solution |
|
|
152
|
+
|-------|----------|
|
|
153
|
+
| Large vendor bundle | Tree shaking, smaller alternatives |
|
|
154
|
+
| Duplicate code | Extract to shared module |
|
|
155
|
+
| Unused exports | Remove dead code with knip |
|
|
156
|
+
| Moment.js | Use date-fns or dayjs (smaller) |
|
|
157
|
+
| Lodash | Use lodash-es or native methods |
|
|
158
|
+
| Large icons library | Import only needed icons |
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
// BAD: Import entire library
|
|
162
|
+
import _ from 'lodash';
|
|
163
|
+
import moment from 'moment';
|
|
164
|
+
|
|
165
|
+
// GOOD: Import only what you need
|
|
166
|
+
import debounce from 'lodash/debounce';
|
|
167
|
+
import { format, addDays } from 'date-fns';
|
|
168
|
+
|
|
169
|
+
// Or use lodash-es with tree shaking
|
|
170
|
+
import { debounce, throttle } from 'lodash-es';
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 5. Database & Query Optimization
|
|
174
|
+
|
|
175
|
+
**Query Optimization Patterns:**
|
|
176
|
+
|
|
177
|
+
```sql
|
|
178
|
+
-- BAD: Select all columns
|
|
179
|
+
SELECT * FROM users WHERE active = true;
|
|
180
|
+
|
|
181
|
+
-- GOOD: Select only needed columns
|
|
182
|
+
SELECT id, name, email FROM users WHERE active = true;
|
|
183
|
+
|
|
184
|
+
-- BAD: N+1 queries (in application loop)
|
|
185
|
+
-- 1 query for users, then N queries for each user's orders
|
|
186
|
+
|
|
187
|
+
-- GOOD: Single query with JOIN or batch fetch
|
|
188
|
+
SELECT u.*, o.id as order_id, o.total
|
|
189
|
+
FROM users u
|
|
190
|
+
LEFT JOIN orders o ON u.id = o.user_id
|
|
191
|
+
WHERE u.active = true;
|
|
192
|
+
|
|
193
|
+
-- Add index for frequently queried columns
|
|
194
|
+
CREATE INDEX idx_users_active ON users(active);
|
|
195
|
+
CREATE INDEX idx_orders_user_id ON orders(user_id);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Database Performance Checklist:**
|
|
199
|
+
|
|
200
|
+
- [ ] Indexes on frequently queried columns
|
|
201
|
+
- [ ] Composite indexes for multi-column queries
|
|
202
|
+
- [ ] Avoid SELECT * in production code
|
|
203
|
+
- [ ] Use connection pooling
|
|
204
|
+
- [ ] Implement query result caching
|
|
205
|
+
- [ ] Use pagination for large result sets
|
|
206
|
+
- [ ] Monitor slow query logs
|
|
207
|
+
|
|
208
|
+
### 6. Network & API Optimization
|
|
209
|
+
|
|
210
|
+
**Network Optimization Strategies:**
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// BAD: Multiple sequential requests
|
|
214
|
+
const user = await fetchUser(id);
|
|
215
|
+
const posts = await fetchPosts(user.id);
|
|
216
|
+
const comments = await fetchComments(posts[0].id);
|
|
217
|
+
|
|
218
|
+
// GOOD: Parallel requests when independent
|
|
219
|
+
const [user, posts] = await Promise.all([
|
|
220
|
+
fetchUser(id),
|
|
221
|
+
fetchPosts(id)
|
|
222
|
+
]);
|
|
223
|
+
|
|
224
|
+
// GOOD: Batch requests when possible
|
|
225
|
+
const results = await batchFetch(['user1', 'user2', 'user3']);
|
|
226
|
+
|
|
227
|
+
// Implement request caching
|
|
228
|
+
const fetchWithCache = async (url: string, ttl = 300000) => {
|
|
229
|
+
const cached = cache.get(url);
|
|
230
|
+
if (cached) return cached;
|
|
231
|
+
|
|
232
|
+
const data = await fetch(url).then(r => r.json());
|
|
233
|
+
cache.set(url, data, ttl);
|
|
234
|
+
return data;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// Debounce rapid API calls
|
|
238
|
+
const debouncedSearch = debounce(async (query: string) => {
|
|
239
|
+
const results = await searchAPI(query);
|
|
240
|
+
setResults(results);
|
|
241
|
+
}, 300);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Network Optimization Checklist:**
|
|
245
|
+
|
|
246
|
+
- [ ] Parallel independent requests with `Promise.all`
|
|
247
|
+
- [ ] Implement request caching
|
|
248
|
+
- [ ] Debounce rapid-fire requests
|
|
249
|
+
- [ ] Use streaming for large responses
|
|
250
|
+
- [ ] Implement pagination for large datasets
|
|
251
|
+
- [ ] Use GraphQL or API batching to reduce requests
|
|
252
|
+
- [ ] Enable compression (gzip/brotli) on server
|
|
253
|
+
|
|
254
|
+
### 7. Memory Leak Detection
|
|
255
|
+
|
|
256
|
+
**Common Memory Leak Patterns:**
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
// BAD: Event listener without cleanup
|
|
260
|
+
useEffect(() => {
|
|
261
|
+
window.addEventListener('resize', handleResize);
|
|
262
|
+
// Missing cleanup!
|
|
263
|
+
}, []);
|
|
264
|
+
|
|
265
|
+
// GOOD: Clean up event listeners
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
window.addEventListener('resize', handleResize);
|
|
268
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
269
|
+
}, []);
|
|
270
|
+
|
|
271
|
+
// BAD: Timer without cleanup
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
setInterval(() => pollData(), 1000);
|
|
274
|
+
// Missing cleanup!
|
|
275
|
+
}, []);
|
|
276
|
+
|
|
277
|
+
// GOOD: Clean up timers
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
const interval = setInterval(() => pollData(), 1000);
|
|
280
|
+
return () => clearInterval(interval);
|
|
281
|
+
}, []);
|
|
282
|
+
|
|
283
|
+
// BAD: Holding references in closures
|
|
284
|
+
const Component = () => {
|
|
285
|
+
const largeData = useLargeData();
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
eventEmitter.on('update', () => {
|
|
288
|
+
console.log(largeData); // Closure keeps reference
|
|
289
|
+
});
|
|
290
|
+
}, [largeData]);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// GOOD: Use refs or proper dependencies
|
|
294
|
+
const largeDataRef = useRef(largeData);
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
largeDataRef.current = largeData;
|
|
297
|
+
}, [largeData]);
|
|
298
|
+
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
const handleUpdate = () => {
|
|
301
|
+
console.log(largeDataRef.current);
|
|
302
|
+
};
|
|
303
|
+
eventEmitter.on('update', handleUpdate);
|
|
304
|
+
return () => eventEmitter.off('update', handleUpdate);
|
|
305
|
+
}, []);
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Memory Leak Detection:**
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# Chrome DevTools Memory tab:
|
|
312
|
+
# 1. Take heap snapshot
|
|
313
|
+
# 2. Perform action
|
|
314
|
+
# 3. Take another snapshot
|
|
315
|
+
# 4. Compare to find objects that shouldn't exist
|
|
316
|
+
# 5. Look for detached DOM nodes, event listeners, closures
|
|
317
|
+
|
|
318
|
+
# Node.js memory debugging
|
|
319
|
+
node --inspect app.js
|
|
320
|
+
# Open chrome://inspect
|
|
321
|
+
# Take heap snapshots and compare
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Performance Testing
|
|
325
|
+
|
|
326
|
+
### Lighthouse Audits
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Run full lighthouse audit
|
|
330
|
+
npx lighthouse https://your-app.com --view --preset=desktop
|
|
331
|
+
|
|
332
|
+
# CI mode for automated checks
|
|
333
|
+
npx lighthouse https://your-app.com --output=json --output-path=./lighthouse.json
|
|
334
|
+
|
|
335
|
+
# Check specific metrics
|
|
336
|
+
npx lighthouse https://your-app.com --only-categories=performance
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Performance Budgets
|
|
340
|
+
|
|
341
|
+
```json
|
|
342
|
+
// package.json
|
|
343
|
+
{
|
|
344
|
+
"bundlesize": [
|
|
345
|
+
{
|
|
346
|
+
"path": "./build/static/js/*.js",
|
|
347
|
+
"maxSize": "200 kB"
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Web Vitals Monitoring
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// Track Core Web Vitals
|
|
357
|
+
import { getCLS, getFID, getLCP, getFCP, getTTFB } from 'web-vitals';
|
|
358
|
+
|
|
359
|
+
getCLS(console.log); // Cumulative Layout Shift
|
|
360
|
+
getFID(console.log); // First Input Delay
|
|
361
|
+
getLCP(console.log); // Largest Contentful Paint
|
|
362
|
+
getFCP(console.log); // First Contentful Paint
|
|
363
|
+
getTTFB(console.log); // Time to First Byte
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## Performance Report Template
|
|
367
|
+
|
|
368
|
+
````markdown
|
|
369
|
+
# Performance Audit Report
|
|
370
|
+
|
|
371
|
+
## Executive Summary
|
|
372
|
+
- **Overall Score**: X/100
|
|
373
|
+
- **Critical Issues**: X
|
|
374
|
+
- **Recommendations**: X
|
|
375
|
+
|
|
376
|
+
## Bundle Analysis
|
|
377
|
+
| Metric | Current | Target | Status |
|
|
378
|
+
|--------|---------|--------|--------|
|
|
379
|
+
| Total Size (gzip) | XXX KB | < 200 KB | WARNING: |
|
|
380
|
+
| Main Bundle | XXX KB | < 100 KB | PASS: |
|
|
381
|
+
| Vendor Bundle | XXX KB | < 150 KB | WARNING: |
|
|
382
|
+
|
|
383
|
+
## Web Vitals
|
|
384
|
+
| Metric | Current | Target | Status |
|
|
385
|
+
|--------|---------|--------|--------|
|
|
386
|
+
| LCP | X.Xs | < 2.5s | PASS: |
|
|
387
|
+
| FID | XXms | < 100ms | PASS: |
|
|
388
|
+
| CLS | X.XX | < 0.1 | WARNING: |
|
|
389
|
+
|
|
390
|
+
## Critical Issues
|
|
391
|
+
|
|
392
|
+
### 1. [Issue Title]
|
|
393
|
+
**File**: path/to/file.ts:42
|
|
394
|
+
**Impact**: High - Causes XXXms delay
|
|
395
|
+
**Fix**: [Description of fix]
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
// Before (slow)
|
|
399
|
+
const slowCode = ...;
|
|
400
|
+
|
|
401
|
+
// After (optimized)
|
|
402
|
+
const fastCode = ...;
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### 2. [Issue Title]
|
|
406
|
+
...
|
|
407
|
+
|
|
408
|
+
## Recommendations
|
|
409
|
+
1. [Priority recommendation]
|
|
410
|
+
2. [Priority recommendation]
|
|
411
|
+
3. [Priority recommendation]
|
|
412
|
+
|
|
413
|
+
## Estimated Impact
|
|
414
|
+
- Bundle size reduction: XX KB (XX%)
|
|
415
|
+
- LCP improvement: XXms
|
|
416
|
+
- Time to Interactive improvement: XXms
|
|
417
|
+
````
|
|
418
|
+
|
|
419
|
+
## When to Run
|
|
420
|
+
|
|
421
|
+
**ALWAYS:** Before major releases, after adding new features, when users report slowness, during performance regression testing.
|
|
422
|
+
|
|
423
|
+
**IMMEDIATELY:** Lighthouse score drops, bundle size increases >10%, memory usage grows, slow page loads.
|
|
424
|
+
|
|
425
|
+
## Red Flags - Act Immediately
|
|
426
|
+
|
|
427
|
+
| Issue | Action |
|
|
428
|
+
|-------|--------|
|
|
429
|
+
| Bundle > 500KB gzip | Code split, lazy load, tree shake |
|
|
430
|
+
| LCP > 4s | Optimize critical path, preload resources |
|
|
431
|
+
| Memory usage growing | Check for leaks, review useEffect cleanup |
|
|
432
|
+
| CPU spikes | Profile with Chrome DevTools |
|
|
433
|
+
| Database query > 1s | Add index, optimize query, cache results |
|
|
434
|
+
|
|
435
|
+
## Success Metrics
|
|
436
|
+
|
|
437
|
+
- Lighthouse performance score > 90
|
|
438
|
+
- All Core Web Vitals in "good" range
|
|
439
|
+
- Bundle size under budget
|
|
440
|
+
- No memory leaks detected
|
|
441
|
+
- Test suite still passing
|
|
442
|
+
- No performance regressions
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
**Remember**: Performance is a feature. Users notice speed. Every 100ms of improvement matters. Optimize for the 90th percentile, not the average.
|
|
@@ -32,7 +32,7 @@ available-rules/
|
|
|
32
32
|
|
|
33
33
|
## Installation
|
|
34
34
|
|
|
35
|
-
Rules are installed automatically by Claude Code Pilot. The `/setup` wizard detects your project's tech stack and copies the appropriate common + language-specific rule directories into `.claude/rules/`.
|
|
35
|
+
Rules are installed automatically by Claude Code Pilot. The `/ccp:setup` wizard detects your project's tech stack and copies the appropriate common + language-specific rule directories into `.claude/rules/`.
|
|
36
36
|
|
|
37
37
|
> **Important:** Rules directories must maintain their structure (common/ and language-specific/ as separate directories). Do NOT flatten them -- common and language-specific directories contain files with the same names. Flattening causes language-specific files to overwrite common rules, and breaks the relative `../common/` references.
|
|
38
38
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
name: ccp:aside
|
|
2
3
|
description: Answer a quick side question without interrupting or losing context from the current task. Resume work automatically after answering.
|
|
3
4
|
---
|
|
4
5
|
|
|
@@ -17,12 +18,12 @@ Ask a question mid-task and get an immediate, focused answer — then continue r
|
|
|
17
18
|
## Usage
|
|
18
19
|
|
|
19
20
|
```
|
|
20
|
-
/aside <your question>
|
|
21
|
-
/aside what does this function actually return?
|
|
22
|
-
/aside is this pattern thread-safe?
|
|
23
|
-
/aside why are we using X instead of Y here?
|
|
24
|
-
/aside what's the difference between foo() and bar()?
|
|
25
|
-
/aside should we be worried about the N+1 query we just added?
|
|
21
|
+
/ccp:aside <your question>
|
|
22
|
+
/ccp:aside what does this function actually return?
|
|
23
|
+
/ccp:aside is this pattern thread-safe?
|
|
24
|
+
/ccp:aside why are we using X instead of Y here?
|
|
25
|
+
/ccp:aside what's the difference between foo() and bar()?
|
|
26
|
+
/ccp:aside should we be worried about the N+1 query we just added?
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
## Process
|
|
@@ -31,7 +32,7 @@ Ask a question mid-task and get an immediate, focused answer — then continue r
|
|
|
31
32
|
|
|
32
33
|
Before answering anything, mentally note:
|
|
33
34
|
- What is the active task? (what file, feature, or problem was being worked on)
|
|
34
|
-
- What step was in progress at the moment `/aside` was invoked?
|
|
35
|
+
- What step was in progress at the moment `/ccp:aside` was invoked?
|
|
35
36
|
- What was about to happen next?
|
|
36
37
|
|
|
37
38
|
Do NOT touch, edit, create, or delete any files during the aside.
|
|
@@ -63,7 +64,7 @@ After delivering the answer, immediately continue the active task from the exact
|
|
|
63
64
|
|
|
64
65
|
## Edge Cases
|
|
65
66
|
|
|
66
|
-
**No question provided (`/aside` with nothing after it):**
|
|
67
|
+
**No question provided (`/ccp:aside` with nothing after it):**
|
|
67
68
|
Respond:
|
|
68
69
|
```
|
|
69
70
|
ASIDE: no question provided
|
|
@@ -83,7 +84,7 @@ ASIDE: [answer]
|
|
|
83
84
|
Wait for the user's decision before resuming.
|
|
84
85
|
|
|
85
86
|
**Question is actually a task redirect (not a side question):**
|
|
86
|
-
If the question implies changing what is being built (e.g., `/aside actually, let's use Redis instead`), clarify:
|
|
87
|
+
If the question implies changing what is being built (e.g., `/ccp:aside actually, let's use Redis instead`), clarify:
|
|
87
88
|
```
|
|
88
89
|
ASIDE: That sounds like a direction change, not just a side question.
|
|
89
90
|
Do you want to:
|
|
@@ -95,7 +96,7 @@ Wait for the user's answer — do not make assumptions.
|
|
|
95
96
|
**Question is about the currently open file or code:**
|
|
96
97
|
Answer from the live context. If the file was read earlier in the session, reference it directly. If not, read it now (read-only) and answer with a file:line reference.
|
|
97
98
|
|
|
98
|
-
**No active task (nothing in progress when `/aside` is invoked):**
|
|
99
|
+
**No active task (nothing in progress when `/ccp:aside` is invoked):**
|
|
99
100
|
Still use the standard wrapper so the response shape stays consistent:
|
|
100
101
|
```
|
|
101
102
|
ASIDE: [restate the question briefly]
|
|
@@ -111,7 +112,7 @@ Give the essential answer concisely, then offer:
|
|
|
111
112
|
That's the short version. Want a deeper explanation after we finish [current task]?
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
**Multiple `/aside` questions in a row:**
|
|
115
|
+
**Multiple `/ccp:aside` questions in a row:**
|
|
115
116
|
Answer each one in sequence. After the last answer, resume the main task. Do not lose task state across a chain of asides.
|
|
116
117
|
|
|
117
118
|
**Aside answer implies a code change is needed:**
|
|
@@ -130,7 +131,7 @@ Ask one clarifying question — the shortest question that gets the information
|
|
|
130
131
|
## Example Output
|
|
131
132
|
|
|
132
133
|
```
|
|
133
|
-
User: /aside what does fetchWithRetry() actually do?
|
|
134
|
+
User: /ccp:aside what does fetchWithRetry() actually do?
|
|
134
135
|
|
|
135
136
|
ASIDE: what does fetchWithRetry() do?
|
|
136
137
|
|
|
@@ -142,7 +143,7 @@ network errors — 4xx errors are treated as final and not retried.
|
|
|
142
143
|
```
|
|
143
144
|
|
|
144
145
|
```
|
|
145
|
-
User: /aside is the approach we're taking thread-safe?
|
|
146
|
+
User: /ccp:aside is the approach we're taking thread-safe?
|
|
146
147
|
|
|
147
148
|
ASIDE: is the current approach thread-safe?
|
|
148
149
|
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ccp:checkpoint
|
|
3
|
+
description: "Create or verify a checkpoint in your workflow"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# Checkpoint Command
|
|
2
7
|
|
|
3
8
|
Create or verify a checkpoint in your workflow.
|
|
4
9
|
|
|
5
10
|
## Usage
|
|
6
11
|
|
|
7
|
-
`/checkpoint [create|verify|list] [name]`
|
|
12
|
+
`/ccp:checkpoint [create|verify|list] [name]`
|
|
8
13
|
|
|
9
14
|
## Create Checkpoint
|
|
10
15
|
|
|
11
16
|
When creating a checkpoint:
|
|
12
17
|
|
|
13
|
-
1. Run `/verify quick` to ensure current state is clean
|
|
18
|
+
1. Run `/ccp:verify quick` to ensure current state is clean
|
|
14
19
|
2. Create a git stash or commit with checkpoint name
|
|
15
20
|
3. Log checkpoint to `.claude/checkpoints.log`:
|
|
16
21
|
|
|
@@ -54,15 +59,15 @@ Show all checkpoints with:
|
|
|
54
59
|
Typical checkpoint flow:
|
|
55
60
|
|
|
56
61
|
```
|
|
57
|
-
[Start] --> /checkpoint create "feature-start"
|
|
62
|
+
[Start] --> /ccp:checkpoint create "feature-start"
|
|
58
63
|
|
|
|
59
|
-
[Implement] --> /checkpoint create "core-done"
|
|
64
|
+
[Implement] --> /ccp:checkpoint create "core-done"
|
|
60
65
|
|
|
|
61
|
-
[Test] --> /checkpoint verify "core-done"
|
|
66
|
+
[Test] --> /ccp:checkpoint verify "core-done"
|
|
62
67
|
|
|
|
63
|
-
[Refactor] --> /checkpoint create "refactor-done"
|
|
68
|
+
[Refactor] --> /ccp:checkpoint create "refactor-done"
|
|
64
69
|
|
|
|
65
|
-
[PR] --> /checkpoint verify "feature-start"
|
|
70
|
+
[PR] --> /ccp:checkpoint verify "feature-start"
|
|
66
71
|
```
|
|
67
72
|
|
|
68
73
|
## Arguments
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
name: ccp:context-budget
|
|
2
3
|
description: Analyze context window usage across agents, skills, MCP servers, and rules to find optimization opportunities. Helps reduce token overhead and avoid performance warnings.
|
|
3
4
|
---
|
|
4
5
|
|
|
@@ -9,7 +10,7 @@ Analyze your Claude Code setup's context window consumption and produce actionab
|
|
|
9
10
|
## Usage
|
|
10
11
|
|
|
11
12
|
```
|
|
12
|
-
/context-budget [--verbose]
|
|
13
|
+
/ccp:context-budget [--verbose]
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
- Default: summary with top recommendations
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
name: ccp:cpp-build
|
|
2
3
|
description: Fix C++ build errors, CMake issues, and linker problems incrementally. Invokes the cpp-build-resolver agent for minimal, surgical fixes.
|
|
3
4
|
---
|
|
4
5
|
|
|
@@ -16,7 +17,7 @@ This command invokes the **cpp-build-resolver** agent to incrementally fix C++ b
|
|
|
16
17
|
|
|
17
18
|
## When to Use
|
|
18
19
|
|
|
19
|
-
Use `/cpp-build` when:
|
|
20
|
+
Use `/ccp:cpp-build` when:
|
|
20
21
|
- `cmake --build build` fails with errors
|
|
21
22
|
- Linker errors (undefined references, multiple definitions)
|
|
22
23
|
- Template instantiation failures
|
|
@@ -40,7 +41,7 @@ cppcheck --enable=all src/
|
|
|
40
41
|
## Example Session
|
|
41
42
|
|
|
42
43
|
```text
|
|
43
|
-
User: /cpp-build
|
|
44
|
+
User: /ccp:cpp-build
|
|
44
45
|
|
|
45
46
|
Agent:
|
|
46
47
|
# C++ Build Resolution
|
|
@@ -163,9 +164,9 @@ The agent will stop and report if:
|
|
|
163
164
|
|
|
164
165
|
## Related Commands
|
|
165
166
|
|
|
166
|
-
- `/cpp-test` - Run tests after build succeeds
|
|
167
|
-
- `/cpp-review` - Review code quality
|
|
168
|
-
- `/verify` - Full verification loop
|
|
167
|
+
- `/ccp:cpp-test` - Run tests after build succeeds
|
|
168
|
+
- `/ccp:cpp-review` - Review code quality
|
|
169
|
+
- `/ccp:verify` - Full verification loop
|
|
169
170
|
|
|
170
171
|
## Related
|
|
171
172
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
name: ccp:cpp-review
|
|
2
3
|
description: Comprehensive C++ code review for memory safety, modern C++ idioms, concurrency, and security. Invokes the cpp-reviewer agent.
|
|
3
4
|
---
|
|
4
5
|
|
|
@@ -17,7 +18,7 @@ This command invokes the **cpp-reviewer** agent for comprehensive C++-specific c
|
|
|
17
18
|
|
|
18
19
|
## When to Use
|
|
19
20
|
|
|
20
|
-
Use `/cpp-review` when:
|
|
21
|
+
Use `/ccp:cpp-review` when:
|
|
21
22
|
- After writing or modifying C++ code
|
|
22
23
|
- Before committing C++ changes
|
|
23
24
|
- Reviewing pull requests with C++ code
|
|
@@ -64,7 +65,7 @@ cmake --build build -- -Wall -Wextra -Wpedantic
|
|
|
64
65
|
## Example Usage
|
|
65
66
|
|
|
66
67
|
```text
|
|
67
|
-
User: /cpp-review
|
|
68
|
+
User: /ccp:cpp-review
|
|
68
69
|
|
|
69
70
|
Agent:
|
|
70
71
|
# C++ Code Review Report
|
|
@@ -121,10 +122,10 @@ Recommendation: ❌ Block merge until CRITICAL issue is fixed
|
|
|
121
122
|
|
|
122
123
|
## Integration with Other Commands
|
|
123
124
|
|
|
124
|
-
- Use `/cpp-test` first to ensure tests pass
|
|
125
|
-
- Use `/cpp-build` if build errors occur
|
|
126
|
-
- Use `/cpp-review` before committing
|
|
127
|
-
- Use `/code-review` for non-C++ specific concerns
|
|
125
|
+
- Use `/ccp:cpp-test` first to ensure tests pass
|
|
126
|
+
- Use `/ccp:cpp-build` if build errors occur
|
|
127
|
+
- Use `/ccp:cpp-review` before committing
|
|
128
|
+
- Use `/ccp:code-review` for non-C++ specific concerns
|
|
128
129
|
|
|
129
130
|
## Related
|
|
130
131
|
|