Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/Arete-Consortium/ai-skills --skill sqlコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
Intelligent CI failure diagnosis and guided remediation for GitHub Actions, GitLab CI, and local builds
Pre-execution mapping of codebases, document collections, or problem spaces. Runs BEFORE any Gorgon workflow to give all agents shared situational awareness
Investigative methodology for analyzing document collections — provenance analysis, anomaly detection, redaction detection, and cross-document validation
SKILL.md を表示中
| name | sql |
| description | SQL Query Optimization |
| lifecycle | experimental |
Analyze and optimize SQL queries.
/sql "SELECT * FROM users..." # Analyze query
/sql --explain # Generate EXPLAIN plan
/sql --index # Suggest indexes
/sql --rewrite # Rewrite for performance
# SQL Analysis
## Original Query
```sql
SELECT u.*, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01'
GROUP BY u.id
ORDER BY order_count DESC
LIMIT 100;
Problem: Selects all columns, may fetch unnecessary data Impact: More memory, slower network transfer Fix: Specify only needed columns
Problem: No index on users.created_at
Impact: Full table scan for date filter
Fix: CREATE INDEX idx_users_created_at ON users(created_at);
Problem: No index on orders.user_id
Impact: Slow JOIN operation
Fix: CREATE INDEX idx_orders_user_id ON orders(user_id);
SELECT
u.id,
u.username,
u.email,
COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at > '2024-01-01'
GROUP BY u.id, u.username, u.email
ORDER BY order_count DESC
LIMIT 100;
-- For WHERE clause filtering
CREATE INDEX idx_users_created_at ON users(created_at);
-- For JOIN performance
CREATE INDEX idx_orders_user_id ON orders(user_id);
-- Composite index for common query pattern
CREATE INDEX idx_users_created_at_id ON users(created_at, id);
## Common Anti-Patterns
### SELECT *
```sql
-- Bad
SELECT * FROM users WHERE id = 1;
-- Good
SELECT id, username, email FROM users WHERE id = 1;
-- Bad: N+1 (1 query + N queries)
SELECT * FROM users;
-- Then for each user:
SELECT * FROM orders WHERE user_id = ?;
-- Good: Single query with JOIN
SELECT u.*, o.*
FROM users u
LEFT JOIN orders o ON o.user_id = u.id;
-- Bad: May return millions of rows
SELECT * FROM logs WHERE level = 'ERROR';
-- Good: Bounded result set
SELECT * FROM logs WHERE level = 'ERROR' LIMIT 1000;
-- Bad: Can't use indexes efficiently
SELECT * FROM users WHERE email = 'x' OR username = 'y';
-- Good: Use UNION
SELECT * FROM users WHERE email = 'x'
UNION
SELECT * FROM users WHERE username = 'y';
-- Bad: Can't use index
SELECT * FROM products WHERE name LIKE '%phone%';
-- Good: Use full-text search
SELECT * FROM products WHERE MATCH(name) AGAINST('phone');
-- Index on (a, b, c) can be used for:
WHERE a = ?
WHERE a = ? AND b = ?
WHERE a = ? AND b = ? AND c = ?
-- But NOT for:
WHERE b = ?
WHERE c = ?
WHERE b = ? AND c = ?
EXPLAIN ANALYZE SELECT ...;
| Metric | Good | Bad |
|---|---|---|
| Seq Scan | Small tables | Large tables |
| Index Scan | Large tables | - |
| Rows | Low estimate | High estimate |
| Cost | Low | High |
When /sql is invoked: