Skip to content
Development
Skill

/postgresql

PostgreSQL database agent: deploy locally (Docker/K8s), manage schemas, run queries, analyze performance, configure permissions, and seed data.

From plugin
sdd
4359 skills7 agents3 commands

Claude Code

$ npx -y skills add LiorCohen/sdd --skill postgresql --agent claude-code

SKILL.md

postgresql.SKILL.md
name: postgresql
description: "PostgreSQL database agent: deploy locally (Docker/K8s), manage schemas, run queries, analyze performance, configure permissions, and seed data."
user-invocable: false

PostgreSQL Skill

SQL-native PostgreSQL operations via `psql`. No Python dependencies required.

---

Version Compatibility

| Feature | Minimum Version | |---------|-----------------| | Core functionality | PostgreSQL 12+ | | `pg_blocking_pids()` | 9.6+ | | `REINDEX CONCURRENTLY` | 12+ | | `pg_stat_progress_*` views | 12+ | | `VACUUM PARALLEL` | 13+ | | `pg_stat_wal` | 14+ | | `pg_stat_checkpointer` | 17+ |

**Recommended**: PostgreSQL 14+

---

Connection

Environment Variables

export PGHOST=localhost
export PGPORT=5432
export PGUSER=app
export PGPASSWORD=secret
export PGDATABASE=myapp

Connect via psql

# Using environment variables
psql

# Using connection string
psql "postgresql://app:secret@localhost:5432/myapp"

# Docker
docker exec -it postgres psql -U app -d myapp

# Kubernetes
kubectl exec -it postgres -- psql -U postgres

---

Seed Data

Basic Insert

INSERT INTO app.users (email, name) VALUES
    ('alice@example.com', 'Alice'),
    ('bob@example.com', 'Bob')
RETURNING id, email;

Upsert

INSERT INTO app.users (email, name)
VALUES ('alice@example.com', 'Alice Updated')
ON CONFLICT (email) DO UPDATE SET
    name = EXCLUDED.name,
    updated_at = NOW();

Generate Test Data

INSERT INTO app.users (email, name)
SELECT
    'user' || n || '@example.com',
    'User ' || n
FROM generate_series(1, 1000) AS n;

COPY from CSV

\copy app.users (email, name) FROM 'users.csv' WITH (FORMAT csv, HEADER true);

---

Query Execution

Parameterized Queries

**CRITICAL**: Always use parameterized queries to prevent SQL injection.

-- In psql with variables
\set user_id 123
SELECT * FROM app.users WHERE id = :user_id;

-- Prepared statements
PREPARE get_user(bigint) AS
    SELECT * FROM app.users WHERE id = $1;
EXECUTE get_user(123);

Transactions

BEGIN;
    UPDATE app.accounts SET balance = balance - 100 WHERE id = 1;
    UPDATE app.accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;

-- With savepoint
BEGIN;
    INSERT INTO app.orders (user_id, total) VALUES (1, 99.99);
    SAVEPOINT before_items;
    INSERT INTO app.order_items (order_id, product_id) VALUES (1, 999);
    -- Oops, rollback just the items
    ROLLBACK TO before_items;
COMMIT;

---

Safety Guidelines

**CRITICAL**: Follow these rules to prevent data loss and security issues.

1. **Always use parameterized queries** - Never concatenate user input into SQL strings 2. **Wrap modifications in transactions** - Use BEGIN/COMMIT for multi-statement changes 3. **Always include WHERE clause** - Never run UPDATE/DELETE without WHERE 4. **Test on non-production first** - Validate queries on dev/staging before production 5. **Use CONCURRENTLY for indexes** - Avoid locking tables during index operations 6. **Backup before migrations** - Always have a restore point before schema changes 7. **Limit query results** - Use LIMIT during exploration to avoid memory issues

---

psql Quick Reference

| Command | Description | |---------|-------------| | `\l` | List databases | | `\c dbname` | Connect to database | | `\dt` | List tables | | `\dt schema.*` | List tables in schema | | `\d tablename` | Describe table | | `\di` | List indexes | | `\df` | List functions | | `\du` | List roles/users | | `\dn` | List schemas | | `\x` | Toggle expanded display | | `\timing` | Toggle query timing | | `\i file.sql` | Execute SQL file | | `\copy` | Import/export CSV | | `\q` | Quit |

---

Resource Files

For detailed guidance, read these on-demand:

  • [deployment.md](resources/deployment.md) — Docker, Docker Compose, Kubernetes setups
  • [schema-management.md](resources/schema-management.md) — Tables, indexes, migrations
  • [monitoring.md](resources/monitoring.md) — System views, performance analysis
  • [administration.md](resources/administration.md) — Permissions, backup, import/export

---

Input / Output

This skill defines no input parameters or structured output.

Read more
@liorcohen
Ships withsdd

Structure for AI-assisted development AI coding assistants are powerful but chaotic. You prompt, you get code, but then what?

4359 skills7 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
43
Star history of LiorCohen/sdd on GitHub, a chart by star-history.com

Other skills on sdd.

agents-standards

agents-standards

Standards for authoring SDD plugin agents — frontmatter, self-containment, skill references, and no-user-interaction rules.

@liorcohen@liorcohenInstall Skill
commands-standards

commands-standards

Standards for authoring SDD plugin commands — frontmatter, user interaction, skill/agent invocation, CLI integration, and output…

@liorcohen@liorcohenInstall Skill
commit

commit

Create a commit following repository guidelines with proper versioning and changelog updates.

@liorcohen@liorcohenInstall Skill
critic

critic

Two-step self-review at every task lifecycle phase. Step 1 (this skill) runs in-context to gather session signals — files read vs…

@liorcohen@liorcohenInstall Skill
d2

d2

D2 diagramming language reference for architecture diagrams, sequence diagrams, grid layouts, SQL tables, and class diagrams.…

@liorcohen@liorcohenInstall Skill
docs-standards

docs-standards

Writes and maintains user-facing documentation for the SDD plugin. Proactively detects when docs are out of sync with plugin…

@liorcohen@liorcohenInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react5d252k
@facebook@facebookInstall Skill

Questions about postgresql.

Which coding agents can use postgresql?
postgresql installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.