pg-aiguide is a knowledge and tooling project that gives AI coding assistants version-aware PostgreSQL documentation and curated database practices. Developers use it through agent skills, an MCP server, or a Claude Code plugin to help coding tools generate better PostgreSQL code. The catalogue entries are its skills, instructions, MCP integration, and rule.
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 timescale/pg-aiguide --skill timescaledb-hyperfunctionsgit clone --depth 1 https://github.com/timescale/pg-aiguideWrote 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/timescale/pg-aiguide/timescaledb-hyperfunctions)<a href="https://agentmods.dev/skills/timescale/pg-aiguide/timescaledb-hyperfunctions"><img src="https://agentmods.dev/badge/skills/timescale/pg-aiguide/timescaledb-hyperfunctions/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/timescale/pg-aiguide/timescaledb-hyperfunctions"><img src="https://agentmods.dev/badge/skills/timescale/pg-aiguide/timescaledb-hyperfunctions.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.00298 | $0.05507 |
| Opus 5.5 | $0.00119 | $0.02203 |
| Sonnet 5.5 | $0.00060 | $0.01101 |
| Haiku 4.5 | $0.00030 | $0.00551 |
Grade A, and why
timescaledb-hyperfunctions 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 8d 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 — 375 lines — stays where its author put it; the contents beside it link to each section on GitHub.
TimescaleDB Toolkit Hyperfunctions
Hyperfunctions are SQL aggregates and accessors from the timescaledb_toolkit extension for analysis that plain PostgreSQL aggregates handle badly: percentiles that can be re-aggregated, rates over resetting counters, averages over irregular samples, uptime, state durations, and more.
Setup
CREATE EXTENSION IF NOT EXISTS timescaledb_toolkit; -- preinstalled on Tiger Cloud
SELECT extversion FROM pg_extension WHERE extname = 'timescaledb_toolkit';
ALTER EXTENSION timescaledb_toolkit UPDATE; -- after upgrading the package
Only use functions from the default schema in persistent objects. Anything in the toolkit_experimental schema can change between releases, and ALTER EXTENSION ... UPDATE drops views, continuous aggregates, and functions that depend on it. All functions in this skill are stable.
The Two-Step Pattern (read this first)
Nearly every hyperfunction works in two steps:
- An aggregate builds a compact summary (
percentile_agg(val)→uddsketch,time_weight(...)→timeweightsummary, ...). - An accessor extracts a result from the summary (
approx_percentile(0.95, summary),average(summary), ...).
-- Function-call style
SELECT approx_percentile(0.95, percentile_agg(latency_ms)) FROM requests;
-- Arrow style (same result, reads left to right, chains multiple accessors)
SELECT percentile_agg(latency_ms) -> approx_percentile(0.95) FROM requests;
The pattern exists so summaries can be stored and re-aggregated:
rollup(summary)merges summaries correctly. Use it to go from hourly to daily buckets.- Combining entities depends on the summary type. Distribution summaries (
percentile_agg,uddsketch,tdigest,stats_agg,hyperloglog,mcv_agg,min_n/max_n) can be rolled up across entities, e.g. one p99 for all hosts. Time-series summaries (time_weight,counter_agg,gauge_agg,heartbeat_agg,state_agg) describe one series. They can only be rolled up over consecutive, non-overlapping time ranges of the same entity: rolling up overlapping summaries from different hosts raises an ordering error. Compute the per-entity result first, then combine the numbers (e.g.SUMof per-host rates for a fleet-wide rate). - Never average averages, percentiles, or rates.
AVG(p95_hourly)is not a daily p95.rollup(hourly_sketch) -> approx_percentile(0.95)is the correct value. - Store the summary in a continuous aggregate, not the final number. Then any accessor works at query time.
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.
- 8d ago First seen · 375 lines · 298 tokens per session scan A 36329e273094
timescaledb-hyperfunctions is a skill published in the GitHub repository timescale/pg-aiguide (1,869 stars, last pushed yesterday), licensed Apache-2.0. It adds 298 tokens to every session and 5,507 once invoked, about $0.0012 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-10-08.
Other skills, from other repositories
database-optimizer
Optimizes database queries and improves performance across PostgreSQL and MySQL systems. Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.
postgres-pro
Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.
kysely
Guidelines for developing with Kysely, a type-safe TypeScript SQL query builder with autocompletion support.
postgresql-best-practices
PostgreSQL development best practices for schema design, query optimization, and database administration.
pdlc-db-migrate
A database migration manager driven by database design documents. A migration is a versioned script that changes a database structure and can also undo that change.
pdlc-db-design
A database design workflow that turns an existing product requirements document and, when available, API design into a database plan. It describes entities, fields, links, indexes, constraints, and an entity-relationship diagram, which shows how data types connect.