jilei.blog

Architect Mode: The Evolution of a Multi-Agent Pipeline

How AI-assisted programming evolved from simple chat-based collaboration to a production-grade multi-agent pipeline. A retrospective on the design decisions, trade-offs, and real-world results of Architect Mode.

Background

AI-assisted programming is reshaping software development, but a fundamental tension persists: AI context windows are finite, while real-world project complexity is infinite.

When asking Claude Code to build a complete full-stack project, conversations quickly grow bloated. The early approach was straightforward — keep making requests in a single session and let the AI generate code. This works well for small scripts or single-file tasks, but breaks down when:

  • You need to understand multiple frontend and backend modules simultaneously
  • Requirements evolve across many conversation turns
  • Code style and architectural consistency must be maintained
  • Context needs to be frequently switched during development

This is the context in which Architect Mode was born — not to solve a single specific problem, but as the product of gradual evolution across multiple real-world projects.

The Evolution: Three Stages of Growth

Stage 1: Single-Session Collaboration

The most primitive approach — do everything in one Claude Code session. It’s simple and direct, but as projects grow, problems emerge:

  • Longer conversations degrade AI reasoning quality
  • Frontend and backend code compete for the same context window
  • No parallelism — every task executes serially
  • A session crash means complete progress loss

Stage 2: Task Separation

To break through the single-session bottleneck, I started splitting work across multiple sub-sessions — the prototype of Subagents. The idea was:

  • Break large tasks into independent smaller tasks
  • Execute each in its own sub-session
  • Sub-sessions return summaries, not full conversation logs
  • The main session handles orchestration and integration

This brought some improvement, but introduced a new problem: no unified quality standard or review mechanism. Code from different sub-sessions had inconsistent styles, the architecture lacked a global perspective, and interface alignment relied entirely on manual checks.

Stage 3: The Birth of Architect Mode

After iterating through several projects, a complete pipeline design gradually took shape. Drawing inspiration from traditional software engineering — just as human teams need product managers, architects, developers, and testers — AI programming needs similar role specialization.

Thus Architect Mode was born: a 6-role × 3-phase multi-agent pipeline.

Architecture

Role Breakdown

RolePhaseResponsibility
ArchitectPhase 1Tech stack decisions, module design, interface contracts, risk assessment
PlannerPhase 1Decompose architecture into independently deliverable tasks
ImplementerPhase 2Parallel implementation in isolated worktrees
ReviewerPhase 3Code review across five dimensions (correctness, quality, completeness, efficiency, security)
TesterPhase 3Integration tests covering golden paths and edge cases
Security AuditorPhase 3Security review (OWASP Top 10, dependency vulnerabilities, etc.)

The Three Phases

Phase 1 ──────────→  Phase 2 ──────────→  Phase 3 ──────────
Architect → Planner   Implementer × N      Reviewer → Tester
     ↓                    (parallel)           ↓
  PLAN.md                                    Security Auditor
     ↓                                         ↓
  /compact                                  Test Report

Phase 1 — Architecture & Planning: The Architect produces a complete architecture plan (PLAN.md), and the Planner decomposes it into properly scoped tasks with dependency tracking and complexity estimates.

Phase 2 — Parallel Implementation: Multiple Implementers work simultaneously on isolated code copies via isolation="worktree", completely independent of each other. Each returns only a summary, preventing detailed conversations from accumulating in the main session.

Phase 3 — Review & Quality Assurance: The Reviewer performs multi-dimensional code review, the Tester adds integration tests, and the Security Auditor checks for vulnerabilities.

Context Management Strategy

Architect Mode includes four layers of context protection:

  1. Implementers use worktree isolation — sub-agent details don’t pollute the main session
  2. Run /compact before phase transitions — compress history to free context
  3. Persist state to STATUS.md — ensure compaction doesn’t lose progress
  4. Agents return summaries, not full logs — minimize data volume per sub-agent call

Plus a Safe Cut procedure: when context pressure signals appear (50+ conversation turns, slowing responses, completing an Implementer batch), it automatically saves state, runs /compact, and if needed, guides the user to continue in a new session.

Pros and Cons

Strengths

1. Task Isolation Improves Focus

