postgres-patterns
PostgreSQL database patterns for query optimization, schema design, indexing, and security.
Skill by AshenDulsanka
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ashendulsanka-postgres-patterns
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, backend, data, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/postgres-patterns
What's inside
- Skill name
postgres-patterns- Description
- PostgreSQL database patterns for query optimization, schema design, indexing, and security. Use only when PostgreSQL is confirmed in the codebase or explicitly named by the user, and the task involves SQL, migrations, schemas, slow queries, Row Level Security, indexes, or connection pooling. Do not trigger for generic data work or a different database. Based on Supabase-leaning Postgres practice.
- License
- MIT
- Instructions
- 144 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- openai.yaml · agents/
SKILL.md (first lines)
# PostgreSQL Patterns
Quick reference for PostgreSQL best practices. For deeper org-specific database reviews, follow your team's own review workflow alongside this guide.
## When to Activate
- Writing SQL queries or migrations
- Designing database schemas
- Troubleshooting slow queries
- Implementing Row Level Security
- Setting up connection pooling
## Quick Reference
### Index Cheat Sheet
| Query Pattern | Index Type | Example |
|--------------|------------|---------|
| `WHERE col = value` | B-tree (default) | `CREATE INDEX idx ON t (col)` |
| `WHERE col > value` | B-tree | `CREATE INDEX idx ON t (col)` |
| `WHERE a = x AND b > y` | Composite | `CREATE INDEX idx ON t (a, b)` |
| `WHERE jsonb @> '{}'` | GIN | `CREATE INDEX idx ON t USING gin (col)` |
| `WHERE tsv @@ query` | GIN | `CREATE INDEX idx ON t USING gin (col)` |
| Time-series ranges | BRIN | `CREATE INDEX idx ON t USING brin (col)` |
### Data Type Quick Reference
| Use Case | Correct Type | Avoid |
|----------|-------------|-------|
| IDs | `bigint` or `uuid` | `int`, unindexed text IDs |
| Strings | `text` | `varchar(255)` |
| Timestamps | `timestamptz` | `timestamp` |
| Money | `numeric(10,2)` | `float` |
| Flags | `boolean` | `varchar`, `int` |
### Common Patterns
**Composite Index Order:**
```sql
-- Equality columns first, then range columns
CREATE INDEX idx ON orders (status, created_at);
-- Works for: WHERE status = 'pending' AND created_at > '2024-01-01'
```
**Covering Index:**
```sql
CREATE INDEX idx ON users (email) INCLUDE (name, created_at);
-- Avoids table lookup for SELECT email, name, created_at
```
**Partial Index:**
```sql
CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL;
-- Smaller index, only includes active users
```
**RLS Policy (Supabase auth example):**
```sql
CREATE POLICY policy ON orders
USING ((SELECT auth.uid()) = user_id); -- Wrap in SELECT!
```
**UPSERT:**
```sql
INSERT INTO settings (user_id, key, value)
VALUES (123, 'theme', 'dark')
ON CONFLICT (user_id, key)
DO UPDATE SET value = EXCLUDED.value;
```
**Cursor Pagination:**
```sql
SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20;
-- O(1) vs OFFSET which is O(n)
```
**Queue Processing:**
```sql
UPDATE jobs SET status = 'processing'
WHERE id = (
SELECT id FROM jobs WHERE status = 'pending'
ORDER BY created_at LIMIT 1
FOR UPDATE SKIP LOCKED
) RETURNING *;
```
### Anti-Pattern Detection
```sql
-- Find unindexed foreign keys
SELECT conrelid::regclass, a.attname
FROM pg_constraint c
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey)
WHERE c.contype = 'f'
AND NOT EXISTS (
SELECT 1 FROM pg_index i
WHERE i.indrelid = c.conrelid AND a.attnum = ANY(i.indkey)
);
-- Find slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
WHERE mean_exec_time > 100
ORDER BY mean_exec_time DESC;
-- Check table bloat
SELECT relname, n_dead_tup, last_vacuum
FROM pg_stat_user_tables
WHERE n_dead_tup > 1000
ORDER BY n_dead_tup DESC;
```
### Configuration Review Checklist
```sql
-- Review only. Do not run blindly; tune for the deployment environment.
-- Connection limits (adjust for RAM, pooler, and workload)
ALTER SYSTEM SET max_connections = 100;From AshenDulsanka/agent-arche, MIT.
More from AshenDulsanka/agent-arche
- 0.571score
klaviyo-operations
AshenDulsanka
Diagnose and safely operate Klaviyo profiles, events, metrics, flows, campaigns, templates, catalogs, consent, and Shopify-synced data.
SkillBFreshness: B★ 4Claude Code +9 - 0.571score
klaviyo-product-recommendations
AshenDulsanka
Diagnose incorrect, duplicated, missing, or irrelevant Klaviyo product recommendations across email Product blocks, product feeds, Next Best Product, Customer…
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
orchestrate
AshenDulsanka
Route a complex, divisible engineering task through the project-scoped Codex orchestrator and specialized subagents.
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
commerce-integration-debugging
AshenDulsanka
Trace customer, catalog, order, event, webhook, and recommendation failures across Shopify, Klaviyo, and a Django backend.
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
design
AshenDulsanka
Consolidated UI/UX design skill for product-fit direction, new interface implementation, redesigns, animation and micro-interactions, GSAP/ScrollTrigger…
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
django-commerce-backend
AshenDulsanka
Build and debug Django services that integrate with Shopify and Klaviyo APIs, OAuth, events, catalogs, and webhooks.
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
git
AshenDulsanka
Consolidated Git workflow skill.
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
security-review
AshenDulsanka
Threat-model, test, and review security-sensitive code changes.
SkillBFreshness: B★ 4Claude Code +9 - 0.566score
project-startup
AshenDulsanka
Optional first-run setup for a new or unconfigured Agent Arche project.
SkillBFreshness: B★ 4Claude Code +9 - 0.566score
implement
AshenDulsanka
Implement requested code changes end to end from a prompt, spec, or ticket.
SkillBFreshness: B★ 4Claude Code +9 - 0.566score
klaviyo-customer-agent
AshenDulsanka
Configure, test, and troubleshoot Klaviyo Customer Agent skills, tools, Guidance, prerequisites, routing, channel behavior, and escalations.
SkillBFreshness: B★ 4Claude Code +9 - 0.549score
diagnosing-bugs
AshenDulsanka
Diagnosis loop for hard bugs and performance regressions.
SkillBFreshness: B★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 12, 2026 (2 months ago)
- Last release
- Aug 20, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/AshenDulsanka/agent-arche
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from AshenDulsanka
- 0.571score
klaviyo-operations
AshenDulsanka
Diagnose and safely operate Klaviyo profiles, events, metrics, flows, campaigns, templates, catalogs, consent, and Shopify-synced data.
SkillBFreshness: B★ 4Claude Code +9 - 0.571score
klaviyo-product-recommendations
AshenDulsanka
Diagnose incorrect, duplicated, missing, or irrelevant Klaviyo product recommendations across email Product blocks, product feeds, Next Best Product, Customer…
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
git
AshenDulsanka
Consolidated Git workflow skill.
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
design
AshenDulsanka
Consolidated UI/UX design skill for product-fit direction, new interface implementation, redesigns, animation and micro-interactions, GSAP/ScrollTrigger…
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
commerce-integration-debugging
AshenDulsanka
Trace customer, catalog, order, event, webhook, and recommendation failures across Shopify, Klaviyo, and a Django backend.
SkillBFreshness: B★ 4Claude Code +9 - 0.569score
django-commerce-backend
AshenDulsanka
Build and debug Django services that integrate with Shopify and Klaviyo APIs, OAuth, events, catalogs, and webhooks.
SkillBFreshness: B★ 4Claude Code +9
Cite this page
postgres-patterns skill. Agent Mart. https://agentmart.dev/skills/ashendulsanka-postgres-patterns (last updated 2026-10-24)