Nâng caoHướng dẫnClaude Agent SDKNguồn: Anthropic

Chief of Staff Agent — Điều phối multi-agent với Claude SDK

Nghe bài viết
00:00

Điểm nổi bật

Nhấn để đến mục tương ứng

  1. 1 Hành động cụ thể: CEO cần data-driven insights để cân bằng giữa tăng trưởng mạnh và bền vững tài chính. Phần này hướng dẫn bạn cách triển khai thực tế, không chỉ lý thuyết suông.
  2. 2 Góc nhìn thực tế: Cách dùng chiefofstaffagent/CLAUDE.md Company Context - TechStart: 50-person startu. Điều quan trọng là hiểu rõ khi nào nên và không nên áp dụng phương pháp này.
  3. 3 Theo dữ liệu: Agent tự gọi script khi cần "Tính impact nếu hire 5 engineers?" → Agent chạy: python scripts/hiringimpact.py --count 5. Con số 4 tháng minh chứng cho hiệu quả thực tế mà bạn có thể kỳ vọng khi triển khai.
  4. 4 Tận dụng Claude hiệu quả: options = ClaudeAgentOptions permissionmode="plan" Chỉ lập kế hoạch Workflow: 1 — mẹo quan trọng là cung cấp đủ ngữ cảnh để AI trả về kết quả chính xác hơn 80% so với prompt chung chung.
  5. 5 Thành thật mà nói: Chief of Staff điều phối 3 subagents chuyên biệt: Subagent Vai trò Tools Financial Analyst Burn rate, runway, ARR. Phương pháp này hiệu quả trong hầu hết trường hợp, nhưng bạn cần điều chỉnh cho phù hợp ngữ cảnh riêng.
img IX mining rig inside white and gray room

Trong bài này, bạn sẽ xây dựng một AI Chief of Staff cho startup 50 người vừa raise $10M Series A. Agent này điều phối nhiều subagents chuyên biệt, tổng hợp insights từ nhiều nguồn, và đưa ra executive summaries với actionable recommendations.

Qua quá trình xây dựng, bạn sẽ học 6 tính năng quan trọng của Claude Agent SDK.

Scenario

CEO cần data-driven insights để cân bằng giữa tăng trưởng mạnh và bền vững tài chính. Chief of Staff agent sẽ:

  • Coordinate subagents chuyên biệt cho từng domain (finance, recruiting, strategy)
  • Aggregate insights từ nhiều nguồn dữ liệu
  • Provide executive summaries với recommendations cụ thể

Feature 0: CLAUDE.md — Persistent Memory

CLAUDE.md là file persistent memory cho agent. Khi có trong project directory, Claude tự động đọc và incorporate context này.

Tại sao cần?

Thay vì lặp lại project context, team preferences, hoặc standards trong mỗi interaction, define một lần trong CLAUDE.md. Đảm bảo consistent behavior và giảm token usage.

Cách dùng

# chief_of_staff_agent/CLAUDE.md

## Company Context
- TechStart: 50-person startup, Series A ($10M)
- Monthly burn: $500K, Runway: 20 months
- ARR: $2.4M, growing 15% MoM
- Target: $30M Series B in 18 months

## Available Scripts
- scripts/hiring_impact.py — Model hiring scenarios
- scripts/financial_forecast.py — ARR projections
- scripts/talent_scorer.py — Score candidates
- scripts/decision_matrix.py — Weighted decisions
options = ClaudeAgentOptions(
    model="claude-sonnet-4-6",
    cwd="chief_of_staff_agent"  # CLAUDE.md tự động được load
)

Data source preferences

Khi cả CLAUDE.md và CSV files đều có, agent ưu tiên data chi tiết hơn (CSV). Đây là behavior đúng — agent tìm nguồn authoritative nhất. Để ép agent dùng high-level context, dùng prompt: "sử dụng high-level financial numbers from context".

Kiến trúc đúng: CLAUDE.md chứa context + strategy + pointers. Detailed files là source systems agent query khi cần precision.

Feature 1: Bash Tool — Chạy Python Scripts

