database-indexing-strategy — Claude Code skill: Postgres and MySQL
A skill for planning indexes: picks the type, builds composite and partial ones, covers maintenance. Useful when queries slow down.
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a claude-codeWhat database-indexing-strategy does
The skill covers index planning for PostgreSQL and MySQL. It walks through type selection (B-tree, Hash, GiST, BRIN), composite and partial indexes, expression indexes, full-text search, plus maintenance and monitoring. The quick start shows the common cases: an index on email, one on created_at DESC, and a composite on user_id and status with WHERE cancelled_at IS NULL.
The layout is plain: a SKILL.md file and a references/ directory with three guides — PostgreSQL index types, MySQL index types, and single-column, composite, partial and expression indexes. Your agent opens the right file when you ask about a specific query or table.
One limit worth knowing: this is about indexes, not the whole schema. If the query itself is slow because of joins or the planner, the skill won't fix that. And before adding an index to production, check how it lands on writes — that's a reason to run the scenario on a copy first.
What it helps with
- pick an index type for a date-range query
- replace three single-column indexes with one composite
- add a partial index for active orders
- set up full-text search in PostgreSQL
- plan index maintenance and monitoring
Example prompts for the agent
- look at this query plan and suggest an index for PostgreSQL
- I need a composite index on user_id and status, only for non-cancelled orders
- which MySQL indexes would speed up this SELECT, and how do they differ from B-tree
How to install database-indexing-strategy
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a claude-code2Manually: put the files in place
~/.claude/skills/database-indexing-strategy/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/database-indexing-strategy/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a codex2Manually: put the files in place
.agents/skills/database-indexing-strategy/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a cursor2Manually: put the files in place
.cursor/skills/database-indexing-strategy/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aj-geddes/useful-ai-prompts database-indexing-strategy2Manually: put the files in place
.github/skills/database-indexing-strategy/SKILL.md1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a gemini-cli2Platform CLI
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/database-indexing-strategyManually: put the files in place
.devin/skills/database-indexing-strategy/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about database-indexing-strategy
How do I install database-indexing-strategy in Claude?
Run npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a claude-code. The skill lands in ~/.claude/skills/database-indexing-strategy/SKILL.md.
What does database-indexing-strategy do?
It helps design indexes: picks the type, suggests composite and partial options, and covers maintenance and monitoring. It targets PostgreSQL and MySQL.
Which databases are supported?
PostgreSQL and MySQL. The references/ directory holds separate index-type guides for each.
Source text
SKILL.md · MIT
--- name: database-indexing-strategy description: > Design and implement database indexing strategies. Use when creating indexes, choosing index types, or optimizing index performance in PostgreSQL and MySQL. --- # Database Indexing Strategy ## Table of Contents - [Overview](#overview) - [When to Use](#when-to-use) - [Quick Start](#quick-start) - [Reference Guides](#reference-guides) - [Best Practices](#best-practices) ## Overview Design comprehensive indexing strategies to improve query performance, reduce lock contention, and maintain data integrity. Covers index types, design patterns, and maintenance procedures. ## When to Use - Index creation and planning - Query performance optimization through indexing - Index type selection (B-tree, Hash, GiST, BRIN) - Composite and partial index design - Index maintenance and monitoring - Storage optimization with indexes - Full-text search index design ## Quick Start **B-tree Indexes (Default):** ```sql -- Standard equality and range queries CREATE INDEX idx_users_email ON users(email); CREATE INDEX idx_orders_created_at ON orders(created_at DESC); -- Composite indexes for multi-column queries CREATE INDEX idx_orders_user_status ON orders(user_id, status) WHERE cancelled_at IS NULL; ``` ## Reference Guides Detailed implementations in the `references/` directory: | Guide | Contents | |---|---| | [PostgreSQL Index Types](references/postgresql-index-types.md) | PostgreSQL Index Types | | [MySQL Index Types](references/mysql-index-types.md) | MySQL Index Types | | [Single Column Indexes](references/single-column-indexes.md) | Single Column Indexes, Composite Indexes, Partial/Filtered Indexes, Expression Indexes | ## Best Practices ### ✅ DO - Follow established patterns and conventions - Write clean, maintainable code - Add appropriate documentation - Test thoroughly before deploying ### ❌ DON'T - Skip testing or validation - Ignore error handling - Hard-code configuration values
© aj-geddes · MIT · aj-geddes/useful-ai-prompts