スキル一覧に戻る
zacharyr0th

performance-optimizer

by zacharyr0th

Ready to deploy template repo with Next16, Better-Auth, Drizzle, Neon, Shadcn, Claude, Bun, Biome, Pino, Stripe, Velite, Vitest, SEO, etc

1🍴 0📅 2025年11月11日
GitHubで見るManusで実行

SKILL.md


name: performance-optimizer description: Use when analyzing code for performance bottlenecks, optimizing slow queries, reducing memory usage, or improving application speed. Identifies N+1 queries, inefficient algorithms, and caching opportunities. allowed-tools: Read, Grep, Glob, Bash model: sonnet

Performance Optimizer Skill

Purpose

Analyzes code for performance issues and provides optimization recommendations including:

  • Database query optimization
  • Algorithm efficiency improvements
  • Memory usage reduction
  • Caching strategies
  • Lazy loading opportunities

When to Use

This skill should be invoked when:

  • Application is running slowly
  • High memory consumption detected
  • Database queries taking too long
  • Need to optimize before scaling
  • Performance regression after changes
  • Preparing for production deployment

Process

  1. Identify Bottlenecks

    • Profile critical code paths
    • Analyze database queries
    • Check loop efficiency
    • Review memory allocations
    • Examine API calls
  2. Analyze Root Causes

    • N+1 query problems
    • Missing database indexes
    • Inefficient algorithms (O(n²) vs O(n log n))
    • Unnecessary re-renders (React/Vue)
    • Large bundle sizes
    • Synchronous blocking operations
  3. Recommend Optimizations

    • Add database indexes
    • Implement query batching
    • Use more efficient algorithms
    • Add caching (Redis, memory)
    • Implement lazy loading
    • Use pagination
    • Optimize images/assets
  4. Estimate Impact

    • High impact: 10x+ improvement
    • Medium impact: 2-10x improvement
    • Low impact: <2x improvement

Output Format

Performance Analysis Report

🔴 Critical Issues (High Impact)

  • [Location] - [Issue description]
    • Current: [performance metric]
    • Expected: [improved metric]
    • Fix: [specific solution]

🟡 Optimization Opportunities (Medium Impact)

  • [Location] - [Issue description]
    • Impact: [estimated improvement]
    • Fix: [specific solution]

🟢 Minor Improvements (Low Impact)

  • [Location] - [Issue description]
    • Fix: [specific solution]

📊 Metrics

  • Queries analyzed: X
  • Potential speedup: Xx
  • Memory reduction: X%

Best Practices

  • Profile before optimizing (measure first)
  • Focus on high-impact changes first
  • Consider readability vs performance tradeoffs
  • Test optimizations with realistic data
  • Monitor production metrics
  • Document why optimizations were made

Examples

Example 1: N+1 Query Detection

Input: "Why is this API endpoint slow?"

Analysis:

// BEFORE: N+1 query problem
async function getUsers() {
  const users = await User.findAll();
  for (const user of users) {
    user.posts = await Post.findAll({ userId: user.id });
  }
  return users;
}

Output:

🔴 Critical: N+1 Query Pattern
Location: api/users.js:15-19
Current: 1 + N queries (101 queries for 100 users)
Expected: 2 queries total
Impact: ~50x faster with large datasets

Fix:
async function getUsers() {
  const users = await User.findAll({
    include: [{ model: Post }]
  });
  return users;
}

Example 2: Algorithm Optimization

Input: "This search is too slow"

Analysis:

// BEFORE: O(n²) nested loop
function findDuplicates(arr) {
  const duplicates = [];
  for (let i = 0; i < arr.length; i++) {
    for (let j = i + 1; j < arr.length; j++) {
      if (arr[i] === arr[j]) duplicates.push(arr[i]);
    }
  }
  return duplicates;
}

Output:

🟡 Medium Impact: Inefficient Algorithm
Location: utils/search.js:23-30
Current: O(n²) - 10,000ms for 1000 items
Expected: O(n) - 10ms for 1000 items
Impact: 1000x faster

Fix:
function findDuplicates(arr) {
  const seen = new Set();
  const duplicates = new Set();
  for (const item of arr) {
    if (seen.has(item)) duplicates.add(item);
    seen.add(item);
  }
  return Array.from(duplicates);
}

Example 3: React Re-render Optimization

Input: "Component re-renders too often"

Analysis:

// BEFORE: Creates new object every render
function UserList({ users }) {
  const config = { sortBy: 'name', order: 'asc' };
  return <Table data={users} config={config} />;
}

Output:

🟢 Low Impact: Unnecessary Re-renders
Location: components/UserList.jsx:12-14
Impact: Reduces re-renders by ~60%

Fix:
const config = { sortBy: 'name', order: 'asc' };
function UserList({ users }) {
  return <Table data={users} config={config} />;
}
// Or use useMemo if config needs to be computed

Error Handling

  • No performance issues found: Confirm with profiling data
  • Need metrics: Request actual performance measurements
  • Optimization premature: Advise profiling first
  • Breaking change risk: Warn about potential issues

Notes

  • Always profile before and after optimizations
  • Consider tradeoffs: speed vs readability vs maintenance
  • Some optimizations are language/framework specific
  • Database optimizations often have highest impact
  • Don't optimize without measuring
  • Production data may differ from development

スコア

総合スコア

70/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です