Skip to content
Back to skills

Supabase Postgres

ASecurity

Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.

  • 18 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 17, 2026
ai-agentssqldockerdebugginggitdatabaseperformancedocumentation

Security analysis

A100/100

Scanned October 17, 2026

npx -y skills add HiAi-gg/hiai-opencode --skill supabase-postgres --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Supabase Postgres?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Supabase Postgres
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hiai-gg-supabase-postgres/badge)](https://www.skillsdirectory.com/skills/hiai-gg-supabase-postgres)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: supabase-postgres
description: Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
---

# Supabase Postgres Best Practices

Use this skill when working with PostgreSQL databases — writing queries, designing schemas, optimizing performance, or debugging database issues.

## When to Use

- Writing or reviewing SQL queries
- Designing or modifying database schemas
- Optimizing query performance (EXPLAIN ANALYZE, indexes, etc.)
- Debugging connection issues, timeouts, or lock contention
- Working with pgvector extensions for embeddings
- Configuring connection pooling (PgBouncer, Supabase Pooler)

## Key Patterns

### Query Optimization
- Always use `EXPLAIN (ANALYZE, BUFFERS)` for slow queries
- Prefer `EXISTS` over `IN` for subqueries
- Use partial indexes for filtered queries
- Avoid `SELECT *` — specify columns explicitly

### Schema Design
- Use `timestamptz` (not `timestamp`) for all datetime columns
- Prefer `uuid` with `gen_random_uuid()` over serial IDs
- Use `jsonb` (not `json`) for document columns
- Add `ON DELETE CASCADE` or `ON DELETE SET NULL` explicitly

### Connection Management
- Use connection pooling for production workloads
- Set `statement_timeout` and `lock_timeout` per-query when needed
- Monitor `pg_stat_activity` for long-running queries

### pgvector
- Use `vector(1536)` or `vector(768)` for embedding columns
- Create HNSW indexes for approximate nearest neighbor search
- Use `ivfflat` for smaller datasets (<1M rows)

## Integration with hiai-bob

When the Researcher or Writer agents need database context:
1. Use `docker exec ai-core-postgres psql -U aiuser -d ai_orchestration -c "..."` (port 5433) for ai-core database
2. Use `docker exec webs-postgres psql -U admin -d webs -c "..."` (port 5432) for webs database
3. Always check table structures, foreign keys, and metadata BEFORE code changes

## References

- [Supabase Postgres Docs](https://supabase.com/docs/guides/database)
- [PostgreSQL EXPLAIN](https://www.postgresql.org/docs/current/using-explain.html)
- [pgvector Documentation](https://github.com/pgvector/pgvector)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.