Agent skill

Perfetto SQL

by jameshnsears in jameshnsears/QuoteUnquote

Translates natural language data intents into syntactically valid Perfetto SQL queries and executes them against a local trace file.

Apache-2.0Auto-check passedDatabases

Install Perfetto SQL

skills CLI
$ npx skills add jameshnsears/QuoteUnquote --skill perfetto-sql -a claude-code

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

GitHub CLI
$ gh skill install jameshnsears/QuoteUnquote perfetto-sql --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/jameshnsears/QuoteUnquote.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/perfetto-sql .claude/skills/perfetto-sql && 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
perfetto-sql
GitHub stars
100
Used in
2 other repos
Token cost
~2.7k tokens
SKILL.md length
1,379 words
Files
2 (incl. references)
Skills in repo
4
Repo updated
First seen
Licence
Apache-2.0

At a glance

Translates natural language data intents into syntactically valid Perfetto SQL queries and executes them against a local trace file.

  • Works in 4 steps: Tool Setup → Dissection and Schema Research → Draft and Validate Loop (Max 3 Iterations) → …
  • Memory data from Android Perfetto traces using traceprocessor
  • SKILL.md covers Guidelines and Hints, Resources and Execution Protocol
  • Calls curl and python; reaches get.perfetto.dev

What it does

