android-perfetto-sql

Generates and executes Perfetto SQL queries against Android trace files.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/Zeyad-37/tech-agency --skill android-perfetto-sql-zeyad-37
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: android-perfetto-sql
Source: https://github.com/Zeyad-37/tech-agency/tree/main/.claude/skills/android-perfetto-sql
Command: npx skills add https://github.com/Zeyad-37/tech-agency --skill android-perfetto-sql-zeyad-37

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing correct Perfetto SQL against Android traces requires deep knowledge of the standard library schema, idempotency rules, and pitfalls like recycled PIDs, incomplete slices, and SPAN_JOIN crashes. This Skill translates natural language questions into validated Perfetto SQL and executes it against a local trace file. ## Core Features & Use Cases - Natural Language to Perfetto SQL: Converts data intents into syntactically valid queries using schemas from the bundled Perfetto standard library reference. - Guided Execution Pipeline: Follows a strict protocol of schema research, draft-and-validate loops (max 3 iterations), and execution via the official trace_processor wrapper with CSV output. - Built-in Safety Rules: Enforces idempotent object creation, GLOB instead of LIKE, utid/upid joins, PARTITIONED SPAN_JOINs, and safe handling of dur = -1 slices. - Use Case: Ask how long the RenderThread spent in a specific function during an app startup trace, and receive a validated SQL query plus the aggregated results in milliseconds. ## Quick Start Ask the assistant to analyze the attached Perfetto trace file and calculate the total time spent in slices matching a given name pattern.

Frequently Asked Questions about android-perfetto-sql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query Android Perfetto traces with SQL?▼

Use the trace_processor wrapper with the --query-string flag to run Perfetto SQL directly against a trace file. Download the wrapper from get.perfetto.dev, make it executable, and pass your query and trace file as arguments to get CSV output.

How to calculate total duration of slices matching a name in Perfetto?▼

Sum the durations of matching slices using GLOB for the name pattern, and handle incomplete slices with IIF(dur = -1, trace_end() - ts, dur). Divide by 1000000.0 to convert nanoseconds to milliseconds.

Why does SPAN_JOIN crash in Perfetto SQL?▼

SPAN_JOIN crashes when intervals within the same input table overlap. Add a PARTITIONED clause such as PARTITIONED upid to isolate intervals, and materialize intermediate tables with CREATE PERFETTO TABLE rather than views.

Should I use tid or utid when joining Perfetto trace tables?▼

Always join using utid or upid instead of tid or pid. Operating systems recycle thread and process IDs during a trace, while utid and upid remain unique for the trace lifetime, preventing incorrect joins.

Why is LIKE discouraged in Perfetto SQL queries?▼

LIKE causes performance bottlenecks and treats underscores as wildcards, producing incorrect matches. Use = for exact matches and GLOB with asterisks for substring or case-insensitive matching via LOWER(name) GLOB.