Logfire Instrumentation
pydantic/skills
Add Pydantic Logfire observability to application code — traces, logs, metrics, and AI/agent spans.
Adds Pydantic Logfire tracing, logging and metrics to Python, JavaScript or TypeScript and Rust projects, with the correct setup order and library extras.
$ npx skills add basicmachines-co/basic-memory --skill instrumentation -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install basicmachines-co/basic-memory instrumentation --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/instrumentation .claude/skills/instrumentation && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "instrumentation" agent skill from https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentation into .claude/skills/instrumentation/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "instrumentation", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentationType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add basicmachines-co/basic-memory --skill instrumentation -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install basicmachines-co/basic-memory instrumentation --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agents/skills/instrumentation .agents/skills/instrumentation && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "instrumentation" agent skill from https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentation into .agents/skills/instrumentation/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "instrumentation", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add basicmachines-co/basic-memory --skill instrumentation -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install basicmachines-co/basic-memory instrumentation --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agents/skills/instrumentation .cursor/skills/instrumentation && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "instrumentation" agent skill from https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentation into .cursor/skills/instrumentation/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "instrumentation", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/basicmachines-co/basic-memory.git --path .agents/skills/instrumentation--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add basicmachines-co/basic-memory --skill instrumentation -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install basicmachines-co/basic-memory instrumentation --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agents/skills/instrumentation .gemini/skills/instrumentation && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "instrumentation" agent skill from https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentation into .gemini/skills/instrumentation/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "instrumentation", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install basicmachines-co/basic-memory instrumentationInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add basicmachines-co/basic-memory --skill instrumentation -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agents/skills/instrumentation .github/skills/instrumentation && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "instrumentation" agent skill from https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentation into .github/skills/instrumentation/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "instrumentation", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add basicmachines-co/basic-memory --skill instrumentation -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install basicmachines-co/basic-memory instrumentation --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/basicmachines-co/basic-memory.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agents/skills/instrumentation .opencode/skills/instrumentation && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "instrumentation" agent skill from https://github.com/basicmachines-co/basic-memory/tree/main/.agents/skills/instrumentation into .opencode/skills/instrumentation/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "instrumentation", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
instrumentationAdds Pydantic Logfire tracing, logging and metrics to Python, JavaScript or TypeScript and Rust projects, with the correct setup order and library extras.
Logfire is an observability platform built on OpenTelemetry, and this skill exists because agents often get its setup subtly wrong: the order of configure and the instrument calls, the structured logging syntax and the extras to install. The agent identifies the language and instrumentable libraries by reading pyproject.toml, requirements.txt, package.json or Cargo.toml.
For Python it installs logfire with extras matching frameworks such as FastAPI, httpx, asyncpg, SQLAlchemy and Redis, calls configure first so traces are not dropped, then registers the instrument calls. Reference files cover JavaScript frameworks and patterns, Python integrations and logging patterns, and Rust patterns. The skill also covers monitoring AI and LLM calls through PydanticAI, OpenAI and Anthropic.
3 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 6982cfc. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmuvnodeFrom the folder's file list and the shell code blocks in SKILL.md.
Hosts in commands or code, which the agent is likely to contact:
logfire-api.pydantic.devAlso links to:
logfire.pydantic.devFrom URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
LOGFIRE_TOKENFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Logfire Instrumentation loads about 2.3k tokens when it runs, and up to ~5k if it reads all its reference files. Until then it costs about 131 tokens; SKILL.md has 695 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from basicmachines-co/basic-memory at commit 6982cfc, republished under its AGPL-3.0 licence (© basicmachines-co). 695 words, ~2,272 tokens.
.claude/skills/instrumentation/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.Invoke this skill when:
Logfire is an observability platform built on OpenTelemetry. It captures traces, logs, and metrics from applications. Logfire has native SDKs for Python, JavaScript/TypeScript, and Rust, plus support for any language via OpenTelemetry.
The reason this skill exists is that Claude tends to get a few things subtly wrong with Logfire - especially the ordering of configure() vs instrument_*() calls, the structured logging syntax, and which extras to install. These matter because a misconfigured setup silently drops traces.
Identify the project language and instrumentable libraries:
pyproject.toml or requirements.txt. Common instrumentable libraries: FastAPI, httpx, asyncpg, SQLAlchemy, psycopg, Redis, Celery, Django, Flask, requests, PydanticAI.package.json. Common frameworks: Express, Next.js, Fastify. Also check for Cloudflare Workers or Deno.Cargo.toml.Then follow the language-specific steps below.
Install logfire with extras matching the detected frameworks. Each instrumented library needs its corresponding extra - without it, the instrument_*() call will fail at runtime with a missing dependency error.
uv add 'logfire[fastapi,httpx,asyncpg]'The full list of available extras: fastapi, starlette, django, flask, httpx, requests, asyncpg, psycopg, psycopg2, sqlalchemy, redis, pymongo, mysql, sqlite3, celery, aiohttp, aws-lambda, system-metrics, litellm, dspy, google-genai.
This is where ordering matters. logfire.configure() initializes the SDK and must come before everything else. The instrument_*() calls register hooks into each library. If you call instrument_*() before configure(), the hooks register but traces go nowhere.
import logfire
# 1. Configure first - always
logfire.configure()
# 2. Instrument libraries - after configure, before app starts
logfire.instrument_fastapi(app)
logfire.instrument_httpx()
logfire.instrument_asyncpg()Placement rules:
logfire.configure() goes in the application entry point (main.py, or the module that creates the app)instrument_*() calls go right after configure()instrument_fastapi, instrument_flask, instrument_django) need the app instance as an argument. HTTP client and database instrumentors (instrument_httpx, instrument_asyncpg) are global and take no arguments.logfire.configure() inside the post_fork hook, not at module level - each worker is a separate processReplace print() and logging.*() calls with Logfire's structured logging. The key pattern: use {key} placeholders with keyword arguments, never f-strings.
# Correct - each {key} becomes a searchable attribute in the Logfire UI
logfire.info("Created user {user_id}", user_id=uid)
logfire.error("Payment failed {amount} {currency}", amount=100, currency="USD")
# Wrong - creates a flat string, nothing is searchable
logfire.info(f"Created user {uid}")For grouping related operations and measuring duration, use spans:
with logfire.span("Processing order {order_id}", order_id=order_id):
items = await fetch_items(order_id)
total = calculate_total(items)
logfire.info("Calculated total {total}", total=total)For exceptions, use logfire.exception() which automatically captures the traceback:
try:
await process_order(order_id)
except Exception:
logfire.exception("Failed to process order {order_id}", order_id=order_id)
raiseLogfire auto-instruments AI libraries to capture LLM calls, token usage, tool invocations, and agent runs.
uv add 'logfire[pydantic-ai]'
# or: uv add 'logfire[openai]' / uv add 'logfire[anthropic]'Available AI extras: pydantic-ai, openai, anthropic, litellm, dspy, google-genai.
logfire.configure()
logfire.instrument_pydantic_ai() # captures agent runs, tool calls, LLM request/response
# or:
logfire.instrument_openai() # captures chat completions, embeddings, token counts
logfire.instrument_anthropic() # captures messages, token usageFor PydanticAI, each agent run becomes a parent span containing child spans for every tool call and LLM request.
# Node.js
npm install @pydantic/logfire-node
# Cloudflare Workers
npm install @pydantic/logfire-cf-workers logfire
# Next.js / generic
npm install logfireNode.js (Express, Fastify, etc.) - create an instrumentation.ts loaded before your app:
import * as logfire from '@pydantic/logfire-node'
logfire.configure()Launch with: node --require ./instrumentation.js app.js
The SDK auto-instruments common libraries when loaded before the app. Set LOGFIRE_TOKEN in your environment or pass token to configure().
Cloudflare Workers - wrap your handler with instrument():
import { instrument } from '@pydantic/logfire-cf-workers'
export default instrument(handler, {
service: { name: 'my-worker', version: '1.0.0' }
})Next.js - set environment variables for OpenTelemetry export:
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://logfire-api.pydantic.dev/v1/traces
OTEL_EXPORTER_OTLP_HEADERS=Authorization=<your-write-token>// Structured attributes as second argument
logfire.info('Created user', { user_id: uid })
logfire.error('Payment failed', { amount: 100, currency: 'USD' })
// Spans
logfire.span('Processing order', { order_id }, {}, async () => {
logfire.info('Processing step completed')
})
// Error reporting
logfire.reportError('order processing', error)Log levels: trace, debug, info, notice, warn, error, fatal.
[dependencies]
logfire = "0.6"let shutdown_handler = logfire::configure()
.install_panic_handler()
.finish()?;Set LOGFIRE_TOKEN in your environment or use the Logfire CLI to select a project.
The Rust SDK is built on tracing and opentelemetry - existing tracing macros work automatically.
// Spans
logfire::span!("processing order", order_id = order_id).in_scope(|| {
// traced code
});
// Events
logfire::info!("Created user {user_id}", user_id = uid);Always call shutdown_handler.shutdown() before program exit to flush data.
After instrumentation, verify the setup works:
logfire auth to check authentication (or set LOGFIRE_TOKEN)If traces aren't appearing: check that configure() is called before instrument_*() (Python), check that LOGFIRE_TOKEN is set, and check that the correct packages/extras are installed.
Detailed patterns and integration tables, organized by language:
${CLAUDE_PLUGIN_ROOT}/skills/instrumentation/references/python/logging-patterns.md (log levels, spans, stdlib integration, metrics, capfire testing) and ${CLAUDE_PLUGIN_ROOT}/skills/instrumentation/references/python/integrations.md (full instrumentor table with extras)${CLAUDE_PLUGIN_ROOT}/skills/instrumentation/references/javascript/patterns.md (log levels, spans, error handling, config) and ${CLAUDE_PLUGIN_ROOT}/skills/instrumentation/references/javascript/frameworks.md (Node.js, Cloudflare Workers, Next.js, Deno setup)${CLAUDE_PLUGIN_ROOT}/skills/instrumentation/references/rust/patterns.md (macros, spans, tracing/log crate integration, async, shutdown)© basicmachines-co, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 5 other files (references) in .agents/skills/instrumentation of basicmachines-co/basic-memory.
Open the folder on GitHubat commit 6982cfc
Logfire Instrumentation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Logfire Instrumentation this skillbasicmachines-co/basic-memory | 4.1k | — | ~2.3k | Automated safety check: Pass | AGPL-3.0 | |
| Logfire Instrumentationpydantic/skills | 140 | — | ~6.1k | Automated safety check: Pass | MIT | |
| Observability Architecturemajiayu000/litellm-rs | 116 | — | ~1.3k | Automated safety check: Pass | MIT | |
| Azure Monitor Opentelemetry TSmicrosoft/skills | 3.1k | 6 repos | ~2.2k | Automated safety check: Pass | MIT | |
| Opentelemetrygrafana/skills | 278 | — | ~1.7k | Automated safety check: Pass | Apache-2.0 | |
| Python Observability Patternsaiskillstore/marketplace | 430 | 1 repos | ~1.3k | Automated safety check: Pass | None |
pydantic/skills
Add Pydantic Logfire observability to application code — traces, logs, metrics, and AI/agent spans.
majiayu000/litellm-rs
LiteLLM-RS Observability Architecture. An agent skill from majiayu000/litellm-rs.
microsoft/skills
Instrument applications with Azure Monitor and OpenTelemetry for JavaScript (@azure/monitor-opentelemetry).
grafana/skills
Instrument any app with OpenTelemetry and ship metrics / logs / traces to Grafana Cloud or self-hosted Mimir / Loki / Tempo / Pyroscope.
aiskillstore/marketplace
Observability patterns for Python applications. An agent skill from aiskillstore/marketplace.
ollygarden/opentelemetry-agent-skills
OpenTelemetry in Node.js / JavaScript / TypeScript — NodeSDK, declarative YAML configuration, auto-instrumentations, ESM vs CJS import patterns.
basicmachines-co/basic-memory
Views, sets, unsets and validates cmux settings in ~/.config/cmux/cmux.json with a helper script that checks keys against the schema.
basicmachines-co/basic-memory
End-user control of cmux topology and routing (windows, workspaces, panes/surfaces, focus, moves, reorder, identify, trigger flash). Use when automation needs…
basicmachines-co/basic-memory
Opens markdown files in a formatted cmux panel beside the terminal that re-renders on every change, handy for plans and task lists.
basicmachines-co/basic-memory
Keeps agent actions scoped to the cmux workspace and terminal that invoked it, and lays out pane and surface commands that avoid disrupting the user's own focus.
basicmachines-co/basic-memory
Produces PR, changelog and two-week retro images for the Basic Memory repository from evidence in PR bodies, saved to fixed paths under docs/assets/infographics.
basicmachines-co/basic-memory
Guides a newcomer to Basic Memory through designing a personal knowledge system, then teaches its use and sets up their assistant to load it each session.
Categories
Adds Pydantic Logfire tracing, logging and metrics to Python, JavaScript or TypeScript and Rust projects, with the correct setup order and library extras. Logfire is an observability platform built on OpenTelemetry, and this skill exists because agents often get its setup subtly wrong: the order of configure and the instrument calls, the structured logging syntax and the extras to install.toml.
Logfire Instrumentation fits situations like: adding tracing and structured logging to a FastAPI or Express service; instrumenting database, HTTP and LLM calls with Logfire; checking that a Logfire setup is not silently dropping traces.
Run `npx skills add basicmachines-co/basic-memory --skill instrumentation -a claude-code`. Or copy the skill folder (.agents/skills/instrumentation in basicmachines-co/basic-memory) into .claude/skills/instrumentation in your project. Claude Code loads it when a task matches its description.
Run `npx skills add basicmachines-co/basic-memory --skill instrumentation -a codex`. Or copy the skill folder (.agents/skills/instrumentation in basicmachines-co/basic-memory) into .agents/skills/instrumentation in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add basicmachines-co/basic-memory --skill instrumentation -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/instrumentation, .gemini/skills/instrumentation, .github/skills/instrumentation and .opencode/skills/instrumentation in your project.
Going by SKILL.md and its folder, Logfire Instrumentation needs the command-line tools its instructions call (npm, uv and node) and credentials named LOGFIRE_TOKEN.
SKILL.md names 2 domains. In commands or code: logfire-api.pydantic.dev; the agent is likely to contact it when it follows the instructions. As links in the text: logfire.pydantic.dev. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Logfire Instrumentation is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.3k tokens (SKILL.md is roughly 9.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.7k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Logfire Instrumentation: Logfire Instrumentation (pydantic/skills, 140 stars), Observability Architecture (majiayu000/litellm-rs, 116 stars), Azure Monitor Opentelemetry TS (microsoft/skills, 3.1k stars) and Opentelemetry (grafana/skills, 278 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
basicmachines-co (a GitHub organization) maintains it in basicmachines-co/basic-memory, which has 4,107 GitHub stars. The repository holds 49 skills in this directory. The repository was last updated on October 7, 2026.
Source: basicmachines-co/basic-memory on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.