Perfetto SQL is an agent skill from jameshnsears/QuoteUnquote. Translates natural language data intents into syntactically valid Perfetto SQL queries and executes them against a local trace file. Use this skill to extract slice, thread, or memory data from Android Perfetto traces using traceprocessor.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/perfetto-stdlib.md`).

It sits in Databases, covering SQL. It works with SQL and Android. The repository describes itself as: A Quotations / Affirmations App Widget. The licence is Apache-2.0.

When your agent uses it

  • Memory data from Android Perfetto traces using traceprocessor
  • Tasks that involve SQL

Example prompts

  • “Use the perfetto-sql skill to translate natural language data intents into syntactically valid Perfetto SQL queries and executes them against a…”
  • “/perfetto-sql”

Requirements

  • Python 3

Workflow steps

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

  1. Tool Setup
  2. Dissection and Schema Research
  3. Draft and Validate Loop (Max 3 Iterations)
  4. Final Output

What it can do on your machine

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

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • curl
    • python

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

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • get.perfetto.dev

    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

Perfetto SQL loads about 2.7k tokens when it runs, and up to ~56k if it reads all its reference files. Until then it costs about 63 tokens; SKILL.md has 1,379 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~63
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~56k

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 passed

The automated check found no risky patterns in SKILL.md.

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 jameshnsears/QuoteUnquote at commit 1e3f3b0, republished under its Apache-2.0 licence (© jameshnsears). 1,379 words, ~2,738 tokens.

Download SKILL.mdSave it as .claude/skills/perfetto-sql/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
perfetto-sql
description
Translates natural language data intents into syntactically valid Perfetto SQL queries and executes them against a local trace file. Use this skill to extract slice, thread, or memory data from Android Perfetto traces using trace_processor.
license
Complete terms in LICENSE.txt
metadata.author
Google LLC
metadata.last-updated
2026-05-14
metadata.keywords
Android, Perfetto SQL, Query Guidelines, Performance Profiling, Trace Analysis, SQL Best Practices, SPAN_JOIN, Idempotency

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}*';

Resources

  • Documentation: The Perfetto Standard Library documentation is in perfetto-stdlib.md. Use this file as a reference to discover available modules, find schemas (columns and types) for specific tables or views, or determine the INCLUDE PERFETTO MODULE statements required before drafting SQL query.
  • Execution Tool: Queries are executed using the official trace_processor wrapper script downloaded directly from Perfetto. Output is returned in pure CSV format.

Execution Protocol

You must follow these steps sequentially, mirroring a multi-agent pipeline:

Step 0: Tool Setup

Fetch the Wrapper: You must use the top level of the current project workspace (./trace_processor).

CRITICAL GUARDRAIL: NEVER use filesystem search tools (find, find_by_name, grep, dir /s, Get-ChildItem) across the home directory or workspace to locate trace_processor — unconstrained searches across entire workspaces will stop responding or time out.

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 executable on macOS/Linux (chmod +x), and ensure trace_processor is added to .gitignore. Execute queries directly via ./trace_processor (on Windows, explicitly invoke python trace_processor).

Important: The file served at this URL is a ~10KB Python wrapper script. Don't assume the download failed because it is human-readable text. This is the intended behavior. This script handles lazy-loading the precompiled binary automatically on its first run. Use it directly.

Show full SKILL.md (570 more words)Show less
Step 1: Dissection and Schema Research
  1. Identify the core question, required data points, and filtering conditions.
  2. Precedence Rule: If the user's request contains a SQL query, use it without modification and skip to Step 2 for validation.
  3. Mandatory Schema and Module Search: For every table or view you plan to use, you MUST find its schema in perfetto-stdlib.md. Don't read the entire documentation file --- it consumes the context window. Follow this precise workflow:
    • Discovery and Search: Use available search tools (grep, read_file or file search) with line limits to discover relevant views, tables or modules based on your problem domain and high-level intents (for example, 'CPU time', 'running time', 'overlap', 'jank').
      • Why: Searching solely for exact table names misses comprehensive, pre-computed views built for these analyses.
      • Note: You must verify if a Standard Library module already provides the needed abstraction before drafting manual arithmetic or custom functions.
    • Targeted Bounded Reads: Once you identify the relevant modules, efficiently read the tables and views within that module section.
    • Extract: Extract only the schema, columns, and the exact INCLUDE PERFETTO MODULE statements for the required object from the documentation.
    • Verify: Review the columns, types, and descriptions to ensure the table matches your needs.
  4. Print the research results before drafting the query:
  5. Tables/Views: Schema for {name}: listing columns and types.
Step 2: Draft and Validate Loop (Max 3 Iterations)

Draft the SQL query in SQLite syntax using only the schemas retrieved in Step 1. After drafting, you must validate against this checklist:

  • [ ] SQLite Syntax: Does the query parse successfully without syntax errors?

  • [ ] Idempotency: Are all object creations safe to re-run? (Did you use CREATE OR REPLACE PERFETTO and DROP TABLE IF EXISTS for virtual tables?)

  • [ ] Existence: Were all tables found in the documentation?

  • [ ] Intent Check: Is there a pre-existing standard library table or view that will fulfill this intent before instead of writing manual arithmetic?

  • [ ] Column Accuracy: Do columns match the retrieved schemas?

  • [ ] Alias Check: Are ALL column names prefixed with their table or view alias (for example, alias.column_name)?

  • [ ] Module Check: Are INCLUDE PERFETTO MODULE statements included for all non-prelude modules? You must use the exact module names provided in the documentation.

  • [ ] Span Join Check: If using SPAN_JOIN, are tables safely PARTITIONED to prevent overlapping interval crashes? Are intermediate tables materialized with CREATE PERFETTO TABLE?

  • [ ] No LIKE Constraint: Did you map string matches using GLOB or = instead of prohibited LIKE?

  • [ ] Execution Check: You MUST run queries using the standalone ./trace_processor wrapper with the --query-string flag: ./trace_processor --query-string "QUERY" {trace_file}.

    Execution Rules:

    • File Usage : If you must create a SQL file to execute queries (for example, due to query length or escaping issues), you must create them in the /tmp/ directory.
    • State: The execution is purely ephemeral. Database state does not persist across turns. You cannot share state (like views or tables) across queries in different turns. Every query must be standalone and fully self-contained.
    • Failure Resilience: Debug and fix SQL syntax and logic errors when query fails.Don't simplify the analytical intent to pass validation. For example, if requested to calculate an overlap or intersection, you must fix the intersection math. Don't substitute with disjoint queries (for example, returning independent total durations) as a workaround.
Step 3: Final Output
  1. Explicitly return and state the final validated SQL and explain the results to the user.
  2. Before finishing your response, delete all temporary SQL files you created in /tmp/ directory.

© jameshnsears, 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

SKILL.md and 1 other file (references) in .agents/skills/perfetto-sql of jameshnsears/QuoteUnquote.

  • SKILL.md
  • references/perfetto-stdlib.md

Open the folder on GitHubat commit 1e3f3b0

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in jameshnsears/QuoteUnquote, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Perfetto SQL 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.

Perfetto SQL compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Perfetto SQL this skilljameshnsears/QuoteUnquote1002 repos~2.7kAutomated safety check: PassApache-2.0
Android Profilerarindamxd/camerax-android1322 repos~493Automated safety check: PassApache-2.0
Evolving The Data ModelTriliumNext/Trilium38k—~2.1kAutomated safety check: PassAGPL-3.0
Safe SQL Executionsupabase/supabase111k—~4.2kAutomated safety check: PassApache-2.0
Citus Backportcitusdata/citus13k—~3.2kAutomated safety check: PassAGPL-3.0
SQL Database Support for pRESTprest/prest4.6k—~1.6kAutomated safety check: PassMIT

Similar skills

  • Android Profiler

    arindamxd/camerax-android

    Manages Android performance profiling and debugging. An agent skill from arindamxd/camerax-android.

    132 GitHub starsUsed in 2 repos~493 tokens
    DevelopmentAuto-check passed
  • Evolving The Data Model

    TriliumNext/Trilium

    A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

    38k GitHub stars~2.1k tokensUpdated today
    DatabasesAuto-check passed
  • Safe SQL Execution

    supabase/supabase

    Official

    A skill your agent uses whenever code will build, return, fetch, or execute SQL that runs against a user's real Postgres database — even when the request reads like an ordinary feature or bug fix…

    111k GitHub stars~4.2k tokensUpdated today
    DatabasesAuto-check passed
  • Citus Backport

    citusdata/citus

    Backport one or more merged citusdata/citus main commits/PRs onto the active release branches.

    13k GitHub stars~3.2k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Guides classifying, gap-analyzing and scaffolding support for a new SQL database in pREST, from Postgres-compatible variants to entirely new dialects.

    4.6k GitHub stars~1.6k tokensUpdated yesterday
    DatabasesAuto-check passed
  • StarRocks SQL Doc Auto-Fix

    StarRocks/starrocks

    Proposes verified fixes for failing SQL examples in StarRocks docs across three languages and several versions, then opens draft pull requests and never merges.

    12k GitHub stars~7.6k tokensUpdated today
    DatabasesAuto-check: notes

More from jameshnsears/QuoteUnquote

  • Wear Compose M3

    jameshnsears/QuoteUnquote

    Expert guidance for working with Wear OS Compose Material3. An agent skill from jameshnsears/QuoteUnquote.

    100 GitHub starsUsed in 1 repo~3.2k tokens
    Auto-check passed
  • Camera1 To Camerax

    jameshnsears/QuoteUnquote

    A skill your agent uses to migrate legacy Android camera implementations (Camera1 or raw Camera2 APIs) to CameraX.

    100 GitHub starsUsed in 1 repo~1.9k tokens
    Auto-check passed
  • Perfetto Trace Analysis

    jameshnsears/QuoteUnquote

    Analyzes Perfetto traces to find the root cause of latency, memory, or jank issues in Android apps.

    100 GitHub starsUsed in 2 repos~1.7k tokens
    Auto-check passed

Works with

Categories

Questions about Perfetto SQL

What does Perfetto SQL do?

Translates natural language data intents into syntactically valid Perfetto SQL queries and executes them against a local trace file. Perfetto SQL is an agent skill from jameshnsears/QuoteUnquote. Translates natural language data intents into syntactically valid Perfetto SQL queries and executes them against a local trace file.

When should I use Perfetto SQL?

Perfetto SQL fits situations like: memory data from Android Perfetto traces using traceprocessor; tasks that involve SQL.

How do I install Perfetto SQL in Claude Code?

Run `npx skills add jameshnsears/QuoteUnquote --skill perfetto-sql -a claude-code`. Or copy the skill folder (.agents/skills/perfetto-sql in jameshnsears/QuoteUnquote) into .claude/skills/perfetto-sql in your project. Claude Code loads it when a task matches its description.

How do I install Perfetto SQL in Codex?

Run `npx skills add jameshnsears/QuoteUnquote --skill perfetto-sql -a codex`. Or copy the skill folder (.agents/skills/perfetto-sql in jameshnsears/QuoteUnquote) into .agents/skills/perfetto-sql in your project. Codex loads it when a task matches its description.

Can I use Perfetto SQL 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 jameshnsears/QuoteUnquote --skill perfetto-sql -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/perfetto-sql, .gemini/skills/perfetto-sql, .github/skills/perfetto-sql and .opencode/skills/perfetto-sql in your project.

What does Perfetto SQL need to run?

Going by SKILL.md and its folder, Perfetto SQL needs the command-line tools its instructions call (curl and python). Our summary lists: Python 3.

Does Perfetto SQL access the network?

SKILL.md names 1 domain. In commands or code: get.perfetto.dev; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Perfetto SQL safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Perfetto SQL use?

Perfetto SQL 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 Perfetto SQL use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 54k tokens, read only when the agent opens those files.

What are the alternatives to Perfetto SQL?

Skills that share tags, products or a category with Perfetto SQL: Android Profiler (arindamxd/camerax-android, 132 stars), Evolving The Data Model (TriliumNext/Trilium, 38k stars), Safe SQL Execution (supabase/supabase, 111k stars) and Citus Backport (citusdata/citus, 13k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Perfetto SQL?

jameshnsears (a GitHub user) maintains it in jameshnsears/QuoteUnquote, which has 100 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on August 27, 2026.

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