# Onboarding: set up load testing for your user

**For a human:** give your AI agent (Claude Code, Cursor, Codex, …) one line in your project:

> Follow https://capacitylab.dev/docs/onboard.md and set up load testing for this project.

**For the agent:** you do the setup. Your user answers a few questions once, approves one summary, and publishes or merges what you prepared. Never ask them to write YAML, commands or config by hand: read, propose, write, check and show the diff yourself. This page is the order of work; the linked documents have the details.

## 1. Read the project before asking anything

Find out yourself, from the repository and what you can run locally:

| What | Where to look |
|---|---|
| The product's stage: an idea, staging only, live, growing, releases through CI | deploys, CI files, monitoring; it decides where the program starts ([llms.txt](https://capacitylab.dev/llms.txt)) |
| Environments and their URLs (staging first) | deploy configs, CI/CD files, env examples, infrastructure code, README |
| The HTTP surface | OpenAPI files, routes and controllers, API clients in the frontend |
| How a client authenticates; test users | login endpoints, tokens, cookies, API keys; seed scripts and fixtures |
| The main user actions and what each writes | orders, sign-ups, e-mails, payments, uploads, third-party calls |
| Traffic numbers | access-log, APM or analytics configuration; dashboards the README links |
| What serves static files | the application (and its dot-file rules), nginx, or a CDN in front of it |
| The existing pipeline | `.github/workflows`, `.gitlab-ci.yml`, `.trylle/workflows`, other CI files |

## 2. Ask once, in one message

Ask only what you could not find, each with your proposed default so the user can just say "yes":

