/armory:sql-optimizerfrom armory
Analyzes SQL queries for missing indexes, N+1 patterns, suboptimal joins, and full table scans. Interprets EXPLAIN plans and rewrites queries with performance explanations.
Ships in armory. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Systematic SQL performance analysis: parse query structure, interpret EXPLAIN plans, detect anti-patterns (N+1, full scans, cartesian joins), recommend indexes, and rewrite queries — with explanations of WHY each change improves performance, not just WHAT changed.
| File | Contents | Load When |
|---|---|---|
references/anti-patterns.md | Common SQL anti-patterns with detection rules and fixes | Always |
references/index-strategies.md | Index type selection, composite index ordering, covering indexes | Index recommendations needed |
references/explain-guide.md | Reading EXPLAIN output for PostgreSQL, MySQL, SQLite | EXPLAIN plan provided |
references/join-optimization.md | Join type selection, join order optimization, subquery-to-join conversion | Query contains joins or subqueries |
Parse the SQL to understand its structure:
SELECT * — fetching unnecessary columnsOR in WHERE — often prevents index useIf an EXPLAIN plan is provided:
ANALYZE).Check for known performance anti-patterns (see references/anti-patterns.md):
| Pattern | Detection | Impact |
|---|---|---|
| SELECT * | Star in select list | Transfers unnecessary data |
| N+1 queries | Loop with query inside | N additional roundtrips |
| Function on indexed column | WHERE UPPER(name) = 'X' | Index bypass |
| Implicit type cast | String compared to integer | Index bypass |
| Missing join condition | Cartesian product | Exponential rows |
| LIKE '%prefix' | Leading wildcard | Full scan |
| OR with different columns | WHERE a=1 OR b=2 | Index bypass |
| SELECT DISTINCT as band-aid | Hides duplicate-producing join | Fix the join instead |
IN (SELECT...)
with EXISTS, use CTEs for readability without performance cost (PostgreSQL 12+
may inline CTEs).Present the original query, detected issues, recommended indexes, rewritten query, and explanation of each change.
## SQL Optimization Analysis
### Original Query
```sql
{original SQL}
```
### Issues Detected
| # | Issue | Severity | Location | Impact |
| --- | ------- | ----------------- | ------------------- | ---------------- |
| 1 | {issue} | {High/Medium/Low} | {WHERE/JOIN/SELECT} | {what it causes} |
### EXPLAIN Interpretation
{If EXPLAIN provided}
- **Bottleneck:** {node type} on `{table}` (cost: {N})
- **Rows scanned:** {N} (estimated {M})
- **Index used:** {name or "None"}
- **Key insight:** {what this reveals}
### Recommended Indexes
```sql
-- {Reason for this index}
CREATE INDEX {name} ON {table}({columns});
```
### Optimized Query
```sql
{rewritten query}
```
### Change Explanation
1. **{Change}** — {Why this improves performance. Include estimated impact.}
### Expected Improvement
- Scan type: {before} → {after}
- Estimated rows scanned: {before} → {after}
- Index usage: {before} → {after}
| Mode | Input | Depth | When to Use |
|---|---|---|---|
quick | Single query | Anti-pattern scan + index suggestion | Fast feedback during development |
standard | Query + schema | Full analysis with rewrites | Default for optimization requests |
deep | Query + EXPLAIN + schema + row counts | Full analysis with statistics validation | Production performance investigation |
users.email" is incomplete.
"Add an index on users.email because the WHERE clause filters by email, currently
causing a sequential scan of 1M rows" is actionable.| Problem | Resolution |
|---|---|
| No EXPLAIN output provided | Analyze query structure and anti-patterns. Note that recommendations are best-effort without EXPLAIN. |
| Unknown database engine | Ask which engine. Default anti-pattern analysis applies to all engines. |
| Query uses ORM-generated SQL | Optimize the SQL, then suggest ORM-level changes (e.g., select_related in Django, eager loading). |
| Schema not provided | Infer table structure from the query. Note assumptions. |
| Query is already optimal | State that no significant improvements are possible. Suggest non-query optimizations (caching, denormalization). |
| Complex multi-CTE query | Analyze each CTE independently, then analyze the composition. |
Push back if:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
SQL, PostgreSQL, MySQL, SQLite
npx claudepluginhub mathews-tom/armory --plugin armory94 skills in this plugin
/adr-writerGenerates Architecture Decision Records capturing context, rationale, alternatives, and consequences in numbered status-tracked format. Triggers on: "write an ADR", "document this decision", "architecture decision record", "decision record", "design decision", "ADR for"./agent-builderBuild AI agents and automate Claude Code programmatically via the Claude Agent SDK and headless CLI mode. Covers Python SDK, claude -p, SDK MCP servers, hooks, sessions. Triggers on: "build an agent", "agent SDK", "headless mode", "automate Claude", "programmatic agent"./animateCreate Manim (Python) animated explainers: algorithm step-throughs, math and equation walkthroughs, pipeline and data-flow diagrams, comparisons and timelines, rendered to MP4, WebM or GIF with optional audio overlay. Includes a template path that renders validated config data with no model call, plus output checks (ffprobe duration, fps, dimensions, full decode, sampled-frame review receipt). Use when asked to "create a video", "animate this", "make an explainer", "manim animation", "animate this algorithm", or "motion graphic". NOT for HTML/CSS/GSAP or Hyperframes video, NOT for React or Remotion video, and NOT for a launch or promo video of the user's own project, use launch-video./api-docs-generatorAudits and enhances FastAPI and REST API documentation: missing descriptions, response codes, examples, docstrings, Pydantic models, OpenAPI spec. Triggers on: "generate API docs", "document this API", "OpenAPI for", "FastAPI docs", "document endpoints", "swagger docs"./appraiseEvidence-based competency and seniority appraisal of a software engineer from one or more Git repositories: attributes authorship with git blame, separates fork and upstream code, verifies every cited line, and calibrates technical, scope and overall levels with explicit uncertainty, a development plan and targeted questions. Use this skill when asked to "appraise this developer", "calibrate my seniority", "assess this candidate from their GitHub", "what level am I based on my repos", "review this engineer's contributions", "build a promotion evidence pack", or "how can I grow as an engineer from my code". Covers candidate review, self-appraisal, promotion packs, manager or mentor appraisals with consent, progress over time and recalibration after interview answers. Not for code review of a diff, repository tutorials, or architecture reviews./architecture-diagramGenerate architecture diagrams as fully editable SVG with native AWS, Azure, and GCP icons for cloud diagrams, or hand-drawn generic icons for everything else. Optionally deliver a self-contained editable draw.io mxGraph companion. Deterministic layout computes zone nesting and orthogonal routing instead of hand-placed coordinates. Triggers on: "architecture diagram", "infra diagram", "system diagram", "deployment diagram", "topology diagram", "draw architecture", "AWS diagram", "Azure diagram", "GCP diagram", "cloud infrastructure diagram", "VPC diagram", "draw my AWS setup". Use when a user wants a static architecture diagram they can still edit afterward in Figma, Illustrator, Inkscape, or draw.io. NOT for architecture reviews, use architecture-reviewer.Other plugins' skills for the same job