Use Cases

Le Chonk AI coding & agent workflow exercises

Use a small repository and a deterministic test before trusting an agent with a larger codebase.

Download the local fixture

This synthetic JavaScript fixture belongs to this tutorial. Download cart.mjs, acceptance tests, and the authored reference diff. The reference is written for the exercise; it is not a model-generated patch.

Starting code
export function total(items) {
  return items.reduce((sum, x) => sum + x.price * x.quantity, 0);
}

Case 1: understand the repository

Prompt
Inspect cart.mjs and cart.test.mjs. Explain the public interface, data flow and invariants. Cite function names. Identify which cases the current implementation misses. Do not edit files.
  • Input: both fixture files; read-only file access.
  • Acceptance: identify total(items), its return value and non-mutation requirement. Mention empty arrays, negative values, non-finite numbers and final-cent rounding.
  • Tool budget: 4 reads, no network or file modification. Output record: not run.

Case 2: fix the bug

Prompt
Fix total(items) without changing its export. Return 0 for empty input. Reject negative or non-finite price/quantity with RangeError. Round only the final sum to cents. Do not mutate input. Run the supplied tests. Return a unified diff and test output.

Grant read, write and node --test cart.test.mjs in a disposable local directory, with at most 8 tool calls and no network. Review the diff before accepting it.

Authored reference diff
- return items.reduce((sum, x) => sum + x.price * x.quantity, 0);
+ const sum = items.reduce((sum, x) => {
+   if (!Number.isFinite(x.price) || !Number.isFinite(x.quantity) ||
+       x.price < 0 || x.quantity < 0) throw new RangeError("Invalid item");
+   return sum + x.price * x.quantity;
+ }, 0);
+ return Math.round((sum + Number.EPSILON) * 100) / 100;

Reference implementation tests are executed locally. Passing this fixture establishes only these input requirements; it is not a general accounting implementation or a Large 4 success claim.

Case 3: add meaningful tests

Prompt
Add tests that would fail for per-item rounding and for accepting Infinity. Add a non-mutation test. Explain why each assertion detects a distinct defect. Do not merely assert the current implementation’s output.
CheckReference expectation
Two entries of 0.3350.67, not 0.68
Infinity / NaN / negative valuesRangeError
Empty cart0
Input objects after callUnchanged

Keep the original acceptance tests fixed. Review added tests separately from the candidate implementation. Model-added test output remains unavailable.

Record an agent run

Evidence template
model ID / provider / date:
system prompt / reasoning / tool permissions:
input file checksums / step limit:
raw response / unified diff / full tool trace:
test command / exit code / stdout:
elapsed seconds / billed input / output / cached tokens:
manual edits / final acceptance / total task cost:
EvidenceCurrent status
Model output / patchNot available: model exercise not run
Tool trace / human editsNot recorded
Latency / usage / task costNot measured
Reference expectationsAuthored and inspectable; not model output

No IDE or CLI integration is advertised as verified for this model. The server-side REST example is the supported protocol starting point; tool execution is implemented by your host application.

Sources & verification

Research snapshot: . Source statements are dated; API access and prices can change.

Original model runs are marked “not run” unless a trace is provided. Read our editorial method.