agentleFS
PydanticKnown publisherpydantic/logfire-js/AGENTS.md

logfire-js

AGENTS.md72 starsChanged 10 days agoMITView on GitHub

This file is the canonical project guide for coding agents. CLAUDE.md is kept as a symlink for tools that still look for that name. Keep this file tool-neutral and update it when project commands, package layout, or non-obvious conventions change. This repository is the Pydantic Logfire JavaScript SDK monorepo. It provides OpenTelemetry-based tracing and logging packages for Node.js, browsers, Cloudflare Workers, and standalone manual tracing. Install dependencies: Build all packages: Build packages in watch-style development mode:

  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

22 rules. About 0 are common, 15 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the Node.js version in .node-version.

    line 25
  2. Very specific:

    Use pnpm 11.5.2. The package manager is pinned in packageManager.

    line 26
  3. Very specific:

    Use Vite+ (vp) for the JavaScript toolchain entrypoint.

    line 27
  4. Distinctive:

    Run workspace commands from the repository root unless a package-level command is explicitly needed.

    line 28
  5. Distinctive:

    Run all package tests:

    line 50
  6. Distinctive:

    Run all checks before broad or release-oriented changes:

    line 56
  7. Distinctive:

    Run focused checks for one package:

    line 62
  8. Distinctive:

    Run a single Vite+ test by name from a package:

    line 70
  9. Distinctive:

    Add a changeset when a package-visible change needs a release note or version bump:

    line 83
  10. Distinctive:

    Prefer existing package patterns, helpers, and OpenTelemetry abstractions over introducing new wrappers.

    line 102
  11. Distinctive:

    Keep changes scoped to the package or example relevant to the task.

    line 103
  12. Distinctive:

    Update examples or docs when public behavior, configuration, or package usage changes.

    line 104
  13. Distinctive:

    Update it alongside changes to published JS docs pages.

    line 106
  14. Very specific:

    Add or update tests for behavior changes.

    line 111
  15. Distinctive:

    Avoid adding production dependencies without a clear need.

    line 112
  16. Distinctive:

    Do not put agent-specific or vendor-specific instructions here unless they are explicitly about repository compatibility.

    line 113
  17. Very specific:

    Prefer exact assertions over fuzzy matching for stable output.

    line 118
  18. Distinctive:

    When testing formatted errors or stack output, mock stack strings so assertions stay deterministic.

    line 119
  19. Very specific:

    Prefer browser configureFrontend({ baseUrl, token, ...options }) for direct frontend application setup.

    line 134
  20. Very specific:

    Use examples to validate integration behavior when package-level tests do not cover the runtime path.

    line 138
  21. Distinctive:

    Keep this file concise and operational.

    line 150
  22. Distinctive:

    If a subdirectory needs different build, test, or safety rules, add a nested AGENTS.md in that directory instead of growing this root file.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agent Instructions

This file is the canonical project guide for coding agents. CLAUDE.md is kept as a symlink for tools that still look for that name. Keep this file tool-neutral and update it when project commands, package layout, or non-obvious conventions change.

Project Overview

This repository is the Pydantic Logfire JavaScript SDK monorepo. It provides OpenTelemetry-based tracing and logging packages for Node.js, browsers, Cloudflare Workers, and standalone manual tracing.

Repository Layout

  • packages/logfire-api publishes logfire, the core manual tracing API.
  • packages/logfire-node publishes @pydantic/logfire-node, which adds Node.js SDK setup and automatic instrumentation.
  • packages/logfire-cf-workers publishes @pydantic/logfire-cf-workers, which adapts Logfire to Cloudflare Workers.
  • packages/otel-cf-workers publishes @pydantic/otel-cf-workers, the lower-level Cloudflare Workers OpenTelemetry implementation used by the Logfire wrapper.
  • packages/logfire-browser publishes @pydantic/logfire-browser, which adapts Logfire to browser tracing.
  • packages/logfire-session-replay publishes @pydantic/logfire-session-replay, the optional standalone rrweb recorder used by the browser package's session replay integration.
  • packages/logfire-agent-sandboxes publishes @pydantic/logfire-agent-sandboxes, which connects Node.js to Logfire Agent Sandboxes through the MontyRemote gRPC pool from the @pydantic/monty peer dependency. Its docs page (docs/agent-sandboxes.md) is hidden in navigation until the feature leaves beta.
  • packages/logfire-ai-sdk-code-mode publishes @pydantic/logfire-ai-sdk-code-mode, the code mode for the Vercel AI SDK: codeMode() gives an agent one run_code tool that runs Python in one sandbox session per run, with the agent's tools as the typed stubs pydantic-ai CodeMode shows the model. Its prompt (src/prompt.ts) and messages are ported from pydantic-ai at the pinned commit, except the osPolicy clock line, ported from a later commit, and the sleep: 'zero' sentence, which is this package's own (both noted in src/prompt.ts). fixtures/signatures/ holds the parity fixtures, including pydantic-ai's whole run_code description: vp test with UPDATE_FIXTURES=1 rewrites the generated ones, and python3 scripts/render-fixtures.py renders the expected output with pydantic-ai (--ref main checks for upstream changes).
  • vite.shared.ts holds the build helpers every package config imports: packageDefines() stamps PACKAGE_VERSION and PACKAGE_TIMESTAMP from the package's own package.json, and copyCjsDeclarations() emits the .d.cts files.
  • vite.config.ts and tsconfig.base.json at the repository root hold the shared format, lint, task, and TypeScript configuration.
  • examples/ contains runnable examples for Express, Next.js, Deno, Cloudflare Workers, browser usage, browser route grouping with React Router, TanStack Router, and Vue Router, Agent Sandboxes, and related integrations. examples/agent-sandboxes doubles as a smoke test (pnpm run test:examples) that relays to a local monty subprocess worker instead of Logfire. The router examples run in the Playwright browser acceptance suite (packages/logfire-session-replay/browser-tests/router-examples.pw.ts), so keep their routes and link names in sync with that test.

