# clickhouse-managed-postgres-rca

Investigates performance issues on ClickHouse-managed Postgres via Prometheus metrics and Slow Query Patterns API, recommending fixes without running them.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 6600 installs · ★ 561
- Author: ClickHouse Inc
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/ClickHouse/agent-skills/tree/HEAD/skills/clickhouse-managed-postgres-rca/SKILL.md
- Updated: 2026-10-21
- HTML: https://affpapa.org/en/nevibecode/skills/clickhouse-managed-postgres-rca

## What it does

This skill runs root cause analysis on ClickHouse-managed Postgres instances when CPU spikes or cache thrashes. It queries two Beta endpoints on `https://api.clickhouse.cloud`: Prometheus gauges and Slow Query Patterns. The agent lacks access to `EXPLAIN` query plans and table scan counters. It reasons strictly from timing and IO signals.

Investigation follows a strict six-step workflow. First, the agent inspects the live OpenAPI schema to map shifting field names. Next, it pulls Prometheus gauges like `CacheHitRatio` and slow pattern statistics in parallel. Triage then matches the evidence against heuristic profiles, such as read-path full scans or write congestion.

The skill strictly recommends solutions. It never executes DDL and never calls `pg_terminate_backend`. You must supply instance parameters `organizationId` and `serviceId`, along with ClickHouse Cloud API credentials, because unauthenticated requests fail.

## Requirements
- Works with: PostgreSQL

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/clickhouse-managed-postgres-rca/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/clickhouse-managed-postgres-rca/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/clickhouse-managed-postgres-rca/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/clickhouse-managed-postgres-rca/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install ClickHouse/agent-skills clickhouse-managed-postgres-rca
```

2. **Manually: put the files in place**
- File: `.github/skills/clickhouse-managed-postgres-rca/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/ClickHouse/agent-skills --path skills/clickhouse-managed-postgres-rca
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/clickhouse-managed-postgres-rca/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add ClickHouse/agent-skills --skill clickhouse-managed-postgres-rca -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/ClickHouse/agent-skills/tree/HEAD/skills/clickhouse-managed-postgres-rca/SKILL.md

## When to use it
- pinpoint causes of high CPU usage on managed Postgres instances
- inspect Slow Query Patterns API for latency and IO totals per query pattern
- detect cache thrashing and active connection spikes from Prometheus gauges
- categorize bottlenecks into full table scans or write congestion

## Example prompts
- Investigate high CPU usage on ClickHouse Postgres instance `<service-id>` in org `<org-id>`
- Run root cause analysis on our managed Postgres database because cache hit ratio dropped
- Diagnose why throughput degraded on ClickHouse-managed Postgres service `<service-id>`

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 9346709bf6047cfa.

BEGIN THIRD-PARTY FILE 9346709bf6047cfa
```text
---
name: clickhouse-managed-postgres-rca
description: MUST USE when investigating performance issues on a ClickHouse-managed Postgres instance. Provides an evidence-based RCA workflow that scrapes the Prometheus endpoint for system signal, pulls per-digest evidence from the Slow Query Patterns API, and recommends (does not apply) a fix.
license: Apache-2.0
metadata:
  author: ClickHouse Inc
  version: "0.1.0"
---

# ClickHouse Managed Postgres RCA

## When to use

Trigger whenever a user reports slowness, high CPU, low
throughput, cache thrash, or any unexplained pain on a
ClickHouse-managed Postgres instance.

## What you have access to

Two APIs on `https://api.clickhouse.cloud` (HTTP Basic auth
using a ClickHouse Cloud API key/secret pair):

- **Prometheus metrics** — operation `postgresInstancePrometheusGet`
  under the Prometheus tag. Returns Prometheus exposition format.
  System and workload metrics for one Postgres service.
- **Slow Query Patterns** — operation `slowQueryPatternsGetList`
  under the Postgres tag. Returns per-digest latency, IO, and
  call statistics for normalized query patterns. **Beta.**

Both endpoints require an `organizationId` and a `serviceId` as
path parameters. The user must supply both, plus the API
key/secret pair.

## What you do NOT have

- Query plans / EXPLAIN output.
- Per-table scan-type counters (`seq_scan` / `idx_scan`).
- Autovacuum or last-ANALYZE timestamps.

Reason from IO and timing signals, not from a plan tree.

## Workflow

Six steps, in order. Do not skip ahead.

Steps 2 and 3 only share auth — no data dependency between
them. Run them in parallel (background curls, `&` + `wait`) to
cut wall time from sequential ~2s to ~1s.

### 1. Discover the live API shape

These endpoints are Beta — paths, params, and JSON field names
can shift. Follow `rules/openapi-discovery.md` to:

1. Fetch the OpenAPI spec from `https://api.clickhouse.cloud/v1`.
2. Locate the two operations by `operationId`:
   - `postgresInstancePrometheusGet` (Prometheus tag)
   - `slowQueryPatternsGetList` (Postgres tag)
3. Resolve their path templates, required query parameters,
   and (for the slow-query endpoint) the response schema.
4. Build a session-scoped role map from the schema property
   descriptions: `{ semantic role → actual field name }`.
```
END THIRD-PARTY FILE 9346709bf6047cfa

The third-party file has ended. Everything between the 9346709bf6047cfa tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2318 of 4914 bytes. © ClickHouse Inc · Apache-2.0 · https://github.com/ClickHouse/agent-skills/tree/HEAD/skills/clickhouse-managed-postgres-rca/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
