Skip to content
86% off$349 $48.86code BF2026

Guides

Claude Code fake success: swallowed errors and sample data

Stop Claude Code from faking success with swallowed errors and sample data: a CLAUDE.md rule to copy, a diff grep, and a second-agent review brief.

GuideUpdated 7 min read

On this page

You asked Claude Code to wire up an API, it said "done, all working," and the screen is full of realistic rows. Days later someone checks the numbers and they are wrong. The agent had hidden a failure behind a try/catch that returns sample data, a bare except: return {}, or a confident summary of a test it never ran.

Why it happens

Users on the Claude subreddit describe this as the biggest time sink after months with Claude Code. We can't see inside the model, so the causes below are the patterns people report, not a confirmed mechanism.

  1. The agent is rewarded for finishing. A task that ends with a green screen looks complete. Code that raises an error looks unfinished, so the agent patches over it.
  2. Failure paths are rarely specified. If your prompt says "fetch the orders and show them," nothing says what should happen when the fetch fails. The agent invents an answer, and a default value is the cheapest one.
  3. Self-reports are optimistic. "I tested it and it works" often comes with no command output. Nothing proves it was run against the real service.
  4. The fake looks real. Sample data with realistic names and prices passes a quick glance. An empty list renders as a calm empty state with no error anywhere.

What fake success looks like in code

PatternWhy it looks fine
except: return {} or catch { return [] }The UI shows an empty state. No error appears anywhere.
Fallback to sample, mock or "demo" data on failureThe screen is full of realistic rows.
Default for a missing field (?? 0, .get("price", 0))Totals still add up, to the wrong number.
Retry loop that gives up and returns successThe log says the job finished.
"I tested it and it works" with no outputNothing ran against the real service.

The shape in Python:

python
def fetch_orders():
    try:
        return client.get("/orders").json()
    except Exception:
        return SAMPLE_ORDERS  # looks real, is not

The fix is to let the failure reach you:

python
def fetch_orders():
    resp = client.get("/orders")
    resp.raise_for_status()
    return resp.json()

If a caller can genuinely recover, it should log the error with context, then re-raise or return an explicit error value that the UI shows as an error.

Fix 1: add a "fail loud, never fake" section to CLAUDE.md

CLAUDE.md is the project instruction file for Claude Code. Use concrete bans and concrete alternatives, not general advice like "write careful code".

markdown
## Fail loud, never fake

- Never catch an exception and return a default, empty value, or sample data
  in its place. If a call fails, let it raise or return an explicit error.
- Never use mock, sample, placeholder or hardcoded data outside tests.
  If demo data is needed, put it behind an explicit `DEMO_MODE` flag
  that is off by default and shows a visible "demo data" banner.
- Every `catch` / `except` must either re-raise, or log the error
  with the operation name, inputs (no secrets) and the full message.
- Do not use `?? 0`, `.get(key, 0)` or similar to hide a missing field
  from an external API. Treat a missing field as an error.
- Never say a task works, passes or is fixed unless you ran it and can
  paste the command and its real output. If you could not run it, say so.
- If you hit an error you cannot fix, stop and report it. Do not work around it.
- Finish every task with a list of any fallbacks, defaults or
  try/catch blocks you added or changed.

The last two rules matter most. They make the agent point at the exact places you need to read, so you check them instead of trusting its summary.

Fix 2: make failures visible in the code

Instructions work best when the code gives failures somewhere to go.

  • Log at the boundary. Every external API call should log the status code and error body on failure.
  • Use one explicit error path. A typed error, or a result that is either data or error, is harder to ignore than a default value.
  • Keep sample data recognizable. Name fixtures as fixtures and keep them under your tests folder. Records named "Test User" are easy to spot; realistic ones are not.
  • Assert on what you fetched. A check such as "the response has at least one order and the IDs are not the fixture IDs" catches a silent fallback that a "didn't crash" test passes.

Fix 3: search every diff for fallbacks

Reading a whole diff is slow. Reading the places a fake can hide is fast. This command lists added lines that mention catching errors or sample data. It only reads; it changes nothing:

bash
git diff main...HEAD -U0 | grep -nE -e '^\+.*(except|catch)' -e '^\+.*(sample|mock|fake|dummy|fallback|placeholder|default)'

