Skip to content

A Context Engineering Workflow that is optimized for Claude Code to utilize subagents.

License

Notifications You must be signed in to change notification settings

jdrolls/subagent-context-engineering-workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Subagent Context Engineering Workflow

Transform how you build web applications with intelligent agent orchestration and human-in-the-loop development

License: MIT Claude Code Compatible Workflow Status

Overview

The Subagent Context Engineering Workflow revolutionizes web application development by combining the power of context engineering with Claude Code's intelligent subagent capabilities. This workflow emphasizes rapid prototyping with systematic testing checkpoints, clean code practices, and specialized agent orchestration to deliver production-ready applications faster than traditional development approaches.

Why This Workflow Matters

Traditional development often falls into these traps:

  • Over-engineering before validation - Building complex features before user testing
  • Context loss between sessions - Losing project understanding across development cycles
  • Inconsistent patterns - Code quality degrading as projects grow
  • Deployment complexity - Manual, error-prone deployment processes
  • Siloed development - Different aspects of the project developed in isolation

This workflow solves these problems through:

  • Structured context management - AI agents maintain comprehensive project understanding
  • Incremental development gates - Human testing checkpoints prevent over-building
  • Specialized agent teams - Project-specific AI agents handle complex coordination
  • Automated deployment orchestration - Multi-service deployments made simple

Key Benefits

  • 60% Faster Development - Parallel agent execution and automated coordination
  • Higher Code Quality - Built-in clean code practices and refactoring workflows
  • Reduced Technical Debt - Continuous cleanup and pattern enforcement
  • Simplified Deployments - Automated multi-service deployment management
  • Better Testing Coverage - Human-in-the-loop testing at every checkpoint
  • Enhanced Team Coordination - Clear context sharing and decision documentation

Quick Start

Prerequisites

  • Claude Code installed and configured
  • Node.js 18+ (for web projects)
  • Git for version control

Installation

  1. Clone the workflow into your project:

    git clone https://github.com/yourusername/subagent-context-engineering-workflow.git .claude
    cd your-project
  2. Initialize from your PRD (Product Requirements Document):

    claude chat
    > /init-from-prd your-prd.md

    The system will analyze your PRD, generate a Project Requirements Plan (PRP), create specialized agents, and prepare your development environment.

  3. Start building incrementally:

    > /prototype-feature "User Authentication"
    > /test-checkpoint
    > /prototype-feature "Dashboard Interface"
    > /test-checkpoint

Example: AI-Powered SaaS in One Day

# Day 1: Complete AI SaaS Application
> /init-from-prd ai-analytics-prd.md
# Auto-creates: ai-integration, payment-processor, auth-specialist agents

> /prototype-feature "Magic link authentication"
> /test-checkpoint
# ✅ Test: Users can log in via email

> /prototype-feature "AI data analysis interface"
> /test-checkpoint  
# ✅ Test: Users can upload CSV and get insights

> /prototype-feature "Stripe subscription billing"
> /test-checkpoint
# ✅ Test: Payment flow works end-to-end

> /deploy-check vercel,railway
# 🚀 Live application in production

Core Philosophy

1. Human-in-the-Loop Prototyping

Build incrementally with mandatory testing gates. Never build more than 45 minutes worth of features without human validation.

2. Adaptive Agent Creation

The system analyzes your PRD and automatically generates project-specific AI agents. A real-time collaboration app gets WebSocket specialists; an e-commerce platform gets payment and inventory agents.

3. Clean Code from Day One

Agents prioritize simplicity, maintainability, and consistent patterns. Technical debt is addressed continuously, not accumulated.

4. Parallel Intelligence

Use the task tool to run multiple specialized agents simultaneously:

task "Frontend: Build login UI" frontend-dev
task "Backend: Create auth API" backend-dev  
task "Database: User schema" database-eng

5. Context-Aware Development

Each agent maintains specialized knowledge while sharing project understanding through structured context files.

File Structure

