🛠️ Performance最適化ツール
コードやデータベース、APIの性能問題を特定し、改善前後の効果を測定して最適化するSkill。
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Identifies and fixes performance bottlenecks in code, databases, and APIs. Measures before and after to prove improvements.
🇯🇵 日本人クリエイター向け解説
コードやデータベース、APIの性能問題を特定し、改善前後の効果を測定して最適化するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o performance-optimizer.zip https://jpskill.com/download/3281.zip && unzip -o performance-optimizer.zip && rm performance-optimizer.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3281.zip -OutFile "$d\performance-optimizer.zip"; Expand-Archive "$d\performance-optimizer.zip" -DestinationPath $d -Force; ri "$d\performance-optimizer.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
performance-optimizer.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
performance-optimizerフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 2
💬 こう話しかけるだけ — サンプルプロンプト
- › Performance Optimizer を使って、最小構成のサンプルコードを示して
- › Performance Optimizer の主な使い方と注意点を教えて
- › Performance Optimizer を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] performance-optimizer
パフォーマンス最適化
パフォーマンスのボトルネックを見つけて修正します。測定し、最適化し、検証します。高速化を実現します。
このスキルを使用するタイミング
- アプリが遅い、またはラグい場合
- ユーザーがパフォーマンスについて不満を述べている場合
- ページ読み込み時間が長い場合
- API応答が遅い場合
- データベースクエリに時間がかかりすぎる場合
- ユーザーが「遅い」「ラグい」「パフォーマンス」「最適化」といった言葉に言及している場合
最適化プロセス
1. まず測定する
測定せずに最適化することは決してありません。
// 実行時間を測定
console.time('operation');
await slowOperation();
console.timeEnd('operation'); // operation: 2341ms
何を測定するか:
- ページ読み込み時間
- API応答時間
- データベースクエリ時間
- 関数実行時間
- メモリ使用量
- ネットワークリクエスト
2. ボトルネックを見つける
プロファイリングツールを使用して、遅い部分を見つけます。
ブラウザ:
DevTools → Performanceタブ → Record → Stop
長いタスク(赤いバー)を探します
Node.js:
node --prof app.js
node --prof-process isolate-*.log > profile.txt
データベース:
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'test@example.com';
3. 最適化する
最も遅いものから修正します(最も影響が大きいもの)。
一般的な最適化
データベースクエリ
問題: N+1クエリ
// 悪い例: N+1クエリ
const users = await db.users.find();
for (const user of users) {
user.posts = await db.posts.find({ userId: user.id }); // Nクエリ
}
// 良い例: JOINによる単一クエリ
const users = await db.users.find()
.populate('posts'); // 1クエリ
問題: インデックスの欠落
-- 遅いクエリをチェック
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
-- 表示: Seq Scan (悪い)
-- インデックスを追加
CREATE INDEX idx_users_email ON users(email);
-- 再度チェック
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
-- 表示: Index Scan (良い)
**問題: SELECT ***
// 悪い例: 全てのカラムを取得
const users = await db.query('SELECT * FROM users');
// 良い例: 必要なカラムのみ
const users = await db.query('SELECT id, name, email FROM users');
問題: ページネーションなし
// 悪い例: 全てのレコードを返す
const users = await db.users.find();
// 良い例: ページネーション
const users = await db.users.find()
.limit(20)
.skip((page - 1) * 20);
APIパフォーマンス
問題: キャッシュなし
// 悪い例: 毎回データベースにアクセス
app.get('/api/stats', async (req, res) => {
const stats = await db.stats.calculate(); // 遅い
res.json(stats);
});
// 良い例: 5分間キャッシュ
const cache = new Map();
app.get('/api/stats', async (req, res) => {
const cached = cache.get('stats');
if (cached && Date.now() - cached.time < 300000) {
return res.json(cached.data);
}
const stats = await db.stats.calculate();
cache.set('stats', { data: stats, time: Date.now() });
res.json(stats);
});
問題: 逐次処理
// 悪い例: 逐次処理 (遅い)
const user = await getUser(id);
const posts = await getPosts(id);
const comments = await getComments(id);
// 合計: 300ms + 200ms + 150ms = 650ms
// 良い例: 並列処理 (速い)
const [user, posts, comments] = await Promise.all([
getUser(id),
getPosts(id),
getComments(id)
]);
// 合計: max(300ms, 200ms, 150ms) = 300ms
問題: 大きなペイロード
// 悪い例: 全てを返す
res.json(users); // 5MBの応答
// 良い例: 必要なフィールドのみ
res.json(users.map(u => ({
id: u.id,
name: u.name,
email: u.email
}))); // 500KBの応答
フロントエンドパフォーマンス
問題: 不要な再レンダリング
// 悪い例: 親が更新されるたびに再レンダリング
function UserList({ users }) {
return users.map(user => <UserCard user={user} />);
}
// 良い例: メモ化
const UserCard = React.memo(({ user }) => {
return <div>{user.name}</div>;
});
問題: 大きなバンドル
// 悪い例: ライブラリ全体をインポート
import _ from 'lodash'; // 70KB
// 良い例: 必要なものだけをインポート
import debounce from 'lodash/debounce'; // 2KB
問題: コード分割なし
// 悪い例: 全てを1つのバンドルに
import HeavyComponent from './HeavyComponent';
// 良い例: 遅延読み込み
const HeavyComponent = React.lazy(() => import('./HeavyComponent'));
問題: 最適化されていない画像
<!-- 悪い例: 大きな画像 -->
<img src="photo.jpg" /> <!-- 5MB -->
<!-- 良い例: 最適化され、レスポンシブ -->
<img
src="photo-small.webp"
srcset="photo-small.webp 400w, photo-large.webp 800w"
loading="lazy"
width="400"
height="300"
/> <!-- 50KB -->
アルゴリズムの最適化
問題: 非効率なアルゴリズム
// 悪い例: O(n²) - ネストされたループ
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;
}
// 良い例: O(n) - Setを使った単一パス
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);
}
問題: 繰り返される計算
// 悪い例: 毎回計算
function getTotal(items) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
// レンダリングで100回呼び出される
// 良い例: メモ化
const getTotal = useMemo(() => {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}, [items]);
メモリ最適化
問題: メモリリーク
// 悪い例: イベントリスナーがクリーンアップされない
useEffect(() => {
window.addEventListener('scroll', handleScroll);
// メモリリーク!
}, []);
// 良い例: クリーンアップ
useEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, []);
問題: メモリ内の大きなデータ
// 悪い例: ファイル全体をメモリに読み込む
const data = fs.readFileSync('huge-file.txt'); // 1GB
// 良い例: ストリームで処理
const stream = fs.createReadStream('huge-file.txt');
stream.on('data', chunk 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Performance Optimizer
Find and fix performance bottlenecks. Measure, optimize, verify. Make it fast.
When to Use This Skill
- App is slow or laggy
- User complains about performance
- Page load times are high
- API responses are slow
- Database queries take too long
- User mentions "slow", "lag", "performance", or "optimize"
The Optimization Process
1. Measure First
Never optimize without measuring:
// Measure execution time
console.time('operation');
await slowOperation();
console.timeEnd('operation'); // operation: 2341ms
What to measure:
- Page load time
- API response time
- Database query time
- Function execution time
- Memory usage
- Network requests
2. Find the Bottleneck
Use profiling tools to find the slow parts:
Browser:
DevTools → Performance tab → Record → Stop
Look for long tasks (red bars)
Node.js:
node --prof app.js
node --prof-process isolate-*.log > profile.txt
Database:
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'test@example.com';
3. Optimize
Fix the slowest thing first (biggest impact).
Common Optimizations
Database Queries
Problem: N+1 Queries
// Bad: N+1 queries
const users = await db.users.find();
for (const user of users) {
user.posts = await db.posts.find({ userId: user.id }); // N queries
}
// Good: Single query with JOIN
const users = await db.users.find()
.populate('posts'); // 1 query
Problem: Missing Index
-- Check slow query
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
-- Shows: Seq Scan (bad)
-- Add index
CREATE INDEX idx_users_email ON users(email);
-- Check again
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
-- Shows: Index Scan (good)
**Problem: SELECT ***
// Bad: Fetches all columns
const users = await db.query('SELECT * FROM users');
// Good: Only needed columns
const users = await db.query('SELECT id, name, email FROM users');
Problem: No Pagination
// Bad: Returns all records
const users = await db.users.find();
// Good: Paginated
const users = await db.users.find()
.limit(20)
.skip((page - 1) * 20);
API Performance
Problem: No Caching
// Bad: Hits database every time
app.get('/api/stats', async (req, res) => {
const stats = await db.stats.calculate(); // Slow
res.json(stats);
});
// Good: Cache for 5 minutes
const cache = new Map();
app.get('/api/stats', async (req, res) => {
const cached = cache.get('stats');
if (cached && Date.now() - cached.time < 300000) {
return res.json(cached.data);
}
const stats = await db.stats.calculate();
cache.set('stats', { data: stats, time: Date.now() });
res.json(stats);
});
Problem: Sequential Operations
// Bad: Sequential (slow)
const user = await getUser(id);
const posts = await getPosts(id);
const comments = await getComments(id);
// Total: 300ms + 200ms + 150ms = 650ms
// Good: Parallel (fast)
const [user, posts, comments] = await Promise.all([
getUser(id),
getPosts(id),
getComments(id)
]);
// Total: max(300ms, 200ms, 150ms) = 300ms
Problem: Large Payloads
// Bad: Returns everything
res.json(users); // 5MB response
// Good: Only needed fields
res.json(users.map(u => ({
id: u.id,
name: u.name,
email: u.email
}))); // 500KB response
Frontend Performance
Problem: Unnecessary Re-renders
// Bad: Re-renders on every parent update
function UserList({ users }) {
return users.map(user => <UserCard user={user} />);
}
// Good: Memoized
const UserCard = React.memo(({ user }) => {
return <div>{user.name}</div>;
});
Problem: Large Bundle
// Bad: Imports entire library
import _ from 'lodash'; // 70KB
// Good: Import only what you need
import debounce from 'lodash/debounce'; // 2KB
Problem: No Code Splitting
// Bad: Everything in one bundle
import HeavyComponent from './HeavyComponent';
// Good: Lazy load
const HeavyComponent = React.lazy(() => import('./HeavyComponent'));
Problem: Unoptimized Images
<!-- Bad: Large image -->
<img src="photo.jpg" /> <!-- 5MB -->
<!-- Good: Optimized and responsive -->
<img
src="photo-small.webp"
srcset="photo-small.webp 400w, photo-large.webp 800w"
loading="lazy"
width="400"
height="300"
/> <!-- 50KB -->
Algorithm Optimization
Problem: Inefficient Algorithm
// Bad: O(n²) - nested loops
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;
}
// Good: O(n) - single pass with Set
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);
}
Problem: Repeated Calculations
// Bad: Calculates every time
function getTotal(items) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
// Called 100 times in render
// Good: Memoized
const getTotal = useMemo(() => {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}, [items]);
Memory Optimization
Problem: Memory Leak
// Bad: Event listener not cleaned up
useEffect(() => {
window.addEventListener('scroll', handleScroll);
// Memory leak!
}, []);
// Good: Cleanup
useEffect(() => {
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, []);
Problem: Large Data in Memory
// Bad: Loads entire file into memory
const data = fs.readFileSync('huge-file.txt'); // 1GB
// Good: Stream it
const stream = fs.createReadStream('huge-file.txt');
stream.on('data', chunk => process(chunk));
Measuring Impact
Always measure before and after:
// Before optimization
console.time('query');
const users = await db.users.find();
console.timeEnd('query');
// query: 2341ms
// After optimization (added index)
console.time('query');
const users = await db.users.find();
console.timeEnd('query');
// query: 23ms
// Improvement: 100x faster!
Performance Budgets
Set targets:
Page Load: < 2 seconds
API Response: < 200ms
Database Query: < 50ms
Bundle Size: < 200KB
Time to Interactive: < 3 seconds
Tools
Browser:
- Chrome DevTools Performance tab
- Lighthouse (audit)
- Network tab (waterfall)
Node.js:
node --prof(profiling)clinic(diagnostics)autocannon(load testing)
Database:
EXPLAIN ANALYZE(query plans)- Slow query log
- Database profiler
Monitoring:
- New Relic
- Datadog
- Sentry Performance
Quick Wins
Easy optimizations with big impact:
- Add database indexes on frequently queried columns
- Enable gzip compression on server
- Add caching for expensive operations
- Lazy load images and heavy components
- Use CDN for static assets
- Minify and compress JavaScript/CSS
- Remove unused dependencies
- Use pagination instead of loading all data
- Optimize images (WebP, proper sizing)
- Enable HTTP/2 on server
Optimization Checklist
- [ ] Measured current performance
- [ ] Identified bottleneck
- [ ] Applied optimization
- [ ] Measured improvement
- [ ] Verified functionality still works
- [ ] No new bugs introduced
- [ ] Documented the change
When NOT to Optimize
- Premature optimization (optimize when it's actually slow)
- Micro-optimizations (save 1ms when page takes 5 seconds)
- Readable code is more important than tiny speed gains
- If it's already fast enough
Key Principles
- Measure before optimizing
- Fix the biggest bottleneck first
- Measure after to prove improvement
- Don't sacrifice readability for tiny gains
- Profile in production-like environment
- Consider the 80/20 rule (20% of code causes 80% of slowness)
Related Skills
@database-design- Query optimization@codebase-audit-pre-push- Code review@bug-hunter- Debugging
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (8,841 bytes)
- 📎 README.md (465 bytes)