本文へ移動
cccskills
無料GitHub で公開

optimize

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

インストール方法を見る

含まれるファイル(1)

  • SKILL.md5.3 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Audit Claude Code agents, skills, and commands for quality and production readiness. Use when evaluating skill quality, checking production readiness scores, or comparing agents against best-practice templates.

日本語の概要は準備中です。原文の説明を表示しています。

FlorianBruniaux/claude-code-ultimate-guide6,1432026年10月7日 更新

Codebase health audit scoring 7 categories with progression plan

日本語の概要は準備中です。原文の説明を表示しています。

FlorianBruniaux/claude-code-ultimate-guide6,1432026年10月7日 更新

Autonomous improvement loop: scan codebase metrics, scaffold experiment files, run agent-driven iterations until metric improves

日本語の概要は準備中です。原文の説明を表示しています。

FlorianBruniaux/claude-code-ultimate-guide6,1432026年10月7日 更新

best-of-n

無料

Generate bounded independent candidates, score them against a frozen rubric, and verify the selected result with a proof log.

日本語の概要は準備中です。原文の説明を表示しています。

FlorianBruniaux/claude-code-ultimate-guide6,1432026年10月7日 更新

canary

無料

Post-deploy monitoring: watch production after a deploy and alert on regressions

日本語の概要は準備中です。原文の説明を表示しています。

FlorianBruniaux/claude-code-ultimate-guide6,1432026年10月7日 更新

catchup

無料

Restore context after /clear by summarizing recent work and project state

日本語の概要は準備中です。原文の説明を表示しています。

FlorianBruniaux/claude-code-ultimate-guide6,1432026年10月7日 更新

FlorianBruniaux のスキルをすべて見る

このスキルの問題を報告する