Skip to content

Pipeline Architecture

The pipeline pattern runs each phase of development in a fresh agent context, passing artifacts (not context) between stages. This maximizes context purity — each agent starts clean and focused.

  1. Research Agent

    • Fresh context window
    • Explores codebase extensively (may read 30+ files)
    • Produces: .sdlc/research/[topic].md
    • Context cost: high (but isolated)
  2. Planning Agent

    • Fresh context window
    • Reads only the research summary (not raw files)
    • Produces: .sdlc/plans/[feature].md
    • Context cost: low
  3. Implementation Agent

    • Fresh context window (often in worktree)
    • Reads only the plan (not research or raw files)
    • Produces: code commits
    • Context cost: medium
  4. Review Agent

    • Fresh context window
    • Reads the spec + the diff
    • Produces: review feedback
    • Context cost: low-medium
  5. Iteration Agent (if needed)

    • Fresh context window
    • Reads review feedback + plan
    • Produces: fixes
    • Context cost: low

Start each pipeline stage in a fresh agent session, passing only the output artifact from the previous stage:

Terminal window
# Stage 1: Research (new session)
# Prompt: "Research how the auth system works. Save to .sdlc/research/auth.md"
# Stage 2: Planning (new session, fresh context)
# Prompt: "Read .sdlc/research/auth.md and create implementation plan. Save to .sdlc/plans/auth-v2.md"
# Stage 3: Implementation (new session, fresh context)
# Prompt: "Follow .sdlc/plans/auth-v2.md using TDD. Commit after each step."
# Stage 4: Review (new session, fresh context)
# Prompt: "Review the auth-v2 branch against .sdlc/specs/auth-v2.md"

For tools that support non-interactive (headless) execution, run each stage as a separate invocation. See the Tool Configuration Reference for the exact syntax in your tool.

Terminal window
# Automated pipeline — run your agent in non-interactive mode for each stage:
# Stage 1: Research
# Prompt: "Research the payment integration. Save to .sdlc/research/payments.md"
# Stage 2: Planning
# Prompt: "Read .sdlc/research/payments.md. Create plan at .sdlc/plans/payments.md"
# Stage 3: Implementation
# Prompt: "Implement .sdlc/plans/payments.md with TDD. Commit incrementally."
# Restrict allowed tools to: Read, Write, Edit, Bash(pnpm *), Bash(git *)

The pipeline’s power comes from controlled information flow:

Raw Codebase (millions of tokens)
▼ [Research Agent: reads broadly]
Research Summary (2,000 tokens)
▼ [Planning Agent: reasons about approach]
Implementation Plan (1,500 tokens)
▼ [Implementation Agent: follows plan]
Code Changes (varies)
▼ [Review Agent: validates against spec]
Review Feedback (500 tokens)

At each stage, information is compressed — the raw codebase (millions of tokens) becomes a research summary (2,000 tokens), which becomes a plan (1,500 tokens). Each downstream agent works with increasingly refined context.

FactorPipeline WinsHierarchical Wins
Task complexityVery highModerate
Quality requirementsCriticalStandard
Time pressureCan waitNeed speed
Human reviewBetween each stageAt key points
Context purityMaximumGood
Information preservationLower (lossy compression)Higher

You can combine pipeline and hierarchical patterns:

Research Phase (pipeline stage 1)
├── Sub-agent A: Research auth system
├── Sub-agent B: Research payment system ← Hierarchical
├── Sub-agent C: Research notification system within pipeline
└── Combined research summary
Planning Phase (pipeline stage 2, fresh context)
└── Lead agent creates unified plan
Implementation Phase (pipeline stage 3, fresh context)
├── Worktree agent A: Auth changes ← Hierarchical
├── Worktree agent B: Payment changes within pipeline
└── Worktree agent C: Notification changes
Review Phase (pipeline stage 4, fresh context)
└── Review agent checks all changes