project-root/
├── .claude/
│   ├── claude.md                    # Master context (auto-updated)
│   ├── subagents.md                # Dynamic agent registry
│   ├── commands/
│   │   ├── init-from-prd.md       # PRD → PRP → Project setup
│   │   ├── prototype-feature.md    # Rapid feature prototyping
│   │   ├── test-checkpoint.md      # Human testing workflow
│   │   ├── refactor-clean.md       # Code cleanup passes
│   │   ├── add-feature.md          # Adding features to existing project
│   │   ├── deploy-check.md         # Pre-deployment validation
│   │   └── migrate-to-workflow.md  # Adopt workflow in existing projects
│   ├── agents/
│   │   ├── core/                   # Always-present agents
│   │   │   ├── prd-analyzer.md     # Converts PRD to PRP
│   │   │   ├── architect.md        # System design
│   │   │   ├── prototype-lead.md   # Rapid prototyping coordinator
│   │   │   ├── test-coordinator.md # Human test management
│   │   │   ├── context-keeper.md   # Maintains context accuracy
│   │   │   └── deploy-manager.md   # Deployment orchestration
│   │   └── project/                # Project-specific agents (auto-generated)
│   │       ├── websocket-specialist.md  # Real-time features
│   │       ├── payment-integration.md   # Stripe/payment processing
│   │       ├── ai-integration.md        # LLM features
│   │       └── email-automation.md      # Email sequences
│   └── context/
│       ├── prp.md                  # Project Requirements Plan
│       ├── current-state.md        # What's built so far
│       ├── test-results.md         # Human testing feedback
│       ├── tech-decisions.md       # Architecture choices
│       └── deployment-status.md    # Current deployment info
├── README.md                       # Your project's README
└── [your project files]

Agent System Overview

Core Agents (Always Present)

PRD Analyzer - Converts business requirements into technical specifications

  • Analyzes Product Requirements Documents
  • Generates comprehensive Project Requirements Plans (PRPs)
  • Identifies needed specialized agents based on project complexity
  • Defines testable milestones and success criteria

Architect - Designs system architecture and maintains technical consistency

  • Creates system architecture diagrams
  • Defines API contracts and data models
  • Makes technology stack decisions with documented rationale
  • Ensures pattern consistency across the application

Prototype Lead - Rapid feature development with clean code practices

  • Breaks features into 30-45 minute development chunks
  • Implements with clean, testable code from the start
  • Manages parallel development coordination
  • Prepares clear test scenarios for human validation

Test Coordinator - Manages human testing checkpoints

  • Generates comprehensive test scenarios
  • Creates visual test guides and documentation
  • Processes human feedback into actionable tasks
  • Maintains testing history and issue tracking

Context Keeper - Maintains project context accuracy in real-time

  • Updates context files automatically after each development cycle
  • Identifies and resolves context contradictions
  • Archives outdated decisions appropriately
  • Ensures single source of truth across all project documentation

Deploy Manager - Orchestrates complex multi-service deployments

  • Manages deployment across Railway, Vercel, Supabase, and custom platforms
  • Coordinates environment variables and service dependencies
  • Handles deployment sequencing for interdependent services
  • Provides rollback capabilities and deployment monitoring

Project-Specific Agents (Auto-Generated)

Based on your PRD analysis, the system creates specialized agents:

  • WebSocket Specialist - Real-time features, live collaboration, chat systems
  • Payment Integration - Stripe, PayPal, subscription management, billing
  • AI Integration - OpenAI, Anthropic, local LLMs, prompt engineering
  • Email Automation - Transactional emails, sequences, template management
  • Database Migration - Schema changes, data migrations, optimization
  • Security Auditor - Security reviews, vulnerability scanning, compliance
  • Performance Optimizer - Code optimization, caching, monitoring

Command Reference

Essential Commands

/init-from-prd [prd-file]

Initialize a new project from a Product Requirements Document.

> /init-from-prd startup-idea-prd.md

Process:

  1. Analyzes PRD for technical requirements
  2. Generates comprehensive PRP with milestones
  3. Creates project-specific agents
  4. Sets up file structure and git repository
  5. Prepares for first prototype iteration

/prototype-feature "[feature-name]"

Rapidly prototype a feature with automatic testing checkpoints.

