# postgres-best-practices

This skill guides Claude Code through Postgres queries, schemas, and configuration. Use it when tuning indexes, reviewing RLS, or investigating database performance.

- skill · `type=skill` · Claude Code · 722 installs
- Author: supabase
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/development/postgres-best-practices
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/postgres-best-practices

## What it does

postgres-best-practices gives Claude Code a structured set of Supabase guidance for Postgres work. It covers query tuning, connection handling, access control with RLS, schema choices, locking, data access, diagnostics, and advanced features. The categories are ranked so critical query and connection concerns come before lower-priority topics.

The package is organized as individual rule files. They explain the issue, contrast flawed and corrected SQL, and may include `EXPLAIN` output or Supabase-specific notes. The compiled reference is `AGENTS.md`; focused material includes `rules/query-missing-indexes.md` and `rules/schema-partial-indexes.md`. For a Postgres review, this makes the skill useful beyond query text: it also checks the surrounding schema and database setup.

## Requirements
- Works with: PostgreSQL, Supabase

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill development/postgres-best-practices
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill postgres-best-practices -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/postgres-best-practices/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/postgres-best-practices/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/postgres-best-practices/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/postgres-best-practices/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates postgres-best-practices
```

2. **Manually: put the files in place**
- File: `.github/skills/postgres-best-practices/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/development/postgres-best-practices
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/postgres-best-practices/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/development/postgres-best-practices

## When to use it
- spot missing indexes in a Postgres query
- review a schema against access-control rules
- investigate locks between concurrent operations
- adjust connection pooling and scaling choices
- check database settings with diagnostic rules

## Example prompts
- Review this Postgres query and suggest indexes using `postgres-best-practices`.
- Inspect the schema with RLS and connection management in mind.
- Compare this change with `rules/query-missing-indexes.md` and `AGENTS.md`.

## Similar
- [postgres-patterns](https://affpapa.org/en/nevibecode/skills/postgres-patterns.md) — skill · 5200 installs
- [supabase-audit-rpc](https://affpapa.org/en/nevibecode/skills/supabase-audit-rpc.md) — skill · 524 installs
- [sql-pro](https://affpapa.org/en/nevibecode/skills/httpsgithubcomjeffallan-sql-pro.md) — skill · 6400 installs
- [supabase](https://affpapa.org/en/nevibecode/skills/supabase.md) — skill · 8 installs
- [postgresql-best-practices](https://affpapa.org/en/nevibecode/skills/postgresql-best-practices.md) — skill · 1500 installs
- [postgres](https://affpapa.org/en/nevibecode/skills/sanjay3290-postgres.md) — skill · 620 installs

## Other versions with the same name
- [postgres-best-practices · neondatabase](https://affpapa.org/en/nevibecode/skills/neondatabase-postgres-best-practices.md) — 1900 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 361 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
