# How to stop an AI coding agent from over-engineering

> Paste minimal-scope stop-rules, fence allowed files, and reject diffs that invent extras the request never asked for.

Source: https://fullbytedeveloper.com/blog/stop-ai-coding-agent-over-engineering
Published here: 2026-11-16

Part 1 of 2 in the Guide the agent series. Part 2 is [constraints that keep coding agents small](/blog/constrain-ai-coding-agent-scope).

To stop an AI coding agent from over-engineering, ask for only the requested change, name the files it may touch, and reject diffs that add files, abstractions, or error handling nobody asked for. Anthropic documents this overengineering for Claude Opus 4.5 and 4.6 [1]. OpenAI's docs favor short `AGENTS.md` files and small, focused diffs [7] [8].

## Paste a minimal-scope stop block

Anthropic's Overeagerness guidance tells the model to make only the changes directly requested: no unrequested features or refactors, no docs for untouched code, no speculative error handling, no helpers for one-time ops, and no design for hypothetical futures. It also asks for cleanup of temporary scripts after the task [1]. For Claude Opus 5, the prompting page separately warns about unrequested steps and says to deliver what was asked, then stop short of actions beyond the request [2]. Read the prompting page for the model you actually run, because the advice differs by model [1] [2].

Put the same idea in the project memory file your tool actually reads (`CLAUDE.md` or `AGENTS.md`). Claude Code docs say keep `CLAUDE.md` short (target under about 200 lines) and path-scoped [5] [6]. Codex docs say a short accurate `AGENTS.md` beats a long vague one, and that you should add rules after repeated mistakes [7] [9]. Anthropic's 2024-12-19 agents guide still starts with the simplest workable solution before adding complexity [3]. Their 2025-11-26 note on long-running agents says agents tended to try to do too much at once [4].

A generic done definition you can paste (replace the lint line with your repo's real commands):

```text
Done means: (1) only the requested behavior changed, (2) no new files unless required,
(3) project lint/tests for touched paths pass: <paste repo commands>,
(4) if you want extra work, ask in one line and wait.
```

## Compare a small diff with a bloated one

This synthetic git demo is not a claim about any vendor model. It only shows how file touch counts look when a one-line edit stays in one file versus when extra modules appear.

**Warning:** the seed commit needs a Git identity. If `git config user.email` prints nothing, run `git config --global user.email "you@example.com"` and `git config --global user.name "Your Name"` first.

```bash
rm -rf /tmp/scope-demo && mkdir /tmp/scope-demo && cd /tmp/scope-demo && git init -q
echo 'def add(a,b): return a+b' > app.py && git add app.py && git commit -q -m seed
echo 'def add(a,b): return a+b  # sum' > app.py
git diff --stat
mkdir -p lib/config && echo interface > lib/config/opts.py && echo helper > lib/utils.py
git add -A && git diff --cached --stat
```

You should see a one-file `app.py` change first, then a staged set that also adds `lib/config/opts.py` and `lib/utils.py`. Prefer the first shape unless the request required the extras.

## Audit the diff before you merge

Print a reviewer checklist after every agent patch:

```bash
python3 - <<'PY'
checks = [
    "Did the agent create files not required by the request?",
    "Did it add abstractions or config flags nobody asked for?",
    "Did it edit files outside the stated paths?",
    "Did it add error handling for impossible cases?",
    "Did existing project tests/lint run for touched paths?",
]
for i, c in enumerate(checks, 1):
    print(f"{i}. {c}")
print("Fail any -> revise before merge.")
PY
```

You should see five numbered checks, then the fail line. OpenAI's apply_patch guidance already pushes minimal targeted edits; keep that pressure in review and in the prompt [8].

If you still need the definition of the agent loop itself, start with [what is an AI agent](/blog/what-is-an-ai-agent). For the earlier "workflow before agent" cut, see [choose an AI workflow before building an agent](/blog/choose-ai-workflow-before-agent) and [five rules for building an AI agent that works](/blog/five-rules-for-effective-ai-agents).

Paste the done definition into your `AGENTS.md` or `CLAUDE.md` before the next agent task.

Send this to the friend who asked their agent for one fix and got a whole new framework.

Image: Side-by-side code comparison for the request Return 0 when items is empty. The left panel, labeled Bloated, shows a long Python snippet with an EmptyPolicy enum, a SummerConfig dataclass, and a hand-rolled loop. The right panel, labeled Small change, shows a four-line total function plus two assert tests: total of an empty list is 0, and total of 1, 2, 3 is 6.
https://fullbytedeveloper.com/media/stop-ai-coding-agent-over-engineering/bloated-vs-small.webp
The same request, two sizes of change. The small version meets the request, has a test, and then you stop.

Image: Checklist card titled Stop rules for a coding agent, with four numbered rules: 1 Do the smallest change that meets the request. 2 Do not add a new type, file, or flag unless the request needs it. 3 Prove the change with a test. 4 Stop when the test passes.
https://fullbytedeveloper.com/media/stop-ai-coding-agent-over-engineering/stop-rules.webp
Practical stop rules to use as a gate after each change. These are not a quote from any vendor.

## Sources

1. [Anthropic: Claude prompting best practices (Overeagerness), accessed 2026-11-12](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices)
2. [Anthropic: Prompting Claude Opus 5, accessed 2026-11-12](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5)
3. [Anthropic: Building effective agents (2024-12-19)](https://www.anthropic.com/research/building-effective-agents)
4. [Anthropic: Effective harnesses for long-running agents (2025-11-26)](https://www.anthropic.com/research/effective-harnesses-for-long-running-agents)
5. [Claude Code best practices, accessed 2026-11-12](https://code.claude.com/docs/en/best-practices)
6. [Claude Code: CLAUDE.md, accessed 2026-11-12](https://code.claude.com/docs/en/claude-md)
7. [OpenAI Codex best practices, accessed 2026-11-12](https://learn.chatgpt.com/guides/best-practices)
8. [OpenAI: apply_patch guide, accessed 2026-11-12](https://developers.openai.com/api/docs/guides/tools-apply-patch)
9. [OpenAI: AGENTS.md guide, accessed 2026-11-12](https://learn.chatgpt.com/docs/agent-configuration/agents-md)
