Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add kid-sid/codex-spellbook --skill postgresqlgit clone --depth 1 https://github.com/kid-sid/codex-spellbookWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/kid-sid/codex-spellbook/postgresql)<a href="https://agentmods.dev/skills/kid-sid/codex-spellbook/postgresql"><img src="https://agentmods.dev/badge/skills/kid-sid/codex-spellbook/postgresql/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/kid-sid/codex-spellbook/postgresql"><img src="https://agentmods.dev/badge/skills/kid-sid/codex-spellbook/postgresql.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00038 | $0.03709 |
| Opus 5.5 | $0.00015 | $0.01484 |
| Sonnet 5.5 | $0.00008 | $0.00742 |
| Haiku 4.5 | $0.00004 | $0.00371 |
Grade A, and why
postgresql scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 462 lines — stays where its author put it; the contents beside it link to each section on GitHub.
PostgreSQL Patterns
Advanced querying, indexing, and schema design for PostgreSQL 14+.
When to Activate
- Writing window functions, CTEs, or recursive queries
- Querying JSONB columns
- Designing indexes or diagnosing missing indexes
- Interpreting
EXPLAIN ANALYZEoutput - Handling concurrent writes (upsert, locking, transactions)
- Full-text search without Elasticsearch
- Planning schema migrations safely
Window Functions
Window functions compute values across rows related to the current row — without collapsing them like GROUP BY.
-- ROW_NUMBER: unique rank per partition
SELECT
user_id,
order_id,
total,
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC) AS rn
FROM orders;
-- Get each user's latest order
SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC) AS rn
FROM orders
) ranked
WHERE rn = 1;
-- RANK vs DENSE_RANK vs ROW_NUMBER
-- RANK: 1,2,2,4 (gaps after tie)
-- DENSE_RANK: 1,2,2,3 (no gaps)
-- ROW_NUMBER: 1,2,3,4 (always unique)
-- Running total
SELECT
date,
amount,
SUM(amount) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_total
FROM transactions;
-- Moving average (last 7 days)
SELECT
date,
value,
AVG(value) OVER (ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS ma7
FROM metrics;
-- LAG/LEAD: access previous/next row
SELECT
date,
revenue,
LAG(revenue) OVER (ORDER BY date) AS prev_revenue,
LEAD(revenue) OVER (ORDER BY date) AS next_revenue,
revenue - LAG(revenue) OVER (ORDER BY date) AS day_over_day
FROM daily_revenue;
-- NTILE: divide rows into buckets
SELECT user_id, spend,
NTILE(4) OVER (ORDER BY spend DESC) AS quartile -- 1=top 25%
FROM user_spend;
CTEs (Common Table Expressions)
-- Basic CTE — improves readability, reuse within query
WITH active_users AS (
SELECT id, name, email
FROM users
WHERE status = 'active' AND last_login > NOW() - INTERVAL '30 days'
),
user_orders AS (
SELECT user_id, COUNT(*) AS order_count, SUM(total) AS lifetime_value
FROM orders
WHERE status = 'completed'
GROUP BY user_id
)
SELECT
u.name,
u.email,
COALESCE(o.order_count, 0) AS orders,
COALESCE(o.lifetime_value, 0) AS ltv
FROM active_users u
LEFT JOIN user_orders o ON u.id = o.user_id
ORDER BY o.lifetime_value DESC NULLS LAST;
-- Recursive CTE — hierarchies, trees, paths
WITH RECURSIVE category_tree AS (
-- Anchor: start from roots
SELECT id, name, parent_id, 0 AS depth, ARRAY[id] AS path
FROM categories
WHERE parent_id IS NULL
UNION ALL
-- Recursive: join children
SELECT c.id, c.name, c.parent_id, ct.depth + 1, ct.path || c.id
FROM categories c
INNER JOIN category_tree ct ON c.parent_id = ct.id
)
SELECT * FROM category_tree ORDER BY path;
-- Writable CTEs (INSERT/UPDATE/DELETE in CTE)
WITH deleted_sessions AS (
DELETE FROM sessions
WHERE expires_at < NOW()
RETURNING user_id, session_id
)
INSERT INTO audit_log (user_id, action, metadata)
SELECT user_id, 'session_expired', jsonb_build_object('session_id', session_id)
FROM deleted_sessions;
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 462 lines · 38 tokens per session scan A 165204962e83
postgresql is a skill published in the GitHub repository kid-sid/codex-spellbook (22 stars, last pushed 6mo ago), licensed MIT. It adds 38 tokens to every session and 3,709 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
postgresql compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| postgresqlkid-sid/codex-spellbook | Skill | 22 | 6mo ago | MIT | A | 38 | Claude Code, Codex |
| alloydb-basicsgoogle/skills | Skill | 25k | yesterday | Apache-2.0 | A | 72 | Claude Code, Codex |
| postgresql-table-designwshobson/agents | Skill | 43k | 2d ago | MIT | A | 37 | Claude Code |
| db-repairgarrytan/gbrain | Skill | 34k | today | MIT | A | 96 | Claude Code |
| dsqlawslabs/agent-plugins | Skill | 956 | yesterday | Apache-2.0 | A | 247 | Claude Code |
| volcengine-rds-postgresqlbytedance/agentkit-samples | Skill | 496 | yesterday | Apache-2.0 | A | 63 | Claude Code, Codex |
| postgresdbericrisco/rsc-harness | Skill | 695 | yesterday | MIT | A | 91 | Claude Code, Codex |