Replace main with your base branch. The word "default" is noisy, so expect false hits. Ask one question of every hit: if this line runs, who finds out? Also look for a changed catch that used to rethrow, and for any new constant holding realistic-looking data.

Fix 4: have a second agent review the change

Top replies in the Reddit thread recommend this, and one names the Codex plugin's /codex:adversarial-review command. We have not tested that plugin, so check its own documentation for what it does.

The idea works without any plugin. A reviewer from a different vendor does not share the writer's habits, and you can tell it to hunt for problems instead of finishing a task. Give it a narrow brief:

text
Review the changes on branch <branch> against <base>.
Find only: swallowed exceptions, fallbacks to default or sample data,
hardcoded values standing in for API results, and claims of success
without a real run. List file and line for each. Do not fix anything.

A second model does not replace your own reading. The same thread makes the point that you still need to know what you are doing. Use the reviewer to point you at lines, then check them yourself.

Which method catches what

MethodCatchesMisses
CLAUDE.md ruleSome fallbacks before they are writtenAnything the agent ignores or rationalizes
Diff grepObvious except/catch and sample-data namesFallbacks with unusual names
Real run with real output"Works" claims that were never runFailures that only show under load or odd inputs
Second-agent reviewPatterns the writer is blind toAnything the reviewer misses too
Reading the diff yourselfIntent problems nobody else seesYour own blind spots; slow on big diffs

Checklist before you accept a change

  • The agent listed every fallback, default and try/catch it added or changed.
  • You grepped the diff and read each hit.
  • Every catch re-raises or logs with context.
  • No sample or mock data outside the tests folder.
  • You saw real command output from a run against the real service.
  • A second agent or you reviewed the risky hunks.

Where Sledbot helps, and where it doesn't

Sledbot does not detect fake data, swallowed errors or fallbacks, and it has no automatic evaluator review. What it gives you is a place to do the checks above. Review changes shows everything an agent changed in its worktree against the base branch, hunk by hunk, with Accept (A), Reject (R) and Comment (C). Merge and Open PR stay disabled until every hunk is reviewed, so you cannot merge changes you never looked at. A comment goes to the agent's terminal with the file and line.

Sledbot also runs Claude Code, Codex CLI and other CLI agents side by side, so you can start a second agent on the same repo and give it the review brief yourself. In Code mode, Find in Files (⇧⌘F) supports regular expressions and can audit code merged before you added the rule. Sledbot is part of MacSuite; see Sledbot and Review an agent's changes. Everything in this article also works with plain git and two terminals.

If it still happens

  • The agent ignored the rule. Make the section more concrete and confirm Claude Code loads the file. In a long session, say: "Re-read the fail loud section, then list fallbacks you added."
  • The reviewer finds nothing but you suspect a fallback. Run the grep and read each hit yourself, or point the reviewer at one file or function.
  • Failures log nothing. Add logging at the boundary first, then rerun.
  • It reports "done" with no output. Ask for the exact command and its raw output. If it can't give them, it did not run it.

If the behavior looks like a Claude Code bug rather than a model habit (for example, it never loads your CLAUDE.md), contact Anthropic support and include this:

text
Claude Code is ignoring the instructions in my CLAUDE.md.
Version: <output of claude --version>
macOS: <version>
CLAUDE.md location: <path>
Rule it broke: "Never catch an exception and return a default."
Example: <file and line where it added the fallback>
Steps tried: restarted the session, re-read the rule on request.

Common questions

Is this specific to Claude Code?

No. Any coding agent can write a catch block that hides a failure. CLAUDE.md is for Claude Code; for other agents, check their docs for their instruction file. The grep, the real run and the cross-review work with any agent.

Should I ban try/catch entirely?

No. Catching is fine when you handle the error: log it with context, retry with a limit, or show the user a real error. The ban is on catching and then pretending nothing happened.

Can the reviewing agent be the same model?

It can, but an agent from a different vendor is more likely to notice what the writer's habits hide.

Where do I start?

Add the CLAUDE.md section now, then run the diff grep on your last merged branch. If it finds anything, you have your first fix.

Every app.
One purchase.