SmartPerfetto Skill System Guide

July 20, 2026 · View on GitHub

English | 中文

SmartPerfetto Skills are YAML-defined trace analysis pipelines. They package performance expertise into reusable, composable, deterministic analysis units. The agent decides which Skill to use; the Skill engine handles SQL execution, iteration, conditional flow, display metadata, and layered output.

Skill Inventory

The authoritative inventory is the backend/skills/**/*.skill.yaml file tree. Do not hardcode a total count in code or durable docs. To inspect the current inventory, run:

rg --files backend/skills | rg '\.skill\.yaml$' | wc -l

Directory roles:

TypeLocationDescription
Atomicbackend/skills/atomic/Single SQL query or small query group
Compositebackend/skills/composite/Multi-step orchestration
Comparisonbackend/skills/comparison/Multi-trace or multi-result comparison Skills
Deepbackend/skills/deep/Deep analysis such as CPU profiling
Pipelinebackend/skills/pipelines/Rendering subpath detection, supporting feature evidence, and teaching-source references
Modulebackend/skills/modules/Modular app/framework/hardware/kernel analysis
Templatebackend/skills/_template/Authoring templates, not necessarily runtime analysis capability

YAML Structure

name: consumer_jank_detection
version: "2.0"
type: atomic
category: rendering

meta:
  display_name: "Consumer jank detection"
  description: "Detects real jank from present_ts intervals"
  tags: [jank, consumer, surfaceflinger]

inputs:
  - name: package
    type: string
    required: false
    description: "Application package name"

steps:
  - id: frame_stats
    type: atomic
    sql: |
      SELECT COUNT(*) AS total_frames
      FROM actual_frame_timeline_slice
      WHERE process_name GLOB '${package}*'
    save_as: frame_stats
    display:
      layer: overview
      title: "Frame statistics"

Input Types

TypeDescriptionSQL default
stringString valueEmpty string ''
numberFloating numberNULL
integerIntegerNULL
booleanBooleanNULL
timestampNanosecond timestampNULL
durationNanosecond durationNULL

Step Types

Step typePurpose
atomicExecute one SQL query
skill / skill_refCall another Skill
iteratorIterate over rows and run nested steps
parallelRun independent child steps concurrently
conditionalBranch by expression
diagnosticEmit rule-based findings
ai_decisionAsk the configured AI runtime for a structured decision; disabled runtimes produce an explicit skipped result
ai_summaryAsk the configured AI runtime to summarize selected step inputs; disabled runtimes produce an explicit skipped result
pipelineDetect or describe rendering pipeline behavior

Rendering Pipeline Catalog

