Skip to content
cccskills
FreePublished on GitHub

optimize

Analyze code, database queries, or systems for performance problems involving speed, memory, and frontend file size. Get prioritized recommendations with code examples, expected impact, implementation effort, risks, and a roadmap for improvements.

OriginalShow the original description

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

See how to install

Good for

  • Investigate a slow function or module
  • Review memory usage and possible leaks
  • Find inefficient database queries
  • Explore ways to reduce frontend file size

Files included (1)

  • SKILL.md5.3 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

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,js}" . | head -20

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

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

Memory analysis

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

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

Database query analysis

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

# Missing indexes hints
grep -rn "WHERE\|ORDER BY\|GROUP BY" --include="*.{ts,js,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

Week 1: Critical fixes (items 1-3)
Week 2: High priority (items 4-6)
Week 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

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Evaluate Claude Code agents, skills, and commands with weighted quality criteria. Get scores, readiness grades, template comparisons, and practical improvement suggestions in Markdown or JSON reports to guide reviews before release.

  • Review skills before release
  • Compare agent definitions with reference templates
  • Quickly check critical quality criteria
FlorianBruniaux/claude-code-ultimate-guide6.2KUpdated Oct 18, 2026

audit-codebase

FreeSummary

Assess a codebase across seven areas, including exposed credentials, security, dependencies, structure, and tests. Receive category scores, findings tied to file locations, and a prioritized improvement plan with smaller tasks that can be completed quickly.

  • Assessing the overall health of an inherited project
  • Reviewing exposed credentials and security risks
  • Identifying dependency and test coverage gaps
FlorianBruniaux/claude-code-ultimate-guide6.2KUpdated Oct 18, 2026

autoresearch

FreeSummary

Measure code patterns such as casts to any or disabled lint rules, then run repeated, targeted edits. Keep changes that improve the chosen metric, revert unsuccessful changes, and track results for each improvement loop.

  • Finding code patterns to prioritize for cleanup
  • Preparing measurement files for an improvement loop
  • Repeating targeted edits to reduce casts to any
FlorianBruniaux/claude-code-ultimate-guide6.2KUpdated Oct 18, 2026

best-of-n

FreeSummary

Generate several separate solutions, compare them against criteria fixed in advance, and verify the selected result through executable checks or an independent reviewer. Keep a proof log documenting candidates, evidence, failures, and remaining limits.

  • Comparing implementation options before choosing one
  • Verifying a solution when a wrong choice would be costly
  • Keeping evaluation evidence for delivery or audit
FlorianBruniaux/claude-code-ultimate-guide6.2KUpdated Oct 18, 2026

canary

FreeSummary

Monitor a live application after deployment and compare it with a saved baseline, a record of its earlier state. Check page responses, loading times, and new errors, flag persistent changes, and produce a per-page health report.

  • Recording a healthy baseline before deployment
  • Monitoring production immediately after deployment
  • Checking key pages for slower responses or failures
FlorianBruniaux/claude-code-ultimate-guide6.2KUpdated Oct 18, 2026

catchup

FreeSummary

Rebuild project context after clearing a conversation or returning to work. Review recent Git history, uncommitted changes, and TODO markers to get a structured summary of project status and suggested next steps.

  • Restoring project context after /clear
  • Reviewing recent changes after a long break
  • Checking unfinished work before choosing the next task
FlorianBruniaux/claude-code-ultimate-guide6.2KUpdated Oct 18, 2026

See all skills by FlorianBruniaux

Report a problem with this skill