Skip to main content

Advanced Workflows

Implement powerful patterns like TDD, plan mode, and memory management to maximize productivity

Introduction

Advanced Workflows

Claude Code's true power emerges when you adopt advanced workflows that leverage its AI capabilities strategically. In this module, we'll explore Test-Driven Development with Claude, master Plan Mode, optimize memory management, and harness parallel sessions.

By the end of this module, you'll be able to:

  • Implement Test-Driven Development (TDD) with Claude as your pair programmer
  • Use Plan Mode to break down complex tasks systematically
  • Manage Claude's memory effectively for long sessions
  • Run parallel Claude sessions for concurrent development tasks

TDD with Claude transforms the red-green-refactor cycle into a collaborative process where Claude helps write both tests and implementations.

The Claude-Enhanced TDD Cycle

Real-World TDD Example

Let's build a rate limiter using TDD with Claude:

TDD Best Practices with Claude

πŸ’‘

Claude excels at generating comprehensive test cases, including edge cases you might miss. Always review and enhance the generated tests.

  1. Test First, Always: Ask Claude for tests before implementation
  2. Edge Case Discovery: "What edge cases should I test for this function?"
  3. Test Refactoring: "How can I make these tests more maintainable?"
  4. Coverage Analysis: "What test cases am I missing for full coverage?"

Plan Mode transforms Claude from a coding assistant into a strategic planning partner. It's perfect for complex, multi-step tasks.

Activating Plan Mode

Plan Mode in Action

Here's how Claude breaks down a complex migration:

Advanced Plan Mode Techniques

Plan Validation

Claude's context window is powerful but finite. Effective memory management ensures productive long sessions.

Understanding Context Windows

Memory Optimization Techniques

1. Chunking Large Tasks

2. Memory Markers

3. Context Summarization

Memory Management Patterns

πŸ’‘

The "Checkpoint Pattern": Regularly save progress summaries and clear context to maintain performance over long sessions.

Maximize productivity by running multiple Claude sessions for different aspects of your project.

Setting Up Parallel Sessions

Parallel Session Strategies

1. Feature Development Pattern

2. Refactoring Pattern

3. Multi-Language Pattern

Session Coordination

1. In TDD with Claude, what should you always ask for before implementation?

  • A)Performance benchmarks
  • B)Comprehensive tests including edge cases
  • C)Code style guidelines
  • D)Database schemas
Show Answer

Correct Answer: B

In TDD with Claude, always ask for comprehensive tests first. Claude excels at generating thorough test cases including edge cases you might miss.

2. What command would you use to check Claude's context usage?

  • A)claude --memory
  • B)claude --context-info
  • C)claude --status
  • D)claude --check-tokens
Show Answer

Correct Answer: C

The --status flag shows current context usage, including tokens used, files in context, and active memory markers.

3. What is the Checkpoint Pattern used for?

  • A)Creating database backups
  • B)Saving progress and clearing context in long sessions
  • C)Version control commits
  • D)Testing deployments
Show Answer

Correct Answer: B

The Checkpoint Pattern involves regularly saving progress summaries and clearing context to maintain performance over long coding sessions.

4. When running parallel Claude sessions, what's the benefit of using --session-name?

  • A)It makes Claude work faster
  • B)It allows context isolation between different tasks
  • C)It's required for Claude to work
  • D)It automatically syncs code between sessions
Show Answer

Correct Answer: B

Using --session-name creates isolated contexts for different tasks, allowing you to work on multiple aspects of a project simultaneously without context pollution.

Let's build a complete feature using all the advanced workflows we've learned.

Scenario: Real-time Commenting System

Build a real-time commenting system with nested replies, reactions, and live updates.

Exercise Tasks

  1. TDD Challenge: Use Claude to build a rate limiter with sliding window algorithm using pure TDD
  2. Plan Mode Project: Plan a migration from REST to GraphQL API using Claude's planning capabilities
  3. Memory Management: Build a large feature using the checkpoint pattern, never exceeding 50% context usage
  4. Parallel Development: Use 4 parallel sessions to build a full-stack feature with automatic session coordination

