Lessons from Building Coding Agent Skills for Langfuse
AI Engineergo watch the original →
the gist
Marc Klingen explains how Langfuse improved agent-driven onboarding by replacing static pre-training context with a dynamic, search-based skill that forces agents to fetch up-to-date documentation and follow best practices.
The Problem: Stale Context and Non-Optimal Agent Behavior
When using coding agents like Claude Code to integrate Langfuse, the agent often relies on outdated pre-training data. This leads to "hallucinated" SDK methods or non-optimal instrumentation patterns. Because the agent lacks a deep understanding of the user's specific application, it often ships broken code, realizes the failure, and then performs a secondary, inefficient search to fix it. This process is slow, opaque, and results in poor instrumentation that fails to capture meaningful traces.
The Solution: A Formalized "Skill" Architecture
Langfuse developed a dedicated "skill" to guide agents through the integration process. Instead of relying on the agent's internal knowledge, the skill provides a structured skill.md file that dictates style (e.g., "ask follow-up questions before deciding") and surfaces a natural language search endpoint. This allows the agent to query the latest documentation directly rather than crawling hundreds of pages. By providing a sitemap and forcing markdown-formatted documentation retrieval, the agent can navigate the infrastructure's capabilities more reliably.
Evaluation and Optimization
To ensure the skill actually works, the team implemented a basic evaluation suite using LLM-as-a-judge. The agent is tasked with instrumenting a sample repository, and the judge verifies the presence of specific spans (e.g., retrieval spans for RAG apps). This prevents regressions during development. Furthermore, the team experimented with "auto-research" loops to improve the skill itself. They discovered that the agent's performance is entirely dependent on the defined target function; if the goal is simply to "minimize turns," the agent will aggressively delete documentation-fetching steps, leading to brittle, outdated implementations.
Key Takeaways
- Trace Everything: Use observability to watch how agents interact with your tools. Looking at traces provides 80% of the insight needed to fix agent behavior.
- Search Over Duplication: Avoid hardcoding documentation into the skill. Instead, provide a search endpoint so the agent fetches the most current information.
- Target Functions Dictate Quality: If you optimize for speed (fewer turns), agents will cut corners and remove reliability-focused steps like documentation lookups.
- Default to Flexibility: Don't assume user environments (e.g., defaulting to European data regions). Prompt the agent to discover the user's specific context.
- Standardize Documentation: Ensure your docs are queryable in markdown format to reduce token overhead and improve parsing accuracy for agents.