# Timescaledb hyperfunctions

> Timescaledb hyperfunctions is an open-source agent skill for analytics and data. Lets your agent write analytical SQL with TimescaleDB Toolkit hyperfunctions. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/timescale/pg-aiguide/tree/main/skills/timescaledb-hyperfunctions
- **Repository:** https://github.com/timescale/pg-aiguide
- **GitHub stars:** 1,892
- **License:** Apache-2.0
- **Skill name:** timescaledb-hyperfunctions
- **Collection:** https://github.com/timescale/pg-aiguide
- **Categories:** [analytics and data](https://ai-powered.com/categories/analytics-and-data)
- **Listing updated:** 2026-12-04

## About

This skill gives the agent a working reference for the timescaledb_toolkit extension, covering re-aggregatable percentile sketches, statistical summaries, time-weighted averages, counter and gauge rates, heartbeat uptime, state durations, candlesticks, approximate distinct counts, top-N and downsampling. It explains the two-step pattern of building a summary with an aggregate and reading results with an accessor, so summaries can be stored in continuous aggregates and rolled up later.

The guidance includes concrete SQL examples and a list of common mistakes, such as averaging precomputed percentiles, applying counter logic to gauges, rolling up time-series summaries across entities, and building views on experimental schema objects that get dropped on extension updates. It also notes which results are approximate and which accessors exist only in function form.

Using the skill requires PostgreSQL 15 or later with TimescaleDB and the timescaledb_toolkit extension, version 1.16 or newer, with gauge_agg needing 1.25 or newer. Queries are written in SQL against the user's own tables.

## When your agent uses it

> Use this skill when writing analytical SQL over time-series data with the TimescaleDB Toolkit (timescaledb_toolkit extension) hyperfunctions: approximate percentiles, statistical summaries, time-weighted averages, counter/gauge rates, uptime/heartbeat tracking, state durations, OHLC candlesticks, approximate distinct counts, top-N, and downsampling. **Trigger when user asks to:** - Compute percentiles/medians/p95/p99 over large or rolled-up time-series data - Compute rates or deltas from monotonic counters (Prometheus-style) or gauges - Compute time-weighted averages or integrals over irregularly sampled data - Track uptime/downtime from heartbeats, or time spent in each state - Build OHLC/candlestick or VWAP data for financial ticks - Store re-aggregatable summaries in continuous aggregates (two-step aggregation, rollup) - Approximate COUNT DISTINCT, find top-N / most frequent values, or downsample for charts **Keywords:** timescaledb_toolkit, hyperfunctions, percentile_agg, uddsketch, tdigest, approx_perc

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/timescale/pg-aiguide/tree/HEAD/skills/timescaledb-hyperfunctions)
- [License: Apache-2.0](https://github.com/timescale/pg-aiguide/tree/HEAD/skills/timescaledb-hyperfunctions)

## Features

- **Re-aggregatable percentiles:** Covers percentile sketches that can be stored and combined later to get p50, p95 or p99 across rolled-up data.
- **Counter and gauge rates:** Explains computing deltas and rates from resetting counters and from gauges that move both ways.
- **Time-weighted averages:** Shows how to weight values by how long they applied, for irregularly sampled readings.
- **Uptime and state tracking:** Covers heartbeat-based uptime, outage ranges and time spent in each state.
- **Continuous aggregate patterns:** Shows storing summaries in continuous aggregates and rolling them up hierarchically from hourly to daily.
- **Candlesticks and top-N:** Provides OHLC and VWAP calculations for ticks, plus approximate distinct counts and top-N queries.

## Good for

- Compute p95 and p99 latency per service in five-minute buckets
- Calculate per-second request rates from a Prometheus-style byte counter
- Find how long each machine spent in the running or error state each day
- Build hourly OHLC candles and VWAP from raw trade ticks
- Store daily summaries and roll them up into a fleet-wide percentile

## Install

### Claude Code

This skill ships in the `pg` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add timescale/pg-aiguide
/plugin install pg@aiguide
```

Or copy only this skill to `~/.claude/skills/timescaledb-hyperfunctions`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/timescaledb-hyperfunctions &&
cp -R "$tmp/skills/timescaledb-hyperfunctions" ~/.claude/skills/timescaledb-hyperfunctions &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/timescaledb-hyperfunctions` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/timescaledb-hyperfunctions` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/timescaledb-hyperfunctions &&
cp -R "$tmp/skills/timescaledb-hyperfunctions" ~/.agents/skills/timescaledb-hyperfunctions &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/timescaledb-hyperfunctions` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/timescaledb-hyperfunctions` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/timescaledb-hyperfunctions &&
cp -R "$tmp/skills/timescaledb-hyperfunctions" ~/.cursor/skills/timescaledb-hyperfunctions &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/timescaledb-hyperfunctions` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/timescale/pg-aiguide.git --path skills/timescaledb-hyperfunctions
```

Or copy the folder to `~/.gemini/skills/timescaledb-hyperfunctions` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/timescaledb-hyperfunctions`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/timescaledb-hyperfunctions &&
cp -R "$tmp/skills/timescaledb-hyperfunctions" ~/.copilot/skills/timescaledb-hyperfunctions &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/timescaledb-hyperfunctions` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/timescale/pg-aiguide.git
```

Then copy `pg-aiguide/skills/timescaledb-hyperfunctions` into your agent's skills folder as `timescaledb-hyperfunctions`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill require to be installed?

PostgreSQL 15 or later with TimescaleDB and the timescaledb_toolkit extension, version 1.16 or newer; gauge_agg needs version 1.25 or newer.

### Which functions should be used in persistent objects?

Only functions from the default schema. Anything in toolkit_experimental can change between releases, and extension updates drop views and continuous aggregates that depend on it.

### Are the results exact?

Percentiles, tdigest, hyperloglog and mcv_agg results are approximate; the skill says to report this when precision matters.

### When should gauge_agg be used instead of counter_agg?

Use counter_agg for values that only fall on restarts, and gauge_agg when drops are real changes such as memory being freed.

### How do I install Timescaledb hyperfunctions in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/timescaledb-hyperfunctions to use it in all your projects, or to .claude/skills/timescaledb-hyperfunctions in one project. Or install the pg plugin, which includes it: /plugin marketplace add timescale/pg-aiguide, then /plugin install pg@aiguide.

### Does Timescaledb hyperfunctions run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Timescaledb hyperfunctions?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Timescaledb hyperfunctions?

The closest alternatives to Timescaledb hyperfunctions are Data analysis, Data analysis, Duo proprietary data reports, Kql and Famou data analysis.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Data analysis](https://ai-powered.com/skills/data-analysis-melandlabs): Data analysis is an open-source agent skill for analytics and data.
- [Data analysis](https://ai-powered.com/skills/data-analysis-superhero-tech): Data analysis is an open-source agent skill for analytics and data.
- [Duo proprietary data reports](https://ai-powered.com/skills/duo-proprietary-data-reports): Duo proprietary data reports is an open-source agent skill for analytics and data.
- [Kql](https://ai-powered.com/skills/kql): Kql is an open-source agent skill for knowledge and memory.
- [Famou data analysis](https://ai-powered.com/skills/famou-data-analysis): Famou data analysis is an open-source agent skill for analytics and data.
- [Build charts with typed params](https://ai-powered.com/skills/build-charts-with-typed-params): Build charts with typed params is an open-source agent skill for analytics and data.
- [Scheduled report refresh](https://ai-powered.com/skills/scheduled-report-refresh): Scheduled report refresh is an open-source agent skill for analytics and data.
- [Quantitative analysis](https://ai-powered.com/skills/quantitative-analysis): Quantitative analysis is an open-source agent skill for analytics and data.

---
Source: https://ai-powered.com/skills/timescaledb-hyperfunctions