Each Implementer works in its own worktree, free from cross-task interference. The AI operates in a clean, focused context, producing higher quality reasoning.

2. Built-in Quality Assurance

From architecture design to code implementation, review, and testing — a complete quality loop. The Reviewer scores across five dimensions and flags issues by severity (critical/major/minor).

3. Trackable Progress

Through STATUS.md and Task lists, you always know the current state: which tasks are done, in progress, or blocked. Even after a session crash, recovery is fast and reliable.

4. Parallel Efficiency

Independent tasks can run simultaneously across multiple Implementers, fully utilizing AI compute resources and reducing overall development time.

5. Cross-Session Recovery

A key design goal — sessions may crash for various reasons (context overflow, network issues, model switching). With state persistence, a new session can recover progress in milliseconds.

Weaknesses

1. Context Window Remains a Bottleneck

This is the most significant limitation. Despite extensive optimization — worktree isolation, /compact, summary mechanisms — Architect Mode cannot break through the model’s physical context ceiling. In the 128K context era, a moderate full-stack project (a dozen backend APIs plus a frontend) was enough to overwhelm the session. This bottleneck was ultimately resolved by upgrading to the 1M-context deepseek-v4-flash.

2. Overkill for Small Tasks

For a simple script, a one-line bug fix, or a quick API endpoint, going through the full 6-role, 3-phase pipeline is excessive. Direct conversation is far more efficient for these cases.

3. Phase Transition Overhead

Each phase transition requires /compact and state synchronization. While these operations are fast (usually under a few seconds), the accumulated cost is noticeable in rapid-iteration scenarios.

4. Sensitive to PLAN.md Quality

Architect Mode’s quality heavily depends on Phase 1’s PLAN.md output. If the architecture has flaws or omissions, all subsequent implementation and review work is affected — exactly as in human software engineering teams.

Production-Grade Results

Tested across multiple full-stack business systems, Architect Mode has demonstrated production-grade capabilities in the following areas:

Code Quality

The Reviewer mechanism ensures all code undergoes multi-dimensional review before integration. In practice, most critical and major issues are caught and fixed during the review phase, resulting in significantly higher quality than AI-generated code without review.

Architectural Consistency

With the Architect role providing unified planning in Phase 1, all Implementers work within the same architectural framework. Code style, interface conventions, and data flow design remain highly consistent — avoiding the “siloed” code quality typical of uncoordinated multi-agent generation.

Efficiency Comparison

Compared to single-session development, Architect Mode excels in these scenarios:

ScenarioSingle-SessionArchitect Mode
New module developmentContext grows fast, prone to crashesPhased delivery, stable
Multi-module parallel workSerial only, long wait timesParallel pipeline, shorter cycle
Cross-session recoveryManual context reload requiredRead STATUS.md and continue
Code reviewRelies on manual reviewAutomated Reviewer

When to Use Architect Mode

  • Best for: Full-stack business systems, medium-to-large feature development, AI-driven team workflows
  • Suitable for: Projects requiring strict quality control, architecture-first engineering
  • Not suitable for: Simple scripts, single-file edits, quick prototyping

Conclusion and Future Directions

The core idea behind Architect Mode isn’t new — it borrows proven practices from traditional software engineering: architecture first, task decomposition, parallel development, code review, automated testing. It simply adapts these practices to the context of AI programming.

This pipeline demonstrates that AI-assisted programming can evolve from a “code-writing assistant” into a “full-development-cycle collaborator”. The benefits of role specialization and process standardization far outweigh the overhead of phase transitions.

Of course, it’s far from perfect. Context window limitations remain an ongoing concern. As project scales grow further, finer-grained modularization strategies and incremental review mechanisms may be needed.

Additionally, the current design is primarily a sequential pipeline — phases execute in series. Future iterations could explore more flexible topologies, such as running certain review activities in parallel with implementation, or starting high-certainty work in Phase 1 while Phase 2 is still in progress.

Ultimately, whether through Architect Mode or other AI programming methodologies, the goal is not to replace developers with AI — it’s to enable developers to tackle more complex projects and deliver higher quality software. Architect Mode is just one milestone on this road, far from the final destination.