Agent có thể chạy Python scripts trực tiếp — xử lý data, chạy financial models, generate visualizations.

# Agent tự gọi script khi cần
# "Tính impact nếu hire 5 engineers?"
# → Agent chạy: python scripts/hiring_impact.py --count 5
# → Nhận kết quả: burn tăng $100K/tháng, runway giảm 4 tháng

5 scripts mẫu: hiring_impact, talent_scorer, simple_calculation, financial_forecast, decision_matrix.

Feature 2: Output Styles — Audience-specific

Output styles cho phép format khác nhau cho audiences khác nhau — không cần tạo agents riêng.

# .claude/output-styles/executive.md
---
name: executive
description: Concise executive summary format
---
- Lead with the decision/action needed
- Use bullet points, not paragraphs
- Include key metrics with trends
- End with 3 specific recommendations
options = ClaudeAgentOptions(
    settings={"output_style": "executive"},
    setting_sources=["project"]  # BẮT BUỘC để load styles
)

Quan trọng: Output styles modify system prompt, bỏ phần software engineering mặc định — cho bạn control cho use cases ngoài coding.

Feature 3: Plan Mode — Lên kế hoạch trước khi hành động

Plan mode chỉ tạo execution plan, không thực thi. Lý tưởng cho high-stakes decisions.

options = ClaudeAgentOptions(
    permission_mode="plan"  # Chỉ lập kế hoạch
)

# Workflow:
# 1. Agent tạo plan → save to file
# 2. Stakeholders review plan
# 3. Approve → chạy lại KHÔNG có plan mode
# 4. Agent thực thi theo plan đã duyệt

Plan → Review → Approve → Execute

Cycle này perfect cho: restructure tổ chức, infrastructure changes, acquisition decisions.

Feature 4: Multi-Agent Coordination — Subagents

Chief of Staff điều phối 3 subagents chuyên biệt:

Subagent Vai trò Tools
Financial Analyst Burn rate, runway, ARR projections Bash (financial_forecast.py)
Recruiter Score candidates, hiring pipeline Bash (talent_scorer.py)
Strategy Advisor Market analysis, competitive intel WebSearch

Chief of Staff nhận kết quả từ tất cả subagents, tổng hợp, và đưa ra executive summary với recommendations.

Feature 5: Hooks — Governance và Safety

Hooks cho phép bạn intercept và validate actions trước khi agent thực thi.

# PreToolUse hook — kiểm tra trước khi agent chạy script
async def validate_bash_command(input_data):
    command = input_data.get("command", "")
    if "rm" in command or "sudo" in command:
        return {"decision": "block", "reason": "Dangerous command"}
    return {}  # Allow

Hooks types: UserPromptSubmit (validate input), PreToolUse (gate tool calls), Stop (post-process).

Tổng kết: Features Cheatsheet

Feature Mục đích Khi nào dùng
CLAUDE.md Persistent context Project context, standards, pointers
Bash Tool Chạy scripts Data processing, calculations
Output Styles Format theo audience Executive vs technical audiences
Plan Mode Lập kế hoạch không thực thi High-stakes decisions
Subagents Multi-agent coordination Complex multi-domain tasks
Hooks Governance, safety Validate actions trước khi thực thi

Bước tiếp theo: Đọc Observability Agent để học cách tích hợp MCP servers, hoặc SRE Agent để xây agent có khả năng sửa lỗi hệ thống.


Bài viết liên quan

Tính năng liên quan:Agent SDKMulti-AgentCLAUDE.mdPlan ModeOutput StylesSubagentsHooks

Bai viet co huu ich khong?

Bản quyền thuộc về tác giả. Vui lòng dẫn nguồn khi chia sẻ.

Bình luận (0)
Ảnh đại diện
Đăng nhập để bình luận...
Đăng nhập để bình luận
  • Đang tải bình luận...

Đăng ký nhận bản tin

Nhận bài viết hay nhất về sản phẩm và vận hành, gửi thẳng vào hộp thư của bạn.

Bảo mật thông tin. Hủy đăng ký bất cứ lúc nào. Chính sách bảo mật.