How it works
We have an experiment
import { declareTestCase } from "thunderjar";
export default declareTestCase({
baseImage: ["node20"],
codeState: ["commit-a1b2c3"],
promptSet: ["commit-aaabbb", "commit-bbbccc"],
harnessModel: [
"claude-code-2.1.311/claude-opus-5-5",
"claude-code-2.1.311/claude-haiku-5-5",
],
task: "is-prime",
initialPrompt: ["plain"],
iterations: 5,
});When we run the experiment
thunderjar run is-prime-baselineThe five arrays cross to make four permutations (1/1/2/2/1):
| # | Base image | Prompt set | Harness / model | Initial prompt |
|---|---|---|---|---|
| 1 | node20 | commit-aaabbb | claude-code-2.1.311/claude-opus-5-5 | plain |
| 2 | node20 | commit-aaabbb | claude-code-2.1.311/claude-haiku-5-5 | plain |
| 3 | node20 | commit-bbbccc | claude-code-2.1.311/claude-opus-5-5 | plain |
| 4 | node20 | commit-bbbccc | claude-code-2.1.311/claude-haiku-5-5 | plain |
Each permutation creates a docker image:
# 1. Base image
FROM node:20-bookworm
RUN npm install --global bun@1.3.14
RUN git config --system user.name "Thunderjar agent" \
&& git config --system user.email agent@thunderjar.invalid
WORKDIR /workspace
# 2. Apply the code state
RUN git clone --quiet https://github.com/acme/widgets.git /workspace \
&& git -C /workspace checkout --quiet --detach a1b2c3 \
&& git -C /workspace remote remove origin
# 3. Apply the prompt set
RUN git clone --quiet https://github.com/acme/prompts.git /tmp/prompts \
&& git -C /tmp/prompts checkout --quiet --detach aaabbb \
&& find /workspace -type f \( -name AGENTS.md -o -name CLAUDE.md -o -name SKILL.md \) -delete \
&& cd /tmp/prompts \
&& cp AGENTS.md CLAUDE.md /workspace/ \
&& find . -type f -name SKILL.md -exec cp --parents {} /workspace/ \; \
&& cd /workspace && git add -A && git commit --quiet -m "Thunderjar: apply promptSet"
# 4. Harness: installs the agent, and writes the model and the script that runs it
RUN npm install -g @anthropic-ai/claude-code@2.1.311
RUN mkdir -p /thunderjar && chown -R node:node /workspace /thunderjar
COPY <<'THUNDERJAR_EOF' /thunderjar/model.txt
claude-opus-5-5
THUNDERJAR_EOF
COPY --chmod=755 <<'THUNDERJAR_EOF' /thunderjar/thunderjar-run.sh
#!/bin/sh
claude -p "$(cat /thunderjar/prompt.txt)" --model "$(cat /thunderjar/model.txt)" --output-format json --dangerously-skip-permissions > /thunderjar/result.json
THUNDERJAR_EOF
USER node
# 5. Task: writes the initial prompt
COPY <<'THUNDERJAR_EOF' /thunderjar/prompt.txt
Create isPrime.ts, exporting isPrime(n: number): boolean, and implement it.
THUNDERJAR_EOFEach layer is a parameter's applyParameter. The harness's writes the model and thunderjar-run.sh, the script that runs the agent, and the initial prompt's writes the prompt:
// harnessModels/claude-code-2.1.311/index.ts
export default claudeCode({ version: "2.1.311" });
// tasks/is-prime/initial-prompts/plain.ts
export default declareInitialPrompt({
applyParameter: () => writePrompt("Create isPrime.ts, exporting isPrime(n: number): boolean, and implement it."),
timeoutSeconds: 600,
});claudeCode and writePrompt are helpers: each returns the Dockerfile fragment above. So the image holds everything a run needs:
docker run thunderjar-prerun:3f2c9a10 sh /thunderjar/thunderjar-run.shThe script runs in the image's working directory, /workspace by default. A code state or initial prompt can set another with WORKDIR, e.g. to run the agent in one package of a monorepo.
The layers go from least to most often changed, so permutations share every layer below the first one they differ in. Two models share the harness install. Two initial prompts share everything but the last layer.
An initial prompt is a single prompt for now: an agent can't yet be given several turns.
We then run all the permutations x the number of iterations.
When the task completes we save the container as a postrun docker image, for each run.
We then apply measurements against each image, and aggregate the results:
| # | Prompt set | Model | Runs | isPrimeTemplateTest (mean passed / failed) | isPrimeTsExists (rate) | tsIgnoreCount (mean / max) |
|---|---|---|---|---|---|---|
| 1 | commit-aaabbb | claude-opus-5-5 | 5/5 | 5.0 / 0.0 | 5/5 | 0.0 / 0 |
| 2 | commit-aaabbb | claude-haiku-5-5 | 5/5 | 4.6 / 0.4 | 5/5 | 0.2 / 1 |
| 3 | commit-bbbccc | claude-opus-5-5 | 5/5 | 5.0 / 0.0 | 5/5 | 0.0 / 0 |
| 4 | commit-bbbccc | claude-haiku-5-5 | 5/5 | 4.8 / 0.2 | 5/5 | 0.0 / 0 |
Later, we can update our experiement
import { declareTestCase } from "thunderjar";
export default declareTestCase({
baseImage: ["node20"],
codeState: ["commit-b2c3d4"], // 👈
promptSet: ["commit-aaabbb", "commit-bbbccc"],
harnessModel: [
"claude-code-2.1.311/claude-opus-5-5",
"claude-code-2.1.311/claude-haiku-5-5",
],
task: "is-prime",
initialPrompt: ["plain"],
iterations: 5,
});Because the task is the same, because it has the same set of measurements, this set of results can be compared against the previous results.
We can always update our measurements. Because we preserved the final state in a docker image, we dont' need to rerun any agents, we just reapply the measurements.