Installation
Run the CLI from your project directory:/bitfab:setup.
Pass an initial setup request with --prompt (or -p) to send it straight to the agent:
claude auth login first.
Manual installation (without the CLI)
Manual installation (without the CLI)
Add the Bitfab plugin marketplace and install:Then restart Claude Code and run the setup command to authenticate and instrument your codebase:
What the Plugin Does
Automatic Setup
The/bitfab:setup command runs a multi-phase workflow:
- Login — Opens your browser for OAuth authentication, saves credentials securely
- Instrument + Replay (in parallel, per workflow) — Reads your codebase, finds all AI workflows (LLM calls, agents, AI-driven decisions), and presents them as a numbered list. You choose which to instrument — it adds tracing with minimal diffs, and at the same time generates a replay script so you can regression-test your trace functions against production data with one command
Assistant
The/bitfab:assistant command turns production traces into code improvements, whether the goal is correctness (improving pass rates) or efficiency (cutting token usage and cost). Your agent will do the mechanical work and collaborate with you on three steps:
- Build a dataset from production traces — search for failures, label them with expected outcomes
- Experiment against that dataset — make isolated code changes, replay, compare results
- Hill climb — repeat until the best change is found, then present results
Building the Dataset
Your coding agent does the data wrangling — it searches production traces for failures, reads full inputs and outputs, and identifies edge cases. It then presents edge cases for your judgment: is this a failure (and what should the output be), correct, or irrelevant? This labeled dataset becomes the benchmark for all experiments. The plugin opens a rich UI for navigating and labeling the dataset, then brings you back to your coding agent so you stay in flow. You can label every trace yourself, or label a few and let the agent classify the rest based on the patterns you’ve established.Running Experiments
The command reads your code, diagnoses failure patterns, and categorizes proposed changes:- Code fixes — deterministic bugs, bundled into one experiment as a foundation
- Judgment-based fixes — prompt changes, search tuning, output formatting — each gets its own experiment
- Infrastructure proposals — larger changes noted for future work, not experimented on
Results
After each round, you see which traces now match expected outcomes, which still diverge, and whether any regressions occurred. The assistant works through the planned experiments in turn without pausing to ask whether to keep going, then wraps up once the plan is complete. The final summary shows pass rate improvement and all files changed, uncommitted in your working tree for review.MCP Tools
The plugin registers MCP tools that Claude Code can call during conversations. These let you inspect traces, manage datasets and labels, run experiments, and improve your code without leaving the editor.Core
get_bitfab_api_key
Retrieve your API key for SDK initialization and environment variable configuration.
get_api_key_context
Returns which Bitfab org the plugin reads/writes to (it can differ from the project’s BITFAB_API_KEY and from the org open in Studio). Call before the first plugin write of a session, or when data you wrote isn’t visible in Studio.
list_organizations
List the Bitfab organizations available to the signed-in user, marking the current plugin org.
get_database_connection_status
Reports whether the org has a database connected for per-trace replay branching (none, checking, connected, or failed). Used by /bitfab:setup db-snapshot to tell when the branchable copy is ready.
Trace Inspection
list_trace_functions
List all traced functions in your organization.
search_traces
Search and filter traces with full-text search, date ranges, status filters, regex matching, environment, and label filters. Supports drill-down to narrow results progressively. Filter by datasetId to scope to a specific dataset, or by testRunId to scope to a specific experiment’s replay traces. Filter by hasDbSnapshot to scope to traces that captured (or lack) a database snapshot reference.
read_traces
Read one or more traces by ID with the trace environment plus summary (truncated) or full span details (input, output, reasoning, context, errors, per-span duration, tokens, and model).
read_trace_labels
Read just the labels for one or more traces by ID: each trace’s pass/fail verdict, its annotation, and whether the label is human-validated. No span content is loaded, so one call accepts up to 100 IDs, ideal for loading a whole dataset’s verdicts at once.
read_span_field
Fetch the complete, untruncated value of a single span field (input, output, reasoning, content, errors, or contexts) when read_traces truncated it. Pass the trace ID, the span’s [ID: ...], and the field name.
Labeling and Datasets
update_agent_labels
Set, skip, or archive the agent’s pass/fail verdict on one or more traces. Supports confidence levels (VeryLow through VeryHigh) and annotations shown to human reviewers. New verdicts start unapproved; once a human approves one in the UI, the label joins the validated dataset.
set_human_labels
Write a validated human pass/fail verdict on one or more traces, with an optional annotation. Unlike update_agent_labels, these labels are validated the instant they’re written (no UI approval step). Used by assistant fix before adding the failing trace to a dataset once the fix is verified.
create_dataset
Create a named dataset for a traced function. Datasets are buckets of traces that humans review and that experiments replay against.
list_datasets
List all datasets for a traced function with IDs, names, descriptions, trace counts, and assigned graders.
add_traces_to_dataset / remove_traces_from_dataset
Add or remove traces from a dataset (idempotent, up to 100 per call). Removing a trace from a dataset does not delete the trace itself.
add_graders_to_dataset / remove_graders_from_dataset
Assign or remove graders from a dataset (idempotent, up to 100 per call). Assignments are restricted to graders in the same organization and trace function as the dataset. Removing an assignment does not delete the grader.
save_grader / list_graders
Create or edit an automated grader (an LLM-as-judge pass/fail check) for a traced function, or list the graders defined for one. save_grader upserts by grader id or by name, supports renaming, clearing pass/fail criteria, and archive/restore. list_graders returns each grader’s name, status, evaluation focus, and criteria; supports case-insensitive name search; and paginates newest-first with 20 results by default, up to 50 per page. Pass the returned cursor to retrieve the next page. Archived graders are hidden by default.
Experiments
create_experiment_group
Assign or reuse one shared group UUID across selected experiments (test runs).
add_grader_to_experiment_group
Assign one grader directly to every experiment currently in a group. Completed experiments queue any missing evaluations immediately; pending experiments use the grader when they complete. Because assignments live on experiments rather than the group, experiments added later do not inherit the grader automatically.
list_experiments
List experiments (replay test runs) for a traced function with status, pass/fail totals, and delta (fixed, regressed, still passing, still failing) for each.
get_experiment_traces
Get individual trace results for an experiment, including each replay trace’s verdict by comparing against the original trace’s label, plus token usage (input, output, cached, total) for the replay and the paired original.
add_graders_to_experiment / remove_graders_from_experiment
Attach or detach graders directly on an experiment (test run) so they run against its replay traces (idempotent, up to 100 per call). Attachments are restricted to active graders in the same organization and trace function as the experiment. The effective grader set at completion is the union of these direct attachments and the dataset’s current runnable graders. Detaching does not delete the grader. Its effect depends on run state: for an in-progress experiment a detached grader that is also a dataset grader is re-added from the dataset at completion (so it still runs), while for an already-completed experiment the grader set is a finalized snapshot with no dataset re-union, so detaching permanently drops that grader from the run’s results. Attaching to an already-completed experiment persists the assignment but does not immediately grade its existing replay traces; those traces are graded only the next time the experiment runs completion again (e.g. an SDK replay retry) or a fresh replay runs.
get_replay_status
Read the current replay test run status, including the mapping from local replay trace IDs to server trace IDs while a replay is still running.
Templates
get_template_reference
Read the agent-facing reference for Bitfab span templates: the Nunjucks engine, render-context schema, registered filters, and common patterns. Call once per session before editing templates.
get_template
Read the rendering template for a span type (llm, agent, function, guardrail, handoff, custom), scoped to a trace function key or org-global.
update_template
Upsert a rendering template for a span type. Controls how span input/output renders in the Bitfab UI.
Instrumentation
create_trace_plan
Post a tracing instrumentation plan (call tree with recommended captured nodes) and get a URL the user opens to confirm or adjust selections.
confirm_trace_plan
Confirm a trace plan without the browser, for the inline “Continue” path where the user reviewed the ASCII plan in chat and skipped Studio. Persists it as the confirmed plan for its trace function key so setup view and setup modify can find it later, and returns the final captured set and per-node replay decisions.
get_trace_plan
Read a trace plan by ID (after user confirmation) or by trace function key (to bootstrap a Modify cycle from a prior plan).
Slash Commands
Session Notifications
The plugin runs a hook on every session start and resume that checks:- Authentication: If you’re not logged in, it reminds you to run
/bitfab:setup - Updates: If a new plugin version is available, it tells you how to update (or auto-updates if you’ve enabled it)
Example Workflows
Instrument a new project
Diagnose and fix a failing function
Ask Claude Code naturally:search_traces and read_traces to inspect failing traces, then suggests code fixes directly.
For a specific failing trace, run /bitfab:assistant fix <trace-id>. The agent diagnoses the failure, confirms why the original trace is wrong before editing when the trace or conversation does not already make that clear, makes the focused code fix, and replays only that trace first. Once the fix passes, it adds that trace to a dataset with a validated failing label, then branches: inspect the before/after in Studio, re-run the full dataset (in Studio or terminal-only), keep iterating, or stop. If that full-dataset re-run reveals real regressions (previously-passing traces the fix broke), it reports them and keeps the target trace saved as a red test to revisit. If the replay still fails, it offers to keep iterating or save the trace as a failing test instead.
Iterate on a trace function
Replay after a code change
After updating a function, run your replay script to test against production data:.bitfab/replays/<run-id>/items/ folder and referenced from .bitfab/replays/<run-id>/events.jsonl.
Configuration
Credentials
Credentials are stored in.bitfab/credentials.local.json when that project-local file exists, otherwise in ~/.config/bitfab/credentials.json (created by /bitfab:setup login with owner-readable permissions).
Environment Variables
Troubleshooting
Not authenticated
If you see “Not authenticated” on session start:- Run
/bitfab:setup loginto authenticate via browser - Check that
~/.config/bitfab/credentials.jsonexists and contains your API key - If using an environment variable, verify
BITFAB_API_KEYis set
MCP tools not available
If Claude Code can’t access the Bitfab tools:- Run
/bitfab:statusto check connection status - Try restarting Claude Code — the MCP server initializes on startup
- Verify the plugin is installed: check
/plugin list
Stale session
The plugin automatically detects and recovers from stale MCP sessions. If tools stop working mid-conversation, they’ll reconnect on the next call.Plugin updates
Run/bitfab:status to check for updates, then /bitfab:update to install the latest version. Restart Claude Code after updating.