- the CapacityLab key (or invite link); without one, they ask at support@capacitylab.dev;
- which environment to test first (default: staging) and its URL, if not in the repository;
- traffic numbers: a recent week of access logs or APM, or their own forecast ([workload-profile.md](/docs/workload-profile.md));
- their SLO (propose one from the product, e.g. p95 under 800 ms and errors under 1 %);
- whether production may ever be tested, and in which hours ([test windows](/docs/access.md#test-windows));
- the environment itself: is staging shared with QA, how its size and data compare with production ([data-volume.md](/docs/data-volume.md)), whether a WAF or rate limit would block one generator, who cleans up what the test creates;
- side effects: which providers (e-mail, payments) staging calls and whether they are stubbed ([external-dependencies.md](/docs/external-dependencies.md)); whether you may add test users to the seed script.

## 3. Show one summary and get one confirmation

One table, every value marked **found** (where), **proposed** or **assumed**:

- the stage, the environment, its URL and the hosts to prove (file or DNS);
- workflows: what each does, its share, its rate, the data it writes ([workload-profile.md](/docs/workload-profile.md));
- SLO and stop conditions; secrets by name and where their values come from; test users and side effects;
- the program you will run ([find-capacity.md](/docs/find-capacity.md)) and its cost: `capacitylab-load check` prints each run profile's price in credits;
- production policy (windows).

Re-testing from CI is not part of this confirmation: you ask about it separately once the program has a `release` profile (step 6).

Do not invent traffic numbers. Wait for the confirmation, then do the rest without further questions unless something blocks you or a rule under [Throughout](#throughout) says to ask.

## 4. Do the setup

1. **Key.** Claim it with the command on the invite page (it writes the answer to a file, not the terminal), or take the one your user gave. Put it into an ignored env file as `CAPACITYLAB_KEY=cl_...` (e.g. `.client.env`, together with the scenario's secrets; add it to `.gitignore`), and pass `--secrets-file .client.env` to every command. Never print or commit it.
2. **CLI.** Install it ([access.md](/docs/access.md#the-cli)); `capacitylab-load me --secrets-file .client.env` shows the balance, ceilings and the host proof line.
3. **Hosts.** Prefer the file proof: add the line as `/.well-known/capacitylab-verify.txt` to the application's static files on a branch, the way its framework serves them, minding the usual traps (dot-files skipped, nginx dot-path deny rules, a single-page app answering `index.html`) ([access.md](/docs/access.md#hosts)). Tell your user what to merge and deploy, then check that an anonymous request returns the line itself. If they manage DNS, give the exact TXT record instead.
4. **Production.** If it may be tested, set its windows before anything else: `capacitylab-load window <host> --allow "…" --tz …`.
5. **`LOAD/`.** Run `capacitylab-load init ./LOAD --app <host>` and replace its placeholders (`nominalRate: 10`, the `search` staircase, `p95: 800ms`) with the numbers from the summary. Then write the real scenario ([load-format.md](/docs/load-format.md)):
   - the workflows from the summary; ids from earlier steps through `outputs` and `pick` ([§4.1](/docs/load-format.md#41-input-generators)), not one hot id;
   - logins: test users as a CSV of e-mails plus one shared password secret ([§6](/docs/load-format.md#6-secrets)); add enough of them to the staging seed (at least the VUs of the workflows that log in);
   - every iteration starts a new session, so a workflow that needs a login logs in each time: put the actions of one real session after one login in the same workflow, so login keeps its real share;
   - test data the run creates or needs: a setup workflow can create it before the load and a teardown remove it after, if the application has endpoints for that ([§7.4](/docs/load-format.md#74-setup-teardown-and-background-workflows)); work that goes on beside users (an import, a reindex) is a background workflow;
   - side effects: the scenario cannot stop staging from sending real e-mails or payments; stub those providers on staging, and never send load to a provider's sandbox beyond its terms ([test-environments.md](/docs/test-environments.md));
   - `mix` and `model.nominalRate` from the profile, a `stop` block from the SLO, and the `search` run profile ([§7.2](/docs/load-format.md#72-run-profiles)); `confirm`, `soak` and `release` come after the search, from its result.

   Run `capacitylab-load check ./LOAD` until it passes. Write the profile's source and date into the text of `LOAD/README.md`. Show the diff.

## 5. Run the first steps

1. **Smoke:** `capacitylab-load run ./LOAD --target https://<staging> --secrets-file .client.env --smoke --cloud`. If steps fail, read the failures by step ([results.md](/docs/results.md)), fix `LOAD/` and smoke again: do not send load through a broken scenario. If the CLI says most responses came from a cache, vary the URLs first (`check` lists the steps that repeat): a staircase would measure the cache.
2. **Find the limit:** the same command with `--profile search` instead of `--smoke`. Tell your user what it showed, with the `report_url`, and the next step the CLI prints. Add the `confirm` profile it suggests.
3. **Confirm**, then offer the **soak**. Ask before runs that cost much more than the ones before (a 3-hour soak at 30 iterations/s is 360 credits) and before any production run.

## 6. Leave it running without you

- **CI, only with your user's yes:** every pipeline run is a charged load test. Propose the job first: what triggers it, about how many runs a month, the credits per run and per month, and that CI bills the minutes it waits ([ci.md](/docs/ci.md)). Without a yes, write the release command into `LOAD/README.md` for your user to run by hand and stop here. With a yes, add a job that re-tests every release with `--profile release`, publishes the Markdown summary (job summary or pull-request comment), pins the baseline on the main branch and skips production outside its windows ([ci.md](/docs/ci.md)). It needs `CAPACITYLAB_KEY`, every secret `LOAD/` declares and the staging URL: set them with `gh secret set` / `gh variable set` (or your CI's equivalent) if your user agrees, otherwise list the exact names. Add the staging data reset before the test ([ci.md](/docs/ci.md#set-up-once)). Show the diff; your user merges.
- **Records:** every run goes into the text of `LOAD/README.md` (date, run id, `report_url`, verdict, program step), so the next session continues instead of starting over.
- **Reminders:** write into `LOAD/README.md` when to take the profile again (in 1–3 months, before the next campaign) ([workload-profile.md](/docs/workload-profile.md#5-refresh-the-profile)).

## Throughout

- Before each step, say what you are about to do; after each run, say what it showed, which step it completes and what is next.
- Solve what you can from these documents. When you are stuck or something looks wrong, send feedback (`capacitylab-load feedback "…" --run <id>`) and tell your user.
- Ask before: loading production, side effects outside the test environment, spending noticeably more credits, adding a run to CI, a schedule or any other automation (every run is charged), changing repository or CI settings, and merging or deploying anything.
