Separating Planning from Execution: A Practical Guide to the New AI Coding Paradigm
This article explains why one-shot AI code generation struggles with real-world engineering and introduces a practical paradigm that separates planning from execution. It covers a five-step workflow, a sample planning document structure, cost-control strategies, a four-dimension model evaluation framework, an engineering approach to high-fidelity UI rendering, common failure modes, and general cloud architecture recommendations. Readers will learn how to turn planning documents into executable contracts that move AI coding from demos to production.
1. The Problem: Why “One-Prompt Generation” Cannot Support Real Engineering
A recurring pattern has emerged in recent technical discussions: a small number of tasks can consume an entire month’s subscription quota, while the output often remains at the demo level. This is not merely a billing issue; it is the result of a mismatch between the interaction paradigm and engineering complexity. Real software systems typically contain millions of lines of code, with numerous cross-cutting concerns such as state management, event loops, rendering pipelines, persistence, permissions, and compatibility. If all of this complexity is compressed into a single session, the model must simultaneously handle requirement clarification, architecture design, interface definition, implementation, and debugging within the same context. Attention becomes diluted, and errors tend to surface in clusters later on.
As a result, the industry is gradually reaching a consensus: separate “planning” from “execution.” The planning phase pursues global consistency and verifiability, producing structured documents. The execution phase pursues local correctness and iteration speed, advancing module by module. This division mirrors the architecture review and task assignment mechanisms of mature software teams, except that the participants are now AI coding tools with different capability strengths.
2. The Core Method: Planning as Documents, Execution by Module
A practical workflow typically consists of five stages.
- Define requirement boundaries. Clarify the functional scope, non-functional metrics (response latency, concurrency, offline capability), target platforms, and acceptance criteria to avoid “infinite expansion.”
- Plan the architecture and data model. Determine the layered structure, module responsibilities, data structures, and persistence formats, then output a module list and dependency relationships.
- Split tasks and order dependencies. Break large goals into small, independently verifiable tasks, mark prerequisites and risk points, and form a trackable board.
- Execute and validate locally. The execution-side model implements each task, running a minimal validation set after each one is completed.
- Regress and refactor. Turn failing cases into test assets that drive the next iteration.
The structure of a sample planning document can look like this:
# GoalBuild a prototype with core spreadsheet capabilities (formulas, references, formatting, export)# Modules- Calculation engine: parsing, dependency graph, recalculation scheduling- Cell model: types, styles, error values- Interaction layer: selection, editing, keyboard shortcuts- Persistence: versioned file format- Rendering layer: virtualized drawing, partial refresh# Acceptance- 100 high-frequency function cases pass- Scrolling frame rate meets target at 10,000 rows x 100 columns- Files can be read and written back and forth without losing styles
The key is that the document serves as an “executable contract”: every module has inputs, outputs, constraints, and acceptance methods, so the execution side does not need to guess the global intent.
3. Cost Control: Spend the Budget on Irreversible Decisions
The root cause of cost overruns is repeated reasoning and the repeated replay of long contexts. Practical optimization measures include:
- Tiered model strategy: use a model with stronger reasoning capability for planning, a more cost-effective model for execution, and upgrade as needed for review and fixes.
- Context minimization: inject only the relevant module documents and interface definitions for each task, rather than the full history.
- Caching and reuse: bring planning artifacts, interface contracts, and test cases under version control for reuse across sessions.
- Budget guardrails: set per-task and per-day quota limits; when exceeded, pause and output a progress snapshot for easy resumption.
- Unit-based metrics: use “cost per passing case” rather than “cost per session” as the optimization metric.
It is worth emphasizing that any billing rules and quotas should be confirmed through the service provider’s official channels, rather than relying on second-hand information for budget assumptions.
4. Capability Evaluation: How to Tell Whether a Model Can “Really Write Software”
Demo-style results can easily create illusions. A four-dimension evaluation framework is recommended:
- Planning quality: whether module division is loosely coupled, whether dependencies form cycles, and whether acceptance is testable.
- Execution stability: the success rate and variance across multiple runs of the same task.
- Maintainability: whether naming, comments, error handling, logging, and externalized configuration follow conventions.
- Migration cost: how much implicit knowledge must be supplemented when switching the execution model or handing over to a human.
A practical signal is “whether the document can exist independently of the conversation.” If the planning document can be handed to another engineer to start work, the abstraction level is correct; if it can only be understood by relying on the original session, then planning has not truly been completed.
5. An Engineering Path for Complex Interfaces and Visual Fidelity
High-fidelity interface reproduction is a touchstone for testing execution-side capability. Taking pixel-level drawing to construct a scene as an example, the difficulty lies not in “drawing a lot” but in “drawing controllably.” The engineering approach is to split visuals into three layers:
- Data layer: primitives, material parameters, lighting, and random seeds, all serializable.
- Scheduling layer: tiled rendering, cache reuse, and progressive refinement, producing a recognizable outline first and then filling in details.
- Validation layer: using structural similarity, edge error, and sampled comparison of key regions as objective metrics.
Sample code:
def render(scene, tile=256, seed=0):rng = random.Random(seed)for chunk in scene.split(tile):cache_key = (chunk.id, seed)if cache_key not in cache:cache[cache_key] = draw(chunk, rng)blit(canvas, cache[cache_key], chunk.offset)return refine(canvas, passes=2)
Only by converging randomness into a seed and splitting rendering into cacheable chunks can performance be improved without sacrificing reproducibility. Similarly, interaction-intensive applications (such as large spreadsheets) should adopt rendering virtualization, incremental recalculation, and dependency graph scheduling to avoid the performance collapse caused by full refreshes.
6. Common Failure Modes and How to Avoid Them
- Planning too coarsely: only a feature list, with no interfaces or acceptance criteria, leaving the execution side to improvise and causing rework.
- Planning too finely: hard-coding implementation details, losing room for refactoring and increasing maintenance costs.
- Missing tests: using “looks correct” as acceptance, so defects surface in clusters during integration.
- Context pollution: leaving failed attempts in the context for a long time, causing the model to repeat erroneous paths.
- Ignoring non-functional requirements: performance, security, and observability are not included in acceptance, and non-compliance is only discovered before launch.
The way to avoid these is to move “verifiability” forward: before any task enters execution, a failing test case must be written first.
7. General Architecture Recommendations for Cloud Deployment
To productize this pattern, a pipeline can be built on general cloud capabilities: use a container platform to host stateless executors, use object storage to store planning documents and build artifacts, use a message queue for task distribution and peak shaving, use logging services and monitoring alerts to track success rate, latency, and quota consumption, and use a key management service to host credentials. Baidu AI Cloud is typically used in such scenarios to carry the above general-purpose capabilities, decoupling the planning and execution sides so they can scale independently.
8. Conclusion
The value of “separating planning from execution” lies not in making the model write longer code in one go, but in confining uncertainty within verifiable boundaries. Planning quality determines the upper limit, execution stability determines the lower limit, and cost control determines sustainability. When planning documents become a contract shared by the team and the model, AI coding moves from demos to production.
