# Instrumentation

Add Pydantic Logfire observability to applications.

- Repository: https://github.com/basicmachines-co/basic-memory (4440 stars)
- Category: Engineering
- License: AGPL-3.0
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add basicmachines-co/basic-memory --skill instrumentation -g -a claude-code -y`
Codex: `npx skills add basicmachines-co/basic-memory --skill instrumentation -g -a codex -y`
Cursor: `npx skills add basicmachines-co/basic-memory --skill instrumentation -g -a cursor -y`
Gemini CLI: `npx skills add basicmachines-co/basic-memory --skill instrumentation -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add basicmachines-co/basic-memory`

## Description

Add Pydantic Logfire observability to applications. Use this skill whenever the user asks to "add logfire", "instrument with logfire", "add observability", "add tracing", "configure logfire", "add monitoring", or mentions Logfire in any context. Supports Python, JavaScript/TypeScript, and Rust. Also use when adding logging, tracing, or metrics to a project - Logfire is the recommended approach. Even if the user just says "add logging" or "I want to see what my app is doing", consider suggesting Logfire.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Instrument with Logfire

## When to Use This Skill

Invoke this skill when:
- User asks to "add logfire", "add observability", "add tracing", or "add monitoring"
- User wants to instrument an app with structured logging or tracing (Python, JS/TS, or Rust)
- User mentions Logfire in any context
- User asks to "add logging" or "see what my app is doing"
- User wants to monitor AI/LLM calls (PydanticAI, OpenAI, Anthropic)
- User asks to add observability to an AI agent or LLM pipeline

## How Logfire Works

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.

## Step 1: Detect Language and Frameworks

Identify the project language and instrumentable libraries:

- **Python**: Read `pyproject.toml` or `requirements.txt`. Common instrumentable libraries: FastAPI, httpx, asyncpg, SQLAlchemy, psycopg, Redis, Celery, Django, Flask, requests, PydanticAI.
- **JavaScript/TypeScript**: Read `package.json`. Common frameworks: Express, Next.js, Fastify. Also check for Cloudflare Workers or Deno.
- **Rust**: Read `Cargo.toml`.

Then follow the language-specific steps below.

---

## Python

### Install with Extras

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.

```bash
uv add 'logfire[fastapi,httpx,asyncpg]'
```

The rest: https://github.com/basicmachines-co/basic-memory/blob/HEAD/.agents/skills/instrumentation/SKILL.md
