Five ways an agent can fake a green build
Agents rarely cheat on purpose, but under pressure to make tests pass they find shortcuts. Here is what to look for — and what PaneScale flags automatically.
The difference between a task that runs overnight and one that wanders is usually a single sentence — the finish line. A short template and examples.
“Improve the upload flow” is a fine thing to say to a colleague over coffee. Given to an agent at 11 pm with nobody watching, it is an invitation to wander: it might refactor the whole module, rename half the functions and stop when it runs out of ideas — or tokens.
Agents are good at reaching a goal. They are much worse at deciding what the goal is. So give them one they can check.
A finish line is a condition the agent can verify itself, with a command, before it stops. Compare:
| Wanders | Finishes |
|---|---|
| Improve upload error handling | npm test -- upload passes, including a new test for a 503 response that retries twice |
| Make the settings page faster | The settings page renders in under 100 ms in npm run bench:settings |
| Clean up the date utils | src/utils/date.ts has no any, npm run typecheck passes, behavior unchanged — all existing tests green |
| Fix the flaky test | upload.retry.test.ts passes ten runs in a row with npm test -- --repeat 10 |
The right column is longer. That’s the point: the extra words are the ones the agent would otherwise have to guess.
Anthropic’s guidance for Claude Code makes the same argument from the other side: an agent that can check its own work — with a test, a build, a screenshot — does far better than one that has to guess whether it is done, and the single most useful line in an instructions file is the command that runs the tests. A finish line is that idea applied to one task.
Goal: <one sentence, the outcome, not the activity>
Done when:
- <a command that must pass>
- <a second check, if any>
Scope:
- Only change files in <folder or module>.
- Do not modify, skip or delete existing tests.
Context:
- <the one thing a newcomer wouldn't know>Four parts, each with a job:
Here is a real-world shaped task, first as it usually gets written:
The upload sometimes fails on slow connections. Can you make it more robust?An agent can do a lot with this, and most of it won’t be what you wanted: a new retry library, a rewritten progress bar, a changed timeout everywhere. Now the same task with a finish line:
Goal: uploads survive a single 503 from the storage API.
Done when:
- npm test -- upload passes.
- A new test "retries once on 503, then succeeds" exists and passes.
- npm run typecheck passes.
Scope:
- Only change src/upload/ and its tests.
- Do not modify, skip or delete existing tests.
- No new dependencies.
Context:
- The storage client is in src/upload/client.ts; it already has a retry
helper (withRetry) that the upload path doesn't use yet.The second version takes two minutes longer to write. In exchange you get a diff you can review in five, a test that will catch the bug if it comes back, and an agent that knows when to stop.
Different work needs different evidence. These have worked well:
| Kind of task | A finish line that holds |
|---|---|
| Bug fix | A new test reproduces the bug, failed before the change and passes after it |
| Refactor | Type checker and the full existing suite pass; public functions keep their signatures |
| Performance | A benchmark command reports a number below a threshold, on the same machine, three runs in a row |
| Dependency upgrade | Install from the lock file, build and tests pass; no source changes outside the call sites the upgrade requires |
| Documentation | Every code sample in the changed pages runs; links checked by a link checker |
| Migration | The migration runs forward and back on a disposable database; tests pass after both |
Notice what the column has in common: every line is something a command can decide. “The code is cleaner” is not on the list, because nobody can check it at 3 am.
A finish line only works if the command exists and works on the starting commit. Before you queue a task overnight, run the command yourself once. If it fails for unrelated reasons, the agent will spend its attempts on the wrong problem.
PaneScale helps here: the autopilot runs your checks on the starting commit first — the baseline — so failures that were already there don’t count. The autopilot preflight refuses to start a night without at least one required check, because “ready” has to be proven.
Some conditions look checkable but aren’t useful:
Some tasks don’t have a finish line yet — “design a better onboarding” is a conversation, not a task. Have that conversation in Chat or with a teammate in Plan mode, write down the result, and turn each piece into a task with its own finish line. Then queue those.
A useful size test: a task is small enough when its diff can be reviewed in about ten minutes. Larger than that, and you will either skim the review or spend the time you saved.
Before handing a task to an agent, ask: if I came back in four hours, could I tell in one minute whether it’s done? If the answer is yes, it’s ready to go.
Then the first task is to write one. Ask an agent to add a test that reproduces the bug or covers the function you want changed, review it yourself, and commit it. From then on the test is the finish line for every task in that area. A type check, a build or a linter is a weaker but still useful finish line in the meantime.
Long enough that nothing important is left to guess, short enough to read in a minute. In practice that is five to fifteen lines. If it grows beyond that, the task is probably several tasks.
Both, at different levels. The instructions file (AGENTS.md, CLAUDE.md) holds what is always true: how to run the tests, what never to touch. The task holds what is true for this change: which test must pass and which folder is in scope.
CLAUDE.mdAgents rarely cheat on purpose, but under pressure to make tests pass they find shortcuts. Here is what to look for — and what PaneScale flags automatically.
Skipping an agent’s permission prompts saves hours — and occasionally costs a lot more. When it is reasonable, and what to put in place first.
When agents work in multi-step workflows, “it worked” isn’t enough. What a run record should contain, and how PaneScale’s workflow runs provide it.