转载笔记:本文是对 Khairallah AL-Awady(@eng_khairallah1)2026 年 11 月 11 日 X 长文《How to Build Your First Team of AI Agents Using Claude Fable 5.2》的总结笔记,不是原文转载;文中 10 份提示词为作者原文引用(作者公开发布供读者复制使用),其余内容为总结。原文链接:https://x.com/eng_khairallah1/status/2120506007143280812

说明:文章发表于 11 月 11 日,核查时(11 月 13 日约 09:30)文章页显示约 3.5 万次展示、128 点赞、30 转发、224 收藏。代码块的缩进在 X 文本提取时会被压缩,本文按标准 Python 缩进恢复,未改动标识符、字符串与逻辑;如需逐字粘贴,请以原文页面为准核对缩进。

大多数开发者以为组建 AI 智能体团队需要框架、复杂的编排或深厚的基础设施知识。作者的观点正好相反:不需要这些,3 分钟就能搭起第一支队伍。这篇 12 分钟阅读的指南用 13 步讲清楚怎么做,并给出了每一步需要的全部提示词。

注意:这篇与本站 11 月 12 日发布的 codila《Fable 5.2 大师课》是不同作者、不同内容——那篇讲 Fable 5.2 的个人工作流设置,这篇讲的是用 Fable 5.2 组建多智能体团队。

第 1 步:问题出在哪——单智能体扛不住一支队伍的活

多数公司还在用单智能体系统:给一个模型一个提示词,寄希望于它一次做好。作者打了个比方:这就像让一个人干一整个团队的活。

调研、规划、写代码、测试、评审、部署——单个模型不可能每样都做好。任务一大,它就会忘上下文、编造细节、犯错。

解决办法很简单:组建团队。每个智能体一个角色:一个规划、一个写代码、一个评审、一个测试。它们一起工作、共享上下文、互相检查。结果是输出更好、错误更少,而且系统真正可以扩展。

第 2 步:从团队负责人开始

团队需要负责人,负责人需要计划。负责人的工作是看一个任务,把它拆成小块,分给合适的专家。

先把工具准备好:去 Anthropic Console 拿 API 密钥,也可以直接用 Claude 应用。

然后在 Claude 里发送下面这条提示词(作者原文引用):

You are an expert software architect and team lead. Build me a software project using a multi-agent team approach. The project is a task management app with the following features: user login, task creation, task editing, and task deletion. Break this project into 5 parts and assign each part to a different expert agent. Give me the list of experts and their roles in a clear table.

你会得到清晰的任务拆分和团队结构。保存好这份回复——它就是你的项目计划。

第 3 步:定义专家智能体

每个专家都是一个独立的 Claude 智能体,用一条独特的系统提示词定义它做什么、怎么做、输出什么。

先定义 Python 专家,复制粘贴下面这条提示词(作者原文引用):

You are an expert Python developer. Your role is to write clean, efficient, and production-ready Python code. Follow PEP 8 standards, use type hints, and include docstrings for all functions. When given a task, write the complete code with proper error handling and comments.

其他专家照此办理,提示词如下:

前端专家提示词(作者原文引用):

You are an expert frontend developer specializing in React and TypeScript. Build responsive, modern user interfaces with clean code. Use Tailwind CSS for styling and ensure accessibility standards are met.

数据库专家提示词(作者原文引用):

You are an expert database architect. Design efficient database schemas, write optimized SQL queries, and ensure data integrity. Use PostgreSQL for relational data and consider indexing strategies for performance.

测试专家提示词(作者原文引用):

You are an expert QA engineer. Write comprehensive test cases, identify edge cases, and ensure code quality. Use pytest for Python testing and Jest for JavaScript testing.

运维专家提示词(作者原文引用):

You are an expert DevOps engineer. Set up CI/CD pipelines, Docker containers, and cloud deployment configurations. Ensure security best practices and monitoring are in place.

这样就有了 5 位专家,随时可以开工。

第 4 步:建立团队沟通机制

这是最关键的一环:智能体之间需要对话。每个智能体完成工作后要分享给团队,让下一个智能体接着做。

沟通格式提示词如下(作者原文引用):

You are part of a multi-agent team. When you receive a task, complete it and then share your results in this format:

TASK COMPLETED:
[Your completed work]

NEXT STEPS:
[What the next agent should do]

CONTEXT FOR TEAM:
[Any important information the team needs to know]

这个简单格式让所有人保持同步:没人重复劳动,没人丢失上下文。

第 5 步:写出三条核心系统提示词

现在搭建真正的系统,核心是三条系统提示词:

负责人提示词(作者原文引用):

You are the Team Manager for a software development team. Your role is to:
1. Analyze the incoming task
2. Break it down into subtasks
3. Assign each subtask to the appropriate expert agent
4. Monitor progress and ensure quality
5. Synthesize the final result

You must be clear, organized, and decisive. When you delegate, be specific about what you want.

专家提示词(作者原文引用):

You are an Expert Agent on a software development team. Your role is to:
1. Receive tasks from the Team Manager
2. Complete your assigned work with high quality
3. Share your results using the team communication format
4. Ask for clarification if the task is unclear

You are a specialist. Focus on your area of expertise and deliver excellent work.

评审提示词(作者原文引用):

You are the Quality Reviewer for a software development team. Your role is to:
1. Review all work completed by expert agents
2. Check for errors, bugs, and quality issues
3. Provide constructive feedback
4. Approve work that meets standards or request revisions

