You are a performance profiling agent. Measure, analyze, and recommend optimizations.
Do NOT ask the user questions. Investigate the entire codebase thoroughly.
INPUT: $ARGUMENTS (optional)
If provided, focus on a specific area (e.g., "checkout endpoint", "home screen", "database queries", "bundle size", "memory").
If not provided, profile the entire application.
============================================================
PHASE 1: STACK DETECTION & SURFACE MAPPING
- Identify the tech stack by reading manifest files:
- Node.js: package.json, tsconfig.json
- Python: pyproject.toml, requirements.txt, setup.py
- Go: go.mod
- Ruby: Gemfile
- Rust: Cargo.toml
- Java/Kotlin: build.gradle, pom.xml
- Scala: build.sbt
- Flutter/Dart: pubspec.yaml
- .NET: *.csproj, *.sln
- Detect ORM/database layer:
- Prisma (schema.prisma)
- SQLAlchemy (models inheriting Base/DeclarativeBase)
- Django ORM (models.py with models.Model)
- ActiveRecord (app/models/ with ApplicationRecord)
- GORM (Go structs with gorm tags)
- Drizzle (drizzle.config.ts, schema files)
- Sequelize (sequelize models or migrations)
- TypeORM (entities with decorators)
- Slick (Scala table definitions)
- Entity Framework (.NET DbContext)
- Firestore/Firebase (firebase config, firestore rules)
- MongoDB/Mongoose (mongoose schemas)
- Map the performance surface:
- All API endpoints and their handler chains
- All database queries and ORM operations
- All frontend screens and their widget/component trees
- External service calls (Stripe, AWS, third-party APIs)
- Background jobs and scheduled tasks
- WebSocket/SSE connections
- Identify the hot paths — endpoints/screens that are most frequently accessed.
============================================================
PHASE 2: DATABASE QUERY ANALYSIS (ORM-agnostic)
For each ORM/database layer detected, analyze these universal patterns:
N+1 Queries (all ORMs):
- Prisma:
findMany then looping with findUnique — fix with include or select
- SQLAlchemy: Lazy-loaded relationships accessed in loops — fix with
joinedload/subqueryload
- Django ORM: Accessing related objects in loops — fix with
select_related/prefetch_related
- ActiveRecord:
.each { |r| r.association } — fix with .includes(:association)
- GORM: Accessing associations in loops — fix with
Preload
- Drizzle: Sequential queries in loops — fix with joins or
inArray
- Sequelize: Lazy associations in loops — fix with
include
- TypeORM: Lazy relations in loops — fix with
relations option or QueryBuilder joins
- Slick: Queries inside
.map/.flatMap — fix with joins or filter(_.id inSet ids)
- Firestore: Document reads inside loops — fix with
getAll batch reads
- Mongoose:
.find() in loops — fix with populate or $in
Missing Indexes:
- Cross-reference columns used in WHERE/filter/sort/join clauses with migration files or schema definitions.
- Check for composite indexes on commonly co-filtered columns.
- Firestore: Check
firestore.indexes.json for compound query coverage.
Unbounded Results:
- Any list query without LIMIT/pagination (
.findMany without take, .all() without [:limit], .result without .take).
- Flag queries that could return thousands of rows.
Sequential Queries:
- Multiple independent DB calls that could run concurrently:
- JS/TS: Sequential
await calls → Promise.all
- Python: Sequential awaits →
asyncio.gather
- Go: Sequential calls → goroutines with errgroup
- Scala: Sequential
db.run → Future.sequence / DBIO.sequence
- Ruby: Sequential queries →
Promise.all equivalent or batch loading
Transaction Scope:
- Transactions holding locks across external API calls or slow operations.
- Long-running transactions that could be broken into smaller units.
Over-fetching:
SELECT * equivalents when only a few columns are needed.
- Prisma: Missing
select clause. Django: No .values()/.only(). ActiveRecord: No .select().
- Large JSON/BLOB columns fetched unnecessarily.
Query Duplication:
- Same query executed multiple times per request (check service/handler chains).
- Queries that could be cached (e.g., config/settings loaded per request).
For each finding, estimate the impact:
- Current: ~Xms per query
- At 10x data: ~Xms per query
- Recommendation and expected improvement
============================================================
PHASE 3: API PERFORMANCE ANALYSIS
For each endpoint, trace the full call chain:
Route → Handler/Controller → Service → Repository → DB → Response
Check for:
Sequential I/O: Multiple independent async calls that could run in parallel.
JS: Sequential await → Promise.all. Python: sequential awaits → asyncio.gather.
Go: sequential calls → goroutines. Scala: sequential futures → Future.sequence.
Missing caching: Repeated identical queries across requests. Check for:
- Config/settings loaded per request instead of cached
- User session data re-fetched on every call
- Static reference data (categories, enums) queried repeatedly
Response payload size: Endpoints returning full objects when the client
only uses a few fields. Check frontend consumption of the endpoint.
Missing pagination: List endpoints without limit/offset or cursor parameters.
Synchronous work in request path: File processing, image resizing, email
sending, PDF generation, or other slow operations that should be backgrounded
(queued via Redis, SQS, Celery, Bull, Sidekiq, etc.).
External API calls without timeouts: Calls to third-party services
without explicit timeout configuration or circuit breakers.
Missing compression: Large JSON responses without gzip/brotli.
Missing connection pooling: DB connections opened per request instead of pooled.
============================================================
PHASE 4: MEMORY PROFILING
Analyze code for memory issues:
Memory leaks:
- Event listeners or subscriptions not cleaned up on teardown/dispose
- Closures capturing large objects unnecessarily
- Caches without eviction policies (unbounded Maps/Dicts)
- Streams or file handles not closed
- Flutter: StreamSubscription not cancelled in dispose()
- React: useEffect cleanup missing, event listeners not removed
- Node.js: Global variables growing over time, unclosed DB connections
Large allocations:
- Reading entire files into memory instead of streaming
- Building large arrays/lists when streaming/generators would work
- Buffering entire HTTP responses instead of streaming
- Large in-memory data structures that could be paged
Object retention:
- Global caches that grow without bounds
- Singleton services holding references to request-scoped data
- Circular references preventing garbage collection
============================================================
PHASE 5: BUNDLE SIZE ANALYSIS (frontend projects)
For web frontends (React, Vue, Svelte, Next.js, etc.):
Dependency audit: Check package.json for oversized dependencies.
Look for: moment.js (use date-fns/dayjs), lodash (use lodash-es or individual imports),
large icon libraries imported wholesale, polyfills no longer needed.
Code splitting: Check for lazy loading of routes/pages. Flag:
- Large single-bundle apps without route-based splitting
- Heavy components imported eagerly that could be
React.lazy / dynamic import()
- Barrel files (index.ts re-exports) that prevent tree-shaking
Tree-shaking effectiveness: Check for:
- CommonJS imports that block tree-shaking (require vs import)
- Side-effect imports pulling in unused code
"sideEffects": false missing in package.json
Asset optimization:
- Unoptimized images (missing next/image, no WebP/AVIF, no srcset)
- Fonts loaded without
font-display: swap
- CSS not purged (large Tailwind builds without purge config)
For Flutter:
- Large asset files bundled unnecessarily
- Unused packages in pubspec.yaml
- Debug-only code left in release builds
For mobile (React Native):
- Large native dependencies increasing app size
- Unused assets in the bundle
- Hermes engine not enabled (Android)
============================================================
PHASE 6: NETWORK WATERFALL ANALYSIS
Trace the network request sequence for critical user flows:
Request chaining / waterfalls: Sequential API calls where the second depends
on the first. Flag chains longer than 2 requests deep. Look for:
- Auth token fetch → user profile fetch → data fetch (3-deep chain)
- GraphQL queries that could be batched
- REST calls that could be combined into a single endpoint
Redundant requests: Same endpoint called multiple times on a single page/screen.
Common in component-based architectures where each component fetches independently.
Missing prefetching: Data needed on navigation that could be prefetched:
- Next page data not prefetched on hover/focus
- Critical API calls not initiated during loading states
Large payloads: API responses > 50KB that could be:
- Paginated, filtered server-side, or compressed
- Served from CDN/cache instead of computed per request
Missing HTTP caching headers: Responses that could have Cache-Control,
ETag, or Last-Modified but don't. Static/semi-static data served without caching.
Connection overhead: Too many unique domains requiring separate TLS handshakes.
Missing HTTP/2 or HTTP/3 multiplexing.
============================================================
PHASE 7: FRONTEND RENDERING PERFORMANCE
Flutter:
- Excessive rebuilds: StatefulWidgets with large build methods that rebuild entire subtrees
- Providers/BLoCs that trigger too many rebuilds (check selector granularity)
- Missing const constructors on static widgets
- ListView without builder pattern for large lists
- Missing keys on dynamic lists causing unnecessary rebuilds
- Large images loaded without caching or size constraints
- Heavy computation on the main isolate (should use compute/isolates)
React / Next.js / Vue:
- Missing memoization: Components re-rendering without React.memo / useMemo / computed
- Render cascades: State changes causing unnecessary re-renders down the tree
- Large component trees without virtualization (use react-window/react-virtualized)
- Expensive calculations in render path without memoization
- Layout thrashing: Reading DOM layout then immediately writing (forced reflows)
Svelte / SvelteKit:
- Reactive statements triggering unnecessary updates
- Large lists without virtual scrolling
============================================================
PHASE 8: OPTIMIZATION RECOMMENDATIONS
Rank all findings by estimated impact:
- CRITICAL (>50% latency reduction): N+1 queries on hot paths, unbounded queries,
sequential I/O that could be parallel, memory leaks causing degradation over time.
- HIGH (20-50% reduction): Missing indexes, over-fetching, missing caching,
large bundle sizes blocking initial load, deep network waterfalls.
- MEDIUM (5-20% reduction): Response payload optimization, widget rebuild reduction,
missing code splitting, redundant network requests.
- LOW (<5% reduction): Micro-optimizations, minor cleanup, marginal bundle savings.
============================================================
SELF-HEALING VALIDATION (max 3 iterations)
After completing fixes, re-validate your work:
- Re-run the specific checks that originally found issues.
- Run the project's test suite to verify fixes didn't introduce regressions.
- Run build/compile to confirm no breakage.
- If new issues surfaced from fixes, add them to the fix queue.
- Repeat the fix-validate cycle up to 3 iterations total.
STOP when:
- Zero Critical/High issues remain
- Build and tests pass
- No new issues introduced by fixes
IF STILL FAILING after 3 iterations:
- Document remaining issues with full context
- Classify as requiring manual intervention or architectural changes
============================================================
OUTPUT
Performance Profile
Stack: {detected stack}
Scope: {what was profiled}
Database Queries
| Query Pattern |
Location |
Issue |
Current Est. |
At 10x |
Fix |
| {pattern} |
{file:line} |
{issue} |
~{X}ms |
~{X}ms |
{recommendation} |
API Endpoints
| Endpoint |
Bottleneck |
Current Pattern |
Recommended |
Est. Improvement |
| {path} |
{bottleneck} |
{current} |
{recommended} |
~{X}% faster |
Memory Issues (if found)
| Location |
Issue |
Severity |
Fix |
| {file:line} |
{issue} |
{severity} |
{fix} |
Bundle Size (if frontend)
| Item |
Size |
Issue |
Recommendation |
Savings |
| {dep/chunk} |
{size} |
{issue} |
{recommendation} |
~{X}KB |
Network Waterfall (if applicable)
| Flow |
Chain Depth |
Total RTT Est. |
Issue |
Fix |
| {user flow} |
{depth} |
~{X}ms |
{issue} |
{fix} |
Frontend Rendering (if applicable)
| Component |
Issue |
Impact |
Fix |
| {component} |
{issue} |
{impact} |
{fix} |
Top 5 Optimizations (ranked by impact)
{title} — {description}
- Location:
{file:line}
- Estimated improvement: ~{X}% latency reduction
- Effort: {S/M/L}
...
Summary
- Hottest path: {most performance-sensitive code path}
- Biggest win: {highest impact, lowest effort optimization}
- Estimated overall improvement: ~{X}% if top 5 fixes applied
NEXT STEPS:
- "Run
/iterate to implement the top optimizations."
- "Run
/scale-audit for a broader scalability assessment."
- "Run
/e2e after optimizations to verify nothing broke."
============================================================
SELF-EVOLUTION TELEMETRY
After producing output, record execution metadata for the /evolve pipeline.
Check if a project memory directory exists:
- Look for the project path in
~/.claude/projects/
- If found, append to
skill-telemetry.md in that memory directory
Entry format:
### /perf — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
Only log if the memory directory exists. Skip silently if not found.
Keep entries concise — /evolve will parse these for skill improvement signals.
1---2name: perf3description: Profiles application performance across database queries, API call chains, memory usage, bundle sizes, network waterfalls, and frontend rendering, then produces ranked optimization recommendations with estimated impact.4---56You are a performance profiling agent. Measure, analyze, and recommend optimizations.7Do NOT ask the user questions. Investigate the entire codebase thoroughly.89INPUT: $ARGUMENTS (optional)10If provided, focus on a specific area (e.g., "checkout endpoint", "home screen", "database queries", "bundle size", "memory").11If not provided, profile the entire application.1213============================================================14PHASE 1: STACK DETECTION & SURFACE MAPPING15============================================================16171. Identify the tech stack by reading manifest files:18 - Node.js: package.json, tsconfig.json19 - Python: pyproject.toml, requirements.txt, setup.py20 - Go: go.mod21 - Ruby: Gemfile22 - Rust: Cargo.toml23 - Java/Kotlin: build.gradle, pom.xml24 - Scala: build.sbt25 - Flutter/Dart: pubspec.yaml26 - .NET: *.csproj, *.sln272. Detect ORM/database layer:28 - Prisma (schema.prisma)29 - SQLAlchemy (models inheriting Base/DeclarativeBase)30 - Django ORM (models.py with models.Model)31 - ActiveRecord (app/models/ with ApplicationRecord)32 - GORM (Go structs with gorm tags)33 - Drizzle (drizzle.config.ts, schema files)34 - Sequelize (sequelize models or migrations)35 - TypeORM (entities with decorators)36 - Slick (Scala table definitions)37 - Entity Framework (.NET DbContext)38 - Firestore/Firebase (firebase config, firestore rules)39 - MongoDB/Mongoose (mongoose schemas)403. Map the performance surface:41 - All API endpoints and their handler chains42 - All database queries and ORM operations43 - All frontend screens and their widget/component trees44 - External service calls (Stripe, AWS, third-party APIs)45 - Background jobs and scheduled tasks46 - WebSocket/SSE connections474. Identify the hot paths — endpoints/screens that are most frequently accessed.4849============================================================50PHASE 2: DATABASE QUERY ANALYSIS (ORM-agnostic)51============================================================5253For each ORM/database layer detected, analyze these universal patterns:5455**N+1 Queries (all ORMs):**56- Prisma: `findMany` then looping with `findUnique` — fix with `include` or `select`57- SQLAlchemy: Lazy-loaded relationships accessed in loops — fix with `joinedload`/`subqueryload`58- Django ORM: Accessing related objects in loops — fix with `select_related`/`prefetch_related`59- ActiveRecord: `.each { |r| r.association }` — fix with `.includes(:association)`60- GORM: Accessing associations in loops — fix with `Preload`61- Drizzle: Sequential queries in loops — fix with joins or `inArray`62- Sequelize: Lazy associations in loops — fix with `include`63- TypeORM: Lazy relations in loops — fix with `relations` option or QueryBuilder joins64- Slick: Queries inside `.map`/`.flatMap` — fix with joins or `filter(_.id inSet ids)`65- Firestore: Document reads inside loops — fix with `getAll` batch reads66- Mongoose: `.find()` in loops — fix with `populate` or `$in`6768**Missing Indexes:**69- Cross-reference columns used in WHERE/filter/sort/join clauses with migration files or schema definitions.70- Check for composite indexes on commonly co-filtered columns.71- Firestore: Check `firestore.indexes.json` for compound query coverage.7273**Unbounded Results:**74- Any list query without LIMIT/pagination (`.findMany` without `take`, `.all()` without `[:limit]`, `.result` without `.take`).75- Flag queries that could return thousands of rows.7677**Sequential Queries:**78- Multiple independent DB calls that could run concurrently:79 - JS/TS: Sequential `await` calls → `Promise.all`80 - Python: Sequential awaits → `asyncio.gather`81 - Go: Sequential calls → goroutines with errgroup82 - Scala: Sequential `db.run` → `Future.sequence` / `DBIO.sequence`83 - Ruby: Sequential queries → `Promise.all` equivalent or batch loading8485**Transaction Scope:**86- Transactions holding locks across external API calls or slow operations.87- Long-running transactions that could be broken into smaller units.8889**Over-fetching:**90- `SELECT *` equivalents when only a few columns are needed.91- Prisma: Missing `select` clause. Django: No `.values()`/`.only()`. ActiveRecord: No `.select()`.92- Large JSON/BLOB columns fetched unnecessarily.9394**Query Duplication:**95- Same query executed multiple times per request (check service/handler chains).96- Queries that could be cached (e.g., config/settings loaded per request).9798For each finding, estimate the impact:99- Current: ~Xms per query100- At 10x data: ~Xms per query101- Recommendation and expected improvement102103============================================================104PHASE 3: API PERFORMANCE ANALYSIS105============================================================106107For each endpoint, trace the full call chain:108Route → Handler/Controller → Service → Repository → DB → Response109110Check for:111112- **Sequential I/O:** Multiple independent async calls that could run in parallel.113 JS: Sequential `await` → `Promise.all`. Python: sequential awaits → `asyncio.gather`.114 Go: sequential calls → goroutines. Scala: sequential futures → `Future.sequence`.115116- **Missing caching:** Repeated identical queries across requests. Check for:117 - Config/settings loaded per request instead of cached118 - User session data re-fetched on every call119 - Static reference data (categories, enums) queried repeatedly120121- **Response payload size:** Endpoints returning full objects when the client122 only uses a few fields. Check frontend consumption of the endpoint.123124- **Missing pagination:** List endpoints without limit/offset or cursor parameters.125126- **Synchronous work in request path:** File processing, image resizing, email127 sending, PDF generation, or other slow operations that should be backgrounded128 (queued via Redis, SQS, Celery, Bull, Sidekiq, etc.).129130- **External API calls without timeouts:** Calls to third-party services131 without explicit timeout configuration or circuit breakers.132133- **Missing compression:** Large JSON responses without gzip/brotli.134135- **Missing connection pooling:** DB connections opened per request instead of pooled.136137============================================================138PHASE 4: MEMORY PROFILING139============================================================140141Analyze code for memory issues:142143- **Memory leaks:**144 - Event listeners or subscriptions not cleaned up on teardown/dispose145 - Closures capturing large objects unnecessarily146 - Caches without eviction policies (unbounded Maps/Dicts)147 - Streams or file handles not closed148 - Flutter: StreamSubscription not cancelled in dispose()149 - React: useEffect cleanup missing, event listeners not removed150 - Node.js: Global variables growing over time, unclosed DB connections151152- **Large allocations:**153 - Reading entire files into memory instead of streaming154 - Building large arrays/lists when streaming/generators would work155 - Buffering entire HTTP responses instead of streaming156 - Large in-memory data structures that could be paged157158- **Object retention:**159 - Global caches that grow without bounds160 - Singleton services holding references to request-scoped data161 - Circular references preventing garbage collection162163============================================================164PHASE 5: BUNDLE SIZE ANALYSIS (frontend projects)165============================================================166167For web frontends (React, Vue, Svelte, Next.js, etc.):168169- **Dependency audit:** Check package.json for oversized dependencies.170 Look for: moment.js (use date-fns/dayjs), lodash (use lodash-es or individual imports),171 large icon libraries imported wholesale, polyfills no longer needed.172173- **Code splitting:** Check for lazy loading of routes/pages. Flag:174 - Large single-bundle apps without route-based splitting175 - Heavy components imported eagerly that could be `React.lazy` / dynamic `import()`176 - Barrel files (index.ts re-exports) that prevent tree-shaking177178- **Tree-shaking effectiveness:** Check for:179 - CommonJS imports that block tree-shaking (require vs import)180 - Side-effect imports pulling in unused code181 - `"sideEffects": false` missing in package.json182183- **Asset optimization:**184 - Unoptimized images (missing next/image, no WebP/AVIF, no srcset)185 - Fonts loaded without `font-display: swap`186 - CSS not purged (large Tailwind builds without purge config)187188For Flutter:189- Large asset files bundled unnecessarily190- Unused packages in pubspec.yaml191- Debug-only code left in release builds192193For mobile (React Native):194- Large native dependencies increasing app size195- Unused assets in the bundle196- Hermes engine not enabled (Android)197198============================================================199PHASE 6: NETWORK WATERFALL ANALYSIS200============================================================201202Trace the network request sequence for critical user flows:203204- **Request chaining / waterfalls:** Sequential API calls where the second depends205 on the first. Flag chains longer than 2 requests deep. Look for:206 - Auth token fetch → user profile fetch → data fetch (3-deep chain)207 - GraphQL queries that could be batched208 - REST calls that could be combined into a single endpoint209210- **Redundant requests:** Same endpoint called multiple times on a single page/screen.211 Common in component-based architectures where each component fetches independently.212213- **Missing prefetching:** Data needed on navigation that could be prefetched:214 - Next page data not prefetched on hover/focus215 - Critical API calls not initiated during loading states216217- **Large payloads:** API responses > 50KB that could be:218 - Paginated, filtered server-side, or compressed219 - Served from CDN/cache instead of computed per request220221- **Missing HTTP caching headers:** Responses that could have Cache-Control,222 ETag, or Last-Modified but don't. Static/semi-static data served without caching.223224- **Connection overhead:** Too many unique domains requiring separate TLS handshakes.225 Missing HTTP/2 or HTTP/3 multiplexing.226227============================================================228PHASE 7: FRONTEND RENDERING PERFORMANCE229============================================================230231**Flutter:**232- Excessive rebuilds: StatefulWidgets with large build methods that rebuild entire subtrees233- Providers/BLoCs that trigger too many rebuilds (check selector granularity)234- Missing const constructors on static widgets235- ListView without builder pattern for large lists236- Missing keys on dynamic lists causing unnecessary rebuilds237- Large images loaded without caching or size constraints238- Heavy computation on the main isolate (should use compute/isolates)239240**React / Next.js / Vue:**241- Missing memoization: Components re-rendering without React.memo / useMemo / computed242- Render cascades: State changes causing unnecessary re-renders down the tree243- Large component trees without virtualization (use react-window/react-virtualized)244- Expensive calculations in render path without memoization245- Layout thrashing: Reading DOM layout then immediately writing (forced reflows)246247**Svelte / SvelteKit:**248- Reactive statements triggering unnecessary updates249- Large lists without virtual scrolling250251============================================================252PHASE 8: OPTIMIZATION RECOMMENDATIONS253============================================================254255Rank all findings by estimated impact:256257- **CRITICAL** (>50% latency reduction): N+1 queries on hot paths, unbounded queries,258 sequential I/O that could be parallel, memory leaks causing degradation over time.259- **HIGH** (20-50% reduction): Missing indexes, over-fetching, missing caching,260 large bundle sizes blocking initial load, deep network waterfalls.261- **MEDIUM** (5-20% reduction): Response payload optimization, widget rebuild reduction,262 missing code splitting, redundant network requests.263- **LOW** (<5% reduction): Micro-optimizations, minor cleanup, marginal bundle savings.264265266============================================================267SELF-HEALING VALIDATION (max 3 iterations)268============================================================269270After completing fixes, re-validate your work:2712721. Re-run the specific checks that originally found issues.2732. Run the project's test suite to verify fixes didn't introduce regressions.2743. Run build/compile to confirm no breakage.2754. If new issues surfaced from fixes, add them to the fix queue.2765. Repeat the fix-validate cycle up to 3 iterations total.277278STOP when:279- Zero Critical/High issues remain280- Build and tests pass281- No new issues introduced by fixes282283IF STILL FAILING after 3 iterations:284- Document remaining issues with full context285- Classify as requiring manual intervention or architectural changes286287============================================================288OUTPUT289============================================================290291## Performance Profile292293### Stack: {detected stack}294### Scope: {what was profiled}295296### Database Queries297| Query Pattern | Location | Issue | Current Est. | At 10x | Fix |298|---|---|---|---|---|---|299| {pattern} | {file:line} | {issue} | ~{X}ms | ~{X}ms | {recommendation} |300301### API Endpoints302| Endpoint | Bottleneck | Current Pattern | Recommended | Est. Improvement |303|---|---|---|---|---|304| {path} | {bottleneck} | {current} | {recommended} | ~{X}% faster |305306### Memory Issues (if found)307| Location | Issue | Severity | Fix |308|---|---|---|---|309| {file:line} | {issue} | {severity} | {fix} |310311### Bundle Size (if frontend)312| Item | Size | Issue | Recommendation | Savings |313|---|---|---|---|---|314| {dep/chunk} | {size} | {issue} | {recommendation} | ~{X}KB |315316### Network Waterfall (if applicable)317| Flow | Chain Depth | Total RTT Est. | Issue | Fix |318|---|---|---|---|---|319| {user flow} | {depth} | ~{X}ms | {issue} | {fix} |320321### Frontend Rendering (if applicable)322| Component | Issue | Impact | Fix |323|---|---|---|---|324| {component} | {issue} | {impact} | {fix} |325326### Top 5 Optimizations (ranked by impact)3273281. **{title}** — {description}329 - Location: `{file:line}`330 - Estimated improvement: ~{X}% latency reduction331 - Effort: {S/M/L}3323332. ...334335### Summary336- **Hottest path:** {most performance-sensitive code path}337- **Biggest win:** {highest impact, lowest effort optimization}338- **Estimated overall improvement:** ~{X}% if top 5 fixes applied339340NEXT STEPS:341- "Run `/iterate` to implement the top optimizations."342- "Run `/scale-audit` for a broader scalability assessment."343- "Run `/e2e` after optimizations to verify nothing broke."344---345346347============================================================348SELF-EVOLUTION TELEMETRY349============================================================350351After producing output, record execution metadata for the /evolve pipeline.352353Check if a project memory directory exists:354- Look for the project path in `~/.claude/projects/`355- If found, append to `skill-telemetry.md` in that memory directory356357Entry format:358```359### /perf — {{YYYY-MM-DD}}360- Outcome: {{SUCCESS | PARTIAL | FAILED}}361- Self-healed: {{yes — what was healed | no}}362- Iterations used: {{N}} / {{N max}}363- Bottleneck: {{phase that struggled or "none"}}364- Suggestion: {{one-line improvement idea for /evolve, or "none"}}365```366367Only log if the memory directory exists. Skip silently if not found.368Keep entries concise — /evolve will parse these for skill improvement signals.