Context Engineering for AI Coding: Remove Old Rules Before Tuning Prompts

    This article explains why hand-written prompts are only a small part of an AI coding assistant's context, and how outdated system instructions, tool definitions, and chat history can interfere with newer multimodal models. It presents five configuration adjustments: deleting conflicting rules, replacing hard bans with reference-based constraints, using staged handoff notes to counter long-context degradation, simplifying tool call descriptions, and treating an evaluation set as a regression baseline. A practical checklist is included for applying subtractive context engineering across different models and deployment environments.

    1. The Problem: You Are Not the Only Voice in the Context

    In AI coding tools, the prompt a user writes often occupies only a small fraction of the entire context. The rest is filled with system instructions, tool definitions, skill descriptions, and prior conversation history. These elements stay active in every subsequent request, even when they no longer fit the current task.

    A senior engineer working in developer experience (previously responsible for open-source community technical direction, now on a model R&D team at a cloud vendor) shared that he writes code and runs evaluations every day with a new-generation multimodal large model. He found that rules originally added to compensate for the shortcomings of older models now interfere with the new model’s judgment. After switching models, he reworked five configuration items around a single principle: subtract first.

    This approach does not depend on any specific product. Whether you use a model service on a public cloud or self-hosted open-weight models locally, the logic of rule governance is the same.

    2. Adjustment 1: Delete Rules That Conflict With Each Other

    A typical path to technical debt is simple: add a rule whenever a problem appears. If the model writes useless comments, restrict comments. If you worry it will touch files it should not, add a rule limiting the scope of changes. A few months later, user-level instructions, project-level instructions, and the current task begin to conflict.

    Consider a concrete case: a global rule forbids adding comments, while the current task asks for docstrings on public functions. That is two opposing instructions at once. In testing, the model spends extra thinking tokens weighing which one to follow, and there is still a chance it follows the old rule, causing the current task to fail.

    The fix is to remove overly strict style bans and replace them with reference-based constraints:

    1. # Removed: no new comments allowed
    2. # Replaced with:
    3. Match the style, naming conventions, and comment density of the
    4. existing code in this repository.
    5. Public APIs need docstrings; internal implementations stay concise.

    To decide whether a rule should stay, ask three questions: Can it be replaced by an objective fact about the current codebase? Could it be mutually exclusive with another rule? Is it only meaningful for some historical version? If the answer to any one of them is yes, delete it.

    3. Adjustment 2: Replace Hard Bans With “Refer to the Current State”

    Hard bans push the model into a binary choice, while reference-based constraints give it an observable anchor. Having the model read three similar files first, then decide what the new code should look like, usually produces noticeably better consistency than a long list of “do not” items. The general form of this principle: do not write into rules anything that can be retrieved; keep in the rules only what cannot be retrieved, such as team conventions, security red lines, and directories that must not be touched.

    4. Adjustment 3: Solidify Context in Stages to Counter Long-Conversation Degradation

    Long-context compression causes information loss, showing up as the model forgetting early constraints or repeating work already completed. A workable engineering practice is to advance in stages: at the end of each stage, explicitly ask the model to produce a handoff record containing the current goal, key decisions made, file paths involved, unfinished items, and how to verify. Then start a new session and use that record as the only input to continue.

    1. ## Stage Handoff Record
    2. - Goal: Add unit tests for the auth module
    3. - Decision: Use table-driven tests; do not add new dependencies
    4. - Files: src/auth/login.go, src/auth/login_test.go
    5. - Unfinished: Expired-token branch
    6. - Verification: Run package-level tests; coverage no lower than current

    This externalizes implicit memory into a readable file, reducing compression loss and letting a person take over at any time.

    5. Adjustment 4: Trim Tool Call Descriptions

    When tool definitions are packed with examples, the model tends to mechanically copy the concrete values from the examples instead of following the field constraints of the interface itself. A safer approach is to delete the examples and keep only the interface signature, required and optional fields, value ranges, and error code semantics. When an example is truly needed, provide a single minimal case and clearly label it as “structure only; replace values according to the actual situation.”

    6. Adjustment 5: Treat the Evaluation Set as a Regression Baseline

    Rule changes must be measured. Maintain a small evaluation set that covers typical tasks, and track three metrics: pass rate, average thinking consumption, and number of manual rework rounds. Run it after every rule deletion or model switch, and use the data to confirm whether the subtraction actually helped rather than relying on intuition. In engineering terms, the evaluation can be wired into the pipeline and connected with logging services and monitoring alerts to form a continuously observable loop; the model service itself can be called through a unified cloud-side interface, making comparisons across different models easier.

    7. Implementation Checklist

    1. Export all current rules, annotate their source and creation time, and delete entries whose purpose cannot be explained.
    2. Scan for mutually exclusive rules and merge them into reference-based statements.
    3. Design a handoff record template for long tasks and enforce staged progression.
    4. Trim tool definitions: remove examples, add constraints.
    5. Establish an evaluation baseline, connect it to the pipeline, and let metrics drive subsequent adjustments.

    Switching models is not swapping one prompt; it is recalibrating the entire context. Subtract first, then optimize — that is the most reusable part of this practice.