skills/bootstrap-existing-agent-with-prefactor-cli/SKILL.md
Use when an existing agent needs Prefactor resources created via the Prefactor CLI before SDK instrumentation is added.
npx skillsauth add prefactordev/typescript-sdk bootstrap-existing-agent-with-prefactor-cliInstall 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.
Set up Prefactor resources for an already-working agent before instrumentation code changes.
Core principle: provision first, instrument second.
Apply this skill first when the user asks to:
After this skill completes:
skills/instrument-existing-agent-with-prefactor-sdk/SKILL.md.skills/create-provider-package-with-core/SKILL.md.langchain, ai, openclaw, or custom)Before running CLI commands, choose package first, then install required Prefactor package(s).
bun, npm, pnpm, or yarn).@prefactor/cli for bootstrap commands.prefactor command requirement:
prefactor command comes from the npm package @prefactor/cli.bunx @prefactor/cli, npx @prefactor/cli, pnpm dlx @prefactor/cli, or yarn dlx @prefactor/cli).prefactor help or prefactor <group> help for command details.Examples:
# bun
bun add @prefactor/cli
# npm
npm install @prefactor/cli
# pnpm
pnpm add @prefactor/cli
# yarn
yarn add @prefactor/cli
Run these in order:
prefactor profiles add default [base-url] --api-token <api-token>
prefactor accounts list
prefactor environments create --name <env-name> --account_id <account-id>
prefactor agents create --name <agent-name> --environment_id <environment-id>
prefactor agent_instances register \
--agent_id <agent-id> \
--agent_version_external_identifier <agent-version-id> \
--agent_version_name <agent-version-name> \
--agent_schema_version_external_identifier <schema-version-id> \
--update_current_version
Profile notes:
<profile-name> is any key like default, staging, or prod.--profile <name>.npx @prefactor/cli profiles add ...).Config resolution notes:
./prefactor.json~/.prefactor/prefactor.json./prefactor.jsonCollect and persist these IDs from command output:
environment_idagent_idagent_instance_idChoose package by provider:
@prefactor/langchain@prefactor/ai@prefactor/openclawskills/create-provider-package-with-core/SKILL.mdWhen handing off to SDK instrumentation, import helpers from that selected package directly, for example:
import { init, withSpan, shutdown } from '@prefactor/ai';
// or '@prefactor/langchain'
Do not mix adapter init with withSpan/shutdown from @prefactor/core unless an explicit tracer is passed.
This guidance targets adapter-style integrations (@prefactor/ai, @prefactor/langchain) and does not change @prefactor/openclaw plugin runtime behavior.
If you have identified and selected an existing package, use skills/instrument-existing-agent-with-prefactor-sdk/SKILL.md
Produce this output for the user after setup:
export PREFACTOR_API_URL="<api-url>"
export PREFACTOR_API_TOKEN="<api-token>"
export PREFACTOR_AGENT_ID="<agent-id>"
Use the created agent_id for PREFACTOR_AGENT_ID.
prefactor.json is ignored by git (git check-ignore prefactor.json, git status --short).agent_id to PREFACTOR_AGENT_ID.@prefactor/core directly when a built-in adapter exists.prefactor.json.prefactor.json (contains API tokens).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.