# AI Coding Rework: Fix It with a Four-Stage Workflow
When AI coding tools go off the rails halfway through a feature, most developers blame the model. This article argues that the real causes are messy context and the lack of a stable, staged process. It walks through context engineering, including why larger contexts tend to produce worse output and how to keep context usage under 60%, followed by a four-stage workflow (Research, Plan, Implement, Validate), how to template those stages into reusable commands, and the common anti-patterns worth avoiding.
Introduction: Rework Comes from Context and Process, Not the Model
When developers first start using AI coding tools, they often run into a frustrating pattern. They get halfway through a feature and discover a flaw in the design that came before it. They fix module A and module B breaks. A change they assumed would take ten minutes turns into a half-day stalemate.
The instinctive conclusion is “the model isn’t good enough.” In practice, the problem usually lies somewhere more fundamental, in two areas: the context fed to the model is too noisy, and there is no stable, staged workflow.
The quality of an AI coding tool’s output depends heavily on the quality of its context. Context is not a case of “more is better.” It behaves more like a workbench with limited surface area. When the surface is crowded with half-finished work, unrelated files, and duplicate information, the model is more likely to fixate on the wrong details and to go in circles. This article covers two threads, context engineering and a four-stage workflow, and offers a set of practices that beginners can apply directly.
1. Context Engineering: Less Is More
1.1 Why More Context Produces Worse Results
Intuition says the more complete the information, the more accurate the answer. In long-context scenarios the opposite tends to happen. Key constraints get diluted by a mass of secondary information, the model’s attention is spread thin, and the probability of repetitive output, missing preconditions, or unintentionally editing unrelated code rises noticeably.
The engineering response is simple: subtract actively, and keep only the information strongly related to the current task.
1.2 Respect the 60% Ceiling
One experience-based threshold that has been validated repeatedly: keep context usage at or below roughly 60% of total capacity. Past that point, output stability degrades noticeably. Practical points:
- Use your tool’s built-in context view to monitor the usage ratio at any time.
- When a new session starts, the baseline components, system prompt, tool definitions, custom instructions, consume a considerable share by themselves. What’s genuinely left for the business task is often only around 30%.
- So don’t bulk-reference a pile of files up front. Load files incrementally as the task requires.
A schematic startup self-check routine:
Session start -> check baseline usage -> estimate remaining budgetIf remaining < 40% -> trim referenced files, keep only the entry file and core modules
1.3 Store Context in Documents, Not in Memory
Write project conventions, directory structure, and coding standards into a project-level documentation file that the tool reads automatically at the start of every session. That is more reliable than pasting the same text into the conversation over and over.
Keep the document lean and maintainable. Otherwise it becomes a dumping ground where anything goes.
2. The Four-Stage Workflow: Divide and Conquer, Settle Each Stage
The deeper cause of rework on complex features is trying to think through everything at once. A more dependable approach is to split development into four stages. Each stage produces a clear, verifiable artifact. Once a stage is done, clear the context before moving to the next.
Stage 1: Research
The iron rule is: don’t write code unless you have to. No code means no new bugs.
The goal of this stage is to map the current state: the responsibilities of existing modules, data flow, existing constraints, and potential risk points. You can run multiple sub-agents in parallel, one for entry points and routing, one for the data layer, one for core business logic, and one for tests and configuration. Their findings are then consolidated into a single research document.
That document must include a summary of findings, code references with file:line, architectural insights, and a list of questions to clarify. References with line numbers matter especially, because they give later planning something concrete to stand on.
Stage 2: Plan
Based on the research document, produce an implementation plan: a list of changes, an impact analysis, boundary conditions, and a rollback strategy.
The planning stage is also where you define which files will not be touched, so that the implementation stage doesn’t accidentally break unrelated modules. Getting the plan reviewed before writing any code sharply reduces directional rework.
Stage 3: Implement
Follow the plan strictly, and do one thing at a time. After each small, verifiable step, run the build and the relevant tests to surface problems as early as possible.
If you discover partway through that the plan is wrong, go back to the planning stage and revise the document. Do not code, fix, and guess all at once.
Stage 4: Validate
Validation is more than “the example runs.” Check the result against the plan item by item: is the functionality complete, are the edge cases covered, were unrelated changes introduced, do the tests pass.
Write the validation conclusions back into the documentation to produce a traceable record.
3. Turning the Workflow into Reusable Commands
Repeating a process manually is easy to drift on. Custom instructions let you template the four stages: create four stage specification files in the directory agreed by the project, and invoke them through a single entry point, one stage at a time.
Each session then focuses on a single stage, context usage stays naturally under control, and everyone on the team works from the same terminology.
/workflow research # research only, and output the research document/workflow plan # produce the implementation plan only/workflow implement # code according to the plan/workflow validate # verify item by item
4. Common Anti-Patterns and Fixes
- Feeding the entire repository at once: load entry files and core modules stage by stage instead.
- Skipping research and going straight to code: produce a research document with line-numbered references first.
- Trying to do all four stages in one session: clear context between stages, and start a new session when needed.
- Changing code without updating documentation: let documentation and code evolve together, so communication cost keeps falling.
Conclusion
The key to less rework is not a stronger model. It is an engineering habit built on three things: controlled context, staged progress, and documentation that leaves a trail.
Hold the 60% line first. Then walk Research, Plan, Implement, and Validate steadily. Complex feature development stops being an endless tug-of-war and becomes a predictable, verifiable pipeline.
