@neyugn/agent-kits 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 +514 -0
- package/README.vi.md +410 -0
- package/README.zh.md +410 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +422 -0
- package/kits/coder/ARCHITECTURE.md +289 -0
- package/kits/coder/agents/ai-engineer.md +344 -0
- package/kits/coder/agents/backend-specialist.md +270 -0
- package/kits/coder/agents/cloud-architect.md +363 -0
- package/kits/coder/agents/code-reviewer.md +284 -0
- package/kits/coder/agents/data-engineer.md +401 -0
- package/kits/coder/agents/database-specialist.md +251 -0
- package/kits/coder/agents/debugger.md +209 -0
- package/kits/coder/agents/devops-engineer.md +281 -0
- package/kits/coder/agents/documentation-writer.md +296 -0
- package/kits/coder/agents/frontend-specialist.md +298 -0
- package/kits/coder/agents/i18n-specialist.md +348 -0
- package/kits/coder/agents/integration-specialist.md +314 -0
- package/kits/coder/agents/mobile-developer.md +271 -0
- package/kits/coder/agents/multi-tenant-architect.md +281 -0
- package/kits/coder/agents/orchestrator.md +263 -0
- package/kits/coder/agents/performance-analyst.md +327 -0
- package/kits/coder/agents/project-planner.md +277 -0
- package/kits/coder/agents/queue-specialist.md +282 -0
- package/kits/coder/agents/realtime-specialist.md +267 -0
- package/kits/coder/agents/security-auditor.md +253 -0
- package/kits/coder/agents/test-engineer.md +315 -0
- package/kits/coder/agents/ux-researcher.md +388 -0
- package/kits/coder/rules/.cursorrules +287 -0
- package/kits/coder/rules/CLAUDE.md +287 -0
- package/kits/coder/rules/CODEX.md +287 -0
- package/kits/coder/rules/GEMINI.md +287 -0
- package/kits/coder/scripts/checklist.py +318 -0
- package/kits/coder/scripts/kit_status.py +292 -0
- package/kits/coder/scripts/skills_manager.py +243 -0
- package/kits/coder/scripts/verify_all.py +391 -0
- package/kits/coder/skills/accessibility-patterns/SKILL.md +372 -0
- package/kits/coder/skills/accessibility-patterns/scripts/a11y_checker.py +211 -0
- package/kits/coder/skills/ai-rag-patterns/SKILL.md +444 -0
- package/kits/coder/skills/api-patterns/SKILL.md +316 -0
- package/kits/coder/skills/api-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/api-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/api-patterns/scripts/api_validator.py +253 -0
- package/kits/coder/skills/api-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/auth-patterns/SKILL.md +267 -0
- package/kits/coder/skills/aws-patterns/SKILL.md +576 -0
- package/kits/coder/skills/brainstorming/SKILL.md +370 -0
- package/kits/coder/skills/brainstorming/assets/.gitkeep +1 -0
- package/kits/coder/skills/brainstorming/references/deep-dive.md +21 -0
- package/kits/coder/skills/brainstorming/scripts/validate.py +56 -0
- package/kits/coder/skills/clean-code/SKILL.md +240 -0
- package/kits/coder/skills/clean-code/assets/.gitkeep +1 -0
- package/kits/coder/skills/clean-code/references/deep-dive.md +21 -0
- package/kits/coder/skills/clean-code/scripts/lint_runner.py +186 -0
- package/kits/coder/skills/clean-code/scripts/validate.py +56 -0
- package/kits/coder/skills/database-design/SKILL.md +255 -0
- package/kits/coder/skills/database-design/assets/.gitkeep +1 -0
- package/kits/coder/skills/database-design/references/deep-dive.md +21 -0
- package/kits/coder/skills/database-design/scripts/schema_validator.py +272 -0
- package/kits/coder/skills/database-design/scripts/validate.py +56 -0
- package/kits/coder/skills/docker-patterns/SKILL.md +240 -0
- package/kits/coder/skills/documentation-templates/SKILL.md +441 -0
- package/kits/coder/skills/e2e-testing/SKILL.md +457 -0
- package/kits/coder/skills/flutter-patterns/SKILL.md +330 -0
- package/kits/coder/skills/frontend-design/SKILL.md +127 -0
- package/kits/coder/skills/github-actions/SKILL.md +349 -0
- package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +466 -0
- package/kits/coder/skills/graphql-patterns/SKILL.md +558 -0
- package/kits/coder/skills/i18n-localization/SKILL.md +345 -0
- package/kits/coder/skills/i18n-localization/scripts/i18n_checker.py +267 -0
- package/kits/coder/skills/kubernetes-patterns/SKILL.md +357 -0
- package/kits/coder/skills/mermaid-diagrams/SKILL.md +351 -0
- package/kits/coder/skills/mobile-design/SKILL.md +305 -0
- package/kits/coder/skills/monitoring-observability/SKILL.md +458 -0
- package/kits/coder/skills/multi-tenancy/SKILL.md +317 -0
- package/kits/coder/skills/multi-tenancy/assets/.gitkeep +1 -0
- package/kits/coder/skills/multi-tenancy/references/deep-dive.md +21 -0
- package/kits/coder/skills/multi-tenancy/scripts/validate.py +56 -0
- package/kits/coder/skills/nodejs-best-practices/SKILL.md +220 -0
- package/kits/coder/skills/performance-profiling/SKILL.md +333 -0
- package/kits/coder/skills/performance-profiling/assets/.gitkeep +1 -0
- package/kits/coder/skills/performance-profiling/references/deep-dive.md +21 -0
- package/kits/coder/skills/performance-profiling/scripts/validate.py +56 -0
- package/kits/coder/skills/plan-writing/SKILL.md +360 -0
- package/kits/coder/skills/plan-writing/assets/.gitkeep +1 -0
- package/kits/coder/skills/plan-writing/references/deep-dive.md +21 -0
- package/kits/coder/skills/plan-writing/scripts/validate.py +56 -0
- package/kits/coder/skills/postgres-patterns/SKILL.md +361 -0
- package/kits/coder/skills/prompt-engineering/SKILL.md +277 -0
- package/kits/coder/skills/queue-patterns/SKILL.md +359 -0
- package/kits/coder/skills/queue-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/queue-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/queue-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/react-native-patterns/SKILL.md +393 -0
- package/kits/coder/skills/react-patterns/SKILL.md +319 -0
- package/kits/coder/skills/realtime-patterns/SKILL.md +506 -0
- package/kits/coder/skills/realtime-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/realtime-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/realtime-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/redis-patterns/SKILL.md +484 -0
- package/kits/coder/skills/security-fundamentals/SKILL.md +363 -0
- package/kits/coder/skills/security-fundamentals/assets/.gitkeep +1 -0
- package/kits/coder/skills/security-fundamentals/references/deep-dive.md +21 -0
- package/kits/coder/skills/security-fundamentals/scripts/security_scan.py +326 -0
- package/kits/coder/skills/security-fundamentals/scripts/validate.py +56 -0
- package/kits/coder/skills/seo-patterns/SKILL.md +262 -0
- package/kits/coder/skills/seo-patterns/scripts/seo_checker.py +211 -0
- package/kits/coder/skills/systematic-debugging/SKILL.md +478 -0
- package/kits/coder/skills/systematic-debugging/assets/.gitkeep +1 -0
- package/kits/coder/skills/systematic-debugging/references/deep-dive.md +21 -0
- package/kits/coder/skills/systematic-debugging/scripts/validate.py +56 -0
- package/kits/coder/skills/tailwind-patterns/SKILL.md +395 -0
- package/kits/coder/skills/terraform-patterns/SKILL.md +470 -0
- package/kits/coder/skills/testing-patterns/SKILL.md +285 -0
- package/kits/coder/skills/testing-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/testing-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/kits/coder/skills/testing-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/typescript-patterns/SKILL.md +417 -0
- package/kits/coder/skills/ui-ux-pro-max/SKILL.md +364 -0
- package/kits/coder/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/kits/coder/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/kits/coder/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/kits/coder/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/kits/coder/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/core.py +257 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/design_system.py +488 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/search.py +76 -0
- package/kits/coder/workflows/.gitkeep +20 -0
- package/kits/coder/workflows/create.md +152 -0
- package/kits/coder/workflows/debug.md +223 -0
- package/kits/coder/workflows/deploy.md +283 -0
- package/kits/coder/workflows/orchestrate.md +243 -0
- package/kits/coder/workflows/plan.md +134 -0
- package/kits/coder/workflows/test.md +237 -0
- package/kits/coder/workflows/ui-ux-pro-max.md +109 -0
- package/package.json +49 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance-profiling
|
|
3
|
+
description: Performance profiling principles and decision-making. Use when diagnosing slow code, optimizing response times, analyzing Core Web Vitals, or establishing performance budgets. Covers measurement, analysis, and optimization techniques.
|
|
4
|
+
allowed-tools: Read, Edit, Glob, Grep, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Performance Profiling - Measure First, Optimize Second
|
|
8
|
+
|
|
9
|
+
> **Philosophy:** Never optimize without data. Gut feelings about performance are usually wrong.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## šÆ Core Principle: Data-Driven Optimization
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
ā WRONG: "This looks slow, let me refactor it to be faster"
|
|
17
|
+
ā
CORRECT: "I measured this takes 850ms, my target is 200ms, profiling shows 70% in DB query"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Performance Optimization Workflow:**
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
1. BASELINE ā Measure current state
|
|
24
|
+
2. PROFILE ā Find the bottleneck
|
|
25
|
+
3. ANALYZE ā Understand root cause
|
|
26
|
+
4. OPTIMIZE ā Fix the specific issue
|
|
27
|
+
5. VALIDATE ā Verify improvement
|
|
28
|
+
6. MONITOR ā Prevent regression
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## š What to Measure
|
|
34
|
+
|
|
35
|
+
### Web Performance: Core Web Vitals
|
|
36
|
+
|
|
37
|
+
| Metric | What It Measures | Good | Needs Work | Poor |
|
|
38
|
+
| ----------------------------------- | ---------------- | ------- | ---------- | ------- |
|
|
39
|
+
| **LCP** (Largest Contentful Paint) | Loading | ⤠2.5s | 2.5-4.0s | > 4.0s |
|
|
40
|
+
| **INP** (Interaction to Next Paint) | Responsiveness | ⤠200ms | 200-500ms | > 500ms |
|
|
41
|
+
| **CLS** (Cumulative Layout Shift) | Visual Stability | ⤠0.1 | 0.1-0.25 | > 0.25 |
|
|
42
|
+
|
|
43
|
+
### Backend Performance
|
|
44
|
+
|
|
45
|
+
| Metric | Target | Critical |
|
|
46
|
+
| ----------------------- | ------- | -------- |
|
|
47
|
+
| API Response Time (p50) | < 100ms | > 500ms |
|
|
48
|
+
| API Response Time (p95) | < 300ms | > 1s |
|
|
49
|
+
| API Response Time (p99) | < 1s | > 3s |
|
|
50
|
+
| Database Query | < 50ms | > 200ms |
|
|
51
|
+
| Background Job | < 30s | > 5min |
|
|
52
|
+
| Memory Usage | < 80% | > 95% |
|
|
53
|
+
| CPU Usage | < 70% | > 90% |
|
|
54
|
+
|
|
55
|
+
### Decision: Which Metric to Prioritize?
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
User-facing latency?
|
|
59
|
+
āāā Yes ā Focus on p95/p99 latency first
|
|
60
|
+
āāā No (batch job) ā Focus on throughput and resource usage
|
|
61
|
+
|
|
62
|
+
High traffic volume?
|
|
63
|
+
āāā Yes ā Optimize p50 for most impact
|
|
64
|
+
āāā No ā Optimize p99 to catch edge cases
|
|
65
|
+
|
|
66
|
+
User perceives slowness?
|
|
67
|
+
āāā Yes ā Measure Time to Interactive (TTI)
|
|
68
|
+
āāā No ā Check if perceived speed is the real issue
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## š Profiling Decision Tree
|
|
74
|
+
|
|
75
|
+
### Frontend Performance
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
Page loads slowly?
|
|
79
|
+
āāā Check LCP element
|
|
80
|
+
ā āāā Large image? ā Compress, use WebP, lazy load
|
|
81
|
+
ā āāā Web font? ā Preload, use font-display: swap
|
|
82
|
+
ā āāā Server slow? ā Check TTFB (Time to First Byte)
|
|
83
|
+
ā
|
|
84
|
+
āāā Check blocking resources
|
|
85
|
+
ā āāā Large JS bundle? ā Code split, tree shake
|
|
86
|
+
ā āāā Render-blocking CSS? ā Inline critical CSS
|
|
87
|
+
ā āāā Third-party scripts? ā Defer, async load
|
|
88
|
+
ā
|
|
89
|
+
āāā Check waterfalls in DevTools Network tab
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Backend Performance
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
API is slow?
|
|
96
|
+
āāā Where is time spent?
|
|
97
|
+
ā āāā Database query ā Check query plan, add indexes
|
|
98
|
+
ā āāā External API ā Add caching, circuit breaker
|
|
99
|
+
ā āāā CPU processing ā Profile code, optimize algorithm
|
|
100
|
+
ā āāā Memory allocation ā Check for leaks, reduce allocations
|
|
101
|
+
ā
|
|
102
|
+
āāā Is it consistent or intermittent?
|
|
103
|
+
ā āāā Consistent ā Systemic issue (algorithm, query)
|
|
104
|
+
ā āāā Intermittent ā Check for lock contention, GC pauses
|
|
105
|
+
ā
|
|
106
|
+
āāā Does it scale?
|
|
107
|
+
āāā No ā O(n²) algorithm? N+1 queries?
|
|
108
|
+
āāā Yes ā Infrastructure bottleneck?
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## š ļø Profiling Tools
|
|
114
|
+
|
|
115
|
+
### Frontend
|
|
116
|
+
|
|
117
|
+
| Tool | Purpose | When to Use |
|
|
118
|
+
| --------------------------- | ------------------------- | ------------------------------------ |
|
|
119
|
+
| Chrome DevTools Performance | Recording-based profiling | Investigating specific interactions |
|
|
120
|
+
| Lighthouse | Automated audits | Quick health check |
|
|
121
|
+
| WebPageTest | Real-world testing | Testing from different locations |
|
|
122
|
+
| PageSpeed Insights | Field + Lab data | SEO + real user metrics |
|
|
123
|
+
| Chrome UX Report | Real user data | Understanding actual user experience |
|
|
124
|
+
|
|
125
|
+
### Backend (Node.js)
|
|
126
|
+
|
|
127
|
+
| Tool | Purpose | When to Use |
|
|
128
|
+
| ---------------------- | ----------------------- | -------------------------- |
|
|
129
|
+
| `clinic.js` | Comprehensive profiling | First investigation |
|
|
130
|
+
| `node --prof` | V8 CPU profiler | Deep CPU analysis |
|
|
131
|
+
| `--inspect` + DevTools | Interactive debugging | Memory leaks, async issues |
|
|
132
|
+
| `0x` | Flame graphs | Visualizing CPU time |
|
|
133
|
+
| `autocannon` / `k6` | Load testing | Stress testing endpoints |
|
|
134
|
+
|
|
135
|
+
### Database
|
|
136
|
+
|
|
137
|
+
| Tool | Purpose | When to Use |
|
|
138
|
+
| -------------------- | -------------------- | ------------------------- |
|
|
139
|
+
| `EXPLAIN ANALYZE` | Query execution plan | Slow query investigation |
|
|
140
|
+
| `pg_stat_statements` | Query statistics | Finding slow queries |
|
|
141
|
+
| MongoDB Profiler | Operation profiling | Slow operation detection |
|
|
142
|
+
| Redis `SLOWLOG` | Slow command log | Identifying slow commands |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## ā” Common Bottlenecks & Solutions
|
|
147
|
+
|
|
148
|
+
### N+1 Queries
|
|
149
|
+
|
|
150
|
+
**Detection:**
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
10 users requested ā 1 query for users + 10 queries for profiles
|
|
154
|
+
Pattern: Query count scales with data size
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Solution:**
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// ā N+1 Problem
|
|
161
|
+
const users = await User.findAll();
|
|
162
|
+
for (const user of users) {
|
|
163
|
+
user.profile = await Profile.findOne({ userId: user.id });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ā
Eager Loading
|
|
167
|
+
const users = await User.findAll({
|
|
168
|
+
include: [{ model: Profile }],
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ā
Batching
|
|
172
|
+
const users = await User.findAll();
|
|
173
|
+
const profiles = await Profile.findAll({
|
|
174
|
+
where: { userId: users.map((u) => u.id) },
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Missing Database Indexes
|
|
179
|
+
|
|
180
|
+
**Detection:**
|
|
181
|
+
|
|
182
|
+
```sql
|
|
183
|
+
EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 123;
|
|
184
|
+
-- Look for: Seq Scan (bad) vs Index Scan (good)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Solution:**
|
|
188
|
+
|
|
189
|
+
```sql
|
|
190
|
+
-- Add index on frequently filtered columns
|
|
191
|
+
CREATE INDEX idx_orders_user_id ON orders(user_id);
|
|
192
|
+
|
|
193
|
+
-- Composite index for common query patterns
|
|
194
|
+
CREATE INDEX idx_orders_user_status ON orders(user_id, status);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Large Bundle Size
|
|
198
|
+
|
|
199
|
+
**Detection:**
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Analyze bundle composition
|
|
203
|
+
npx webpack-bundle-analyzer dist/stats.json
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Solutions:**
|
|
207
|
+
| Problem | Solution |
|
|
208
|
+
| ------- | -------- |
|
|
209
|
+
| Large library | Use lighter alternative (date-fns vs moment) |
|
|
210
|
+
| Unused exports | Enable tree shaking |
|
|
211
|
+
| One big bundle | Code split by route |
|
|
212
|
+
| Duplicate dependencies | Dedupe in package manager |
|
|
213
|
+
|
|
214
|
+
### Memory Leaks
|
|
215
|
+
|
|
216
|
+
**Detection:**
|
|
217
|
+
|
|
218
|
+
- Memory usage increases over time
|
|
219
|
+
- Heap dumps show growing object counts
|
|
220
|
+
- OutOfMemory errors in production
|
|
221
|
+
|
|
222
|
+
**Common Causes:**
|
|
223
|
+
| Cause | Solution |
|
|
224
|
+
| ----- | -------- |
|
|
225
|
+
| Event listeners not removed | Cleanup in useEffect/componentWillUnmount |
|
|
226
|
+
| Growing global arrays/maps | Use WeakMap/WeakSet or bounded caches |
|
|
227
|
+
| Closures holding references | Break reference chains |
|
|
228
|
+
| Uncleared timers | clearTimeout/clearInterval |
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## š Optimization Patterns
|
|
233
|
+
|
|
234
|
+
### Caching Strategy
|
|
235
|
+
|
|
236
|
+
| Data Type | Cache Location | TTL Strategy |
|
|
237
|
+
| ---------------- | -------------- | ----------------------------- |
|
|
238
|
+
| Static assets | CDN | Long (1 year) + cache busting |
|
|
239
|
+
| API responses | Redis | Short (5-60 min) |
|
|
240
|
+
| Computed values | In-memory | Based on computation cost |
|
|
241
|
+
| Database queries | Query cache | Invalidate on write |
|
|
242
|
+
| User sessions | Redis | Based on session requirements |
|
|
243
|
+
|
|
244
|
+
### Lazy Loading
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
// ā
Lazy load components
|
|
248
|
+
const HeavyComponent = lazy(() => import('./HeavyComponent'));
|
|
249
|
+
|
|
250
|
+
// ā
Lazy load images
|
|
251
|
+
<img loading="lazy" src="below-fold.jpg" />
|
|
252
|
+
|
|
253
|
+
// ā
Lazy load data
|
|
254
|
+
const data = useSWR(isVisible ? '/api/data' : null);
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Debouncing & Throttling
|
|
258
|
+
|
|
259
|
+
| Technique | Use Case | Example |
|
|
260
|
+
| --------- | ------------------------- | ------------------------- |
|
|
261
|
+
| Debounce | Wait until activity stops | Search input autocomplete |
|
|
262
|
+
| Throttle | Limit frequency | Scroll handlers, resize |
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// Debounce: Execute after 300ms of no calls
|
|
266
|
+
const debouncedSearch = debounce(search, 300);
|
|
267
|
+
|
|
268
|
+
// Throttle: Execute at most once per 100ms
|
|
269
|
+
const throttledScroll = throttle(handleScroll, 100);
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## šØ Anti-Patterns
|
|
275
|
+
|
|
276
|
+
| ā Don't | ā
Do |
|
|
277
|
+
| --------------------------------- | ------------------------------------------ |
|
|
278
|
+
| Optimize without measuring | Profile first, then optimize |
|
|
279
|
+
| Premature optimization | Focus on correctness, then performance |
|
|
280
|
+
| Optimize cold paths | Focus on hot paths (frequently executed) |
|
|
281
|
+
| Micro-optimize trivial code | Target the biggest bottleneck |
|
|
282
|
+
| Cache everything | Cache strategically, consider invalidation |
|
|
283
|
+
| Load everything upfront | Lazy load non-critical resources |
|
|
284
|
+
| Block main thread with heavy work | Use web workers, async processing |
|
|
285
|
+
| Ignore p99 latency | p99 affects real users, not just averages |
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## š Performance Budget Template
|
|
290
|
+
|
|
291
|
+
```markdown
|
|
292
|
+
## Performance Budget: [Project Name]
|
|
293
|
+
|
|
294
|
+
### Core Web Vitals
|
|
295
|
+
|
|
296
|
+
- LCP: < 2.5s
|
|
297
|
+
- INP: < 200ms
|
|
298
|
+
- CLS: < 0.1
|
|
299
|
+
|
|
300
|
+
### Resource Budgets
|
|
301
|
+
|
|
302
|
+
- Total page weight: < 500KB (compressed)
|
|
303
|
+
- JavaScript: < 200KB (compressed)
|
|
304
|
+
- CSS: < 50KB (compressed)
|
|
305
|
+
- Images: < 200KB total (above the fold)
|
|
306
|
+
|
|
307
|
+
### API Performance
|
|
308
|
+
|
|
309
|
+
- p50 latency: < 100ms
|
|
310
|
+
- p95 latency: < 300ms
|
|
311
|
+
- p99 latency: < 1s
|
|
312
|
+
|
|
313
|
+
### Monitoring
|
|
314
|
+
|
|
315
|
+
- Alert if LCP > 3s for > 5% of users
|
|
316
|
+
- Alert if error rate > 1%
|
|
317
|
+
- Alert if API p95 > 500ms
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## š Related Skills
|
|
323
|
+
|
|
324
|
+
| Need | Skill |
|
|
325
|
+
| --------------------- | ---------------------- |
|
|
326
|
+
| Frontend optimization | `react-best-practices` |
|
|
327
|
+
| Database optimization | `database-design` |
|
|
328
|
+
| Testing performance | `testing-patterns` |
|
|
329
|
+
| Clean efficient code | `clean-code` |
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
> **Remember:** The fastest code is the code that doesn't run. Eliminate unnecessary work before micro-optimizing.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Assets directory - add templates, images, etc.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Reference Documentation for Performance Profiling
|
|
2
|
+
|
|
3
|
+
[TODO: Add detailed reference content here]
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
[Detailed explanation of concepts]
|
|
8
|
+
|
|
9
|
+
## Deep Dive Topics
|
|
10
|
+
|
|
11
|
+
### Topic 1
|
|
12
|
+
|
|
13
|
+
[Content]
|
|
14
|
+
|
|
15
|
+
### Topic 2
|
|
16
|
+
|
|
17
|
+
[Content]
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
[Real-world examples]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Example validator for performance-profiling
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python validate.py <project_path>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def validate(project_path: str) -> dict:
|
|
14
|
+
"""Main validation logic"""
|
|
15
|
+
results = {
|
|
16
|
+
'errors': [],
|
|
17
|
+
'warnings': [],
|
|
18
|
+
'passed': []
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# TODO: Add validation logic
|
|
22
|
+
results['passed'].append('Placeholder validation passed')
|
|
23
|
+
|
|
24
|
+
return results
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def print_results(results: dict):
|
|
28
|
+
"""Pretty print results"""
|
|
29
|
+
print("\nš Validation Results\n")
|
|
30
|
+
|
|
31
|
+
if results['errors']:
|
|
32
|
+
print(f"ā Errors ({len(results['errors'])})")
|
|
33
|
+
for error in results['errors']:
|
|
34
|
+
print(f" - {error}")
|
|
35
|
+
|
|
36
|
+
if results['warnings']:
|
|
37
|
+
print(f"\nā ļø Warnings ({len(results['warnings'])})")
|
|
38
|
+
for warning in results['warnings']:
|
|
39
|
+
print(f" - {warning}")
|
|
40
|
+
|
|
41
|
+
if results['passed']:
|
|
42
|
+
print(f"\nā
Passed ({len(results['passed'])})")
|
|
43
|
+
for passed in results['passed']:
|
|
44
|
+
print(f" - {passed}")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
if len(sys.argv) < 2:
|
|
49
|
+
print("Usage: python validate.py <project_path>")
|
|
50
|
+
sys.exit(1)
|
|
51
|
+
|
|
52
|
+
project_path = sys.argv[1]
|
|
53
|
+
results = validate(project_path)
|
|
54
|
+
print_results(results)
|
|
55
|
+
|
|
56
|
+
sys.exit(1 if results['errors'] else 0)
|