A composable team of AI agents and skills that can design, build, and operate complete systems on Azure Database for PostgreSQL — Flexible Server, built on the premise that "PostgreSQL can be used for everything."
Status: v0.2 · Last updated: 2026-07-17
Modern PostgreSQL — with its extension ecosystem — can credibly absorb the roles of many specialised systems (cache, queue, search, vector DB, document store, geospatial, time-series, analytics). The "just use Postgres" movement is now a mainstream architectural stance, not a novelty.
This project packages that expertise as Agent Skills and presides over them with a small number of agents, all targeting Azure Database for PostgreSQL — Flexible Server.
- Goal. A composable set of AI skills covering PostgreSQL as it applies to Azure, plus the agent(s) that give them a consistent operating posture. Secondary goal: drive Azure consumption and give product/customer teams a reusable asset.
- Non-goals (v1). Vanilla/self-hosted Postgres tuning as a first-class target; non-Azure managed Postgres (RDS, Cloud SQL, Neon). These may be added later behind a platform abstraction.
| Replaced system | PostgreSQL mechanism | Azure Flexible Server note |
|---|---|---|
| Pinecone / vector DB | pgvector, pgvectorscale, DiskANN index |
First-class; DiskANN GA |
| Elasticsearch | pg_search/ParadeDB (BM25), tsvector, hybrid + RRF |
Extension allow-list dependent |
| Redis (cache) | unlogged tables, JSONB, TTL via triggers/pg_cron |
Supported |
| Redis / Kafka (queue) | pgmq, SELECT … FOR UPDATE SKIP LOCKED, LISTEN/NOTIFY |
pgmq allow-list dependent |
| MongoDB | JSONB + GIN indexes |
Native |
| Kafka (CDC) | logical decoding / logical replication | Supported |
| Cron | pg_cron |
Supported |
| Geospatial | PostGIS | Supported |
| Time-series | TimescaleDB, native partitioning | Partitioning native; TimescaleDB varies |
| Analytics / scale-out | Citus (elastic clusters), columnar | Elastic clusters GA |
| In-DB AI calls | azure_ai (Azure OpenAI / Cognitive / ML from SQL) |
Azure-exclusive value-add |
The hard part is not feasibility — it's version/freshness management and Azure-specific constraints. Both are designed for below (§5, §6).
v0.2 — MVP skill set + agents. 11 azpg-* skills and 2 agents are built and
committed. The semantic doc index and scheduled reconciler (freshness Layers B/C,
§5) are still to come; see the roadmap.
| Skill | Cluster | Safety |
|---|---|---|
azpg-schema-design |
C1 data modeling | read-write |
azpg-index-selection |
C2 query performance | read-write |
azpg-explain-analyze |
C2 query performance | read |
azpg-pgvector-rag |
C3/C4 vector & RAG (reference) | read-write |
azpg-ai-in-database |
C4 in-database AI | read-write |
azpg-config-tuning |
C5 administration | read-write |
azpg-backup-pitr |
C5 administration | read-write |
azpg-roles-rbac |
C6 security | read-write |
azpg-provision-iac |
C7 provisioning / IaC | read-write |
azpg-stat-diagnostics |
C9 observability | read-write |
azpg-when-not-to-use |
C10 right-tool advisor | read |
| Agent | Role | Boundary |
|---|---|---|
azure-pg-expert |
Umbrella — sets posture, sequences work, lets skills auto-trigger | read + gated writes |
azure-pg-diagnostician |
Read-only incident-response / forensics specialist | hard read-only (safe on prod) |
See §7. Agents for why the roster stops at these two.
The skills are exercised end-to-end against a real Flexible Server, not just described:
demos/pgflow— PgFlow, a multi-tenant support/knowledge assistant where one Postgres server is the whole backend: JSONB document store, in-databaseazure_aiembeddings,pgvector/DiskANN search, and Row-Level Security tenant isolation, with a small live FastAPI + HTML app (demos/pgflow/app) you can run locally. Provisioned and validated on a live PG 16 server.evals/iteration-1— a genuine with-skill-vs-without-skill evaluation over three build tasks (provisioning, RAG core, async pipeline), scored against grounded expectations. Overall 12/18 → 16/18 (+22 pts) with the skills.
Building the demo surfaced two verified field findings now baked back into the skills:
azure_ai needs the server's system-assigned managed identity (not user-assigned),
and in-database azure_ai.generate (v1.3.1) is incompatible with gpt-5 reasoning
models (fixed temperature=0.2) — see azpg-ai-in-database.
postgres-ai-experts/
├── README.md # this file — overview + full design & conventions
├── skills/ # SKILL.md packages, grouped by cluster
│ └── azpg-<name>/SKILL.md
├── agents/ # agent definitions (umbrella + read-only diagnostician; see §7)
├── demos/ # end-to-end showcases on a live server (PgFlow + runnable app)
│ └── pgflow/
├── evals/ # with-skill vs without-skill evaluations
│ └── iteration-1/
└── .github/ # workflows (scheduled reconciler, CI) — planned
Distribution: authored to the Agent Skills open standard for portability; released to GitHub as the shareable asset.
The rest of this document is the source of truth for how skills and agents in this repo are built. Skills cite these sections (e.g. "design §6").
We follow the Agent Skills open standard (agentskills.io, Dec 2025) as used by Claude Code.
A skill is a directory with a SKILL.md (required) plus optional supporting
files. Progressive disclosure has three levels:
- Metadata — YAML frontmatter (
name,description). Pre-loaded into the agent's context so it knows when to trigger the skill. Thedescriptionis the routing signal — it must be precise. - Body — the
SKILL.mdmarkdown, loaded only when the skill is triggered. Holds the procedure and judgement. - Bundled files —
reference.md,scripts/,templates/, examples, loaded on demand. Holds detail and deterministic code.
- Version-aware, not version-pinned. Skills carry procedure + judgement; they discover the live version/extension matrix at runtime (see §5).
- Azure-scoped. Every skill assumes Flexible Server constraints (superuser restrictions, extension allow-list, managed HA/backup).
- Read/write safety split. Inspection skills are safe & auto-invocable; mutating skills require explicit invocation + a guarded protocol (see §6).
- Deterministic where it matters. Destructive or repeatable operations are
shipped as
scripts/(transaction-wrapped,--dry-runcapable), not free-form model behaviour. - Index-backed. Exhaustive reference lives in a semantic doc index (§5), not inside skills. Skills point to it.
azpg-<name>/
├── SKILL.md # frontmatter (name, description) + procedure
├── reference.md # deep reference, loaded on demand
├── azure-constraints.md# Flexible Server caveats (where relevant)
├── scripts/
│ └── *.sh|*.py|*.sql # deterministic, guarded helpers
└── examples/
└── *.md # worked examples / expected output
---
name: azpg-pgvector-rag
description: >
Design and implement vector / RAG search on Azure Database for PostgreSQL
Flexible Server using pgvector, azure_ai embeddings and DiskANN. Use when the
task involves semantic search, embeddings, RAG retrieval, or vector indexing
on Azure Postgres.
safety: read-write # read | read-write (our extension field)
invocation: explicit # auto | explicit (write skills = explicit)
azure_target: flexible-server
pg_versions: ">=14"
requires_extensions: [vector]
---safety, invocation, azure_target, pg_versions, requires_extensions
are project conventions layered on top of the standard name/description.
Skills are grouped into clusters. Each row is a candidate skill; ★ = MVP (built).
- ★
azpg-schema-design— tables, keys, constraints, naming jsonb-document-modeling— document-store patternspartitioning-strategy— declarative partitioning, pruningwindow-functions-and-ctes— advanced query constructiondata-types-and-domains— type selection, enums, domains
- ★
azpg-explain-analyze— read/interpret plans, spot regressions - ★
azpg-index-selection— btree/GIN/GiST/BRIN/HNSW/DiskANN choice vacuum-and-autovacuum-tuning— bloat, wraparound, statsstatistics-and-planner—ANALYZE, extended stats, planner knobsquery-rewrite-patterns— anti-patterns → optimised forms
- ★
azpg-pgvector-rag— vector/RAG (reference skill) fulltext-and-bm25— tsvector + pg_search/ParadeDB, hybrid + RRFqueues-with-pgmq— durable/ephemeral queues, SKIP LOCKEDcaching-patterns— unlogged tables, JSONB KV, TTLpostgis-geospatial— spatial types, indexes, queriestimeseries-timescaledb— hypertables, continuous aggregatescitus-scale-out— elastic clusters, distribution keys
- ★
azpg-ai-in-database—azure_aiembeddings & LLM calls from SQL chunking-and-ingestion— document chunking, ingestion pipelineshybrid-search-rrf— combine vector + lexical + reciprocal rank fusionvector-index-tuning— HNSW/DiskANN params, recall/latency trade-offs
- ★
azpg-config-tuning— server params, PgBouncer - ★
azpg-backup-pitr— automated backups, point-in-time restore replication-and-ha— zone-redundant HA, read replicas, failoverconnection-pooling— built-in PgBouncer, sizingmajor-version-upgrade— near-zero-downtime upgrade path
- ★
azpg-roles-rbac— roles, least privilege,GRANT, Entra auth row-level-security— RLS policies, multi-tenant isolationentra-id-auth— Microsoft Entra ID authenticationencryption-tls-cmk— TLS enforcement, customer-managed keysauditing-and-pgaudit— audit logging, compliance evidence
- ★
azpg-provision-iac— Bicep/Terraform/AVM provisioning scaling-and-storage— compute/storage scaling, auto-growmonitoring-and-alerts— Azure Monitor, metrics,pg_stat_statementscost-optimization— SKU right-sizing, reserved capacitywaf-alignment— Well-Architected review for the DB tier
migration-assessment— source analysis, compatibilityschema-and-data-migration— pgloader/DMS, cutoveroracle-mysql-to-postgres— dialect conversionmigration-validation— row counts, checksums, parity
- ★
azpg-stat-diagnostics—pg_stat_*, slow-query forensics incident-triage— AppLens / Azure Monitor triage flowalerting-and-slos— define SLOs, alert rules
- ★
azpg-when-not-to-use— break-out thresholds & trade-offs breakout-eventhubs-servicebus— messaging beyondpgmqbreakout-ai-search— search/vector beyondpgvectorat scalebreakout-cosmosdb— global distribution beyond JSONBbreakout-redis-enterprise— extreme-latency cache
The Right-Tool Advisor deliberately argues against the premise where the evidence warrants, recommending when and how to break out of the single- platform approach. It keeps the system honest.
Three complementary layers keep guidance current without constant skill rewrites.
Skills embed shell commands (!`command`) whose output is inlined into the
skill before the model reads it. We use this so skills read the live state
instead of hardcoding facts:
- live extension/version matrix —
SELECT extname, extversion FROM pg_extension - current server config —
az postgres flexible-server show/list - this month's platform changes — fetch Azure "What's new" feed
Ingest Tier-1 sources into Azure AI Search / Foundry IQ (hybrid + semantic). Skills carry procedure; the index carries exhaustive reference. Skills instruct: "for parameter specifics, query the index." This keeps the 3,500-page manual out of skill bodies and makes freshness an indexing problem (easier to automate) rather than a rewriting problem.
A scheduled workflow that:
- diffs upstream release notes / "What's new" since last run;
- re-runs the skills-builder to flag skills whose procedures changed (facts drift into the index automatically — only behavioural changes touch skills);
- opens a PR with proposed skill updates for human review.
┌─────────────────────────┐
upstream docs ─▶ Ingest → AI Search / │──▶ retrieval for all agents
(Tier 1) │ Foundry IQ (hybrid) │
└─────────────────────────┘
┌─────────────────────────┐
release notes ─▶ Scheduled reconciler │──▶ PR: skill procedure updates
│ (diff → skills-builder) │
└─────────────────────────┘
live instance ─▶ Dynamic injection at skill invocation (version-aware)
Tier 1 — canonical (ground truth):
- PostgreSQL official manual (Tutorial, SQL, Server Admin, Client Interfaces, Server Programming, Reference, Internals).
- Microsoft Learn — Azure Database for PostgreSQL Flexible Server,
azure_ai,pgvector, AVM/Bicep/Terraform module docs, Well-Architected. - Per-extension official docs: pgvector, PostGIS, Citus, TimescaleDB, pgmq, pg_cron, ParadeDB/pg_search, pgvectorscale, PgBouncer, Patroni.
Tier 2 — operational depth:
psql/pg_dump/pg_basebackupreferences,postgresql.confparams, system catalogs (pg_stat_*),EXPLAINsemantics.- Azure CLI/REST for PostgreSQL, azure-mcp Postgres tooling, azqr/WAF.
- Practitioner corpora (use-the-index-luke, pgMustard, Depesz, Cybertec, EDB) — cite, don't treat as canonical.
Tier 3 — living / telemetry:
- Release notes + Azure "What's new" feeds (freshness signal).
- The target instance's own catalogs (schema, extensions, config, plans) as dynamic context, not baked knowledge.
Split skills by blast radius; enforce via invocation control + guarded scripts.
| Class | Examples | Invocation | Guardrails |
|---|---|---|---|
| Read / inspect | schema, EXPLAIN, pg_stat_*, config audit |
auto |
none needed; safe |
| Write / mutate | DDL, param writes, provisioning, upgrade, failover | explicit |
plan → dry-run / txn-wrapped → confirm |
Rules:
- Mutating skills MUST present a plan and require explicit confirmation before execution.
- Destructive operations ship as
scripts/that are transaction-wrapped and support--dry-run; the model does not free-hand destructive SQL. - Mutating skills should run in a subagent to contain blast radius.
- A backup/PITR precheck is required before schema-destructive operations.
Do not build one omniscient agent — but also do not reflexively build a roster of
specialists. Current agent-engineering practice (Anthropic's Agent Skills
standard; Cognition's "Don't Build Multi-Agents", 2025) is that skills are
auto-invoked by a general-purpose agent from their description metadata —
they already are the routing layer — and that a **single well-architected agent
- strong context engineering** beats a multi-agent fan-out for most tasks (fan-out adds coordination cost, context fragmentation, weaker traceability).
So we ship a small, deliberate set:
| Agent | Owns / draws on | Produces |
|---|---|---|
azure-pg-expert (umbrella) |
all skills; shared "connect + inspect" context | posture, task decomposition, sequencing, gated writes |
azure-pg-diagnostician (specialist) |
read-only surfaces of C9/C2/C5/C10 | incident triage reports; hands remediation back to the umbrella |
The umbrella agent holds shared context (target instance, PG + extension version matrix) and reconciles cross-cutting conflicts (e.g. a security control that harms performance). The diagnostician is the one justified split (see §7.1).
An earlier design imagined an Orchestrator + seven specialists (Architect, Performance, AI/RAG, DBA/Reliability, Security, SRE, Right-Tool Advisor). Treat that as a capability map — it documents which skill clusters exist and who conceptually owns them — not a mandate to run eight standing agents.
Applied here:
- Default: one umbrella agent.
azure-pg-expertsets the posture (inspect-live-first, read/write safety split, least privilege, cite Learn) and lets theazpg-*skills auto-trigger and carry the procedure. - Split out a specialist only for a real boundary: a permission boundary
(e.g.
azure-pg-diagnostician— a read-only diagnostician with no write tools, safe against prod), context isolation (a large parallel investigation), or a divergent persona that can't coexist. - Blast-radius subagents for mutating skills (§6) are a runtime pattern, not a standing persona.
Taxonomy, agents, freshness, safety.
azpg-pgvector-ragend-to-end (exercisesazure_ai, dynamic injection, read/write split, bundled scripts).azure-pg-expertumbrella agent.
- ★ MVP skills across C1–C10 (11 skills built).
azure-pg-diagnosticianread-only specialist.- ✅ Validated against a sandbox Flexible Server — see
demos/pgflowand the iteration-1 evaluation.
- Fill remaining (non-★) skills across the taxonomy.
- Stand up the AI Search index (Layer B) + scheduled reconciler (Layer C).
- Add the Migration cluster (C8).
- Package to the Agent Skills open standard; publish to GitHub with docs and examples.