bootstrap-existing-agent-with-prefactor-cli
Original:🇺🇸 English
Translated
Use when an existing agent needs Prefactor resources created via the Prefactor CLI before SDK instrumentation is added.
3installs
Added on
NPX Install
npx skill4agent add prefactordev/typescript-sdk bootstrap-existing-agent-with-prefactor-cliTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Bootstrap Existing Agent With Prefactor CLI
Set up Prefactor resources for an already-working agent before instrumentation code changes.
Core principle: provision first, instrument second.
Coding Assistant Usage
Apply this skill first when the user asks to:
- "set up Prefactor for this existing agent"
- "create Prefactor environment/agent/instance"
- "use CLI to bootstrap Prefactor"
- "prepare IDs and env vars before instrumentation"
After this skill completes:
- If provider is supported, continue with .
skills/instrument-existing-agent-with-prefactor-sdk/SKILL.md - If provider is unsupported, continue with .
skills/create-provider-package-with-core/SKILL.md - Return a copy/paste block with exported env vars and the selected package.
Inputs You Need
- Prefactor API token (for CLI profile)
- Base URL (optional, defaults to Prefactor cloud)
- Account ID
- Target provider/framework (,
langchain,ai, or custom)openclaw - Human-readable names for environment and agent
- Working directory to store config (recommended: repo root)
CLI Workflow
Before running CLI commands, choose package first, then install required Prefactor package(s).
- Use whichever package manager the project already uses (,
bun,npm, orpnpm).yarn - Install for bootstrap commands.
@prefactor/cli
prefactor- The command comes from the npm package
prefactor.@prefactor/cli - If the command is not globally available, run it via the package manager launcher (,
bunx @prefactor/cli,npx @prefactor/cli, orpnpm dlx @prefactor/cli).yarn dlx @prefactor/cli - Use or
prefactor helpfor command details.prefactor <group> help
Examples:
bash
# bun
bun add @prefactor/cli
# npm
npm install @prefactor/cli
# pnpm
pnpm add @prefactor/cli
# yarn
yarn add @prefactor/cliRun these in order:
bash
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_versionProfile notes:
- is any key like
<profile-name>,default, orstaging.prod - Select profile with .
--profile <name> - When using launchers, prefix commands consistently (for example ).
npx @prefactor/cli profiles add ...
Config resolution notes:
- CLI config resolution order is:
./prefactor.json~/.prefactor/prefactor.json- if none exists, profile creation writes
./prefactor.json
- Global CLI install does not make config global; command working directory still controls which config file is used.
Collect and persist these IDs from command output:
environment_idagent_idagent_instance_id
Package Selection
Choose package by provider:
- LangChain ->
@prefactor/langchain - AI SDK ->
@prefactor/ai - OpenClaw ->
@prefactor/openclaw - Custom/unsupported provider -> use
skills/create-provider-package-with-core/SKILL.md
If you have identified and selected an existing package, use
skills/instrument-existing-agent-with-prefactor-sdk/SKILL.mdRuntime Environment Variables
Produce this output for the user after setup:
bash
export PREFACTOR_API_URL="<api-url>"
export PREFACTOR_API_TOKEN="<api-token>"
export PREFACTOR_AGENT_ID="<agent-id>"Use the created for .
agent_idPREFACTOR_AGENT_IDVerification
- Confirm CLI commands succeeded without HTTP/auth errors.
- Confirm IDs were returned and captured.
- Confirm package selection matches provider.
- Confirm env vars match created resources.
- Confirm is ignored by git (
prefactor.json,git check-ignore prefactor.json).git status --short
Common Mistakes
- Instrumenting code before creating Prefactor resources.
- Using account ID where environment ID is required.
- Forgetting to propagate created to
agent_id.PREFACTOR_AGENT_ID - Picking directly when a built-in adapter exists.
@prefactor/core - Running commands from the wrong directory and reading/writing the wrong .
prefactor.json - Committing (contains API tokens).
prefactor.json