A Practical Guide to Dual-Model Collaborative Programming

    This guide explains how to combine two AI model roles—a reasoning role for requirement clarification and a coding role for implementation—connected by versioned design documents. It covers a four-stage workflow: converging requirements through adversarial review, injecting machine-readable project constraints, modular development with cross-audits, and test planning with human review, plus common anti-patterns and tuning tips.

    1. Why a Single Model Hits a Ceiling

    Relying on a single AI coding assistant usually runs into three bottlenecks.

    The first is a narrow perspective. A model tends to follow the assumptions embedded in the prompt and lacks genuine adversarial review. Ambiguous requirements get “reasonably filled in,” and the generated code drifts away from the real intent.

    The second is context drift. As the conversation grows, key constraints established early get diluted by later turns, and the model starts to “forget” interface contracts, data structures, and boundary rules.

    The third is role confusion. When the same session handles design, implementation, and review, one role is effectively grading itself, so defects rarely surface on their own.

    The way out is to split thinking, implementation, and review across separate model instances, and to use documentation as the only trusted contract between them.

    2. Overall Framework: Two Roles, Document-Driven

    The recommended structure is: a reasoning role handles requirement clarification and challenges the proposed solution, while an execution role handles engineering delivery. The two interact through versioned design documents.

    • The reasoning role runs in a read-only planning mode. It produces no executable code, only requirement items, risk lists, and points of contention.
    • The execution role starts coding once the document is finalized, advances module by module, and delivers a reviewable artifact after each module.
    • The document is the single source of truth and contains four parts: requirement description, module breakdown, interface contracts, and acceptance criteria.

    A sample document skeleton:

    1. # Design Spec (v0.3, final)
    2. ## 1. Goals and non-goals
    3. ## 2. Data model and field constraints
    4. ## 3. Modules and dependency direction
    5. ## 4. Interface contracts (inputs/outputs/error codes)
    6. ## 5. Boundary and exception handling rules
    7. ## 6. Acceptance criteria (testable items)
    8. ## 7. Open questions (must be empty before development starts)

    3. Stage 1: Converge Requirements with Adversarial Review, Not Agreement

    The execution role first breaks the requirements into a structured draft, making implicit assumptions explicit: user roles, data sources, failure scenarios, and performance and capacity expectations.

    The draft then goes to the reasoning role for challenge, which is asked to do only three things: flag unclear definitions, flag conflicting items, and flag overlooked failure paths. The results go back to the execution role for rebuttal or revision, and the loop repeats.

    Convergence criteria should be verifiable conditions rather than a subjective feeling:

    1. The open questions list is empty;
    2. Every acceptance criterion maps to a clear input and expected output;
    3. Both sides define the same term identically;
    4. Two consecutive rounds produce no new points of contention.

    Keep planning mode on throughout. Neither side may write implementation code early, or the discussion will be pulled off course by implementation details.

    4. Stage 2: Inject Constraints as Machine-Readable Rules

    Once the document is final, add a persistent project-level constraint file that acts like a “project constitution.” It loads automatically in every session to suppress context drift, and should cover technology stack boundaries, directory structure, naming conventions, prohibited practices, and pre-commit checks.

    1. # Project Constraints
    2. - Use only the agreed technology stack; do not add unconfirmed third-party dependencies
    3. - Business logic must not access the storage layer directly; go through the data access module
    4. - All external input must be validated; errors go through the unified error code system
    5. - Never swallow exceptions; log context after catching and propagate upward
    6. - Run static checks and unit tests after each module is complete

    The constraint file should be short, decidable, and executable. “Code must be robust” is worthless; “every interface must validate inputs and return a unified error code on failure” is something a model will actually follow.

    5. Stage 3: Modular Development and Cross-Audits

    Development must proceed module by module, with dependencies flowing in one direction to avoid circular dependencies. After each module is delivered, it enters an audit in which the reasoning role switches to reviewer and checks:

    • Whether the module deviates from the final document, especially interface contracts and field constraints;
    • Whether boundary conditions are covered: nulls, oversized input, concurrency, and duplicate submissions;
    • Whether error handling is complete, and whether any failures are silently ignored;
    • Maintainability: naming, layering, and duplicated code;
    • Security: input validation, permission checks, and whether sensitive data ends up in logs.

    Audit feedback also goes through several rounds of exchange: the developer marks each item as accepted, rebutted, or deferred to a to-do list, and the reviewer re-checks until both sides agree. The key is that every item must land in either “modify the code” or “write it into the to-do list”—verbal agreement alone is not allowed.

    6. Stage 4: Test Planning with a Human Safety Net

    Once the code is stable, the review side drafts an automated test plan and finalizes it with the implementation side over several rounds, covering unit, integration, and end-to-end levels. Test design maps to acceptance criteria one by one first, then adds exception paths.

    1. Acceptance criterion AC-03: paginated query returns an empty list without error when the page number is out of range
    2. → Cases: page=0 / page=very large value / size=0 / invalid type

    A human step must remain at the end. In practice, leftover issues concentrate in the UI layer: misaligned layout, inconsistent state display, missing interaction feedback, and copy that does not match permission prompts. These depend on real visual and hands-on experience that models struggle to self-check, so people need to walk through and regression-test them item by item.

    7. Common Anti-Patterns and Tuning Tips

    • Documents too coarse: writing only “build an admin console” guarantees the model improvises. Granularity should reach the field level and the error code level.
    • Roles not isolated: writing and reviewing in the same session removes the adversarial dynamic, which amounts to no review at all.
    • One big delivery: generating everything at once and fixing defects afterward makes localization extremely costly; deliver in small module-sized steps.
    • No convergence criteria: discussion either drags on or stops too early; replace subjective judgment with verifiable conditions.
    • Skipping human acceptance: UI and experience problems all erupt right before delivery.

    8. Conclusion

    The core of this workflow is not how capable any single tool is, but using document contracts and role opposition to constrain an uncertain generation process into a verifiable engineering process. When running it in the cloud, keep design documents and constraint files in the code repository under unified version control, use a container platform to keep environments consistent, and use logging and monitoring with alerts to track runtime behavior, so the whole chain is reproducible, auditable, and continuously improvable.