perfetto-sql

perfetto-sql is a skill for Claude Code, Codex from TalissonVitorino/kmp-ios-skills. It costs 75 tokens per session (2,596 once invoked), scanned A, original, MIT.

A tool for querying Android performance trace files with Perfetto SQL. Perfetto is a tracing system that records timing, thread, memory, and other runtime data.

In plain words
What is it for?
Use it to translate questions about an Android trace into SQL, run the queries locally, and inspect slices, threads, memory, and incomplete trace intervals.
Why use it?
It removes the need to manually construct and debug trace queries while handling common Perfetto and SQLite query pitfalls.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to translate questions about an Android trace into SQL, run the queries locally, and inspect slices, threads, memory, and incomplete trace intervals.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/talissonvitorino/kmp-ios-skills/perfetto-sql
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 TalissonVitorino/kmp-ios-skills --skill perfetto-sql
Clone the repo
git clone --depth 1 https://github.com/TalissonVitorino/kmp-ios-skills

Made for: Claude Code, Codex.

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 perfetto-sql

README.md
[![agentmods](https://agentmods.dev/badge/skills/talissonvitorino/kmp-ios-skills/perfetto-sql/github.svg)](https://agentmods.dev/skills/talissonvitorino/kmp-ios-skills/perfetto-sql)
Your own site
<a href="https://agentmods.dev/skills/talissonvitorino/kmp-ios-skills/perfetto-sql"><img src="https://agentmods.dev/badge/skills/talissonvitorino/kmp-ios-skills/perfetto-sql/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 perfetto-sql

Your own site · 80×15
<a href="https://agentmods.dev/skills/talissonvitorino/kmp-ios-skills/perfetto-sql"><img src="https://agentmods.dev/badge/skills/talissonvitorino/kmp-ios-skills/perfetto-sql.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,596 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00075 $0.02596
Opus 5 $0.00037 $0.01298
Sonnet 5 $0.00015 $0.00519
Haiku 4.5 $0.00007 $0.00260

Measured 12d ago against content hash 34e8a19e9815, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

perfetto-sql scanned grade A with 1 finding 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 12d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

Perform a direct file check at the top level of your workspace (e.g., `ls trace_processor`). If missing, download `https://get.perfetto.dev/trace_processor` directly into the root workspace (`curl -LO`), make it executab
Origin

Copies of this mod

1 near-identical copy found in the catalogue:

android/perfetto-sql/SKILL.md · 145 lines

How it starts

The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Guidelines and Hints

  • Idempotency: Ensure queries are idempotent to prevent "already exists" errors during multiple executions.

    • For Perfetto objects, always use CREATE OR REPLACE: CREATE OR REPLACE PERFETTO TABLE, CREATE OR REPLACE PERFETTO VIEW, CREATE OR REPLACE PERFETTO FUNCTION, CREATE OR REPLACE PERFETTO MACRO.
    • For SQLite Virtual Tables (such as SPAN_JOIN), CREATE OR REPLACE is not supported. Explicitly drop them first: DROP TABLE IF EXISTS my_table; CREATE VIRTUAL TABLE my_table USING SPAN_JOIN(...);
    • For standard SQLite indexes, prepend DROP INDEX IF EXISTS index_name;.
  • SPAN_JOIN will crash if intervals within the same input table overlap. Always use the PARTITIONED {column} (for example, PARTITIONED upid) clause to isolate intervals.

  • Intermediate tables fed into a SPAN_JOIN must be materialized using CREATE PERFETTO TABLE, not CREATE VIEW.

  • Trace Boundaries (dur = -1): Slices or thread states that don't finish before the trace ends are recorded with dur = -1. When calculating a bounding box (for example, ts + dur) or summing durations (SUM(dur)), handle incomplete durations using: IIF(dur = -1, trace_end() - ts, dur).

  • Robust State Transitions: Avoid manual timestamp arithmetic (for example, ts + dur = next.ts) to join adjacent events. Rely on standard library modules (for example, sched.runnable, linux.perf.counters, intervals.overlap) which safely handle trace gaps and preemptions.

  • Unique Identifiers: When writing SQL queries in Perfetto, you must join tables using utid (unique thread ID) or upid (unique process ID) instead of the regular tid or pid. Why it's useful : The operating system recycles TIDs and PIDs, while UTIDs and UPIDs remain unique for the lifetime of the trace, which prevents incorrect joins.

  • Safe Argument Extraction: Use EXTRACT_ARG(arg_set_id, 'key') to extract dictionary or JSON-like properties from slices or tracks. Don't attempt string parsing.

  • String Matching (Always use GLOB): Use GLOB instead of LIKE. LIKE causes performance bottlenecks and treats underscores (_) as wildcards, leading to bugs.

    • Exact matches: Use =.
    • Substring matches: Use GLOB with * (for example, name GLOB '*RenderThread*').
    • Case-insensitive matches: Use LOWER(name) GLOB and make sure the search string is fully lowercase (for example, LOWER(name) GLOB '*renderthread*'). Use this when dealing with inconsistent trace capitalization (for example, WakeLock versus wakelock).
  • Calculating Time Overlaps: To calculate the overlap duration between two time intervals [start1, end1] and [start2, end2]:

    Precedence Rule: Always prefer using SPAN_JOIN or standard library functions (for example, intervals.overlap) to calculate overlaps between two different sets of intervals . Avoid manual arithmetic if a standard library feature or SPAN_JOIN can achieve the same result. Use the following logic if no built-in alternative exists.

    1. Condition: The intervals overlap if start1 < end2 and start2 < end1.

    2. Duration: The overlap duration is calculated as MIN(end1, end2) - MAX(start1, start2)

      Important: Incomplete Perfetto slices have a duration of -1 (dur = -1). Always calculate the effective end time using ts + IIF(dur = -1, trace_end() - ts, dur) before applying this logic.

  • Query android_thread_slices_for_all_startups for app startup requests.

  • Join counter_track with counter to get values of counter with a specific name.

  • When querying for a CPU frequency counter, include the linux.cpu.frequency module and use the cpu_frequency_counters table.

  • When looking for events around a specific timestamp, start with 100ms as the window size.

  • Always prefix column names with table or view alias, that is: {alias}.{column_name}.

  • To calculate the total time spent in slices matching a specific name pattern (for example, *{name_pattern}*), you must sum their durations. Why it's useful : This helps quantify the total impact of a specific function or feature on performance across multiple calls. Here is an example query (note the safe handling of incomplete slices): sql SELECT count(*) as total_count, sum(IIF(slice.dur = -1, trace_end() - slice.ts, slice.dur)) / 1000000.0 as total_dur_ms FROM slice WHERE slice.name GLOB '*{name_pattern}*';

Read the full file on GitHub · 145 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 12d ago First seen · 145 lines · 75 tokens per session scan A 34e8a19e9815

Subscribe to this mod's changes

perfetto-sql is a skill published in the GitHub repository TalissonVitorino/kmp-ios-skills (12 stars, last pushed 18d ago), licensed MIT. It adds 75 tokens to every session and 2,596 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

compose-multiplatform

Use when building one shared Compose UI in Kotlin across Android, iOS, and desktop — commonMain @Composables, expect/actual, source-set placement, native interop, multiplatform ViewModel/navigation/Koin. NOT a single-platform native build (that is kotlin-android / swift-ios), and NOT Dart/Flutter cross-platform UI…

ericrisco/rsc-harness · 80 tokens

cmp-new

Scaffold a new MOBILE app — Android + iOS from one Kotlin/Compose Multiplatform codebase — from a bare "create a mobile app" to a green, verified build. Guardrails first: if the user already chose a different framework (React Native, Expo, Flutter, SwiftUI, native), do NOT redirect them here; if they only asked a…

kvdm-co-pilot/create-cmp · 478 tokens

npm-publish

Publish the create-cmp CLI to npm as the create-cmp-cli package. Use this when the user asks to "publish create-cmp to npm", "release a new version", "ship create-cmp-cli", "npm publish this", "cut a release", or wants npx create-cmp-cli to work. Runs unattended when a granular npm token is installed in the user's…

kvdm-co-pilot/create-cmp · 150 tokens

cmp-firebase-connect

Wire a freshly scaffolded CMP/KMP app to its OWN real Firebase project — the #1 post-scaffold manual step. Use this when the user wants to connect their app to Firebase, or asks "connect my app to firebase", "set up google-services.json", "wire firebase", "create a firebase project for this app", "replace the…

kvdm-co-pilot/create-cmp · 170 tokens

add-feature

Add a new conforming vertical-slice feature (Screen + ViewModel + UseCase + Repository + spec + tests + golden tree + nav route + DI wiring) to this Compose Multiplatform app, cloned deterministically from the project's configured exemplar feature (qa/approvals.json's exemplarFeature — home by default). Use this when…

kvdm-co-pilot/create-cmp · 169 tokens

cmp-audit

Adversarial audit of one subsystem of a Kotlin/Compose Multiplatform app against its spec AND against platform semantics — the class of defect desktop-tier tests cannot see (alarms, notifications, PendingIntents, reboot, process death, DST). Use this when the user says "audit the notifications", "double check X for…

kvdm-co-pilot/create-cmp · 157 tokens