> /prototype-feature "Real-time chat with message history"

Process:

  1. Breaks feature into testable 30-45 minute chunks
  2. Coordinates parallel agent execution
  3. Implements with clean code practices
  4. Updates project context automatically
  5. Generates test scenarios for human validation

/test-checkpoint

Generate test scenarios and coordinate human testing.

> /test-checkpoint

Output:

  • Specific test scenarios with expected behaviors
  • Easy-to-follow testing instructions
  • Visual guides for UI testing
  • Clear success/failure criteria
  • Quick-fix options for common issues

/refactor-clean "[target-area]"

Clean up and refactor code while maintaining functionality.

> /refactor-clean "authentication system"

Process:

  1. Analyzes code for improvement opportunities
  2. Removes duplication and improves naming
  3. Extracts common patterns into reusable components
  4. Enhances error handling and documentation
  5. Validates changes don't break functionality

/deploy-check [platforms]

Validate and deploy to specified platforms.

> /deploy-check vercel,railway,supabase

Multi-Service Coordination:

  1. Determines optimal deployment sequence
  2. Manages environment variables across services
  3. Coordinates database migrations
  4. Runs integration tests
  5. Provides rollback capabilities

/add-feature "[description]"

Add new features to existing projects.

> /add-feature "Social media sharing with analytics"

/migrate-to-workflow

Adopt this workflow in existing projects.

> /migrate-to-workflow

Analyzes existing codebase and creates appropriate context structure.

Development Workflow

The Complete Cycle

PRD → PRP → Specialized Agents → Prototype → Test → Refactor → Deploy
  ↑                                                            ↓
  ←────────────── Add New Features ←──────────────────────────

Detailed Process

  1. Project Initialization

    • Write comprehensive PRD with business objectives
    • Run /init-from-prd to generate PRP and agents
    • Review generated architecture and milestones
  2. Feature Development

    • Select next feature from PRP milestones
    • Run /prototype-feature for rapid implementation
    • Agents work in parallel on different aspects
    • Code remains clean and well-documented
  3. Human Testing

    • Automatic test checkpoint after each feature
    • Clear test scenarios and success criteria
    • Human provides feedback and reports issues
    • System generates fix tasks from feedback
  4. Continuous Refinement

    • Regular /refactor-clean passes
    • Update documentation and context
    • Address technical debt incrementally
    • Maintain code quality standards
  5. Deployment

    • Run /deploy-check for comprehensive validation
    • Automated multi-service deployment coordination
    • Post-deployment monitoring and verification
    • Rollback capabilities if issues arise

Best Practices

1. Write Effective PRDs

# Good PRD Structure
## Business Objectives
- Clear success metrics
- Target user personas
- Revenue/growth goals

## Functional Requirements
- Detailed user flows
- Feature specifications
- Integration requirements

## Technical Constraints
- Performance requirements
- Security considerations
- Scalability needs

## Success Criteria
- Measurable outcomes
- Testing requirements
- Launch criteria

2. Trust the Testing Process

  • Never skip checkpoints - Each test prevents costly rework
  • Test early and often - Small iterations catch issues quickly
  • Document everything - Issues become learning opportunities
  • Fix before continuing - Technical debt compounds quickly

3. Leverage Parallel Development

# Effective parallel execution
task "Build user interface" frontend-dev
task "Create API endpoints" backend-dev
task "Design email templates" email-specialist
task "Set up monitoring" ops-engineer

# Avoid dependencies in parallel tasks
# Bad: Frontend needs API to be complete first
# Good: Independent tasks that can merge later

4. Maintain Context Quality

  • Let agents update context automatically
  • Review context files weekly for accuracy
  • Archive outdated decisions with timestamps
  • Maintain clear documentation standards

5. Embrace Incremental Development

  • Small features (30-45 minutes of work)
  • Quick testing cycles (immediate feedback)
  • Rapid iteration based on results
  • Continuous deployment and monitoring

Real-World Examples

Example 1: AI-Powered Analytics Dashboard

Project: SaaS analytics platform with AI insights Timeline: 3 days from PRD to production