docs/rendering_pipelines/*.md is synchronized from a pinned Gracker/rendering_pipelines commit and is the Android 17 teaching source of truth. backend/skills/pipelines/index.yaml is the live inventory that maps concrete rendering types to detector entries. A variant may become the primary type; a feature only adds evidence such as ANGLE, PIP, HWC overlay, or SurfaceControl usage.

Pipeline definitions retain trace signals, auto-pin guidance, and analysis recommendations, but their teaching block contains only a source reference to one of the synchronized documents. Builds copy all catalog documents into backend/dist/rendering_pipelines/ for Docker, portable, and npm CLI runtime paths. Use npm run sync:rendering-pipelines -- --source <checkout> --apply to update the import and npm run check:rendering-pipelines to verify the pin, hashes, and references.

Parameter Substitution

Skill parameters use ${param|default}. Resolution order is explicit input, saved prior step output, SmartPerfetto defaults, inline default, then type default. The engine escapes substituted values to reduce SQL injection risk.

Display Configuration

Display metadata tells the frontend how to render results:

FieldPurpose
layerLogical output layer
titleSection title
formatTable, metric, chart, timeline, text, or summary
columnsColumn definitions for table rendering
highlightsConditional highlighting rules
expandableWhether JSON/details can be expanded

Layered Results

LayerMeaning
L1Executive summary and primary conclusion
L2Key lists, sessions, frames, or slices
L3Drill-down evidence
L4Raw diagnostics or supporting detail

Development Workflow

  1. Add or edit a YAML file under backend/skills/.
  2. Keep prompt text out of TypeScript.
  3. Prefer existing fragments/modules when possible.
  4. Run validation:
cd backend
npm run validate:skills
npm run test:scene-trace-regression

Relationship To Standard Agent Skills

SmartPerfetto YAML Skills and standard Agent Skills serve different execution boundaries. YAML under backend/skills/ remains the deterministic product runtime truth: it drives registry selection, multi-step execution, DataEnvelope output, artifacts, reports, session provenance, and frontend projection. It is not replaced by Markdown instructions.

Gracker/Perfetto-Skills is the generated and curated portable projection for compatible agents with local filesystem and terminal access. It exports agent-readable workflows, extracted SQL, selected strategy and knowledge methodology, rendering-pipeline material, and a checksum-pinned local trace-processor runtime. It does not export provider management, session state, artifacts, streaming, or UI behavior.

backend/skills/public-export.yaml explicitly classifies every runtime candidate by workflow, disposition, and destination. The public catalog records the SmartPerfetto source commit and per-file SHA-256 values; normal export never infers missing policy entries. After changing backend/skills/, backend/strategies/, docs/rendering_pipelines/, or the export policy, run:

npm run verify:public-skills

The command uses the sibling ../Perfetto-Skills checkout by default, or PERFETTO_SKILLS_DIR when set, and rejects source/catalog/generated-file drift.

Skill Tiers And Validation Rules

Skills may declare top-level tier: S | A | B to express target complexity and review expectations:

TierUse caseStructural expectation
SFlagship cross-domain analysis such as startup, scrolling, CPU, or scene reconstructiontype: composite or deep, usually multiple Perfetto stdlib modules and 5+ steps
AFocused single-domain analysis that can produce diagnostic findings or key listsDeclares relevant prerequisites.modules and reusable display layers
BSingle-fact or helper data providerClear query boundary, fields, and missing-data semantics

cd backend && npm run validate:skills enforces these stable rules:

RuleBehavior
skill-tier-must-match-declaredValidates tier is S/A/B and reports structural gaps as migration warnings
skill-stdlib-detected-vs-declaredScans SQL for Perfetto stdlib symbols and requires coverage in prerequisites.modules
skill-include-budget-soft-capWarns when prerequisites.modules exceeds 8 modules
skill-step-id-uniquenessRequires unique step ids inside each Skill
skill-vendor-override-runtime-conformantRequires vendor overrides to contain real additional_steps, vendor signatures, and a registered base Skill

backend/skills/_template/ contains authoring templates and is not loaded into the runtime registry. After copying a template, remove placeholders, place the Skill under a runtime Skill directory, then run validate:skills and the matching trace regression.

Local Skill Packs

Local Skill Packs let reviewed team or OEM Skills be installed for one workspace without editing backend/skills/. The first release is a local directory import path, not a remote marketplace: HTTPS URLs, auto-sync, .well-known discovery, and archive unpacking are not supported.

The directory must contain smartperfetto-skill-pack.json:

{
  "schemaVersion": 1,
  "packId": "vendor-scroll-pack",
  "name": "Vendor Scroll Pack",
  "version": "1.0.0",
  "publisher": "vendor-team",
  "description": "Reviewed scrolling diagnostics",
  "license": "AGPL-3.0-or-later",
  "compatibility": {
    "smartPerfettoMinVersion": "0.1.0"
  },
  "assets": [
    {
      "kind": "skill",
      "path": "atomic/vendor_scroll.skill.yaml",
      "sha256": "<64 hex chars>",
      "sizeBytes": 1234
    }
  ]
}

Allowed asset roots are atomic/, composite/, deep/, system/, comparison/, modules/, pipelines/, fragments/, and docs/. strategies/, vendors/, custom/, hidden files, symlinks, executable extensions, and undeclared files are rejected. Each asset's sha256 and sizeBytes must match the actual file.

Workspace management endpoints:

MethodPathDescription
POST/api/workspaces/:workspaceId/skill-packs/previewRead-only preview
POST/api/workspaces/:workspaceId/skill-packs/installRerun preview, then install
GET/api/workspaces/:workspaceId/skill-packsList installed packs
PATCH/api/workspaces/:workspaceId/skill-packs/:packIdEnable or disable
DELETE/api/workspaces/:workspaceId/skill-packs/:packIdDisable and remove the managed copy

Install copies declared assets to managed storage and records manifest hash, content hash, approver, Skill IDs, fragment keys, and docs paths in skill_registry_entries.metadata_json. Reinstalling the same packId + version with a different content hash is rejected. External Skill IDs cannot override built-in Skills, and SQL fragment keys cannot override different built-in fragment content.

Agent sessions with workspace context load built-in Skills plus the enabled Skill Packs for that workspace at runtime. list_skills returns external-pack origin metadata, and invoke_skill refreshes the executor and SQL fragment cache when the registry fingerprint changes, so enabling, disabling, or removing a pack does not keep stale content executable. Legacy global /api/admin/skills and the current smp skill CLI path remain built-in-only; CLI execution of workspace packs requires future explicit tenant/workspace context support.