CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

optimize

The workflow scopes the optimization target, searches for common runtime, memory, database, and bundle-size issues, and ranks findings by impact, effort, and risk. It includes optimization patterns and a structured report template for metrics, prioritized issues, quick wins, and a roadmap, with guidance to profile before optimizing and validate improvements.

Quality

59%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Fix and improve this skill with Tessl

tessl review fix ./examples/skills/optimize/SKILL.md
SKILL.md
Quality
Evals
Security

Performance optimizer

Analyze and suggest performance improvements for code, queries, or systems.

Purpose

Identify optimization opportunities:

  • Runtime performance bottlenecks
  • Memory usage issues
  • Database query inefficiencies
  • Bundle size problems
  • Algorithm complexity

Instructions

Step 1: Scope identification

Determine optimization target:

  • Function: Single function performance
  • Module: Related functions/classes
  • Query: Database query optimization
  • Bundle: Frontend bundle analysis
  • System: Architecture-level optimization

Step 2: Performance analysis

Runtime analysis

# Find potentially slow patterns
grep -rn "forEach\|\.map\|\.filter\|\.reduce" --include="*.ts" --include="*.js" . | head -20

# Find nested loops (O(n²) potential)
grep -rn "for.*for\|\.forEach.*\.forEach\|\.map.*\.map" --include="*.ts" --include="*.js" . | head -10

# Find sync operations that could be async
grep -rn "readFileSync\|writeFileSync\|execSync" --include="*.ts" --include="*.js" . | head -10

Memory analysis

# Large array operations
grep -rn "new Array\|Array\.from\|\.concat\|spread" --include="*.ts" --include="*.js" . | head -10

# Potential memory leaks (event listeners, intervals)
grep -rn "addEventListener\|setInterval\|setTimeout" --include="*.ts" --include="*.js" . | head -10

Database query analysis

# N+1 query patterns
grep -rn "await.*find\|await.*query" --include="*.ts" --include="*.js" . | head -15

# Missing indexes hints
grep -rn "WHERE\|ORDER BY\|GROUP BY" --include="*.ts" --include="*.js" --include="*.sql" . | head -15

Bundle analysis

# Check bundle size (if applicable)
[ -f "package.json" ] && npm run build 2>/dev/null && ls -lh dist/*.js 2>/dev/null

# Large dependencies
[ -f "package.json" ] && cat package.json | jq '.dependencies | keys[]' | head -20

Step 3: Prioritization

Rank findings by:

  1. Impact: How much will this improve performance?
  2. Effort: How hard is the fix?
  3. Risk: What could break?

Output format


⚡ Performance analysis

Target: [file/module/system] Analysis Date: [timestamp]

📊 Current Metrics (if measurable)

MetricCurrentTargetGap
Response timeXms<Yms-Z% needed
Memory usageXMB<YMB-Z% needed
Bundle sizeXKB<YKB-Z% needed

🔴 Critical issues

1. [Issue title] - [location]

Problem: [What's slow and why]

Current:

// O(n²) - nested loops
users.forEach(user => {
  permissions.forEach(perm => {
    if (user.id === perm.userId) { ... }
  });
});

Optimized:

// O(n) - Map lookup
const permMap = new Map(permissions.map(p => [p.userId, p]));
users.forEach(user => {
  const perm = permMap.get(user.id);
  if (perm) { ... }
});

Impact: ~10x faster for 1000 users Effort: Low (5 min) Risk: Low

🟠 High priority

IssueLocationImpactEffort
[description]file:line[estimate][time]

🟡 Medium priority

IssueLocationImpactEffort
[description]file:line[estimate][time]

💡 Quick wins

  1. [Small change with good impact]
  2. [Another quick optimization]
  3. [Low-hanging fruit]

📈 Optimization roadmap

Phase 1: Critical fixes (items 1-3)
Phase 2: High priority (items 4-6)
Phase 3: Measure and validate improvements

Common patterns

Array operations

PatternIssueFix
arr.filter().map()Two iterationsSingle reduce() or flatMap()
arr.find() in loopO(n²)Build Map/Set first
[...arr1, ...arr2]Memory allocationarr1.concat(arr2) or push

Database

PatternIssueFix
Loop with awaitN+1 queriesBatch query with IN
SELECT *Over-fetchingSelect only needed columns
Missing WHERE indexFull table scanAdd composite index

React/frontend

PatternIssueFix
Inline functions in JSXRe-rendersuseCallback
Large list renderingDOM thrashingVirtualization
Unoptimized imagesSlow LCPNext/Image, lazy loading

Node.js

PatternIssueFix
Sync file operationsBlocks event loopAsync alternatives
JSON.parse large filesMemory spikeStreaming parser
No connection poolingConnection overheadPool with pg-pool, etc.

Usage

Analyze specific file:

/optimize src/services/user.ts

Focus on specific area:

/optimize --queries src/repositories/
/optimize --bundle
/optimize --memory src/workers/

With target metrics:

/optimize --target=100ms src/api/search.ts

Quick scan:

/optimize --quick

Notes

  • Measurements beat assumptions: profile before optimizing
  • Premature optimization is the root of all evil (Knuth)
  • Focus on hot paths: optimize what runs often
  • Consider trade-offs: speed vs readability vs maintainability

$ARGUMENTS

Repository

FlorianBruniaux/claude-code-ultimate-guide

Path

examples/skills/optimize/SKILL.md

Last updated
First committed
Purpose
DevelopmentTesting and QADatabase management
Form
WorkflowBest practicesReferenceTemplate
Commands
grepheadnpmnpm runnpm run buildlscatjq

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.