# Day 1: Core Setup
> /init-from-prd ai-analytics-prd.md
# Generated agents: ai-integration, payment-processor, auth-specialist

> /prototype-feature "User authentication with magic links"
> /test-checkpoint
# ✅ Users can register and log in

> /prototype-feature "CSV upload and parsing"
> /test-checkpoint
# ✅ Users can upload data files

# Day 2: AI Features
> /prototype-feature "AI-powered data insights"
# Parallel execution:
task "OpenAI integration" ai-integration
task "Data visualization" frontend-dev
task "Insight generation API" backend-dev

> /test-checkpoint
# ✅ AI generates meaningful insights from data

# Day 3: Monetization & Deploy
> /prototype-feature "Stripe subscription billing"
> /test-checkpoint
# ✅ Payment flow works end-to-end

> /deploy-check vercel,railway
# 🚀 Production deployment successful

Example 2: Real-Time Collaboration Platform

Project: Document collaboration with live editing Timeline: 4 days with complex WebSocket coordination

# Setup with specialized agents
> /init-from-prd collab-platform-prd.md
# Generated: websocket-specialist, conflict-resolver, sync-manager

# Parallel development of complex real-time features
> /prototype-feature "Real-time document editing"
task "WebSocket server with rooms" websocket-specialist
task "Conflict-free data types" conflict-resolver
task "React collaboration hooks" frontend-dev
task "Document persistence" database-eng

> /test-checkpoint
# ✅ Multiple users can edit simultaneously without conflicts

Example 3: E-Commerce Platform

Project: Multi-vendor marketplace with complex workflows Timeline: 1 week for MVP

# Complex multi-service architecture
> /init-from-prd marketplace-prd.md
# Generated: payment-integration, inventory-manager, order-processor,
#           email-automation, shipping-calculator, vendor-portal

# Systematic feature development
> /prototype-feature "Vendor onboarding workflow"
> /test-checkpoint

> /prototype-feature "Product catalog with advanced search"
> /test-checkpoint

> /prototype-feature "Multi-vendor cart and checkout"
> /test-checkpoint

> /prototype-feature "Order management and fulfillment"
> /test-checkpoint

# Complex deployment coordination
> /deploy-check railway,vercel,supabase,stripe,sendgrid
# Coordinates deployment across 5 different services

Troubleshooting

Common Issues and Solutions

"Agent not found" Error

# Check available agents
> task "List all agents" context-keeper

# Regenerate missing agents
> /init-from-prd [original-prd].md

# Manually create specific agent if needed

Context File Conflicts

# Validate and fix context
> task "Resolve context conflicts" context-keeper

# Force context rebuild
> task "Rebuild all context" context-keeper

Deployment Failures

# Check deployment status
> task "Deployment health check" deploy-manager

# Review environment configuration
> task "Validate all env vars" deploy-manager

# Emergency rollback
> /rollback --to-checkpoint [number]

Test Scenarios Unclear

  • Provide more specific acceptance criteria in PRD
  • Include visual mockups for UI features
  • Add edge cases and error scenarios
  • Request step-by-step testing instructions

Debug Commands

# System health check
> task "Complete system analysis" architect

# Agent status verification
> task "Validate all agents and context" context-keeper

# Performance analysis
> task "Identify bottlenecks" performance-optimizer

# Security audit
> task "Security vulnerability scan" security-auditor

Advanced Usage

Custom Agent Creation

Create project-specific agents for unique requirements:

# .claude/agents/project/blockchain-integration.md
You are a blockchain integration specialist for Web3 applications.

## Your Context
- Access: /prp.md, /tech-decisions.md, /current-state.md
- Update: /tech-decisions.md, /blockchain-status.md

## Responsibilities
1. Smart contract deployment and interaction
2. Wallet integration (MetaMask, WalletConnect)
3. Gas optimization strategies
4. Web3 security best practices
5. DeFi protocol integrations

## Integration Patterns
- Use ethers.js for Ethereum interactions
- Implement proper error handling for network issues
- Cache blockchain data appropriately
- Handle wallet connection states gracefully

