| name | logfire |
| description | This skill should be used when the user asks to query Logfire logs, inspect Logfire traces, fetch SQL trace data, get spans for a trace, inspect LLM spans, inspect tool calls, or check token usage from Logfire. Also use it to triage an ARENA spawn run — diagnose why a run failed, timed out, or took too long, get per-stage turns/cost/tokens, or compare a prod trace to a local one. |
| version | 1.0.0 |
Logfire
Shared wrapper for querying Logfire trace data via SQL.
Setup
- Copy
.claude/skills/logfire/scripts/.env.example to .claude/skills/logfire/scripts/.env
- Set
LOGFIRE_TOKEN with your Logfire read token
Usage
./.claude/skills/logfire/scripts/logfire.sh "SQL_QUERY"
ARENA Trace Workflow
- Identify candidate traces by spec id, workdir suffix, or ARENA span names.
Query both
message and attributes because useful identifiers may live
in either place.
- Group candidates by
trace_id and compare MIN(start_timestamp),
MAX(end_timestamp), and COUNT(*) to distinguish planner, skeleton,
feature, and sanity runs.
- Fetch the selected trace ordered by
start_timestamp ASC. If the payload is
large, redirect to a temp file and summarize with Python instead of reading
the full JSON into chat.
- Logfire ingestion can lag. If a local terminal shows the process is still
alive but the trace appears stale, re-query after a short wait and inspect
child processes to tell an ingestion delay from a blocked subprocess.
ARENA emits manual spans in addition to Claude SDK spans:
arena.pipeline: parent span for a complete spawn. Useful attributes include
arena.spec.id, arena.spec.name, arena.spec.custom_prompt,
arena.spec.framework, arena.spec.database, arena.spec.deployment_model,
arena.spec.vulnerability_tokens, arena.spec.defense_tokens,
arena.workdir.name, arena.pipeline.outcome, and aggregate cost/turns.
arena.agent_stage: child span for each agent invocation. Useful attributes
include arena.agent.stage, arena.agent.model, arena.agent.max_turns,
arena.agent.allowed_tools, arena.agent.disallowed_tools,
arena.agent.wallclock_seconds, arena.agent.max_fixup_attempts,
arena.agent.outcome, arena.agent.turns, and arena.agent.cost_usd.
Triaging a spawn run
To diagnose why a run failed, timed out, or was slow — per-stage turns/cost/tokens,
tool histograms, failure root-cause, and prod-vs-local comparison — follow
references/trace-triage.md. It has copy-paste queries
keyed off the span schema above.
Response Format
Logfire returns columnar format:
{
"columns": [
{ "name": "trace_id", "datatype": "Utf8", "values": ["abc123", "def456"] },
{ "name": "span_id", "datatype": "Utf8", "values": ["span1", "span2"] }
]
}
Common Queries
./.claude/skills/logfire/scripts/logfire.sh "SELECT 1 LIMIT 1"
./.claude/skills/logfire/scripts/logfire.sh "SELECT trace_id, MIN(start_timestamp) AS first_seen, MAX(end_timestamp) AS last_seen, COUNT(*) AS record_count FROM records WHERE start_timestamp > now() - interval '2 hours' AND (message ILIKE '%leaky-query%' OR CAST(attributes AS TEXT) ILIKE '%leaky-query%' OR CAST(attributes AS TEXT) ILIKE '%e58aba16%' OR message IN ('arena.pipeline', 'arena.agent_stage')) GROUP BY trace_id ORDER BY first_seen DESC LIMIT 20"
./.claude/skills/logfire/scripts/logfire.sh "SELECT trace_id, span_id, start_timestamp, end_timestamp, attributes->'arena.spec.id' AS spec_id, attributes->'arena.pipeline.outcome' AS outcome FROM records WHERE message = 'arena.pipeline' ORDER BY start_timestamp DESC LIMIT 20"
./.claude/skills/logfire/scripts/logfire.sh "SELECT start_timestamp, end_timestamp, attributes->'arena.agent.stage' AS stage, attributes->'arena.agent.outcome' AS outcome, attributes->'arena.agent.model' AS model, attributes->'arena.agent.turns' AS turns, attributes->'arena.agent.cost_usd' AS cost FROM records WHERE trace_id = 'TRACE_ID' AND message = 'arena.agent_stage' ORDER BY start_timestamp ASC"
./.claude/skills/logfire/scripts/logfire.sh "SELECT span_id, parent_span_id, start_timestamp, end_timestamp, message, attributes FROM records WHERE trace_id = 'TRACE_ID' ORDER BY start_timestamp ASC LIMIT 1000"
./.claude/skills/logfire/scripts/logfire.sh "SELECT DISTINCT span_id, start_timestamp, attributes FROM records WHERE trace_id = 'TRACE_ID' AND (attributes->>'gen_ai.request.model' IS NOT NULL OR attributes->>'gen_ai.response.model' IS NOT NULL) ORDER BY start_timestamp DESC"
./.claude/skills/logfire/scripts/logfire.sh "SELECT message, attributes->'tool.name' as tool_name, attributes->'tool.arguments' as tool_args FROM records WHERE trace_id = 'TRACE_ID' AND attributes ? 'tool.name' ORDER BY start_timestamp ASC"
./.claude/skills/logfire/scripts/logfire.sh "SELECT attributes->'gen_ai.usage.input_tokens' as input_tokens, attributes->'gen_ai.usage.output_tokens' as output_tokens, attributes->'gen_ai.request.model' as model FROM records WHERE trace_id = 'TRACE_ID' AND attributes ? 'gen_ai.usage.input_tokens'"