Environment

  • Use the Node.js version in .node-version. The root package.json also enforces Node.js 24 through engines.
  • Use pnpm 11.5.2. The package manager is pinned in packageManager.
  • Use Vite+ (vp) for the JavaScript toolchain entrypoint. Vite+ manages Vite, Vitest, Oxlint, Oxfmt, and package build tasks.
  • Run workspace commands from the repository root unless a package-level command is explicitly needed.

Useful Commands

Install dependencies:

vp install

Build all packages:

pnpm run build

Build packages in watch-style development mode:

pnpm run dev

Run all package tests:

pnpm run test

Run all checks before broad or release-oriented changes:

pnpm run check

Run focused checks for one package:

vp run logfire#test
vp run @pydantic/logfire-node#test
vp run @pydantic/logfire-browser#typecheck

Run a single Vite+ test by name from a package:

vp run logfire#test -- -t "test name pattern"

Format or verify formatting:

pnpm run format
pnpm run format-check

Add a changeset when a package-visible change needs a release note or version bump:

pnpm run changeset-add

Merging a PR that contains a changeset releases it: the CI release job commits the version bump straight to main and publishes to npm. There is no Version Packages PR, so check the bump type in the changeset before merging.

Architecture Notes

  • logfire wraps OpenTelemetry tracing APIs with convenience methods such as span, startSpan, info, debug, warn, and error.
  • Runtime packages depend on logfire and add environment-specific configuration and instrumentation.
  • Message templates are formatted by logfireFormatWithExtras() in packages/logfire-api/src/formatter.ts; template fields become structured attributes.
  • Sensitive data scrubbing is handled by AttributeScrubber in packages/logfire-api/src/AttributeScrubber.ts.
  • Trace IDs use ULIDs through ULIDGenerator.
  • Logfire spans use logfire.span_type: log for point-in-time events and span for duration-based work.

Development Conventions

  • Prefer existing package patterns, helpers, and OpenTelemetry abstractions over introducing new wrappers.
  • Keep changes scoped to the package or example relevant to the task.
  • Update examples or docs when public behavior, configuration, or package usage changes.
  • docs/navigation.yml owns the TypeScript subtree embedded in the Logfire docs. Update it alongside changes to published JS docs pages; keep public slugs and existing aliases stable unless a redirect is intentional. The Logfire Python repository only supplies the subtree's placement. Unified-docs reads this manifest from logfire-js main; trigger its docs deployment after merging a navigation change. No pydantic/logfire change is needed.
  • Add or update tests for behavior changes. If a package has minimal tests or --passWithNoTests, still run typecheck/build for that package when relevant.
  • Avoid adding production dependencies without a clear need; keep workspace dependency and lockfile changes together.
  • Do not put agent-specific or vendor-specific instructions here unless they are explicitly about repository compatibility. Use generic wording that applies to any coding agent.

Testing Guidance

  • Tests use Vitest and usually live alongside source files as *.test.ts.
  • Prefer exact assertions over fuzzy matching for stable output. Use toBe or toEqual with deterministic inputs instead of toContain or broad regex matching.
  • When testing formatted errors or stack output, mock stack strings so assertions stay deterministic.
  • The focused eval coverage script is temporarily disabled during the Vite+ migration because Vite+ coverage currently reports mixed Vitest package versions. For eval changes, run the package tests and typecheck instead:
vp run logfire#test
vp run logfire#typecheck

Package-Specific Notes

  • packages/logfire-node/src/logfireConfig.ts owns Node SDK configuration and environment variable handling.
  • Relevant environment variables include LOGFIRE_TOKEN, LOGFIRE_SERVICE_NAME, LOGFIRE_SERVICE_VERSION, LOGFIRE_ENVIRONMENT, LOGFIRE_CONSOLE, LOGFIRE_SEND_TO_LOGFIRE, and LOGFIRE_DISTRIBUTED_TRACING.
  • packages/logfire-api is the base API package and should not depend on runtime-specific packages.
  • Cloudflare Workers code should stay compatible with Worker runtime constraints.
  • Browser code should avoid Node-only APIs.
  • Prefer browser configureFrontend({ baseUrl, token, ...options }) for direct frontend application setup; it enables auto-instrumentation and Web Vitals metrics by default. Keep configure() for custom transports and proxies. See docs/packages/browser.md for overrides and optional replay.

Examples

Use examples to validate integration behavior when package-level tests do not cover the runtime path. Check the target example's package.json before running it, because scripts vary by example.

Typical flow:

cd examples/express
pnpm install
pnpm run dev

Agent Guidance Maintenance

  • Keep this file concise and operational. Prefer links or file paths over copied explanations when the code is self-describing.
  • If a subdirectory needs different build, test, or safety rules, add a nested AGENTS.md in that directory instead of growing this root file.
  • Instructions closest to the edited file should be treated as more specific than this root file.
  • Preserve the CLAUDE.md symlink unless the repository drops compatibility with tools that read it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.