Planning and Execution Separation: Using AI to Build Complex Software Prototypes

    Separating planning from implementation creates a more reliable workflow for AI-assisted software development. This article uses a simplified spreadsheet application as a case study to explain how to create reviewable design documents, break them into executable tasks, evaluate planning and implementation quality, and manage failures caused by either flawed plans or flawed code.

    Introduction

    In AI-assisted programming, it is becoming increasingly common to generate an entire project from a one-sentence requirement. For larger software systems, however, this approach often produces disorganized and difficult-to-maintain code.

    Separating planning from execution provides a more reliable collaboration model. First, a model with stronger planning capabilities produces a design document that can be reviewed. Then, a lower-cost model implements the design one task at a time. This article examines how to apply this model and how to evaluate it using a simplified spreadsheet application as an example.

    A spreadsheet is a useful test case for three reasons. First, spreadsheet software covers a broad range of capabilities, including cell access, formula calculation, formatting, sorting, filtering, and file storage. These features expose weaknesses in requirements understanding and module decomposition. Second, the core logic involves dependency graphs, incremental recalculation, and circular-reference detection, all of which require a high degree of correctness. Third, even a minimal viable implementation requires a complete data model and interaction design, making it a useful way to roughly assess a system’s engineering maturity.

    1. Why Separate Planning from Execution?

    1.1 Different Cost Structures

    The planning stage primarily involves text input and output, but it determines the direction of all subsequent code. The execution stage requires more work, but each step has clearer instructions and generally requires less complex reasoning.

    By concentrating high-value decisions in the planning stage and delegating repetitive coding tasks to the execution stage, teams can significantly reduce the overall cost.

    1.2 Planning Results Are Easier to Review

    A design document can be read, modified, and discussed by people. Reviewing module boundaries and interface contracts is much more efficient than reading thousands of lines of generated code line by line.

    If a problem is discovered during planning, correcting it is usually inexpensive. If the same problem is discovered in the code, multiple files may need to be rolled back or rewritten.

    1.3 Planning Reveals Meaningful Capability Differences

    Differences between models in basic syntax generation are narrowing. However, models still differ considerably in their ability to decompose complex requirements, map dependencies, and anticipate risks.

    For this reason, planning quality is often a better indicator of engineering capability than the pass rate of a single code-generation attempt.

    2. Structure of the Planning Documents

    Planning documents should be treated as long-term project assets. They should be stored in the local repository and version-controlled together with the code.

    A recommended structure is:

    1. docs/
    2. 00-overview.md Project goals, scope, and non-goals
    3. 01-data-model.md Core data structures and state definitions
    4. 02-modules.md Module boundaries, responsibilities, and dependency direction
    5. 03-interfaces.md Inter-module signatures and error conventions
    6. 04-algorithms.md Key algorithms and complexity analysis
    7. 05-milestones.md Phased milestones and acceptance criteria
    8. 06-tasks/ Decomposed, executable task specifications

    Each task specification should include:

    • Inputs
    • Outputs
    • Files involved
    • Acceptance tests
    • Features explicitly excluded from the current scope

    A task should be small enough to complete and verify in a single execution cycle. If it is too large, it may exceed the model’s context capacity. If it is too small, coordination overhead will increase.

    3. Designing the Evaluation Criteria

    Evaluation should cover three dimensions, each with observable metrics.

    3.1 Planning Quality

    • Module completeness: Does the plan cover all subsystems required by the target functionality? Are storage, rendering, or input-processing modules missing?
    • Boundary clarity: Do dependencies follow a consistent direction? Are there circular dependencies?
    • Interface precision: Are function signatures, data types, and error-handling conventions detailed enough for another model to implement the module independently?
    • Risk identification: Does the plan identify potential issues involving concurrency, performance, numerical precision, or other difficult areas, and does it provide a strategy for handling them?

    3.2 Execution Results

    • Functional coverage: What proportion of acceptance cases pass?
    • Correctness: Do comparison tests verify formula evaluation, dependency updates, and other core logic?
    • Structural quality: Does the implementation follow the plan? Has arbitrary coupling been introduced outside the planned architecture?

    3.3 Cost Efficiency

    • Track resource consumption separately for the planning and execution stages.
    • Measure the average number of rework cycles required for each feature to pass acceptance testing.
    • Record the amount of human intervention, including time spent reviewing, correcting, and providing additional clarification.

    These three dimensions must be considered together. High planning quality combined with poor execution results usually indicates that the interfaces are not concrete enough. Good execution results combined with excessive cost may indicate that the task granularity needs to be adjusted.

    4. Implementation Workflow

    Step 1: Define the Scope

    List the functionality that must be implemented, as well as the functionality that will not be implemented. The clearer the boundaries, the less likely the planning process is to expand beyond control.

    Step 2: Generate a Planning Draft

    Ask the planning model to produce the document structure described above. Require it to provide acceptance criteria for every module.

    Step 3: Conduct a Human Review

    Pay particular attention to whether:

    • The data model is internally consistent
    • Module dependencies are reasonable
    • Algorithm descriptions contain ambiguities

    This is often the highest-return activity in the entire workflow.

    Step 4: Decompose and Execute Tasks

    The execution model should receive only one task specification at a time, along with the relevant sections of the planning documents. After implementation, it should run the corresponding tests.

    When a task fails, first determine whether the problem is in the plan or in the implementation. Only then decide which document or code should be changed.

    Step 5: Run Regression Tests and Integrate

    After all modules are complete, run the full set of end-to-end cases. Also verify that the interfaces between modules still match the planning documents.

    The core execution loop can be represented with the following pseudocode:

    1. for task in load_tasks("docs/06-tasks"):
    2. context = read_relevant_sections(task.refs)
    3. result = execute_model(task.spec, context)
    4. apply_changes(result)
    5. report = run_tests(task.acceptance)
    6. if report.passed:
    7. mark_done(task)
    8. else:
    9. diagnosis = classify_failure(report) # Planning defect or implementation defect
    10. if diagnosis == "plan":
    11. flag_for_plan_revision(task)
    12. else:
    13. retry(task, feedback=report.summary)

    The key part of this loop is failure classification. If every failure is treated as an implementation problem, the model may repeatedly patch the code while the underlying ambiguity in the interfaces remains unresolved.

    5. Technical Challenges in a Simplified Spreadsheet

    5.1 Cell Dependencies and Recalculation

    Formulas can reference other cells, forming a directed dependency graph. When a cell changes, the system must identify all affected cells and recalculate them in topological order.

    If the dependency graph contains a cycle, the cycle must be detected during parsing and reported clearly. Otherwise, calculation may enter an infinite loop.

    5.2 Formula Parsing

    A formula generally needs to go through lexical analysis, syntax-tree construction, and evaluation.

    The planning documents should specify:

    • Operator precedence
    • Nested parentheses
    • Function argument-count validation
    • Type conversion rules

    Without these definitions, different modules in the execution stage may interpret the same expression differently.

    5.3 Data Modeling and Storage

    Sparse spreadsheets can use dictionaries or hash-based structures to store only non-empty cells and reduce memory usage.

    The plan should define:

    • The difference between an empty value and zero
    • How cell references are represented
    • The serialization format used when saving files

    5.4 Interaction and Rendering

    The interface layer needs to handle selection, scrolling, editing states, and keyboard shortcuts. These details are easy to overlook but have a direct effect on usability.

    Separating input events, state-machine logic, and rendering logic can reduce cascading changes during later revisions.

    6. Common Mistakes

    6.1 Treating a One-Sentence Requirement as a Plan

    A requirement description is not a design. A document without module decomposition cannot support stable execution.

    6.2 Checking Only Whether the Program Runs

    A program launching successfully does not mean that its functionality is correct. Acceptance must be based on test-case results.

    6.3 Failing to Keep Documentation in Sync

    If the code changes but the planning documents are not updated, the next execution cycle will work from outdated information.

    6.4 Skipping Security Review

    Generated code still requires review of input handling, file access, and resource cleanup. Automated generation is not a reason to skip these checks.

    6.5 Estimating Cost Only Once

    The real investment includes planning, execution, and rework. The cost of a single model call cannot represent the total cost of the project.

    7. Conclusion

    Separating planning from execution transforms AI-assisted development from one-time generation into an engineering process that can be reviewed and traced.

    For complex software, the quality of the planning documents determines how reliably the implementation can proceed. A clear plan makes module boundaries, interfaces, algorithms, acceptance criteria, and risks visible before large amounts of code are produced. This allows teams to identify whether a failure comes from an incomplete plan or an incorrect implementation, and to improve the appropriate part of the workflow.