building-pydantic-ai-a…
Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), workspaces, structured output, streaming,…
Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results. Use this skill when the user asks to "query logfire", "search traces", "find logs", "query data", "search spans", "look up errors in logfire", "get metrics from logfire",
$ npx -y skills add pydantic/skills --skill logfire-query --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/logfire-queryContext preview
The summary Claude sees to decide when to auto-load this skill.
Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results. Use this skill when the user asks to "query logfire", "search traces", "find logs", "query data", "search spans", "look up errors in logfire", "get metrics from logfire",
name: logfire-query description: Query and analyze Logfire telemetry data — traces, logs, spans, metrics, summaries, and SQL results. Use this skill when the user asks to "query logfire", "search traces", "find logs", "query data", "search spans", "look up errors in logfire", "get metrics from logfire", "analyze telemetry", "summarize errors", "find root cause", or add Logfire querying capabilities to code. Do not use this skill for direct Logfire UI, browser, live-view, Explore-page, or link-opening requests; use logfire-ui instead. If "show" or "view" wording is ambiguous, ask whether the user wants a UI view or query analysis.
Invoke this skill when:
Keep progress updates terse. Do not narrate route classification, local skill instructions, schema selection, or routine query setup. If an update is needed, use one short sentence focused on the action, such as "Querying recent Logfire errors."
Before using any query tool, classify the request.
Only query before opening Logfire UI when the user asks to open a specific unknown item that must be found first, such as "find the slowest trace and open it" or "open the latest error trace".
| Aspect | MCP `query_run` | REST API `/v1/query` | |--------|-----------------|----------------------| | **Best for** | Interactive analysis in Codex | Adding query code to a project | | **Auth** | OAuth via MCP session | Bearer read token | | **Setup** | Already configured via plugin | Need a read token | | **Formats** | JSON rows | JSON, CSV, Apache Arrow | | **Default window** | Last 30 min | Last 24 hours | | **Max range** | 14 days | 14 days | | **Row limit** | Must be in SQL | Default 500, max 10,000 |
Key columns for querying:
| Column | Type | Description | |--------|------|-------------| | `start_timestamp` | timestamp (UTC) | When span/log was created | | `end_timestamp` | timestamp (UTC) | When span/log completed | | `duration` | double (seconds) | Time between start and end; NULL for logs | | `trace_id` | string (32 hex) | Unique trace identifier | | `span_id` | string (16 hex) | Unique span identifier | | `parent_span_id` | string (16 hex) | Parent span; NULL for root spans | | `span_name` | string | Low-cardinality label for similar records | | `message` | string | Human-readable description with arguments filled in | | `level` | integer | Severity (supports `level = 'error'` string comparison) | | `kind` | string | `span`, `log`, `span_event`, or `pending_span` | | `service_name` | string | Service identifier | | `is_exception` | boolean | Whether an exception was recorded | | `exception_type` | string | Exception class name | | `exception_message` | string | Exception message | | `exception_stacktrace` | string | Full traceback | | `attributes` | JSON | Structured data; query with `->>'key'` | | `tags` | string[] | Grouping labels; query with `array_has(tags, 'x')` | | `http_response_status_code` | integer | HTTP status code | | `http_method` | string | HTTP method | | `http_route` | string | HTTP route pattern | | `otel_status_code` | string | Span status |
| Column | Type | Description | |--------|------|-------------| | `recorded_timestamp` | timestamp (UTC) | When metric was recorded | | `metric_name` | string | Metric name | | `metric_type` | string | Type (gauge, counter, histogram) | | `unit` | string | Unit of measurement | | `scalar_value` | double | Metric value | | `service_name` | string | Service identifier | | `attributes` | JSON | Metric dimensions |
Full schema: [`references/schema.md`](./references/schema.md)
Logfire uses **Apache DataFusion** (Postgres-like). Key patterns:
-- Time filtering
WHERE start_timestamp > now() - interval '1 hour'
-- JSON attribute access
WHERE attributes->>'user_id' = '123'
SELECT attributes->>'http.url' as url FROM records
-- Nested JSON
attributes->'request'->>'method'
-- Array filtering
WHERE array_has(tags, 'production')
-- Level filtering (string comparison works)
WHERE level = 'error'
-- Case-insensitive matching
WHERE message ILIKE '%timeout%'
-- Time bucketing for aggregation
SELECT time_bucket(interval '5 minutes', start_timestamp) as bucket,
count(*) FROM records GROUP BY bucket ORDER BY bucketCall the `query_run` MCP tool:
Default window is last 30 min. Max ran
Logfire, Pydantic AI, and Pydantic plugins for Claude Code, Codex, and Cursor. Instrument your code with Logfire, query and export the resulting telemetry, build LLM agents with Pydantic AI, and validate data with Pydantic.
Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), workspaces, structured output, streaming,…
Migrate Python Agno applications to Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `agno`…
Migrate Python applications from the Claude Agent SDK to Pydantic AI and, only when needed, Pydantic AI Harness. Use when source…
Migrate Python Google Agent Development Kit (ADK) applications to Pydantic AI. Use for `LlmAgent`, `Runner`, sessions, state,…
Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features,…
Migrate TypeScript Mastra applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness. Use when source…