Agent Skill · Android

perfetto-sql

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.

Provider: Android Path in repo: profilers/perfetto-sql/SKILL.md

Skill body

Guidelines and Hints

Resources

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.

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:

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.

Skill frontmatter

license: Complete terms in LICENSE.txt metadata: {"author"=>"Google LLC", "last-updated"=>"2026-05-14", "keywords"=>["Android", "Perfetto SQL", "Query Guidelines", "Performance Profiling", "Trace Analysis", "SQL Best Practices", "SPAN_JOIN", "Idempotency"]}