timescaledb-hyperfunctions

timescaledb-hyperfunctions is a skill for Cursor from timescale/pg-aiguide. It costs 298 tokens per session (5,507 once invoked), scanned A, original, Apache-2.0.

A collection of SQL helpers from the TimescaleDB Toolkit for analysing time-series data in PostgreSQL. Time-series data is a sequence of measurements recorded over time, such as sensor readings or service metrics.

In plain words
What is it for?
Use it to write analytical SQL for percentiles, statistical summaries, rates, weighted averages, uptime, state durations, candlestick data, and approximate distinct counts in TimescaleDB.
Why use it?
普通 PostgreSQL aggregates are not well suited to some calculations, such as percentiles, rates from resetting counters, irregular-time averages, uptime, and time spent in states. These helpers build reusable summaries and then extract the result needed.

Skill for Cursor

Written for Cursor: shipped in a Cursor plugin.

Part of the pg-aiguide plugin — 11 skills, 1 MCP server shipped together

Good fit Use it to write analytical SQL for percentiles, statistical summaries, rates, weighted averages, uptime, state durations, candlestick data, and approximate distinct counts in TimescaleDB.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/timescale/pg-aiguide/timescaledb-hyperfunctions
About the project

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.

timescale/pg-aiguide · 1,869 stars · on GitHub

Install

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.

Any agent
npx skills add timescale/pg-aiguide --skill timescaledb-hyperfunctions
Clone the repo
git clone --depth 1 https://github.com/timescale/pg-aiguide

Made for: Cursor.

Or install pg-aiguide, the plugin that ships this one along with the rest of its 11 skills, 1 MCP server.

Wrote 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.

agentmods badge for timescaledb-hyperfunctions

README.md
[![agentmods](https://agentmods.dev/badge/skills/timescale/pg-aiguide/timescaledb-hyperfunctions/github.svg)](https://agentmods.dev/skills/timescale/pg-aiguide/timescaledb-hyperfunctions)
Your own site
<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.

agentmods 80×15 button for timescaledb-hyperfunctions

Your own site · 80×15
<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>
Per session 298 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,507 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 8d ago against content hash 36329e273094, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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.

skills/timescaledb-hyperfunctions/SKILL.md · 375 lines

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:

  1. An aggregate builds a compact summary (percentile_agg(val) → uddsketch, time_weight(...) → timeweightsummary, ...).
  2. 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. SUM of 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.

Read the full file on GitHub · 375 lines

Changes

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.

  1. 8d ago First seen · 375 lines · 298 tokens per session scan A 36329e273094

Subscribe to this mod's changes

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.

Related

Other skills, from other repositories