Building a Closed-Loop Development Workflow with Dual AI Programming Assistants
In practical development, a single AI coding assistant can rapidly generate code but often struggles with requirement misunderstanding, context omission, and inadequate test coverage. This article introduces a collaborative workflow using two AI programming assistants with distinct roles: one for requirement clarification, documentation, and development, and the other for cross-review, code auditing, and test design. By establishing a closed-loop process of "propose, question, converge, finalize, execute, audit, and verify," this guide details how to implement requirement constraints, modular development, cross-auditing, and test loops to ensure traceable and sustainable AI-assisted software development.
In practical software development, a single AI programming assistant can rapidly generate code but often suffers from requirement misunderstanding, context omission, contract inconsistency across modules, and inadequate test coverage. A more robust approach is not to debate “which assistant to choose,” but to organize two general-purpose AI programming assistants with different capabilities into a reusable collaborative workflow: one is responsible for requirement clarification, documentation, and primary development, while the other handles cross-review, code auditing, and test plan design. The human developer acts as the ultimate decision-maker and acceptor. This article abstracts this practice into a general technical solution, focusing on workflow design, documentation constraints, modular development, cross-auditing, testing loops, and risk control.
1. Overall Concept: Replacing Single-Point Dependency with Dual-Assistant Cross-Review
The core of dual-assistant collaboration is not having them write code simultaneously, but assigning them different responsibilities at different stages, forming a closed loop of “propose—question—converge—finalize—execute—audit—verify.” Let’s designate them as Assistant A and Assistant B. Assistant A focuses on requirement consolidation, constraint document formation, and module implementation. Assistant B focuses on independent review, boundary condition checking, code auditing, and test plan formulation. They do not share all implicit contexts; instead, they exchange opinions through explicit documentation, reducing the risk of “talking past each other.”
An executable workflow looks like this:
Draft Requirements = Assistant A.clarify(Original Requirements)Constraint Doc = Assistant A.formulate(Draft Requirements)for round in 1..N:Feedback B = Assistant B.review(Constraint Doc)Response A = Assistant A.respond_and_revise(Feedback B)if converge(Feedback B, Response A): breakFinalized Doc = merge(Constraint Doc, Feedback B, Response A)Rule File = write_project_rules(Finalized Doc)for module in Module List:Code A = Assistant A.develop(module, Finalized Doc, Rule File)Audit B = Assistant B.audit(Code A, Finalized Doc)iterate until consensusTest Plan = Assistant B.formulate(Code A, Finalized Doc)Test Plan = finalize after rounds of communication with Assistant AManual Supplementary Testing and Bug Fixing
The key to this workflow is “explicitization”: requirements, constraints, interface contracts, audit feedback, and test plans must be documented as text rather than remaining only in conversational context. The more detailed the documentation, the less likely errors will occur during development; the more complete the review records, the easier it is to trace issues and perform regression verification.
2. Phase 1: Requirement Clarification and Constraint Documentation
The first step is for Assistant A and the human developer to jointly clarify requirements and form a structured constraint document. This document should not just be a feature list; it must cover objectives, scope, user roles, core processes, data entities, interface contracts, exception paths, non-functional requirements, acceptance criteria, and prohibited actions. For non-professional developers, this step is crucial as ambiguous requirements will be amplified into massive rework during the coding phase.
The constraint document should include the following fields:
Project Objectives:Scope and Non-Goals:User Roles and Scenarios:Core Business Processes:Data Entities and Field Constraints:Module Division and Dependencies:Interface I/O and Error Code Conventions:Exceptions and Boundary Conditions:Security and Permission Requirements:Performance and Compatibility Baselines:Acceptance Criteria:Prohibited Modifications or Introductions:
After the document is formed, do not immediately start coding. Assistant B should act as an “independent reviewer” to raise opinions, focusing on requirement ambiguity, missing scenarios, module coupling, interface inconsistency, and untestable acceptance criteria. Assistant A then responds item by item: accepted revisions are written into the document, and rejected ones are justified. Repeat this for several rounds until opinions converge. Convergence should be judged not just by “agreement,” but by whether key disputes have clear conclusions, pending items are cleared, and acceptance criteria are executable. It is recommended to set a round limit (e.g., 3-5 rounds); if still unresolved, the human developer arbitrates and records the decision basis.
3. Phase 2: Project Rule Files and Modular Development
The finalized constraint document needs to be translated into a project-level rule file to constrain the assistants’ development behavior. The rule file should be short, clear, and checkable, avoiding vague slogans. For example:
Project Rule Document (Example)- Tech Stack: Follow the finalized document; no unauthorized substitutions.- Directory Conventions: Divide directories by module; place shared code in a common directory.- Interface Conventions: All cross-module calls must follow the finalized interface contract.- Coding Requirements: Functions must have a single responsibility; errors must be handled explicitly.- Testing Requirements: Each module must include unit tests or executable verification scripts before submission.- Prohibited Actions: Do not modify unrelated modules; do not introduce unevaluated dependencies.- Pre-submission Checks: Static checks pass, critical paths are runnable, and documentation is updated synchronously.
The development phase should proceed module by module rather than generating the entire system at once. Before starting each module, clarify inputs, outputs, dependencies, and acceptance criteria; immediately enter auditing upon completion rather than accumulating issues until the integration phase. Modular development keeps context focused, audit granularity fine, and bug localization fast, making it easier for human developers to accept each small step. For UI-related modules, extra conventions should be made for state management, loading states, empty states, error states, boundary inputs, and interaction feedback, as these are often the primary source of defects in manual testing later.
4. Phase 3: Module-by-Module Code Auditing and Iterative Review
After each module is completed, Assistant B conducts an independent audit of Assistant A’s program. The audit should not just focus on “whether the code looks good,” but on verifiable quality items: interface contract consistency, exception path coverage, boundary condition handling, resource release correctness, log and error message traceability, permission and input validation sufficiency, test executability, and absence of irrelevant changes. Audit feedback should be specific to files, functions, input conditions, and expected behaviors, avoiding non-closable statements like “suggest optimization.”
Assistant A then responds to each audit item: fix, explain, or propose an alternative. They can engage in several rounds of debate, but must have clear convergence rules: high-risk issues must be fixed; medium-risk issues must be fixed or have an accepted reason recorded; low-risk suggestions can go to the backlog. The human developer retains final arbitration and records disputes and decisions in the review log. This leverages the dual assistants’ cross-checking ability while avoiding endless arguments.
5. Phase 4: Automated Testing Strategy and Manual Supplementary Testing
After code auditing passes, Assistant B drafts an automated testing strategy based on the finalized document and actual code, covering the focus areas of unit tests, API tests, integration tests, end-to-end tests, and smoke tests. The test plan should specify test objectives, prerequisites, input data, expected results, exception scenarios, and regression scope. Assistant A and Assistant B then communicate for several rounds to correct unexecutable parts, insufficient coverage, or inconsistencies with implementation contracts, finalizing the plan before execution.
Automated testing cannot fully replace manual acceptance. Especially UI issues, often manifesting as layout shifts, state switching anomalies, unclear prompts, or missing interaction feedback, require manual supplementary testing. It is recommended to conduct manual testing in the order of “main flow—exception flow—boundary input—compatibility—accessibility—visual consistency,” and categorize defects into four levels: blocker, critical, major, and minor. After fixing, regression verification must be added to avoid fixing one thing while breaking another. For non-professional developers, a manual testing checklist is more reliable than relying solely on memory.
6. Engineering Practices and Risk Control
Several risks need attention when implementing this workflow. First is context drift: assistants may ignore early agreements, so key constraints must be written into rule files and module specifications, not just relying on conversation memory. Second is excessive arguing: set round limits, risk grading, and human arbitration rules. Third is document bloat: constraint documents should be layered—project-level, module-level, and interface-level—to prevent a single document from expanding infinitely. Fourth is formalistic auditing: audit feedback must be verifiable and closeable, not just giving general evaluations. Fifth is false positive tests: test data, assertions, and expected results must all be reviewed to avoid merely verifying “it runs.”
Overall, the value of dual AI programming assistant collaboration lies in transforming “single-point generation” into “cross-validation.” It does not require the human developer to understand every line of code completely, but it does require them to master requirement boundaries, acceptance criteria, and decision records. Through constraint documents, project rules, modular development, module-by-module auditing, and testing loops, a traceable, reviewable, and continuously improving AI programming collaboration practice can be established without relying on a specific product.
