Building a Three-Stage Web Development Pipeline with an AI Coding Assistant

    Learn how to orchestrate an AI coding assistant into a three-stage pipeline—requirements and design, code implementation, and test validation—with numbered business rules, checkpoint-based resumption, self-healing test loops, and four-layer quality gates for reliable, traceable web application development.

    1. Background and Core Approach

    Small and mid-sized teams building web-based management systems typically face three practical constraints: limited headcount, rapidly changing business requirements, and insufficient testing resources. Manual testing is time-consuming and tends to miss edge cases, code quality depends heavily on individual experience, and development efficiency stagnates.

    Hiring more people is too expensive, and “process standardization” alone lacks an executable mechanism. A pragmatic alternative is to bring an AI coding assistant into the development workflow—delegating mechanical, repetitive, and enumerable work (documentation, code generation, test execution) to the AI, while keeping decisions that require business understanding and judgment in human hands.

    However, using AI as a free-form chat tool produces unstable results: unstructured output, lost context, and failures that cannot be traced. The key is engineering-grade orchestration—defining explicit stage boundaries, rule constraints, and verification loops for the AI. This is exactly what a three-stage pipeline provides.

    2. Overview of the Three-Stage Pipeline

    The overall workflow can be abstracted as:

    1. Requirements & Design → Coding & Implementation → Test Validation
    2. ↓ ↓ ↓
    3. Docs-first approach Code generation Self-healing tests
    4. Checkpoint resumption Human confirmation

    Each stage has well-defined inputs and outputs: Stage 1 produces a design document, Stage 2 takes that document as input and produces source code, and Stage 3 runs automated verification against the code. This “each stage’s artifact is the next stage’s input” design guarantees end-to-end traceability.

    Stage 1: Requirements and Design — Documentation First

    Many teams skip design entirely when generating code with AI, which produces code detached from actual business rules. This approach mandates documentation first. The AI must output a complete design document covering:

    • Requirements specification: functional scope and acceptance criteria;
    • Use case specifications: use case IDs, actors, preconditions, main flows, and exception flows;
    • Database design: table structures, field definitions, indexes, and relationships;
    • API design: unified conventions for endpoints, parameters, and response structures;
    • Menu and permission mappings: how pages map to permission points.

    A particularly valuable practice is the numbered definition of business rules (e.g., BR-001, BR-002). Once each business rule has a unique identifier, subsequent code reviews and test cases can reference it directly, forming a closed “rule → implementation → verification” loop. When requirements change, locating the affected rule ID enables fast impact analysis.

    Stage 2: Code Implementation — Two Modes

    Stage 2 takes the design document as input and produces frontend/backend source code plus database scripts. Two working modes cover different change scenarios:

    Creation Mode (new modules): Generates a module from scratch through a fixed sequence of steps. A typical sequence: read the design document → generate backend code → generate frontend pages → generate SQL scripts → run compile verification. Each step has explicit completion criteria, so the AI does not improvise beyond the rules.

    Modification Mode (incremental changes): Targets existing systems. The AI first analyzes the impact scope, identifies the list of affected files, and then performs incremental updates rather than rewriting entire modules. This matters greatly for legacy systems—large-scale rewrites are the primary source of regression defects.

    Checkpoint-based resumption is essential for long-running tasks. Generating large modules takes time and may be interrupted by network failures or context window limits. By persisting progress records after each step, the AI can reload the progress file on restart and continue from where it stopped—avoiding duplicated work and inconsistent state.

    Stage 3: Test Validation — Self-Healing Loops and Quality Gates

    This is the most critical stage for overall quality.

    Self-healing test loop: When a test fails, the AI does not simply throw the error back to the developer. Instead, it starts an automated fix loop:

    1. Test failure → 5-Why root cause analysis → Fix code → Re-test → Pass / continue loop

    The “5-Why” technique borrows from root cause analysis in lean manufacturing: the AI is forced to repeatedly ask “why did this fail” until it reaches the root cause rather than a surface symptom. For example, the surface fix for a null pointer exception is adding a null check, but the root cause may be missing data validation—the 5-Why mechanism helps the AI distinguish between the two.

    Four-layer quality gates: The fix loop is not the only line of defense. Code must pass four gates in sequence:

    1. Backend compilation verification (compiling is the minimum bar);
    2. Backend unit tests;
    3. Frontend type checking (static type validation);
    4. Frontend build verification.

    Failure at any layer triggers a rollback-and-fix cycle. Only after all four pass does the work proceed to human confirmation.

    Three-dimensional test coverage: Test cases must cover normal scenarios, exception scenarios, and boundary scenarios. A dedicated mechanism pauses the loop when boundary tests are missing—if the AI’s tests only cover the happy path, the pipeline halts and requires them to be completed. This institutionalizes quality instead of relying on “it seems to run.”

    Additionally, every 5-Why reasoning chain produced during self-healing loops is recorded and accumulated into a project knowledge base. When similar problems arise later, the AI can reference historical conclusions directly, so fix efficiency improves as the project progresses.

    3. Workflow Directory Organization

    The pipeline depends on a clear directory structure and rule files, illustrated below:

    1. workflow/
    2. ├── design/ # Requirements and design stage
    3. │ ├── INDEX.md
    4. │ ├── rules/ # Design rules
    5. │ │ ├── use-case-rules.md
    6. │ │ ├── db-design-rules.md
    7. │ │ ├── api-naming.md
    8. │ │ └── menu-permission-rules.md
    9. │ └── stages/ # Design steps
    10. │ ├── Step-01-req.md
    11. │ ├── Step-02-uc.md
    12. │ ├── Step-03-db.md
    13. │ ├── Step-04-api.md
    14. │ └── Step-05-menu.md
    15. ├── code/ # Code implementation stage
    16. │ ├── INDEX.md
    17. │ ├── rules/ # Implementation rules
    18. │ │ ├── backend-structure.md
    19. │ │ ├── controller-rules.md
    20. │ │ ├── orm-rules.md
    21. │ │ └── ui-component-rules.md
    22. │ └── stages/ # Implementation steps
    23. │ ├── Step-01-read-docs.md
    24. │ ├── Step-02-backend.md
    25. │ ├── Step-03-frontend.md
    26. │ ├── Step-04-sql.md
    27. │ └── Step-05-compile.md
    28. └── test/ # Test validation stage (organized the same way)

    Three design principles underpin this structure:

    1. Separation of rules and steps. The rules directory holds standards for how to do things (e.g., API naming conventions, layering constraints), while the stages directory defines in what order to do them. Rules are reusable across steps; steps only describe flow orchestration.
    2. INDEX.md as navigation. The AI uses index files to quickly locate the rules and steps required for the current stage, avoiding loading the entire context every time.
    3. Rule files can be drafted by AI and approved by humans. The AI generates the initial rule framework from general best practices, and developers test and refine it against the team’s reality—an efficient “AI drafts, humans review” collaboration.

    4. The Human Role: Decisions and Confirmation

    It is important to stress that this pipeline is not “fully automated AI delivery.” Human involvement concentrates on three critical checkpoints:

    • Requirement decisions: After the design document is produced, humans confirm the validity of business rules and the data model;
    • Code review: Key logic in AI-generated code can be spot-checked before testing;
    • Final confirmation: Even after all four quality gates pass, human acceptance of business correctness is required before merging.

    This division of labor frees developers from repetitive CRUD coding and test execution, letting them focus on business modeling, architectural trade-offs, and final quality control.

    5. Summary

    This practice can be distilled into four transferable lessons:

    1. Documentation first: The design document is the contract between AI and humans; numbered rules make changes traceable;
    2. Mode separation: Greenfield development and incremental modification use different strategies, protecting existing assets;
    3. Closed-loop verification: Self-healing fix loops + multi-layer quality gates + coverage requirements embed quality constraints into the process rather than relying on discipline;
    4. Knowledge accumulation: Recorded reasoning chains make fix experience reusable, so the pipeline runs more smoothly over time.

    The ceiling of an AI coding assistant’s value depends on how its user orchestrates it. For resource-constrained teams, rather than chasing “full automation,” it is more pragmatic to build a controllable pipeline where “AI executes, humans decide, and the process provides the safety net”—the most realistic path to balancing efficiency and quality under limited staffing and constantly changing requirements.