instrument
/instrument
Use when a developer's LLM app is running but has NO traces yet and wants capture flowing in about a minute with no code changes — "instrument my app", "start capturing my LLM calls", "I have no traces, get me some", "turn on tracing for my agent". Detects the provider SDK, redirects it through the Understudy gateway (capture on by default) via env vars, verifies a capture actually landed, then hands off to ingest-traces.
- Author
- understudylabs ↗
- Repository
- understudy-agent-tools ↗
- Licence
- MIT
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 1
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use when a developer's LLM app is running but has NO traces yet and wants capture flowing in about a minute with no code changes — "instrument my app", "start capturing my LLM calls", "I have no traces, get me some", "turn on tracing for my agent". Detects the provider SDK, redirects it through the Understudy gateway (capture on by default) via env vars, verifies a capture actually landed, then hands off to ingest-traces.
Triggers from the description
Original author description
Use when a developer's LLM app is running but has NO traces yet and wants capture flowing in about a minute with no code changes — "instrument my app", "start capturing my LLM calls", "I have no traces, get me some", "turn on tracing for my agent". Detects the provider SDK, redirects it through the Understudy gateway (capture on by default) via env vars, verifies a capture actually landed, then hands off to ingest-traces.
How it works
- Resolve CLI
- Safety Gates
- Step 1 — Detect what the app talks to (~1 min)
- Step 2 — Sign in and pick the project (~2 min, skipped if done)
- Step 3 — Redirect with zero code changes
- Step 4 — Verify a trace is actually flowing (do not skip)
- Honest fallbacks when env redirect cannot work
- Handoff
SKILL.md preview
---
name: instrument
description: Use when a developer's LLM app is running but has NO traces yet and wants capture flowing in about a minute with no code changes — "instrument my app", "start capturing my LLM calls", "I have no traces, get me some", "turn on tracing for my agent". Detects the provider SDK, redirects it through the Understudy gateway (capture on by default) via env vars, verifies a capture actually landed, then hands off to ingest-traces.
metadata:
understudy:
mode: interactive
safety: auth-gated
cli_required: true
---
# Instrument
[`../ingest-traces/SKILL.md`](../ingest-traces/SKILL.md) and
[`../capture-evidence/SKILL.md`](../capture-evidence/SKILL.md) assume traces
already exist. This worker is the on-ramp before that: a running app, zero
traces, and a developer who wants captures flowing **without editing app
code**. One redirect, one test call, one verified capture — then hand off.
**Say this up front:** "This takes about 5 minutes: ~1 minute to detect your
SDK, ~2 minutes to sign in if you haven't, ~1 minute to redirect and verify a
test call. No code changes, and nothing leaves your machine without your
approval."
## Resolve CLI
Prefer the installed `orchestra` binary. If it is unavailable inside a repo
checkout, run through the package script:
```sh
npm run build
node dist/bin.js instrument --check --json
```
## Safety Gates
- **No app-code edits on this path.** The whole point is env-var redirection.
If a codebase hardcodes a base URL so env vars cannot work, say so and offer
the code-patch recipes in `skills/onboard/` as an explicitly separate,
approval-gated step — do not silently edit.
- **Redirecting traffic through the gateway is an external write of the
developer's prompts and completions** (that is what capture *is*). State
this plainly and get explicit approval before the first redirected call.
- Never print, commit, or write `sk_*` values. Use `orchestra run -- <cmd>`
to inject credentials into the child process only (see
[`../use-understudy-gateway/SKILL.md`](../use-understudy-gateway/SKILL.md)).
- Set redirect env vars in the launch command or the developer's shell
session, not in checked-in files. Only write to `.env` if the developer
explicitly asks, and never commit it.
- Do not declare success until a capture is verified to exist (step 4).
## Step 1 — Detect what the app talks to (~1 min)
Inspect the project read-only. Look at `package.json` /
`requirements.txt` / `pyproject.toml` / lockfiles and grep call sites:
| Found | Provider path |
| --- | --- |
| `@anthropic-ai/sdk`, `anthropic` (py) | Anthropic-shape → `ANTHROPIC_BASE_URL` |
| `openai` (ts/py) | OpenAI-shape → `OPENAI_BASE_URL` |
| `langchain`, `langchain-openai`, `langchain-anthropic` | Wraps the SDKs above — same env vars apply |
| `ai` + `@ai-sdk/openai` / `@ai-sdk/anthropic` (Vercel AI SDK) | Usually needs a `baseURL` in the provider factory — check first; env redirect only works if the factory reads the env var |
| `litellm` | OpenAI-shape → `OPENAI_BASE_URL` or litellm's own base-url config |
| none of the above / hardcoded `baseURL` | Env redirect will not bite — see the honest fallbacks below |
Per-SDK env-var behavior, base-URL shapes (`/v1` or not), and hardcoded-URL
detection greps are in [`reference.md`](reference.md).
Also confirm the developer can actually trigger one call: an npm script, a
CLI invocation, a test, or a curl to their own app. If they cannot, stop —
there is nothing to capture yet.
## Step 2 — Sign in and pick the project (~2 min, skipped if done)
Reuse the login/key flow in
[`../use-understudy-gateway/SKILL.md`](../use-understudy-gateway/SKILL.md) —
do not duplicate it here. In short: `orchestra status --json`; if not signed
in, the two-phase `orchestra login --email` / `--code` flow; then confirm
`orchestra projects list --json`. Gateway capture is on by default for
gateway traffic, so no extra capture toggle is needed.
## Step 3 — Redirect with zero code changes
Preferred: run the app (or one test invocation) through the wrapper, which
injects `UNDERSTUDY_API_KEY` and `UNDERSTUDY_GATEWAY_URL` into the child
process only, and set the SDK base-URL env var inline:
```sh
# Anthropic SDK app (note: no trailing /v1 — the SDK appends it)
ANTHROPIC_BASE_URL="$UNDERSTUDY_GATEWAY_URL" orchestra run -- <your app command>
# OpenAI SDK app (OpenAI-shape wants the /v1 suffix)
OPENAI_BASE_URL="${UNDERSTUDY_GATEWAY_URL:-https://api.understudylabs.com}/v1" \
orchestra run -- <your app command>
```
`orchestra run` resolves the stored credentials, so inside the child process
`$UNDERSTUDY_GATEWAY_URL` is set; the SDK's own env var points it there. The
provider API key env var can stay as-is — the gateway authenticates with the
Understudy key that `orchestra run` injects (see the gateway skill for
key-header details per shape).
## Step 4 — Verify a trace is actually flowing (do not skip)
Trigger exactly one real call through the app, then confirm the capture
landed before saying anything succeeded:
```sh
orchestra captures list --json # newest capture should match the test call
orchestra instrument --check --json # local sanity: env redirect + capture presence
```
If `captures list` shows nothing new: check `orchestra doctor --hosted`,
re-grep for a hardcoded `baseURL` shadowing the env var, and confirm the app
process actually inherited the env (a daemon started earlier did not).
## Honest fallbacks when env redirect cannot work
- **No local capture proxy exists in this CLI today.** There is no
`understudy`-served localhost endpoint that records calls and forwards to
the provider; do not promise one. The zero-code path is the gateway
redirect above.
- **Hardcoded base URL / unsupported SDK:** offer the code-patch recipes in
`skills/onboard/` (`anthropic-typescript.md`, `openai-typescript.md`,
`universal-typescript.md`) as an explicit, approved edit — outside this
skill's no-code promise.
- **Developer cannot or will not route through the gateway:** use provider
log exports (Anthropic/OpenAI console usage or logging exports, or the
app's own request logs) and go straight to
[`../ingest-traces/SKILL.md`](../ingest-traces/SKILL.md), which turns a
JSONL/CSV export in `.understudy/captures/` into local redacted eval sets.
## Handoff
Once roughly 20–50 captures exist (enough for a first slice), route onward:
- Turn them into local redacted eval sets or profile the spend →
[`../ingest-traces/SKILL.md`](../ingest-traces/SKILL.md).
- Build the measured baseline and frozen splits →
[`../capture-evidence/SKILL.md`](../capture-evidence/SKILL.md).
Report to the developer: what was redirected, how many captures exist, and
which handoff you chose.
Files in this package (2)
- SKILL.md 7 KB
- reference.md 4 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · understudylabs/understudy-agent-tools | 100 | MIT |
| ADWilkinson/astack | 100 | MIT |
Database snapshot: 13.11.2026 · package version a3bf9839e34e (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Similar skills
- 100use-understudy-gateway
Use when a developer wants to run inference or evals through the Understudy gateway — "route my app through Understudy", "set up my account and keys", "A/B a model on part of my traffic" — or must choose between local provider keys and the gateway route ("should I use my OpenAI… - 100understudy
Use when a developer asks a coding agent to improve an LLM app or agent — "make my LLM app cheaper/faster", "raise quality or reliability", "compare models", "pick a model or route". Orchestrates trace → evaluate → optimize (GEPA, automatic prompt evolution) → compare → deploy… - 100opik-instrument
Add Opik tracing to an existing app and verify a real trace lands. Installs the Opik package, detects the language and LLM framework, adds the minimum tracing, runs a safe representative path, confirms a trace in Opik, and returns the trace link. Use for "instrument my code",… - 100opik-instrument
Add Opik tracing to an existing app and verify a real trace lands. Installs the Opik package, detects the language and LLM framework, adds the minimum tracing, runs a safe representative path, confirms a trace in Opik, and returns the trace link. Use for "instrument my code",… - 100instrument-llm-observability
Use this when adding tracing/observability to an LLM or AI-agent application - capturing prompts, tool calls, token usage, latency, and cost per step. Trigger whenever someone wants to "add tracing", "instrument", "monitor", "see what my agent is doing", or debug an LLM app in… - 90weave-instrument
Add Weave tracing to Python or TypeScript agents and LLM applications. Use when asked to instrument model calls, tools, or agent turns with Weave.