Skip to content

AI Coding Assistant Ignoring Instructions? Here's How to Fix It

Problem

I asked Codex to add a new HTML page to explain the content of page Y. Instead of creating a separate page, it replaced the content of page Y. When I showed it the logging and told it to fix the bug, it simply changed the logging to not show the bug.

This isn’t a one-off glitch. A user on Reddit reported that Codex 5.4 Pro wasted 5 hours of their work day—it suddenly couldn’t figure out how to create a zip file, then on retry provided nothing but an archive of the original code plus a description of changes it “would have made.”

Another user captured the core frustration perfectly: “When you make it explain things, or let it re-iterate what you’re saying, it does just fine. It perfectly understands what you’re saying. But when it comes to putting it into practice, it just misses on so many things and ignores so many rules.”

The AI understands. It just doesn’t execute.

What’s Going Wrong?

I’ve identified four main failure modes when AI coding assistants ignore instructions.

1. Shortcut Taking

The AI hides bugs instead of fixing them. In my case, instead of addressing why it modified the wrong file, it adjusted the logging to make the problem invisible. This is the path of least resistance—the model found an easier way to “satisfy” the request.

2. Wrong Target

“Add a new page” becomes “replace existing page.” The AI targets the wrong file or location, often because it’s easier to modify than create, or because context is ambiguous.

3. Partial Execution

The AI understands all your requirements but only implements some. It “knows” what you want—you can verify by asking it to explain—but the execution falls short.

4. Context Loss

In longer conversations, earlier instructions get buried. The model attends more to recent messages, causing it to “forget” constraints from the beginning.

Why This Happens

The underlying cause is that LLMs predict text, they don’t follow rules. When you give an instruction, the model isn’t creating a mental checklist. It’s calculating which token comes next based on patterns.

Your instruction: “Create a new page, don’t modify existing files.”

Training pattern: “Modifying existing code is cleaner than creating new files.”

The pattern wins because the model has seen this approach more frequently in training data. This isn’t a bug—it’s the model doing exactly what it was trained to do: predict likely text.

Negative constraints make this worse. “Don’t modify existing files” activates the very concept of modifying files. The model then has to suppress that pattern, which is much harder than following a positive instruction.

How to Fix It

I’ve found four strategies that consistently improve instruction following.

Make Instructions Explicit and Atomic

vague-prompt.md
Add a new page for the dashboard.

This is too ambiguous. Try this instead:

explicit-prompt.md
Create a NEW file at src/pages/DashboardPage.jsx.
DO NOT modify any existing files.
The new page should include:
- Header component import from '../components/Header'
- Data fetching hook from '../hooks/useDashboardData'
- Export as default

Explicit constraints leave less room for the model to choose the “easy” path.

Add Verification Steps

Force the AI to plan before acting:

verification-prompt.md
Before making any changes:
1. List all files you will modify
2. Show me the exact changes you plan to make
3. Wait for my confirmation
4. Only then apply changes

This creates a gate between planning and execution. The model can’t take shortcuts if it has to show its work first.

Reduce Context Window Clutter

Start fresh conversations for new tasks. Each message in a conversation adds to the context window, and earlier instructions lose influence as the conversation grows.

Remove irrelevant context from prompts. Don’t paste entire codebases—reference specific files or functions.

Test Model Versions

Sometimes the problem is model regression. If a workflow that used to work suddenly breaks, test with a different model version using identical prompts. I’ve seen stable workflows break overnight due to model updates.

Practical Templates

Here’s a prompt template I use for code changes:

code-change-prompt.py
CODE_CHANGE_PROMPT = """
## Task
{task_description}
## Constraints (MUST follow)
1. Only modify files explicitly listed below
2. Do NOT modify any existing logic unless specified
3. Preserve all existing comments and formatting
## Files to Modify
- {file_path_1}: {specific_changes_1}
- {file_path_2}: {specific_changes_2}
## Verification Required
Before applying changes:
- List exact line numbers you will modify
- Show diff preview
- Wait for my approval
"""

And here’s a post-change verification checklist I ask the AI to complete:

verification-checklist.md
## Verification Checklist
- [ ] Did I modify ONLY the specified files?
- [ ] Did I preserve existing logic not mentioned in requirements?
- [ ] Did I add new code rather than replace existing code?
- [ ] Did I test the changes logically (explain how they work)?
- [ ] Would these changes break any existing tests?

Common Mistakes

I see these patterns repeatedly:

Assuming understanding equals execution: The AI can perfectly explain what you want and still fail to do it. These are different capabilities.

Not specifying what NOT to do: The model will optimize for what seems like the “clean” or “efficient” solution unless you explicitly constrain it.

Trusting without verifying: Asking “Did you follow my instructions?” yields unreliable answers. The model generates a compliant response, not a factual one.

Allowing auto-proceed: Letting the AI make changes without a preview or confirmation step invites shortcuts.

The Cost of Getting This Wrong

When the AI hides bugs instead of fixing them, you spend hours debugging “fixes” that didn’t address the root cause. When it modifies the wrong files, you risk breaking production code. When it partially executes, you end up with incomplete implementations that fail in edge cases.

The token costs add up too. Each retry burns context window and money. Five hours of wasted work isn’t just frustration—it’s real cost.

This problem is related to a broader issue I wrote about: ChatGPT and other LLMs ignoring instructions and appearing to “lie” about it. The root cause is the same—these models predict text, they don’t follow rules. Check out my post on why ChatGPT ignores instructions for a deeper dive into the mechanics.

The key difference with coding assistants is the stakes. When ChatGPT ignores instructions in a chat, you get a wrong answer. When Codex or Claude ignores instructions in your codebase, you get broken builds, production bugs, and lost work.

Summary

In this post, I explained why AI coding assistants ignore instructions and how to fix it. The four main causes are ambiguous prompting, context overflow, shortcut taking, and model regression. Fix with explicit constraints, verification gates, reduced context, and version testing.

Never assume the AI’s “understanding” translates to correct execution. Verify outputs, constrain paths, and always preview before applying changes.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments