{"slug": "how-to-stop-your-ai-agent-from-shipping-broken-code-with-placebo", "title": "How to stop your AI agent from shipping broken code with placebo", "summary": "A developer proposes a 'placebo proof' technique to prevent AI coding agents from shipping broken code, where tests are validated by replacing function bodies with dummy implementations that must fail before real code is committed. The method, detailed in a prompt structure for agents like Claude Code, requires three phases—clean code, injected placebo, and weakened check—to ensure tests genuinely verify logic rather than merely passing due to the LLM's flawed mental model.", "body_md": "# How to stop your AI agent from shipping broken code with placebo\n\n[AI agent](/en/tags/ai%20agent/)to handle your codebase, you have probably noticed a terrifying pattern: the agent writes code, then writes a test that perfectly validates that broken code. Because the LLM uses the same flawed mental model for both the implementation and the assertion, the test \"passes\" even when the logic is fundamentally wrong. Coverage metrics won't save you here because the broken line is still being executed; the test is just blind to the error.\n\nTo fix this, you need to move beyond simple unit tests and implement a mutation-style validation. I've been thinking about how to force an agent to prove its tests actually work by using what I call \"placebo proofs.\"\n\n## The difference between a mutation and a placebo\n\nMost people think a good test is one that catches a mistake. But in an agentic workflow, you need to distinguish between two types of failures:\n\n**The Mutation Test:** You intentionally break the code (e.g., changing`a + b`\n\nto`a - b`\n\n). If the test turns red, the test is \"good\" because it caught the change.**The Placebo Test:** You replace the entire function body with a dummy implementation (e.g.,`return a`\n\n). If the test stays green, the test is \"garbage.\" It’s a placebo—it provides the illusion of safety without actually verifying the logic.\n\nA test that lets a plausible but wrong implementation slide through isn't testing anything. You need to force your LLM agent to pass the placebo test before it's allowed to commit the real code.\n\n## Setting up a robust AI workflow for proofing\n\nYou can actually automate this by giving your agent a strict set of instructions for a deployment-ready verification loop. Instead of just saying \"write tests,\" you should instruct the agent to maintain a verification file and a specialized runner.\n\nHere is a prompt structure you can drop into your agent (like [Claude Code](/en/tags/claude%20code/) or a custom LLM agent) to enforce this rigor from scratch:\n\n```\nSet up placebo proofs for this repo.\n\n1. Add to CLAUDE.md: \"A check is not finished until a deliberately\n wrong implementation has died against it. Write the placebo\n BEFORE the fix, never after.\"\n\n2. Create a committed proofs file. One entry per check:\n id, the test name, the package\n inject - edits planting the placebo in PRODUCTION code\n weaken - edits switching off that check's own verdict\n note - which defect this imitates; refuse an empty note\n Every edit is an exact anchor plus replacement, or an append.\n\n3. Write a runner. ONE entry per invocation, never a batch:\n concurrent builds produce false \"survived\" verdicts. It must:\n - take the commit SHA as an argument, one SHA per whole run\n - refuse to start if anything is uncommitted\n - work in a throwaway checkout, never my working tree\n - strip GIT_* from the environment before every git call\n - check each anchor occurs EXACTLY once, counting\n occurrences, not matching lines\n - compile as a separate step first: a placebo the compiler\n rejects is not a defect and must not read as success\n - require evidence the target test RAN, by exact name; a\n typo gives exit 0 and an empty failure list\n - take the verdict from the NAME of the red test, never the\n exit code, deciding in this order:\n compile error, infra error, did not run, killed, survived\n - restore the tree afterwards and verify it by hash\n - keep the raw log of every phase\n Three phases, each from a clean checkout:\n phase 1 clean code nothing is red\n phase 2 + placebo THIS test is red\n phase 3 + placebo + weakened check green again\n\n4. Require every check to carry //guard:proof in its\n doc comment, and add a test enforcing it:\n - read the marker only from the doc comment, not the body\n - the entry named must exist, must name THIS test\n```\n\n## Why this works for LLM agents\n\nThis approach turns testing into a formal verification task. By requiring the agent to go through three distinct phases—clean code, injected placebo (which must fail), and weakened check (which must pass)—you are essentially creating a \"proof\" that the test is actually wired to the logic.\n\nIf the agent tries to cheat by writing a weak test, the \"Phase 2\" step will fail because the placebo won't trigger a red status. This forces the agent to write more specific, assertive, and high-quality tests. It’s a heavy lift for a human, but for an LLM agent with a well-defined prompt engineering strategy, it’s a way to ensure the code it ships actually does what it claims to do.\n\n[Next Stop letting LLM planning turn into a jargon-filled mess →](/en/threads/8377/)", "url": "https://wpnews.pro/news/how-to-stop-your-ai-agent-from-shipping-broken-code-with-placebo", "canonical_source": "https://promptcube3.com/en/threads/8379/", "published_at": "2026-08-31 16:39:01+00:00", "updated_at": "2026-08-31 16:53:53.895510+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-safety", "developer-tools"], "entities": ["Claude Code"], "alternates": {"html": "https://wpnews.pro/news/how-to-stop-your-ai-agent-from-shipping-broken-code-with-placebo", "markdown": "https://wpnews.pro/news/how-to-stop-your-ai-agent-from-shipping-broken-code-with-placebo.md", "text": "https://wpnews.pro/news/how-to-stop-your-ai-agent-from-shipping-broken-code-with-placebo.txt", "jsonld": "https://wpnews.pro/news/how-to-stop-your-ai-agent-from-shipping-broken-code-with-placebo.jsonld"}}