db-indexing
Skill22 starsChanged 5 months agoMITView on GitHub
Audit index coverage for the query workload — composite index column order (ESR), covering and partial indexes, specialized types (GIN/GiST/BRIN, FTS, geo, JSONB-GIN), and foreign keys with no covering index. Module M11. Feeds the Performance & Scale score.
In this repository36 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- auditSkill
- checklistSkill
- db-antipatternsSkill
- db-concurrencySkill
- db-connection-poolingSkill
- db-constraintsSkill
- db-defaults-generatedSkill
- db-engine-selectionSkill
- db-index-hygieneSkill
- db-keysSkill
- db-migration-safetySkill
- db-multitenancySkill
- db-namingSkill
- db-normalizationSkill
- db-orchestratorSkill
- db-partitioning-shardingSkill
- db-platform-fitSkill
- db-query-patternsSkill
- db-referential-integritySkill
- db-replicas-viewsSkill
- db-security-accessSkill
- db-specialized-fitSkill
- db-storage-bloatSkill
- db-temporal-historySkill
- db-types-precisionSkill
- designSkill
- explainSkill
- fixSkill
- introspectSkill
- migrateSkill
- nextSkill
- scoreSkill
- seedSkill
- stack-detectSkill
- startSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 73
Never quote a latency/row-count improvement number.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Copyright (c) 2026 Enrique Rocha (@soyenriquerocha) · tododeia.com · id er-f37b7121 -->db-indexing (M11)
Indexing is the single heaviest Performance & Scale (axis performance) lever (relational weight
20, Indexación). This module checks whether the indexes that exist match how the data is queried —
missing, mis-ordered, or wrong-type indexes turn a sub-millisecond lookup into a sequential scan.
What it checks
- Composite order (ESR) — multi-column indexes should order columns Equality → Sort → Range. A leading range/low-selectivity column wastes the index.
- Covering / partial — frequent
SELECT a,b WHERE cbenefits from anINCLUDEcovering index; queries always filtered on a predicate (WHERE deleted_at IS NULL) benefit from a partial index. - Specialized types —
GINforjsonb/array/FTS containment,GiST/SP-GiSTfor geometry/range,BRINfor naturally-ordered append-only columns (timestamps). Flag full-text/geo/JSONB filters served by a plain B-tree (or no index). - FK-no-index — every foreign key column should have a covering index; an unindexed FK forces a
sequential scan on the referenced side during
ON DELETE/ON UPDATEand on joins. This is the highest-yield, lowest-risk index finding.
Score / axis
Feeds performance only (relational Indexación w20; Indexación category in every NoSQL profile).
Tier-0 (static)
Parse DDL/migrations for declared indexes and FKs; cross-reference visible query patterns (ORM
where/orderBy, raw SQL) against index columns. Detect FK columns with no matching index prefix,
composite indexes with a non-equality leading column, and JSONB/array/FTS/geo predicates with no
specialized index. Whether an index is actually used is runtime truth → needs_api at Tier-0.
Tier-1 (verification query) — FK-no-index (Postgres)
SELECT conrelid::regclass AS tbl, conname,
pg_get_constraintdef(c.oid) AS fk
FROM pg_constraint c
WHERE c.contype = 'f'
AND NOT EXISTS (
SELECT 1 FROM pg_index i
WHERE i.indrelid = c.conrelid
AND (c.conkey[1]) = i.indkey[0] -- leading index column == first FK column
);Method index_check. Each returned row is a confirmed unindexed FK (established). For ESR/covering,
EXPLAIN (ANALYZE, BUFFERS) on the real query (method explain_plan, Tier-2) confirms the scan type.
Findings
Emit findings per schema/finding.schema.json. Examples:
M11.orders.customer_id_fk_unindexed— FK column with no covering index (severity:3,warn, axisperformance, confidencedirectionalstatic /establishedTier-1,fixable: auto—CREATE INDEX CONCURRENTLY).M11.events.composite_order_esr— leading range column in a composite index (severity:2,warn,directional,fixable: proposed).M11.posts.jsonb_no_gin—jsonbcontainment filter with no GIN index (severity:3,warn,directional,fixable: proposed).
Each finding: evidence.observed quotes the FK/index DDL or query verbatim; verification.reproduce
is the catalog query above (FK-no-index) or an EXPLAIN referencing $DATABASE_URL; expected_impact
is banded + confidence-tagged (no naked %).
Honesty
- A missing index is not always a defect — a tiny lookup table or a write-heavy table can be slower
with an index. Scope severity to table size/access frequency; default
directionalwithout stats. - Never quote a latency/row-count improvement number; magnitude is
high|medium|lowonly. CREATE INDEX CONCURRENTLYisauto-fixable for FK gaps (additive, non-blocking, verifiable); composite reorders and partial indexes areproposedbecause intent may differ.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