Multi-Repository Coordination

For complex projects spanning multiple repositories:

# Initialize each service with shared context
> /init-from-prd microservice-prd.md --service frontend
> /init-from-prd microservice-prd.md --service backend
> /init-from-prd microservice-prd.md --service auth-service

# Coordinate cross-service features
> /prototype-feature "Cross-service user authentication" --services frontend,backend,auth-service

Custom Deployment Platforms

Extend deployment support for custom platforms:

# .claude/agents/project/custom-deploy.md
You manage deployments to custom Kubernetes clusters.

## Deployment Process
1. Build Docker images with proper tags
2. Update Kubernetes manifests
3. Apply rolling updates
4. Verify health checks
5. Update ingress routing

Contributing

We welcome contributions to improve this workflow! Here's how to get involved:

Contributing Guidelines

  1. Fork the repository and create a feature branch
  2. Test your changes thoroughly with real projects
  3. Update documentation for any new features
  4. Add examples demonstrating new capabilities
  5. Submit a pull request with clear description

Areas for Contribution

  • New core agents for common development patterns
  • Platform integrations for additional deployment targets
  • Command improvements for better developer experience
  • Documentation enhancements with more examples
  • Testing frameworks for agent behavior validation

Adding New Core Agents

  1. Create agent file in .claude/agents/core/
  2. Define clear responsibilities and context access
  3. Add agent to subagents registry
  4. Update documentation with usage examples
  5. Test with multiple project types

Creating New Commands

  1. Create command file in .claude/commands/
  2. Define clear process with error handling
  3. Add comprehensive examples
  4. Update command reference documentation
  5. Test edge cases and failure scenarios

Inspiration and Credits

This workflow is inspired by and builds upon the excellent context engineering patterns introduced by Cole Medin in context-engineering-intro. We've extended these concepts to create a comprehensive development workflow specifically designed for Claude Code's capabilities.

Key Influences

  • Context Engineering Principles - Structured AI context management
  • Human-in-the-Loop Development - Systematic testing checkpoints
  • Agent-Based Architecture - Specialized AI agents for complex tasks
  • Modern DevOps Practices - Automated deployment and monitoring

Resources and Documentation

Essential Links

Learning Resources

  • Video Tutorials - Coming soon on YouTube
  • Blog Posts - Development workflow deep-dives
  • Case Studies - Real-world project examples
  • Community Forum - Questions and best practices

Integration Guides

  • Vercel Deployment - Frontend and full-stack applications
  • Railway Deployment - Backend services and databases
  • Supabase Integration - Authentication, database, and real-time features
  • Stripe Integration - Payment processing and subscription management

License

This project is licensed under the MIT License - see the LICENSE file for details.

License Summary

  • ✅ Commercial use allowed
  • ✅ Modification and distribution permitted
  • ✅ Private use encouraged
  • ⚠️ No warranty provided
  • ⚠️ Authors not liable for any damages

Quick Reference

Essential Commands

/init-from-prd [prd.md]          # Start new project from PRD
/prototype-feature "[name]"       # Build feature incrementally
/test-checkpoint                  # Human testing checkpoint
/refactor-clean "[area]"         # Clean up code
/deploy-check [platforms]         # Deploy application
/add-feature "[description]"      # Add to existing project
/migrate-to-workflow             # Convert existing project

Core Agents

  • prd-analyzer - PRD → PRP conversion
  • architect - System design and architecture
  • prototype-lead - Rapid feature development
  • test-coordinator - Human testing management
  • deploy-manager - Multi-service deployment
  • context-keeper - Context accuracy maintenance

Development Principles

  1. Test early, test often - Human validation at every checkpoint
  2. Keep it clean - Code quality from day one
  3. Build incrementally - Small features, quick iterations
  4. Document decisions - Context-aware development
  5. Deploy confidently - Automated validation and rollback

Ready to transform your development workflow? Start with a simple PRD and watch the agents coordinate to build your application faster than ever before.

Get Started | View Examples | Join Community

About

A Context Engineering Workflow that is optimized for Claude Code to utilize subagents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •