Agent skill

Cpu Profile

by ClickHouse in ClickHouse/ClickHouse

Profile a ClickHouse query using the sampling query profiler and system.tracelog.

Apache-2.0Auto-check: notesDatabases

Install Cpu Profile

skills CLI
$ npx skills add ClickHouse/ClickHouse --skill cpu-profile -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ClickHouse/ClickHouse cpu-profile --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ClickHouse/ClickHouse.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/cpu-profile .claude/skills/cpu-profile && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cpu-profile
GitHub stars
50k
Token cost
~1.9k tokens
SKILL.md length
557 words
Files
1
Skills in repo
24
Repo updated
First seen
Licence
Apache-2.0

At a glance

Profile a ClickHouse query using the sampling query profiler and system.tracelog.

  • Works in 5 steps: Determine what to profile → Execute query with profiling → Collect and analyze trace data → …
  • The user wants to find CPU hotspots
  • SKILL.md covers Arguments, Step 1 — Determine what to…, Step 2 — Execute query with… and Step 3 — Collect and analyze…, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Cpu Profile is an agent skill from ClickHouse/ClickHouse. Profile a ClickHouse query using the sampling query profiler and system.tracelog. Use when the user wants to find CPU hotspots, analyze where time is spent in a query, or investigate performance bottlenecks.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Data warehousing and Performance optimization. It works with ClickHouse and SQL. The repository describes itself as: ClickHouse® is a real-time analytics database management system. The licence is Apache-2.0.

When your agent uses it

  • The user wants to find CPU hotspots
  • Analyze where time is spent in a query
  • Investigate performance bottlenecks

Example prompts

  • “/cpu-profile”

Requirements

  • Pre-approved tools (allowed-tools): Task, Bash, Read, Grep, Glob, AskUserQuestion

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Determine what to profile
  2. Execute query with profiling
  3. Collect and analyze trace data
  4. Synthesize results
  5. Offer drill-down options

What it can do on your machine

Read from SKILL.md and the folder at commit cd023af. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Task
    • Bash
    • Read
    • Grep
    • Glob
    • AskUserQuestion

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • speedscope.app

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cpu Profile loads about 1.9k tokens when it runs. Until then it costs about 55 tokens; SKILL.md has 557 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~55
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Task, Bash, Read, Grep, Glob, AskUserQuestion

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ClickHouse/ClickHouse at commit cd023af, republished under its Apache-2.0 licence (© ClickHouse). 557 words, ~1,873 tokens.