You must be thorough and detail-oriented. Never approve work with known issues.

保存好这三条提示词,它们是整个团队的基础。

第 6 步:用 Python 搭建团队结构

接下来把上面这些变成真正的代码,用 Python 和 Anthropic API。

先安装依赖库:

pip install anthropic

然后创建基础 Agent 类:

class Agent:
    def __init__(self, name, role, client):
        self.name = name
        self.role = role
        self.client = client
        self.memory = []

    def work(self, task):
        response = self.client.messages.create(
            model="claude-opus-4-5",
            max_tokens=4000,
            messages=[{"role": "user", "content": f"{self.role}\n\nTask: {task}"}]
        )
        result = response.content[0].text
        self.memory.append(result)
        return result

每个智能体有名字、角色(系统提示词)和记忆。注意模型用的是 claude-opus-4-5,单次调用上限 4000 个 token。

第 7 步:创建团队负责人(TeamManager)类

class TeamManager:
    def __init__(self, client):
        self.client = client
        self.team = []
        self.messages = []

    def add_agent(self, agent):
        self.team.append(agent)

    def assign_task(self, task, agent_name):
        for agent in self.team:
            if agent.name == agent_name:
                result = agent.work(task)
                self.messages.append(f"{agent.name}: {result}")
                return result
        return "Agent not found"

负责人负责记录团队成员,并把任务派给正确的智能体。

第 8 步:搭建团队通信系统

智能体之间需要互相传消息,代码如下:

class TeamCommunication:
    def __init__(self):
        self.messages = []

    def send_message(self, sender, receiver, message):
        self.messages.append({
            "sender": sender,
            "receiver": receiver,
            "message": message,
            "timestamp": "now"
        })

    def get_messages_for(self, agent_name):
        return [msg for msg in self.messages if msg["receiver"] == agent_name]

这是一个简单的消息系统。作者说明,在生产环境里应该用数据库或消息队列来替代。

第 9 步:运行第一个团队任务

把以上部分拼起来跑一个任务:

from anthropic import Anthropic

client = Anthropic(api_key="your-api-key-here")

manager = TeamManager(client)

python_expert = Agent("Python Expert", "You are an expert Python developer...", client)
frontend_expert = Agent("Frontend Expert", "You are an expert frontend developer...", client)
database_expert = Agent("Database Expert", "You are an expert database architect...", client)

manager.add_agent(python_expert)
manager.add_agent(frontend_expert)
manager.add_agent(database_expert)

result = manager.assign_task("Build a login system with email and password", "Python Expert")
print(result)

把 "your-api-key-here" 换成你从 Anthropic Console 拿到的真实 API 密钥。

第 10 步:加入评审智能体

质量很重要。加上评审来检查工作:

reviewer = Agent("Reviewer", "You are the Quality Reviewer...", client)
manager.add_agent(reviewer)

work = manager.assign_task("Build a login system", "Python Expert")
review = manager.assign_task(f"Review this code and find any issues: {work}", "Reviewer")
print(review)

评审检查工作、提供反馈;有问题时,专家可以据此修复。

第 11 步:测试完整团队工作流

def run_team_workflow(task):
    # Step 1: Manager breaks down the task
    plan = manager.assign_task(f"Break down this task into subtasks: {task}", "Python Expert")

    # Step 2: Experts work on their parts
    backend = manager.assign_task("Build the backend API", "Python Expert")
    frontend = manager.assign_task("Build the frontend UI", "Frontend Expert")
    database = manager.assign_task("Design the database schema", "Database Expert")

    # Step 3: Reviewer checks everything
    review = manager.assign_task(f"Review all work: {backend} {frontend} {database}", "Reviewer")

    return {
        "plan": plan,
        "backend": backend,
        "frontend": frontend,
        "database": database,
        "review": review
    }

result = run_team_workflow("Build a complete task management app")
print(result)

流程是:负责人先拆任务,专家各自完成自己的部分,最后评审统一检查。

第 12 步:部署团队

团队就绪后可以部署,作者给的是 FastAPI 的例子:

# Deploy with FastAPI
from fastapi import FastAPI

app = FastAPI()

@app.post("/run-team")
async def run_team(task: str):
    result = run_team_workflow(task)
    return result

# Run with: uvicorn main:app --reload

也可以用 Docker、AWS 或任何云平台部署,团队结构本身是通用的。

第 13 步:扩展团队

有了能跑的多智能体团队,扩展方向包括:

  • 为专业领域增加更多专家(安全、性能、用户体验);
  • 用共享数据库做团队记忆;
  • 用消息队列实现异步通信;
  • 增加监控与日志;
  • 为常见项目制作模板。

作者的核心结论是:搭建多智能体团队不需要框架,只需要清晰的角色、良好的沟通和 Claude。 第一个团队 3 分钟就能搭起来。

一点提醒

这篇指南的价值在于“最小可用团队”的完整骨架:角色提示词、沟通格式、Python 类、部署示例全都给了,可以直接照着跑。但它同时也是个教学演示——TeamCommunication 的时间戳写死为 "now"、消息没有真正接入工作流、错误处理几乎没有,直接上生产前需要补上这些。把它当作理解多智能体协作的起点,而不是生产级框架,定位就对了。

执笔执笔人

请我喝杯咖啡吧~

Solana

Solana

Solana

Solana

Solana

Solana

背景音乐
直达评论
设置
回到顶部
直达底部
收起工具箱