---
name: "langfuse-observability-tracer"
description: "Instrument LLM applications with traces, latency breakdowns, and cost analytics."
metadata:
  author: "Langfuse"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "trace llm with langfuse"
  - "track agent cost langfuse"
  - "log user feedback langfuse"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Langfuse Open Source LLM Tracing & Telemetry

Integrates Langfuse open-source observability: tracing multi-step agent chains, tracking generation token costs, logging user feedback scores, and exporting OpenTelemetry metrics.

## When to Invoke
Invoke this skill whenever you need to:
- trace llm with langfuse
- track agent cost langfuse
- log user feedback langfuse

## Execution SOP & Rules
1. Initialize Langfuse client with public and secret API keys in environment variables.
2. Wrap model calls with langfuse.trace() and create nested spans for discrete retrieval steps.
3. Record model, prompt tokens, completion tokens, and latency for exact cost telemetry.
4. Attach user feedback scores to trace IDs using langfuse.score().

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