Download SKILL.mdSave it as .claude/skills/cpu-profile/SKILL.md (or your agent's skills folder).
name
cpu-profile
description
Profile a ClickHouse query using the sampling query profiler and system.trace_log. Use when the user wants to find CPU hotspots, analyze where time is spent in a query, or investigate performance bottlenecks.
allowed-tools
Task, Bash, Read, Grep, Glob, AskUserQuestion
argument-hint
query_id or query text
disable-model-invocation
false

CPU Profile Analysis Skill

Profile a ClickHouse query using the built-in sampling query profiler (system.trace_log). Collects CPU stack traces at configurable intervals and analyzes them to find hotspots.

Arguments

  • $ARGUMENTS (optional): Either a query_id to analyze existing traces, or a SQL query to execute with profiling enabled.

Step 1 — Determine what to profile

If $ARGUMENTS looks like a UUID (e.g., a1b2c3d4-e5f6-...), treat it as a query_id and skip to Step 3.

If $ARGUMENTS is a SQL query or query description, proceed to Step 2.

If $ARGUMENTS is empty, ask the user:

  • Question: "What would you like to profile?"
  • Options: "Enter a query_id from a previous run", "Enter a SQL query to execute now", "Show recent slow queries from query_log"

If the user wants to see recent slow queries:

sql
SELECT
    query_id,
    query_duration_ms,
    formatReadableSize(memory_usage) AS peak_memory,
    left(query, 120) AS query_preview
FROM system.query_log
WHERE type = 'QueryFinish'
  AND event_date >= today() - 1
  AND query_duration_ms > 1000
  AND query NOT LIKE '%system.%'
ORDER BY query_duration_ms DESC
LIMIT 20
SETTINGS allow_introspection_functions = 1

Step 2 — Execute query with profiling

Generate a unique query ID and run the query with aggressive profiling settings (100us sampling = ~10,000 samples/sec).

Use clickhouse-client in non-interactive mode with an explicit --query_id to avoid any race with concurrent queries:

bash
PROFILE_QID="cpu-profile-$(uuidgen)"
clickhouse-client --query_id "$PROFILE_QID" -q "
    SELECT ...
    SETTINGS query_profiler_cpu_time_period_ns = 100000,
             query_profiler_real_time_period_ns = 100000
"

Alternatively, if running interactively, parse the Query id: <uuid> line that clickhouse-client prints before each query.

After execution, verify the query completed and collect metadata:

sql
SELECT query_id, query_duration_ms, formatReadableSize(memory_usage) AS peak_memory
FROM system.query_log
WHERE type = 'QueryFinish' AND query_id = '{query_id}'
SETTINGS allow_introspection_functions = 1

Wait 2 seconds for trace_log to flush, then proceed to Step 3.

Step 3 — Collect and analyze trace data

Run these analyses in parallel using Task tool (3 tasks):

Agent A — Top functions by CPU samples
sql
SELECT
    count() AS samples,
    round(100.0 * count() / (SELECT count() FROM system.trace_log WHERE query_id = '{query_id}' AND trace_type = 'CPU'), 2) AS pct,
    demangle(addressToSymbol(trace[1])) AS function
FROM system.trace_log
WHERE query_id = '{query_id}'
  AND trace_type = 'CPU'
GROUP BY function
ORDER BY samples DESC
LIMIT 30
SETTINGS allow_introspection_functions = 1
Agent B — Top stack traces (full call paths)
sql
SELECT
    count() AS samples,
    arrayStringConcat(
        arrayMap(x -> demangle(addressToSymbol(x)), trace),
        '\n    '
    ) AS stack
FROM system.trace_log
WHERE query_id = '{query_id}'
  AND trace_type = 'CPU'
GROUP BY trace
ORDER BY samples DESC
LIMIT 15
SETTINGS allow_introspection_functions = 1
Agent C — Export collapsed stacks for flamegraph
sql
SELECT
    concat(
        arrayStringConcat(
            arrayReverse(arrayMap(x -> demangle(addressToSymbol(x)), trace)),
            ';'
        ),
        ' ',
        toString(count())
    )
FROM system.trace_log
WHERE query_id = '{query_id}'
  AND trace_type = 'CPU'
GROUP BY trace
ORDER BY count() DESC
SETTINGS allow_introspection_functions = 1
FORMAT TSVRaw

Save this output to tmp/cpu_profile_{query_id}.collapsed for optional flamegraph generation.

Also collect metadata:

sql
SELECT
    count() AS total_samples,
    min(event_time_microseconds) AS first_sample,
    max(event_time_microseconds) AS last_sample,
    dateDiff('millisecond', min(event_time_microseconds), max(event_time_microseconds)) AS profile_duration_ms
FROM system.trace_log
WHERE query_id = '{query_id}' AND trace_type = 'CPU'
SETTINGS allow_introspection_functions = 1

Step 4 — Synthesize results

Using outputs from all three agents, produce a structured report:

  1. Profile summary: query_id, total samples, profile duration, sampling rate
  2. Top 15 CPU hotspot functions with sample count and percentage — as a table
  3. Top 5 full stack traces with readable formatting — show the call chain from outermost to innermost
  4. Subsystem breakdown: Group functions into categories:
    • Query Execution (HashJoin, Aggregator, MergeSorter, etc.)
    • Expression Evaluation (ExpressionActions, functions)
    • IO (ReadBuffer, WriteBuffer, S3, disk)
    • Network (Exchange, Connection, Protocol)
    • Compression (LZ4, ZSTD, codecs)
    • Memory Management (Arena, Allocator, PODArray)
    • Optimizer (Cascades, JoinOrder, Statistics)
    • Other
  5. Actionable findings: What's unexpectedly hot, what could be optimized
  6. Collapsed stack file location for flamegraph generation
Show full SKILL.md (233 more words)Show less

Step 5 — Offer drill-down options

Ask the user:

  • "Drill into a function": Filter traces containing a specific function name
  • "Compare CPU vs Real time": Run the same analysis for trace_type = 'Real' to find wall-clock hotspots (IO waits, lock contention)
  • "Generate flamegraph": If flamegraph.pl is available, render SVG:
    bash
    flamegraph.pl --title "CPU Profile: {query_id}" --countname samples --width 1800 \
      tmp/cpu_profile_{query_id}.collapsed > tmp/cpu_flamegraph_{query_id}.svg
    Or suggest using https://www.speedscope.app with the collapsed file.
  • "Show source locations": Re-run with addressToLine for source file:line mapping:
    sql
    SELECT
        count() AS samples,
        demangle(addressToSymbol(trace[1])) AS function,
        addressToLine(trace[1]) AS source_location
    FROM system.trace_log
    WHERE query_id = '{query_id}' AND trace_type = 'CPU'
    GROUP BY function, source_location
    ORDER BY samples DESC
    LIMIT 30
    SETTINGS allow_introspection_functions = 1
  • "Done": Exit

Repeat drill-down until user selects "Done".

Notes

  • The query_profiler_cpu_time_period_ns setting controls sampling frequency. Default is 1,000,000,000 (1 sample/sec). Use 100,000 (100us) for detailed profiling of short queries, 1,000,000 (1ms) for longer queries.
  • trace_type = 'CPU' counts CPU time; trace_type = 'Real' counts wall-clock time (includes IO waits).
  • allow_introspection_functions = 1 is required for addressToSymbol, demangle, addressToLine.
  • The clickhouse-common-static-dbg package must be installed for symbol resolution.
  • On ClickHouse Cloud, use FROM clusterAllReplicas(default, system.trace_log) to collect traces from all nodes.
  • Stack traces in system.trace_log are stored as arrays of addresses, with index 1 being the innermost (leaf) frame.

Examples

  • /cpu-profile — Interactive: choose a query to profile
  • /cpu-profile a1b2c3d4-e5f6-7890-abcd-ef1234567890 — Analyze existing traces for a query_id
  • /cpu-profile SELECT count() FROM lineitem WHERE l_shipdate > '1995-01-01' — Execute and profile a query

© ClickHouse, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/cpu-profile of ClickHouse/ClickHouse.

Open the folder on GitHubat commit cd023af

Compare with similar skills

Cpu Profile next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cpu Profile compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cpu Profile this skillClickHouse/ClickHouse50k—~1.9kAutomated safety check: NotesApache-2.0
Clickhouse Logs Queriessupabase/supabase111k—~2.4kAutomated safety check: PassApache-2.0
Chdb SQLvemetric/vemetric3941 repos~1.2kAutomated safety check: PassApache-2.0
Clickhouse System QueriesFrankChen021/datastoria327—~731Automated safety check: PassCustom licence
Webapp Buildersidequery/sidemantic129—~5.5kAutomated safety check: PassAGPL-3.0
Modelersidequery/sidemantic129—~4.2kAutomated safety check: PassApache-2.0

Similar skills

  • Clickhouse Logs Queries

    supabase/supabase

    Official

    Write, review, and migrate Supabase logs queries against the ClickHouse-backed logs table (the logs.all.otel analytics endpoint).

    111k GitHub stars~2.4k tokensUpdated today
    DatabasesAuto-check passed
  • Chdb SQL

    vemetric/vemetric

    A skill your agent uses when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse…

    394 GitHub starsUsed in 1 repo~1.2k tokens
    DatabasesAuto-check passed
  • Clickhouse System Queries

    FrankChen021/datastoria

    Query ClickHouse system tables to inspect query logs, monitor cluster health, check replication status, and analyze slow queries.

    327 GitHub stars~731 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Webapp Builder

    sidequery/sidemantic

    Build interactive analytics webapps, demos, dashboards, or embedded app surfaces from Sidemantic semantic models using copyable component primitives and deterministic query inspection.

    129 GitHub stars~5.5k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Modeler

    sidequery/sidemantic

    Build, validate, and manage semantic models using Sidemantic.

    129 GitHub stars~4.2k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Querying Tempo

    tempoxyz/tidx

    Query indexed Tempo chain data via tidx HTTP API and CLI. An agent skill from tempoxyz/tidx.

    107 GitHub stars~3.1k tokensUpdated today
    DatabasesAuto-check passed

More from ClickHouse/ClickHouse

All 24 skills in this repo
  • Keeper Stress Analysis

    ClickHouse/ClickHouse

    Analyze ClickHouse Keeper stress-test results from play.clickhouse.com / keeperstresstests data warehouse.

    50k GitHub stars~4.7k tokensUpdated today
    Auto-check passed
  • Perf Comparison

    ClickHouse/ClickHouse

    Evaluate ClickHouse performance test results from existing CI/dashboard data or local perf.py runs.

    50k GitHub stars~3.9k tokensUpdated today
    Auto-check: notes
  • Patch Release Check

    ClickHouse/ClickHouse

    Check whether ClickHouse's supported versions (last 3 majors + latest LTS) have recent stable patch releases, diagnose why the scheduled AutoReleases pipeline failed, and identify which releases…

    50k GitHub stars~4k tokensUpdated today
    Auto-check: notes
  • Alloc Profile

    ClickHouse/ClickHouse

    Analyze a jemalloc (or other) allocation profile in collapsed stack format.

    50k GitHub stars~4.3k tokensUpdated today
    Auto-check passed
  • Bisect

    ClickHouse/ClickHouse

    Bisect a ClickHouse regression using pre-built master binaries from CI.

    50k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Clickhouse PR Description

    ClickHouse/ClickHouse

    Generate PR descriptions for ClickHouse/ClickHouse that match maintainer expectations.

    50k GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Cpu Profile

What does Cpu Profile do?

Profile a ClickHouse query using the sampling query profiler and system.tracelog. Cpu Profile is an agent skill from ClickHouse/ClickHouse.tracelog.

When should I use Cpu Profile?

Cpu Profile fits situations like: the user wants to find CPU hotspots; analyze where time is spent in a query; investigate performance bottlenecks.

How do I install Cpu Profile in Claude Code?

Run `npx skills add ClickHouse/ClickHouse --skill cpu-profile -a claude-code`. Or copy the skill folder (.claude/skills/cpu-profile in ClickHouse/ClickHouse) into .claude/skills/cpu-profile in your project. Claude Code loads it when a task matches its description.

How do I install Cpu Profile in Codex?

Run `npx skills add ClickHouse/ClickHouse --skill cpu-profile -a codex`. Or copy the skill folder (.claude/skills/cpu-profile in ClickHouse/ClickHouse) into .agents/skills/cpu-profile in your project. Codex loads it when a task matches its description.

Can I use Cpu Profile in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ClickHouse/ClickHouse --skill cpu-profile -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cpu-profile, .gemini/skills/cpu-profile, .github/skills/cpu-profile and .opencode/skills/cpu-profile in your project.

What does Cpu Profile need to run?

SKILL.md names no scripts, command-line tools or credentials: Cpu Profile is instructions for the agent only. Its frontmatter pre-approves these tools: Task, Bash, Read, Grep, Glob, AskUserQuestion.

Does Cpu Profile access the network?

SKILL.md names 1 domain. As links in the text: speedscope.app. This is read from the text; nothing was executed.

Is Cpu Profile safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Cpu Profile use?

Cpu Profile is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cpu Profile use?

About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cpu Profile?

Skills that share tags, products or a category with Cpu Profile: Clickhouse Logs Queries (supabase/supabase, 111k stars), Chdb SQL (vemetric/vemetric, 394 stars), Clickhouse System Queries (FrankChen021/datastoria, 327 stars) and Webapp Builder (sidequery/sidemantic, 129 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cpu Profile?

ClickHouse (a GitHub organization) maintains it in ClickHouse/ClickHouse, which has 50,288 GitHub stars. The repository holds 24 skills in this directory. The repository was last updated on October 8, 2026.

Source: ClickHouse/ClickHouse on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.