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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# Kayba Hosted API

The Kayba hosted API lets you upload traces, generate insights, and pull optimised prompts without running ACE roles locally. The `kayba` CLI wraps every API endpoint.

## Prerequisites

1. A Kayba API key (set `KAYBA_API_KEY` or pass `--api-key` to every command).
2. An Anthropic API key (set `ANTHROPIC_API_KEY`) β€” used server-side for LLM calls when generating insights.
3. Install the `cloud` extra:

```bash

uv tool install 'ace-framework[cloud]' --python 3.12

```

Quote the extra in `zsh`/`bash` so `[cloud]` is not treated as a shell glob.

Or if you installed from source:

```bash

uv sync

```

## Authentication

Every command reads `KAYBA_API_KEY` from the environment. You can also pass it explicitly:

```bash

export KAYBA_API_KEY=your-key-here

kayba traces list

```

The default API endpoint is `https://use.kayba.ai/api`. Override it with `KAYBA_API_URL` or `--base-url`.

## Where do traces come from?

Kayba does **not** auto-ingest local transcripts from Claude Code, Codex, Cursor,
or other coding agents. The hosted API and web UI only show traces that you
explicitly upload.

- **Claude Code:** session transcripts are typically written under
  `~/.claude/projects/<slug>/*.jsonl`
- **Codex:** local session logs are discoverable under
  `~/.codex/sessions/YYYY/MM/DD/*.jsonl`
- **Cursor:** no auto-ingest; locate or export the transcript files from your
  setup first, then upload them manually

Copy-pasteable examples:

```bash

kayba traces upload ~/.claude/projects/<slug>/

kayba traces upload ~/.codex/sessions/2026/04/10/

```

You can point `kayba traces upload` at a single file, a glob-expanded file list,
or a directory. Directories are walked recursively, so uploading the project or
day folder is usually the simplest option.

## CLI Reference

### Trace management

```bash

# List uploaded traces

kayba traces list

kayba traces list --json          # machine-parseable output



# View a trace

kayba traces show TRACE_ID

kayba traces show TRACE_ID --meta  # metadata only, no content

kayba traces show TRACE_ID --json



# Upload traces

kayba traces upload trace.md

kayba traces upload session.jsonl  # common for Claude Code / OpenClaw

kayba traces upload traces/       # directory (recursive)

kayba traces upload --type json traces/  # force file type

cat trace.md | kayba upload -     # pipe from stdin (top-level alias)



# Delete traces

kayba traces delete ID1 ID2

kayba traces delete ID1 --force   # skip confirmation

```

Files larger than 350k characters are rejected by the API. The CLI skips them
locally and tells you to split or trim the trace first. Supported types are
auto-detected from the extension: `.md`/`.markdown` β†’ `md`,
`.json`/`.jsonl` β†’ `json`, everything else β†’ `txt`.

### Run the pipeline

The `run` command combines trace selection and pipeline execution:

```bash

# Interactive mode (visual checkbox selector)

kayba run



# Select all traces

kayba run --all --wait



# Explicit trace IDs

kayba run --traces ID1 --traces ID2



# Custom model, epochs, and reflector mode

kayba run --all --model claude-opus-4-6 --epochs 3 --reflector-mode recursive --wait



# Machine-parseable output (for agents/scripts)

kayba run --all --json

```

In interactive mode (`kayba run` with no flags), a visual checkbox selector lets you pick traces with arrow keys, space to toggle, and enter to confirm. Requires the `questionary` package (included in the `cloud` extra).

In programmatic mode (`--traces`, `--all`, or `--json`), no prompts are shown β€” suitable for agents and scripts.

Options:

| Flag | Description |
|------|-------------|
| `--traces ID` | Trace IDs to analyse (repeatable) |
| `--all` | Select all uploaded traces |
| `--model` | `claude-sonnet-4-6` or `claude-opus-4-6` |
| `--epochs N` | Number of analysis epochs |
| `--reflector-mode` | `recursive` or `standard` |
| `--anthropic-key` | Anthropic API key for server-side LLM calls |
| `--wait` | Poll until the job completes |
| `--json` | Machine-parseable JSON output |

### Generate insights

```bash

# From all uploaded traces

kayba insights generate --wait



# Specific traces

kayba insights generate --traces ID1 --traces ID2



# Custom model and epochs

kayba insights generate --model claude-opus-4-6 --epochs 3 --wait

```

### List and triage insights

