LightState Registry / Portable Agent Skill (SKILL.md)s / Engineering & DevOps / skill-postgres-query-tuning
⚡ Pulse Score 84/100
PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill
Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connect
⚡ 1-Click Agent & Developer Install
Zero Auth · Ready for Grok Bot, Claude Code & Cursornpx lightstate install skill-postgres-query-tuning
Copy-Paste System Prompt / Routine Blueprint:
Load the PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill (skill-postgres-query-tuning) playbook. First inspect our current configuration and codebase for PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements. Then propose a concrete, step-by-step implementation plan following the skill-postgres-query-tuning guardrails, run the non-destructive verification commands (psql $DATABASE_URL -c 'EXPLAIN (ANALYZE, BUFFERS) SELECT ...'), and summarize any findings, risks, or required environment variables before making production changes.
📘 Complete SKILL.md Playbook Specification
--- name: postgres-query-tuning description: Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connection pools. Use when working with PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements. triggers: - postgres query tuning - postgresql - explain analyze --- # PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill ## 1. When to Use This Skill Load `skill-postgres-query-tuning` whenever an engineering or operations task involves **PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements**. Specifically: - Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connection pools. - Designing, reviewing, or debugging production configurations without guesswork or deprecated flags. - Running deterministic pre-flight and post-execution verification checks before reporting completion. ## 2. Prerequisites & Required Environment - **Target Stack:** PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements - **Permissions:** Read-only inspection by default; ask for explicit confirmation before executing destructive mutations or production deployments. - **Reference Repository:** `https://github.com/modelcontextprotocol/servers` ## 3. Step-by-Step Execution Playbook 1. **Context & Configuration Discovery:** Inspect existing project manifests (`package.json`, `wrangler.jsonc`, schema files, or environment declarations) before proposing changes. Never overwrite existing bindings or credentials blindly. 2. **Deterministic Implementation:** Apply the canonical patterns for **PostgreSQL**: - Enforce strict schema/type validation at every external boundary. - Include explicit error handling, structured logging, and idempotency keys on all mutating calls. - Keep secrets in environment variables or secret stores—never hardcode tokens in source files. 3. **Verification & Regression Gate:** Run the verification commands below and inspect both exit codes and output payloads before marking the task complete. ## 4. Reference Commands & CLI Workflow ```bash psql $DATABASE_URL -c 'EXPLAIN (ANALYZE, BUFFERS) SELECT ...' ``` ## 5. Edge Cases & Anti-Hallucination Guardrails - **Zero Unverified Claims:** Never claim a deployment, migration, or API call succeeded without inspecting the command output or HTTP status code. - **Rollback Readiness:** Always record the previous state or migration version so changes can be reverted cleanly if downstream health checks fail.
Synthesized Engineering Blueprint & Setup Guide
### Overview & Capability Scope
**PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill** (`skill-postgres-query-tuning`) is a verified, portable `SKILL.md` playbook curated with **@simonw** for Grok Bot (`x.ai/bot/`), Claude Code (`~/.claude/skills/`), and Cursor (`.cursor/skills/`).
Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connection pools.
### Required Stack & Tooling
- **Primary Stack:** PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements
- **Category:** `engineering`
- **Source & Reference:** [https://github.com/modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers)
### Quickstart Installation
Install this `SKILL.md` playbook directly into your agent workspace:
```bash
npx lightstate install skill-postgres-query-tuning
```
Or copy the complete `SKILL.md` specification below into `.cursor/skills/skill-postgres-query-tuning/SKILL.md` or `~/.claude/skills/skill-postgres-query-tuning/SKILL.md`.
### Verification Commands
```bash
psql $DATABASE_URL -c 'EXPLAIN (ANALYZE, BUFFERS) SELECT ...'
```
Tags: #postgresql#explain-analyze#indexing#pg_stat_statements#skill-md#engineering
✓ CERTIFIED X BUILDER PORTFOLIO
More Capabilities Curated from @simonw
Related Verified Capabilities
Explore Engineering & DevOps → MCP Server ★ Featured Partner ✓ Claimed
⚡ 98
Grok Template ✓ Claimed
⚡ 97
Dr. Eggbot — Meta-Agent Architect & Bot Builder
MCP Server ✓ Claimed
⚡ 89
Visual Sentinel MCP — Automated UI Pixel-Diff & Layout QA Server
MCP Server ✓ Claimed
⚡ 88
Cloudflare Official MCP — Workers, D1, R2, KV & Observability
MCP Server ✓ Claimed
⚡ 86
Supabase Official MCP — Postgres Schema, RLS & Edge Functions
MCP Server ✓ Claimed
⚡ 85