Claude Code 多智能体会计管道

用 Claude Code + 自定义 Skill 构建 5 个顺序执行的 Agent 实现端到端会计自动化系统

基本信息

  • 来源:YouTube 视频
  • 时长:22 分钟
  • 示例场景:电商公司(电子产品分销商)会计自动化
  • 技术栈:Claude Code + 自定义 Agent Skills
  • 架构:5 Agent 顺序管道

核心观点

  1. 会计流程适合 Multi-Agent 架构:会计和簿记的每个步骤都是规则驱动(分类、匹配、汇总、报告),规则+结构+顺序正是 Multi-Agent 系统擅长的场景

  2. 顺序管道 > 并行架构:本案例采用严格的 5 Agent 顺序执行:数据准备 → 分类 → 对账 → 报告 → 洞察。每个 Agent 只负责一个职责,输出成为下一个 Agent 的输入

  3. 项目基础比代码更重要:在写任何 Agent 代码前必须先建立 4 个基础文件:

    • data/ 文件夹(共享工作区)
    • CLAUDE.md(项目真相源)
    • 《Claude Skills and Plugins 终极指南》(600 行最佳实践)
    • Agent Skill 详细规格文档(每个 Agent 的角色/输入/输出/规则)
  4. 逐个构建+测试,不要一次性构建所有 Agent:按顺序构建 Agent 1 → 测试 → Agent 2 → 测试 → …,避免在系统末端才发现前置 Agent 的问题

  5. 职责边界清晰才能避免混乱:每个 Agent 有明确的”只做什么”和”不做什么”,例如:

    • Agent 1(数据准备)只标准化格式,不分类
    • Agent 3(对账)只标记差异,不修改数据
    • Agent 4(报告)只聚合数字,不做解读
    • Agent 5(洞察)只解读数据,不修改原始报告

实操内容保留

5 Agent 架构设计

Agent 1: Data Preparation Agent(数据准备)

  • 输入:原始银行对账单、收据、现金记录(格式不统一)
  • 输出:标准化事务列表(4 字段:date, description, amount, type)
  • 规则:
    • 标准化日期格式和货币符号
    • 负金额标记为 expense
    • 不分类,只清洗
    • 强制缺失字段补全(合理推断)

Agent 2: Categorization Agent(分类)

  • 输入:Agent 1 的标准化事务列表
  • 输出:增加 category 和 subcategory 字段的事务列表
  • 规则:
    • 基于 description、amount、上下文分类
    • 支持规则覆盖(特定商户 → 特定类别)
    • 使用一致的分类体系(rent, utilities, transport, revenue 等)
    • 低置信度 → 标记为 “uncategorized”,不要猜

Agent 3: Reconciliation Agent(对账)

  • 输入:Agent 2 的分类事务 + 第二数据源(如银行对账单 vs 内部账本)
  • 输出:对账报告(mismatches, duplicates, missing entries)
  • 规则:
    • 基于 date + amount + description 相似度匹配
    • 所有不一致必须标记原因
    • 不修改数据,不强行匹配
    • 准确性 > 强制对齐

Agent 4: Reporting Agent(报告生成)

  • 输入:Agent 3 验证后的分类事务
  • 输出:结构化财务摘要(total income, total expenses, net income, category breakdown, time period)
  • 规则:
    • 按 category 和 period 分组
    • 所有总计必须回溯到事务数据
    • 不添加解读,不给建议
    • 只输出数字结构

Agent 5: Insights Agent(洞察分析)

  • 输入:Agent 4 的财务报告
  • 输出:业务洞察(trends, spending patterns, actionable signals)
  • 规则:
    • 只突出有意义的变化,不做表面观察
    • 尽可能使用对比(month-over-month)
    • 避免通用建议,每个洞察基于实际数据
    • 简洁、面向决策

实际案例数据(Q1 2024 电商公司)

财务概览

  • Q1 总收入:$226,617
  • Q1 总成本(COGS):$66,900
  • Q1 净利润:$149,230
  • 净利率:21.7%

关键洞察

  1. 1 月净利率异常低(7.7%):工资支出占当月收入 50%,可能是奖金集中发放
  2. 3 月运费飙升 244%:从 6,920,需要排查物流变化或促销活动
  3. 营销效率下降:3 月营销费用翻倍但收入仅增长 17.8%
  4. 平台集中风险:Amazon 占 Q1 收入 78.5%,过度依赖单一平台
  5. 直营渠道增长:Shopify 3 月增长 62.9%,值得加大投入

项目基础文件结构

accounting-pipeline/
├── data/
│   ├── raw/               # 原始输入
│   └── cleaned/           # Agent 输出
├── CLAUDE.md              # 项目配置
├── claude-skills-guide.md # 600 行 Skill 最佳实践
└── agent-details.md       # 5 个 Agent 的详细规格

关键概念

  • Claude Code:Anthropic 的 AI 编程工具,支持自定义 Agent Skill
  • Multi-Agent 系统:多个 AI Agent 协同工作,每个负责一个子任务
  • Agent 技能:Claude Code 中的自定义技能模块,定义 Agent 的行为和规则
  • 顺序管道:数据按固定顺序流经多个处理阶段,每个阶段只处理一件事
  • CLAUDE.md:Claude Code 项目的配置文件,定义项目结构和规则

与其他素材的关联

  • Claude Code 实体页:本案例是 Claude Code 自定义 Skill 的高级应用
  • AI Agent 智能体 主题:展示了 Multi-Agent 协同的实际架构设计
  • 工作流设计 实体页:演示了顺序管道的职责分离原则

原文精彩摘录

“And here’s the thing, almost every step in that workflow is rule-based. Like, categorize this, like that, summarize this into a P&L, send this what finance needs to act on. So, rules, structure, sequence. And this is exactly what a multi-agent system is built for.”

“Four things in this project folder before we build a single agent. The first one is the data folder. It exists because the agents need something to actually work with… Every agent in this system reads from and writes to this folder in sequence. It’s the shared workspace the whole system actually runs on.”

“Five agents, five distinct jobs, and each one built and tested before moving to the next. We are not building all five and hoping the system will just work end-to-end. We will test each agent individually as we go.”

“Critically, it [Agent 3] does not modify anything. It does not resolve discrepancy on its own. Accuracy over forced matching.”

“Do not add interpretation. No advice, no commentary, just the numbers structured correctly. That job belongs to the insight agent.”