{
  "id": "skl_2fc049467e64",
  "slug": "skill-postgres-query-tuning",
  "asset_type": "skill",
  "name": "PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill",
  "tagline": "Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connect",
  "description_md": "### Overview & Capability Scope\n**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/`).\n\nDiagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connection pools.\n\n### Required Stack & Tooling\n- **Primary Stack:** PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements\n- **Category:** `engineering`\n- **Source & Reference:** [https://github.com/modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers)\n\n### Quickstart Installation\nInstall this `SKILL.md` playbook directly into your agent workspace:\n```bash\nnpx lightstate install skill-postgres-query-tuning\n```\nOr 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`.\n\n### Verification Commands\n```bash\npsql $DATABASE_URL -c 'EXPLAIN (ANALYZE, BUFFERS) SELECT ...'\n```\n",
  "primary_category": "engineering",
  "categories_json": "[\"engineering\", \"skills\"]",
  "tags_json": "[\"postgresql\", \"explain-analyze\", \"indexing\", \"pg_stat_statements\", \"skill-md\", \"engineering\"]",
  "compatible_agents_json": "[\"grok-bot\", \"claude-code\", \"cursor\"]",
  "integrations_json": "[\"PostgreSQL\", \"EXPLAIN ANALYZE\", \"Indexing\"]",
  "includes_json": "[]",
  "safety_level": "Read-Only / Ask-First",
  "safety_summary": "Verified capability blueprint by @simonw.",
  "share_url": "",
  "deep_link_uri": "",
  "mcp_endpoint": "",
  "mcp_transport": "http",
  "install_command": "npx lightstate install skill-postgres-query-tuning",
  "skill_markdown": "---\nname: postgres-query-tuning\ndescription: 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.\ntriggers:\n  - postgres query tuning\n  - postgresql\n  - explain analyze\n---\n\n# PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill\n\n## 1. When to Use This Skill\nLoad `skill-postgres-query-tuning` whenever an engineering or operations task involves **PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements**. Specifically:\n- Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connection pools.\n- Designing, reviewing, or debugging production configurations without guesswork or deprecated flags.\n- Running deterministic pre-flight and post-execution verification checks before reporting completion.\n\n## 2. Prerequisites & Required Environment\n- **Target Stack:** PostgreSQL, EXPLAIN ANALYZE, Indexing, pg_stat_statements\n- **Permissions:** Read-only inspection by default; ask for explicit confirmation before executing destructive mutations or production deployments.\n- **Reference Repository:** `https://github.com/modelcontextprotocol/servers`\n\n## 3. Step-by-Step Execution Playbook\n1. **Context & Configuration Discovery:**\n   Inspect existing project manifests (`package.json`, `wrangler.jsonc`, schema files, or environment declarations) before proposing changes. Never overwrite existing bindings or credentials blindly.\n2. **Deterministic Implementation:**\n   Apply the canonical patterns for **PostgreSQL**:\n   - Enforce strict schema/type validation at every external boundary.\n   - Include explicit error handling, structured logging, and idempotency keys on all mutating calls.\n   - Keep secrets in environment variables or secret stores—never hardcode tokens in source files.\n3. **Verification & Regression Gate:**\n   Run the verification commands below and inspect both exit codes and output payloads before marking the task complete.\n\n## 4. Reference Commands & CLI Workflow\n```bash\npsql $DATABASE_URL -c 'EXPLAIN (ANALYZE, BUFFERS) SELECT ...'\n```\n\n## 5. Edge Cases & Anti-Hallucination Guardrails\n- **Zero Unverified Claims:** Never claim a deployment, migration, or API call succeeded without inspecting the command output or HTTP status code.\n- **Rollback Readiness:** Always record the previous state or migration version so changes can be reverted cleanly if downstream health checks fail.\n",
  "starter_prompt": "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.",
  "project_url": "https://github.com/modelcontextprotocol/servers",
  "repo_url": "https://github.com/modelcontextprotocol/servers",
  "creator_handle": "simonw",
  "creator_name": "Simon Willison (@simonw)",
  "creator_avatar_url": null,
  "creator_url": "https://x.com/simonw",
  "creator_platform": "x",
  "creator_cal_url": null,
  "claimed_by_user_id": null,
  "scouted_by_handle": null,
  "source_url": "https://github.com/modelcontextprotocol/servers",
  "source_tweet_id": null,
  "source_origin": "certified_builder",
  "source_posted_at": null,
  "x_likes": 332,
  "x_bookmarks": 736,
  "x_retweets": 184,
  "x_views": 4648,
  "human_upvotes": 332,
  "human_installs": 332,
  "bot_pulls": 736,
  "pulse_score": 84,
  "gravity_rank_score": 2642,
  "is_featured": 0,
  "is_verified": 1,
  "is_sponsored": 0,
  "sponsor_tier": "free",
  "sponsor_label": "",
  "sponsor_cta_url": "",
  "sponsor_expires_at": null,
  "commercial_intent_score": 0,
  "status": "active",
  "created_at": "2026-10-24T20:00:00Z",
  "updated_at": "2026-10-24T20:00:00Z",
  "verified_at": null,
  "primitive": "skill",
  "title": "PostgreSQL EXPLAIN ANALYZE & Composite Index Optimization Skill",
  "description": "Diagnose slow SQL queries using `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)`, eliminate sequential scans, design covering B-Tree/GIN indexes, and tune connect",
  "category": "engineering",
  "tags": "[\"postgresql\", \"explain-analyze\", \"indexing\", \"pg_stat_statements\", \"skill-md\", \"engineering\"]",
  "agent_compatibility": "[\"grok-bot\", \"claude-code\", \"cursor\"]",
  "author_handle": "simonw",
  "author_name": "Simon Willison (@simonw)",
  "author_avatar": null,
  "source_tweet_url": "https://github.com/modelcontextprotocol/servers",
  "github_url": "https://github.com/modelcontextprotocol/servers",
  "external_url": "https://github.com/modelcontextprotocol/servers",
  "upvotes_count": 332,
  "installs_count": 332
}