Set Up TestPilot AI
Why This Matters
Every lesson from here on works in the TestPilot AI repository. A green npm run check now means that, later on, a failure is about your change and not about your setup.
Clone and install
You need Node.js 22.18 or newer (check with node -v).
git clone git@github.com:learn-automated-testing/testpilot-ai.git
cd testpilot-ai
npm install
npm run check
npm run check runs the TypeScript compiler and the tests. It should end with all tests passing, without an API key.
The whole check takes a fraction of a second. That is on purpose: the tests use a fake client that returns prepared answers. They are fast, free and give the same result every time. Testing your code without calling the model is a design choice you will defend more than once in the exam.
Create an API key
To talk to Claude for real you need a key from the Claude Console.
When you click Create key, the Console first asks where your code runs. For your own machine, cloud workloads and CI pipelines there are options that need no stored key at all, which is safer. For TestPilot’s .env you choose Somewhere else.
Give the key a name that says what it is for, and keep the expiry short. A key called testpilot-ai that expires in 30 days is easy to recognise and does little harm if it leaks.
The key is shown once. Copy it straight into your .env file, never into a chat, a ticket, a commit or a screenshot.
cp .env.example .env
# open .env and paste your key after ANTHROPIC_API_KEY=
.env is listed in .gitignore, so it never ends up in git. Check that with git status: .env must not appear.
The keys page shows all your keys, who created them and when they expire. Disable keys you no longer use.
A five-minute tour
| Path | What it is |
|---|---|
src/types.ts | The format of a test run export |
src/runs.ts | Loading runs and plain helpers such as failureRate() |
src/prompt.ts | The system prompt and the message builder |
src/schema.ts | The shape of a triage verdict |
src/triage.ts | The one function that calls Claude |
fixtures/runs/run-1042.json | A test run with five failures, one of each kind |
tests/ | Tests with a fake client |
docs/exercises.md | The exercises per lesson |
AGENTS.md, CLAUDE.md | Instructions for coding agents (module 6) |
Open fixtures/runs/run-1042.json now and read the five failures. You will meet them in every module.
Solution branches
When a lesson has a worked solution, it is on a branch. Compare your work with ours:
git fetch
git diff main...solution/lesson-09-structured-output # three dots: only the lesson's changes
Check
npm run checkis green.envcontains your key and does not show up ingit status- you can name the five failures in
run-1042.json




