Agent skill · Backend & API

api-ai-langfuse

LLM observability with Langfuse — OpenTelemetry-based tracing, evaluations, prompt management, datasets, and production best practices

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-ai-langfuse --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 20 KB
Bundled scripts: none
Path: skills/ai-llm/api-ai-langfuse/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Guides adding observability to LLM applications using Langfuse. It instructs installing tracing and OpenTelemetry packages, enabling automatic context propagation via startActiveObservation or observe, and using observeOpenAI for OpenAI SDK tracing. It also describes managing prompts with LangfuseClient, applying scores/evaluations, and using datasets/experiments. It emphasizes flushing via forceFlush or sdk.shutdown in short-lived processes and environment-based credentials handling.

How it works

  • Install core tracing: @langfuse/tracing, @langfuse/otel, and @opentelemetry/sdk-node.
  • Use startActiveObservation() to create an observation, propagate context automatically, and end it when the callback completes.
  • Use observe() to wrap functions for automatic input/output capture and timing.
  • For OpenAI calls, wrap the client with observeOpenAI() to enable zero-config tracing.
  • Manage prompts with LangfuseClient from @langfuse/client, including prompt.get, compile, and chat prompt handling.
  • Attach scores/evaluations via LangfuseClient/langfuse.score.create with data types NUMERIC, CATEGORICAL, BOOLEAN, and optionally per-observation.
  • Use datasets and experiments for testing; link prompts to traces as part of traces.
  • Ensure flushing and shutdown: call forceFlush() or sdk.shutdown() in short-lived processes; call langfuse.score.flush() when needed.

When to use it

  • Adding observability and tracing to LLM application code (any provider)
  • Wrapping OpenAI SDK calls for automatic token/cost tracking
  • Managing prompt templates with versioning, labels, and variable compilation
  • Evaluating LLM output quality with scores (numeric, categorical, boolean)
  • Running experiments against datasets for regression testing
  • Tracking sessions, users, and metadata across multi-turn conversations
  • Monitoring LLM costs and token usage in production

What it can touch

  • OpenTelemetry setup via instrumentation.ts (top of entry point)
  • Tracing APIs: startActiveObservation, observe, startObservation, and observeOpenAI
  • Langfuse client: LangfuseClient, prompt.get, prompt.compile, score.create, score.flush
  • OpenAI integration: @langfuse/openai wrapper
  • Environment variables: LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, LANGFUSE_BASE_URL

Caveats

  • Requires environment-based credentials (never hardcode credentials)
  • OpenAI auto-instrumentation relies on observeOpenAI() for zero-config tracing; manual generation observations are discouraged
  • Short-lived processes must flush/shutdown to avoid lost events
  • Context propagation relies on using startActiveObservation() or observe() for nested tracing; manual startObservation() needs explicit .end() calls
From the SKILL.md

# Langfuse Observability Patterns > **Quick Guide:** Use the Langfuse TypeScript SDK (built on OpenTelemetry) to add observability to LLM applications. Install `@langfuse/tracing`, `@langfuse/otel`, and `@opentelemetry/sdk-node` for core tracing. Use `startActiveObservation()` for automatic context propagation or `observe()` to wrap functions. Use `@langfuse/openai` with `observeOpenAI()` for zero-config OpenAI tracing. Use `LangfuseClient` from `@langfuse/client` for prompt management, scores, and datasets. Always call `forceFlush()` or `sdk.shutdown()` in short-lived processes. --- <critical_requirements> ## CRITICAL: Before Using This Skill > **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants) **(You MUST import and register `instrumentation.ts` at the top of your entry point BEFORE any other imports -- OpenTelemetry must instrument modules before they are loaded)** **(You MUST call `forceFlush()` or `sdk.shutdown()` in short-lived processes (serverless, scripts, CLI tools) -- events are batched and will be lost without explicit flushing)** **(You MUST use `@langfuse/openai` with `observeOpenAI()`

What's inside
Steps it walks through
  1. CRITICAL: Before Using This Skill
  2. Examples Index
  3. Philosophy
  4. Core Patterns
  5. Pattern 1: OpenTelemetry Setup
  6. Pattern 2: Tracing with startActiveObservation
  7. Pattern 3: The observe() Wrapper
  8. Pattern 4: OpenAI Auto-Instrumentation
  9. Pattern 5: Prompt Management
  10. Pattern 6: Scores and Evaluations
  11. Pattern 7: Flush and Shutdown
  12. Performance Optimization
  13. Sampling for High-Volume Applications
  14. Key Optimization Patterns
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the api-ai-langfuse skill do?

LLM observability with Langfuse — OpenTelemetry-based tracing, evaluations, prompt management, datasets, and production best practices

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-ai-langfuse --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going