skills/instrument-existing-agent-with-prefactor-sdk/SKILL.md
Use when an existing agent already works without Prefactor and you need to add tracing for runs, llm calls, tool calls, and failures with minimal behavior changes.
npx skillsauth add prefactordev/typescript-sdk instrument-existing-agent-with-prefactor-sdkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Instrument a working agent that was built without Prefactor.
Core principle: instrument boundaries, not business logic.
skills/bootstrap-existing-agent-with-prefactor-cli/SKILL.md.bun, npm, pnpm, or yarn).@prefactor/langchain, @prefactor/ai, @prefactor/openclaw) or custom @prefactor/core adapter.Before instrumentation, ensure these runtime credentials are set from CLI bootstrap output:
PREFACTOR_API_URLPREFACTOR_API_TOKENPREFACTOR_AGENT_IDUse the created agent_id for PREFACTOR_AGENT_ID.
Also ensure dependencies are installed from npm via the project's package manager:
@prefactor/langchain, @prefactor/ai, @prefactor/openclaw@prefactor/core only when no built-in adapter is availableIf the user asks for any of these, apply this skill:
Sometimes you need both skills.
skills/create-provider-package-with-core/SKILL.md to build a custom adapter, then use this skill to instrument the existing agent with that adapter.Recommended sequence when unsupported:
@prefactor/core.@prefactor/core:
@prefactor/langchain@prefactor/ai@prefactor/openclawinit, withSpan, and shutdown from the same selected adapter package (@prefactor/ai or @prefactor/langchain) when an adapter exists.init with withSpan/shutdown imported from @prefactor/core unless you pass an explicit tracer to withSpan.No active tracer found (for example with nested package instances), which drops manual custom spans.import { init, withSpan, shutdown } from '@prefactor/ai';
// or
import { init, withSpan, shutdown } from '@prefactor/langchain';
@prefactor/ai, @prefactor/langchain) and not to the @prefactor/openclaw plugin runtime model.skills/create-provider-package-with-core/SKILL.md.langchain:*, ai-sdk:*, openclaw:*).Run equivalent project verification commands (for example build, typecheck, and tests).
Also run at least one real agent request and confirm:
references/coding-tool-triggers.md.references/instrumentation-checklist.md.tools
Use when writing or fixing span summary templates (display templates) on Prefactor span type schemas, when spans show raw JSON or blank summaries in the Prefactor UI, or when you want one-line Liquid summaries of agent, llm, tool, and custom spans.
tools
Use when performing root-cause analysis on a Prefactor agent run — bad output, surprising behavior, high cost, incomplete work, downvotes, or anything worth investigating. Run in the agent's own codebase. User provides agent instance ID (and agent ID if needed).
development
Use when choosing which Prefactor SDK skill to load for agent instrumentation or for building a custom provider integration on top of @prefactor/core.
development
Use when an agent is already instrumented with Prefactor and you need to populate data_risk fields on its span types to enable compliance tracking and data governance.