Why AI Coding Assistants Ignore Your Instructions: Four Failure Modes and a Layered Fix

    AI coding assistants often ignore rules even when those rules are still present in the repository's instruction file. This article explains why the problem usually is not the model itself, but the way guidance is stored. It breaks down four distinct failure modes, shows how to turn a long instruction file into a concise, verifiable work card, describes how to move repeated procedures into explicitly callable steps, and explains why hard limits must be enforced by system guardrails rather than prompts. The article also gives a practical rollout order and three signals to judge whether the governance is working.

    1. The Symptom: The File Keeps Growing, but Compliance Keeps Slipping

    Teams that use AI coding assistants for a while tend to fall into the same habit: whenever the tool gets something wrong, they add one more sentence to the repository’s root-level instruction file.

    If tests were skipped, add “run tests after making changes.” If unrelated files were modified, add “only modify files related to the current task.” If a successful local build was described as “deployed,” add “code changes, local verification, deployment status, and production evidence must be stated separately.”

    This works at first. The same mistakes drop off noticeably. But once the file reaches a few hundred lines and dozens of rule blocks, a new problem appears: some rules are still right there in the file, and the assistant ignores them anyway.

    The subtler part is that the assistant did not simply fail to read them. It follows those rules well in the first half of a task. As tool output accumulates, more files get read, and requirements go through a few more rounds of clarification, the rule gradually gets pushed to the edge of its field of view.

    Blaming the model is not accurate. A more common cause is that we have stuffed many fundamentally different things into the same entry point.

    2. Root Causes: Four Different Problems That Look Like Disobedience

    The same symptom sits on top of four different kinds of causes, and they need very different fixes.

    Type 1: The instruction never made it into the current context.

    Long tasks run through many rounds of tool calls, and output logs, search results, and file excerpts keep piling up. When the context approaches its budget limit, the tool truncates, summarizes, or reorders content, and global rules written early on may no longer be in the effective window. The assistant is not refusing to follow the rule. It genuinely cannot see it.

    Type 2: The instruction is too vague.

    “Write clean code.” “Follow best practices.” “Pay attention to performance.” The model knows the general direction, but not the concrete action, the boundary, or the criteria. Rules like these have almost no binding force, because they cannot be verified and you cannot tell afterward whether they were met.

    Type 3: The instruction is a procedure, not a rule.

    “Run tests after making changes.” “Check formatting before committing.” “Define the interface contract before writing the implementation.” These are ordered steps with expected outputs. Written as static bullet points, they force the model to recall “which step am I on, and did I finish the previous one?” on every pass, and steps get dropped easily in long tasks. A procedure should be modeled explicitly instead of being replayed from memory.

    Type 4: The constraint should be enforced by the system, not left to the model’s self-discipline.

    “Never commit secrets.” “No direct connections to the production database.” “Do not push to the main branch.” “Commit messages must include a ticket number.” These are hard limits, and expressing them in a prompt is essentially asking for probabilistic compliance. Any action that is allowed to fail and is expensive when it does should be enforced by a mechanism.

    All four can be described as “it didn’t do what it was told.” But only the first one is fixed by rewriting the context. If you keep adding sentences to the instruction file for the other three, the file just gets fatter and the failures get more random.

    3. The Entry File Is a Work Card, Not a Control Panel

    A more reliable mental model: the entry instruction file is a work card you carry into the repository, not a master console. It should answer a few specific questions:

    • What this project does and does not do;
    • The tech stack, directory boundaries, and layer responsibilities that are easiest to guess wrong;
    • Where the common commands live (build, test, static checks, startup, rollback);
    • What evidence counts as “done”;
    • Which areas have repeatedly caused problems in the past.

    The key is translating abstract expectations into rules that have a concrete target, a concrete action, and a way to verify.

    1. ## Layer responsibilities
    2. - The API layer only validates input and assembles responses. It contains no business orchestration.
    3. - The Service layer handles business orchestration and transaction boundaries.
    4. - External HTTP calls and model calls must not be placed inside a database transaction.
    5. ## Definition of done
    6. - Code changes + local verification commands run + deployment status separated from production evidence in the summary.
    7. - Any change to a data structure must update the migration script and type definitions in the same change.
    8. ## Directory boundaries
    9. - Only modify <the module paths involved in the current task>; changes to shared utilities require stating the reason first.

    Compare that with the version below, and the difference is clear:

    1. ## Bad example
    2. - Write clean code.
    3. - Follow best practices.
    4. - Pay attention to security and performance.

    The first version can be checked item by item during review. The second one has no pass/fail condition. To decide whether a rule is worth writing down, test it with three questions: Does it have a clear target? A clear action? Can it be verified afterward? All three yes, or it does not go in.

    4. Turn Procedures into Callable Steps

    For Type 3, the right move is to give the procedure an entry point that can be triggered explicitly, rather than folding it into the global rules. Three common approaches:

    1. Commandize it. Fix a set of scripted commands in the project (checks, unit tests, contract tests, change-scope validation), and have the instruction file reference only the command names and when they apply.
    2. Templatize it. Provide step-checklist files for common change types (adding an API, fixing a bug, upgrading a dependency) that are loaded explicitly when needed, so they do not occupy context all the time.
    3. Split into subtasks. Break search, auditing, and large-scale refactoring into independent subtasks. The main task only receives the conclusion, which reduces the buildup of useless context.
    1. # Local verification entry points fixed in the repository (illustrative)
    2. <project>/scripts/verify.sh # type checks + unit tests + contract tests
    3. <project>/scripts/scope-check.sh # verify changes stay within allowed directories

    The benefit is not just saving context. Once the procedure is declared explicitly, “which step are we on” is decided by external state rather than by the model’s recall.

    5. Hand Hard Limits to System Guardrails

    Type 4 has to move down from the prompt layer to the system layer. A workable layering:

    • Pre-commit hooks: formatting, static analysis, unit tests, secret scanning; a failure rejects the commit;
    • Permissions and sandboxing: no credential provisioning for direct production access, and manual confirmation for dangerous operations;
    • CI pipelines as the final judge: build, tests, security scanning, image signing; any failure blocks the merge;
    • Branch protection: protected branches reject direct pushes, and all changes go through review;
    • Observability and alerting: feed pipeline success rate, mean time to repair, and failed-run retry counts into a logging service and monitoring alerts, so that rule failures become quantifiable metrics (generic cloud capabilities such as object storage, message queues, container platforms, logging services, and monitoring alerts can all carry this chain).

    The principle is simple: anything a mechanism can guarantee should not be left to probability. Prompts guide; guardrails block. Neither can substitute for the other.

    6. Rollout Order and Measuring Results

    Recommended order, sorted by return on investment:

    1. Trim the entry file. Delete every abstract clause that cannot be verified, and keep only responsibility boundaries, commands, and the definition of done.
    2. Add a step template for each high-frequency change type, loaded on demand instead of always resident.
    3. Move any hard limit that has recurred more than three times into pre-commit hooks and CI.
    4. Establish a Definition of Done that specifies what evidence proves a change is finished.
    5. Measure and iterate: watch the recurrence rate of the same mistakes, the average number of rework rounds, and the pipeline’s first-pass rate.

    Whether the governance is working is not measured by how long the file is, but by three things: whether the same mistakes stop repeating, whether human rework rounds go down, and whether hard-limit violations get caught early by a mechanism. When a rule keeps being handled by “add one more sentence,” it probably does not belong in a prompt at all, and should be moved into a procedure or a guardrail.

    Treat the entry file as a work card, make procedures callable steps, and hand hard limits to system enforcement. That is the fundamental path to keeping AI coding assistants reliably on instruction.