AI Coding Assistant Workflow: Context Management and a Four-Phase Practice

    This article explains why complex features built with AI coding assistants often need rework, and traces the root causes to two overlooked problems: uncontrolled context and a missing process. It introduces context engineering, including a 60% context-capacity limit and practical techniques for precise context feeding, followed by a four-phase workflow of Research, Plan, Implement, and Validate. It also shows how to固化 the process through project configuration. Readers will learn how to organize context and workflow to cut down rework and get AI to think clearly before writing code.

    Why Complex Features Keep Getting Reworked

    Many developers go through a similar loop the first time they use an AI coding assistant: they state a requirement, the AI immediately generates a large block of code, it fails to run, they add more explanation, and once one module is fixed another one breaks. By the middle or later stages, they realize the original approach was never viable and have to start over.

    On the surface, this looks like “the AI isn’t smart enough” or “the generated code is low quality.” But the real cause usually lies in two overlooked areas:

    1. Out-of-control context: Stuffing the entire project, dozens of files, and scattered conversation history into the model all at once, so it can only make judgments based on noise.
    2. Missing process: Skipping investigation of the current state and solution design, jumping straight from requirements to coding, which makes rework almost inevitable.

    The core of solving this problem is not switching to a stronger model, but establishing a reusable workflow. This workflow has two parts: context engineering and a four-phase workflow.

    Part 1: Context Engineering — More Is Not Better

    A common misconception is that “the more complete the information, the more accurate the answer.” In reality, the reasoning quality of an AI coding assistant is highly correlated with the signal-to-noise ratio of the context, not with the total amount of context. When the context is filled with large amounts of half-finished code, irrelevant files, and outdated discussions, the model starts to repeat itself, omit things, and even “fabricate,” and output quality drops sharply.

    1. Set a 60% Capacity Red Line

    A useful rule of thumb from practice is: context usage should not exceed 60% of total capacity. Once you cross this line, the model’s attention to earlier information clearly decays, and the probability of “going in circles” and self-contradiction rises significantly.

    In every session, you should keep an eye on context usage at all times. System-level content (project-level configuration, tool descriptions, custom agent instructions, and so on) can itself take up around thirty percent, leaving far less room for the actual business task than intuition suggests. Assuming a total capacity on the order of 200K tokens, with the system taking up about 32%, the remaining usable space is often only around fifty-some thousand tokens — which means you have to budget carefully.

    2. Practical Methods for Precise Context Feeding

    • Reference on demand: Add only the files, functions, or code snippets directly relevant to the current subtask to the context, rather than @-mentioning an entire directory.
    • Task splitting: Break a large requirement into multiple small tasks, and complete each task in an independent, clean session.
    • Regular cleanup: After each phase ends, promptly start a new session or compress the history to avoid residual information interfering with the next phase’s judgment.
    • Structured capture: Write investigation conclusions and design decisions into a standalone document (such as a notes file within the project), so the next phase only needs to reference this condensed document instead of reloading the raw materials.

    Part 2: The Four-Phase Workflow — Divide and Conquer

    Splitting the development process into four phases and clearing the context at the end of each phase is the key to controlling complexity.

    Phase 1: Research

    The iron rule is: if you can avoid writing code, don’t write code. First understand the real structure, dependencies, and design constraints of the existing codebase, then talk about implementation.

    An efficient approach is to dispatch multiple “research agents” in parallel, each responsible for:

    • Architecture mapping: module division, layering relationships, core abstractions;
    • Data flow analysis: key inputs and outputs, state transitions, persistence approach;
    • Tests and standards inventory: existing test coverage, code conventions, build method;
    • Locating similar implementations: finding existing similar features in the project and reusing patterns whenever possible.

    The results are finally consolidated into a research document that must include:

    1. A summary of findings;
    2. Code references with file:line numbering (this is especially important, as it keeps conclusions traceable and verifiable);
    3. Architecture-level insights;
    4. A list of questions to be clarified.

    After the research is complete, clear the context, and let only this document carry into the next phase.

    Phase 2: Plan

    Build the implementation approach based on the research document. The planning output should include:

    • Scope of changes (which files will be added, modified, or deleted);
    • A step-by-step implementation order, with each step independently verifiable as much as possible;
    • Risk points and rollback strategy;
    • Clear acceptance criteria.

    Generating complete code is strictly forbidden in the planning phase; only design is produced. Once done, clear the context again and use the planning document as the sole input.

    Phase 3: Implement

    Implement item by item according to the plan. Key constraints:

    • Do only one small step at a time, and run tests or a minimal verification after each step is complete;
    • When you encounter a deviation, update the plan first, then continue coding, to avoid drifting as you write;
    • Keep commits small so problems are easy to locate.

    Phase 4: Validate

    Verify the result from an independent perspective, without relying on the context from the implementation phase:

    • Run the full test suite and build process;
    • Check the results against the acceptance criteria in the plan, item by item;
    • Have a “clean session” review the code to check for omissions, over-engineering, or conflicts with the existing architecture.

    Part 3: Solidifying the Process — Driven by Project Configuration

    The four phases can be固化 into notes documents or custom commands within the project, so the assistant automatically switches roles and constraints at each phase. An example is shown below:

    1. # /research
    2. Research only, no code. Map architecture, data flow, tests, and similar implementations in parallel,
    3. output a research document with file:line references, and list questions to be clarified.
    4. # /plan
    5. Based on the research document, produce a step-by-step implementation plan including scope of changes, acceptance criteria, risks, and rollback strategy.
    6. # /implement
    7. Implement step by step strictly following the plan, verify each step before moving to the next, and do not exceed the scope of the plan.
    8. # /validate
    9. Check against the acceptance criteria from a third-party perspective, run tests, and output a list of issues with fix suggestions.

    This way, each session carries only one phase’s task, and the context naturally stays lean.

    Conclusion

    The upper limit of an AI coding assistant’s capability depends on how you organize context and workflow. Hold the 60% red line, stick to the phased progression of “Research — Plan — Implement — Validate,” and clear the context at the end of each phase, and the rework rate for complex features will drop substantially. First let the AI “think clearly,” then let it “write the code” — that is the essence of a mature workflow.