正在学习

smoke.sh — tiny post-deploy checks

9.1 Multi-Agent and Subagent Workflows

As software projects grow, a single AI assistant can only handle so much context before efficiency drops or responses become inconsistent. This is where multi-agent and subagent workflows come in—a system where multiple specialized Claude instances collaborate to complete complex development tasks. Instead of one Claude handling everything from documentation to deployment, you orchestrate a team of Claude-powered agents, each with a distinct role: a Planner for task decomposition, a Coder for implementation, a Reviewer for QA, and a Deployer for final rollout.

This chapter marks a major shift in your Claude usage—from using Claude as an individual assistant to building a team of coordinated AIs that think, communicate, and execute in parallel. By the end of this project, you’ll have a functioning Claude-based system capable of automating a software sprint: dividing work, writing code, testing, and merging—all under your supervision.

Concept Development

A multi-agent workflow mimics human team dynamics. Each agent specializes in one domain but collaborates through structured prompts and shared context. Claude’s subagents—spawned as separate, goal-driven processes—make this possible while maintaining isolation and focus.

For example:

  • Planner Claude interprets user intent and creates a task breakdown.
  • Coder Claude writes functional code for each task.
  • Reviewer Claude checks logic, readability, and security.
  • Deployer Claude runs tests, builds artifacts, and performs CI/CD actions.

By connecting these agents with clearly defined inputs and outputs, you achieve asynchronous or sequential collaboration similar to real-world DevOps teams. The key principle is context synchronization: each agent receives the relevant subset of project data without flooding Claude’s context window.

Claude Code supports such structured cooperation through prompt chaining and shared memory constructs, allowing you to design systems where each AI instance feeds the next intelligently.

Hands-On Example: Creating a Multi-Agent Workflow in Python

Let’s create a simple prototype that simulates Claude subagent collaboration using a clean and runnable Python script. In this scenario, the main agent delegates coding and review tasks to subagents and merges their outputs into a single deliverable.

from typing import Dict, Any

class ClaudeAgent:

    def __init__(self, name: str):

        self.name = name

    def respond(self, message: str) -> str:

        # In production, this would call Claude's API.

        print(f"[{self.name}] received: {message}")

        if "plan" in message.lower():

            return "1. Write API routes\n2. Add validation\n3. Implement tests"

        elif "implement" in message.lower():

            return "Code snippet: def create_task(): pass"

        elif "review" in message.lower():

            return "The code passes structure and naming standards."

        else:

            return "Acknowledged."

# Instantiate subagents
planner = ClaudeAgent("Planner")

coder = ClaudeAgent("Coder")

reviewer = ClaudeAgent("Reviewer")

练习题

What is the primary benefit of using multi-agent and subagent workflows in software projects?

A. Reducing the number of agents needed
B. Handling larger context without efficiency drops
C. Eliminating the need for task decomposition
D. Increasing the cost of development

Which role in a Claude-powered multi-agent team is responsible for creating a task breakdown?

A. Coder
B. Reviewer
C. Planner
D. Deployer

Select all the roles in a Claude-powered multi-agent team mentioned in the text.

A. Planner
B. Coder
C. Reviewer
D. Deployer
E. Manager

The shift in Claude usage with multi-agent workflows means using Claude as an individual assistant rather than building a team of coordinated AIs.

The goal of a multi-agent Claude-based system is to automate a software sprint including dividing work, writing code, testing, and merging under supervision.

A multi-agent workflow mimics human team dynamics where each agent specializes in one domain but collaborates through structured prompts and shared ___.

Claude's subagents are spawned as separate, goal-driven processes while maintaining isolation and ___.

What is the key principle in multi-agent workflows for collaboration?

How does Claude Code support structured cooperation in multi-agent workflows?

Select all the tasks performed by Claude subagents mentioned in the text.

A. Interpret user intent and create task breakdown
B. Write functional code for each task
C. Check logic, readability, and security
D. Run tests, build artifacts, and perform CI/CD actions
E. Manage project budget

Which of the following is a benefit of using a multi-agent workflow in software development?

A. Simplified task management
B. Reduced need for testing
C. Increased efficiency in handling large context
D. Elimination of the need for supervision

Select all the knowledge points that are related to the roles and tasks of Claude subagents in a multi-agent workflow.

A. kp_9_1_002 - Roles in a Claude-powered multi-agent team
B. kp_9_1_005 - Multi-agent workflow mimics human team dynamics
C. kp_9_1_007 - Roles and tasks of Claude subagents
D. kp_9_1_009 - Claude Code support for structured cooperation
E. kp_9_1_001 - Multi-agent and subagent workflows in software projects

Explain how the collaboration principle in multi-agent workflows ensures efficient teamwork among Claude subagents.

Select all the knowledge points that are related to the shift in Claude usage with multi-agent workflows and the goal of a multi-agent Claude-based system.

A. kp_9_1_003 - Shift in Claude usage with multi-agent workflows
B. kp_9_1_004 - Goal of multi-agent Claude-based system
C. kp_9_1_006 - Claude subagents and their characteristics
D. kp_9_1_007 - Roles and tasks of Claude subagents
E. kp_9_1_001 - Multi-agent and subagent workflows in software projects

In a multi-agent Claude-powered workflow, which agent is primarily responsible for ensuring the security of the code by checking logic, readability, and security standards?

A. Planner Claude
B. Coder Claude
C. Reviewer Claude
D. Deployer Claude

Which of the following are key principles for achieving effective collaboration in a multi-agent Claude workflow? (Select all that apply)

A. Each agent has access to the entire project context to make better decisions.
B. Agents collaborate through structured prompts and shared context.
C. Context synchronization ensures each agent receives only the relevant subset of project data.
D. Claude Code supports structured cooperation through prompt chaining and shared memory constructs.

In a multi-agent Claude workflow, the Deployer Claude is responsible for interpreting user intent and creating a task breakdown.

登录后解锁笔记、知识点解析、AI 问答

立即登录