```bash

# List all

kayba insights list



# Filter by status

kayba insights list --status pending



# JSON output

kayba insights list --json



# Accept specific insights

kayba insights triage --accept ID1 --accept ID2



# Accept all pending

kayba insights triage --accept-all



# Reject with a note

kayba insights triage --reject ID1 --note "Too vague"

```

### Generate and pull prompts

```bash

# Generate a prompt from accepted insights

kayba prompts generate



# Generate with a label and save to file

kayba prompts generate --label "v2-coding" -o prompt.md



# List prompt versions

kayba prompts list



# Pull latest prompt

kayba prompts pull



# Pull specific version

kayba prompts pull --id PROMPT_ID -o skillbook-prompt.md



# Pretty-print full JSON

kayba prompts pull --pretty



# Install the latest prompt into Claude Code's instruction file

kayba prompts install --target claude-code



# Install a local prompt export into AGENTS.md

kayba prompts install --input prompt.md --target universal

```

To install the generated prompt into `CLAUDE.md`, `AGENTS.md`, or
`.cursorrules` without duplicating prior runs, see
[Using your generated prompt](#using-your-generated-prompt).

### Integrations

Manage connections to external trace platforms (MLflow, LangSmith).

```bash

# List configured integrations

kayba integrations list

kayba integrations list --json



# Interactively configure an integration

kayba integrations configure mlflow

kayba integrations configure langsmith



# Test a connection

kayba integrations test langsmith

kayba integrations test mlflow

```

The `configure` command prompts for each field interactively:

- **MLflow**: tracking URI, auth type (none/basic/bearer/databricks), token, username, experiment name
- **LangSmith**: API URL (defaults to `https://api.smith.langchain.com`, use `https://eu.api.smith.langchain.com` for EU), API key, project name

After saving, the connection is automatically tested. Credentials are stored in your Kayba account settings (DynamoDB), accessible from both the CLI and the web dashboard.

### Job status and materialisation

```bash

# Check job status

kayba status JOB_ID



# Poll until complete

kayba status JOB_ID --wait --interval 10



# Materialise results into the skillbook

kayba materialize JOB_ID

```

### Batch pre-processing

The `batch` command groups traces into batches before analysis. It works in two modes:

**Prepare mode** (default) β€” extracts trace metadata and prints a classification prompt:

```bash

kayba batch traces/

```

This writes a skeleton `batches.json` and prints a prompt to stdout. Pipe it to an LLM (e.g. Claude Code) to fill in the batch assignments.

**Apply mode** β€” validates and optionally uploads a batch plan:

```bash

# Validate only

kayba batch traces/ --apply batches.json



# Validate and upload each batch

kayba batch traces/ --apply batches.json --upload

```

Options:

| Flag | Description |
|------|-------------|
| `--prompt FILE` | Custom classification prompt template |
| `-o FILE` | Output batch plan file (default: `batches.json`) |
| `--apply FILE` | Apply an existing batch plan |
| `--upload` | Upload each batch (requires `--apply`) |
| `--min-batch-size N` | Minimum traces per batch (default: 10) |
| `--max-batch-size N` | Maximum traces per batch (default: 30) |

### Agent setup

```bash

# Print CLI instructions and install pipeline skills

kayba setup



# Append to a project agent file

kayba setup --append-to AGENTS.md



# Skip skill installation

kayba setup --no-skills



# Install into a different project

kayba setup --project-dir /path/to/project

```

Options:

| Flag | Description |
|------|-------------|
| `--append-to FILE` | Append instructions to file instead of printing (recommended: `AGENTS.md`) |
| `--skills/--no-skills` | Install Claude Code pipeline skills (default: enabled) |
| `--project-dir DIR` | Project root directory (default: current directory) |

By default `kayba setup` copies the **kayba-pipeline** skill into `.claude/skills/`. This skill orchestrates a 7-stage evaluation pipeline (analyze traces β†’ compute metrics β†’ build rubric β†’ plan fixes β†’ HITL review β†’ apply fixes β†’ verify). See [Claude Code](claude-code.md#pipeline-skill) for details.

## End-to-end workflows

### Interactive (human at terminal)

```bash

# 1. Upload traces

kayba traces upload traces/



# 2. Run the pipeline (interactive trace selector)

kayba run



# 3. Review insights

kayba insights list --status pending

kayba insights triage --accept-all



# 4. Generate a prompt

kayba prompts generate -o prompt.md



# 5. Install it into your agent

kayba prompts install --target claude-code

```

### Programmatic (agent or script)

```bash

# 1. Upload traces

kayba traces upload traces/



# 2. List what was uploaded

TRACES=$(kayba traces list --json | jq -r '.[].id')



# 3. Run the pipeline on all traces

JOB_ID=$(kayba run --all --json | jq -r '.jobId')



# 4. Wait for completion

kayba status $JOB_ID --wait



# 5. Accept all insights and generate prompt

kayba insights triage --accept-all

kayba prompts generate -o prompt.md



# 6. Install the latest prompt into your agent

kayba prompts install --target codex

```

## Python client

The `KaybaClient` class can be used directly in Python code:

```python

from ace.cli.client import KaybaClient



client = KaybaClient(api_key="your-key")



# Trace management

traces = client.list_traces()

trace = client.get_trace("conv-123")

client.delete_trace("conv-123")

result = client.upload_traces([

    {"filename": "trace.md", "content": "...", "fileType": "md"},

])



# Run pipeline

job = client.generate_insights(

    trace_ids=["conv-123", "conv-456"],

    model="claude-sonnet-4-6",

)



# Check status

status = client.get_job(job["jobId"])



# List and triage

insights = client.list_insights(status="pending")

client.triage_insight(insights["insights"][0]["id"], "accepted")



# Generate and pull prompts

client.generate_prompt()

prompts = client.list_prompts()

prompt = client.get_prompt(prompts[0]["id"])



# Integrations

integrations = client.get_integrations()

client.update_integration("langsmith", {

    "enabled": True,

    "apiUrl": "https://eu.api.smith.langchain.com",

    "apiKey": "lsv2_pt_...",

})

result = client.test_integration("langsmith")

```

## API endpoints

| Method | Path | Client method |
|--------|------|---------------|
| `GET` | `/traces` | `list_traces()` |
| `POST` | `/traces` | `upload_traces()` |
| `GET` | `/traces/:id` | `get_trace()` |
| `DELETE` | `/traces/:id` | `delete_trace()` |
| `POST` | `/traces/batch` | `get_traces()` |
| `POST` | `/insights/generate` | `generate_insights()` |
| `GET` | `/insights` | `list_insights()` |
| `PATCH` | `/insights/:id` | `triage_insight()` |
| `GET` | `/jobs/:id` | `get_job()` |
| `POST` | `/jobs/:id` | `materialize_job()` |
| `POST` | `/prompts/generate` | `generate_prompt()` |
| `GET` | `/prompts` | `list_prompts()` |
| `GET` | `/prompts/:id` | `get_prompt()` |
| `GET` | `/integrations` | `get_integrations()` |
| `PUT` | `/integrations/:name` | `update_integration()` |
| `POST` | `/integrations/:name/test` | `test_integration()` |

## Coding agent setup

**Quick (current session):** Tell your coding agent to run `kayba setup`. The agent will see
the full CLI reference in its context and know how to use every command. The pipeline skill is
also installed to `.claude/skills/`, giving Claude Code access to the 7-stage evaluation pipeline.

**Persistent (all future sessions):** Append instructions to your project's agent file:

```bash

kayba setup --append-to AGENTS.md      # universal (Claude Code, Cursor, Copilot, Windsurf, etc.)

kayba setup --append-to CLAUDE.md      # Claude Code only

kayba setup --append-to .cursorrules   # Cursor only

```

`AGENTS.md` is the recommended target β€” it's the universal standard supported by 20+ coding agents.

To skip skill installation (e.g. for non-Claude-Code agents), pass `--no-skills`.

This setup step is separate from prompt installation. Once you have accepted
insights and generated a prompt, use `kayba prompts install` to update
`AGENTS.md`, `CLAUDE.md`, or `.cursorrules` with the generated prompt content.

## Environment variables

| Variable | Description |
|----------|-------------|
| `KAYBA_API_KEY` | API key (required) |
| `KAYBA_API_URL` | Base URL (default: `https://use.kayba.ai/api`) |
| `ANTHROPIC_API_KEY` | Passed to server for LLM calls via `--anthropic-key` |

## Using your generated prompt

`kayba prompts generate -o prompt.md` writes a Markdown prompt block built from
your accepted insights. It does **not** update `CLAUDE.md`, `AGENTS.md`, or
`.cursorrules` automatically; you choose where to apply it.

Use the built-in installer to update the right file without duplicating old
blocks:

```bash

# Install the latest prompt from Kayba into Claude Code

kayba prompts install --target claude-code



# Install the latest prompt into a universal agent file

kayba prompts install --target universal



# Install a local export into Cursor

kayba prompts install --input prompt.md --target cursor

```

The installer manages a dedicated Kayba block, so re-running it replaces the
previous prompt instead of appending duplicates.