The "Documentation-Driven Development" Pattern

  • Always review generated tests for completeness
  • Ask for edge cases explicitly
  • Use Claude to refactor tests for maintainability
  • Request performance tests when relevant

Plan Mode

  • Break large plans into phases
  • Ask for alternative approaches
  • Request risk analysis for critical paths
  • Use hierarchical planning for complex projects

Memory Management

  • Monitor context usage regularly
  • Create checkpoints before major transitions
  • Use selective context loading
  • Summarize before clearing

Parallel Sessions

  • Name sessions clearly by function
  • Coordinate through shared checkpoints
  • Use session export/import for context sharing
  • Merge sessions for integration work
  1. TDD Transformation: Claude makes TDD faster and more thorough
  2. Strategic Planning: Plan Mode turns complex tasks into manageable phases
  3. Memory Mastery: Effective context management enables long productive sessions
  4. Parallel Power: Multiple sessions multiply productivity
  5. Pattern Application: Combine workflows for maximum effectiveness

Beyond parallel sessions, Claude Code now supports sophisticated multi-agent architectures with sub-agents and orchestration patterns.

Understanding Sub-Agents

Sub-agents are specialized Claude instances that handle specific tasks, responding to your primary agent rather than directly to you.

The Sub-Agent Architecture

Creating Effective Sub-Agents

πŸ’‘

Sub-agents receive their context from the primary agent, not from your conversation history. Design accordingly.

Multi-Agent Orchestration Patterns

Pattern 1: Sequential Processing

Pattern 2: Parallel Specialists

Pattern 3: Hierarchical Agents

Building a Meta-Agent

Create agents that create other agents:

Advanced Multi-Agent Workflows

Workflow 1: Full-Stack Feature Development

Workflow 2: Codebase Modernization

Multi-Agent Best Practices

  1. Clear Boundaries: Each agent should have a single, well-defined purpose
  2. Minimal Tools: Only grant necessary permissions
  3. Explicit Communication: Define how agents report back
  4. Context Awareness: Remember sub-agents start fresh
  5. Orchestration Logic: Primary agent must coordinate effectively

Common Pitfalls to Avoid

⚠️

Pitfall 1: Assuming sub-agents have conversation context Solution: Pass all necessary context explicitly

Pitfall 2: Creating too many similar agents
Solution: Consolidate overlapping agents

Pitfall 3: No clear trigger conditions Solution: Use explicit keywords in descriptions

Debugging Multi-Agent Systems

1. What is the key difference between sub-agents and parallel sessions?

  • A)Sub-agents are faster
  • B)Sub-agents respond to the primary agent, not to you
  • C)Sub-agents have more memory
  • D)Sub-agents can use more tools
Show Answer

Correct Answer: B

Sub-agents communicate with your primary agent, not directly with you. This creates a delegation pattern where the primary agent orchestrates specialized agents.

2. What must you remember when designing sub-agent prompts?

  • A)They need to be very long
  • B)They must include your API keys
  • C)They have no conversation history
  • D)They require special syntax
Show Answer

Correct Answer: C

Sub-agents start with a fresh context. They only know what the primary agent explicitly tells them, so prompts must be self-contained.

3. What is a meta-agent?

  • A)An agent that reviews other agents
  • B)An agent that creates other agents
  • C)An agent with extra memory
  • D)An agent that runs faster
Show Answer

Correct Answer: B

A meta-agent is an agent designed to create other agents. It generates agent configurations based on requirements, automating the agent creation process.

You've mastered advanced workflows and multi-agent patterns that transform how you develop with Claude Code. In our final module, we'll explore building custom integrations with the Claude Code SDK.

πŸ’‘

Coming Next: Build custom tools, create Unix utilities, and extend Claude Code with your own integrations using the SDK.