Nâng caoHướng dẫnClaude

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

핵심 요약이 글의 주요 내용
  1. 1Hà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. 2Gó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. 3Theo 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. 4Tậ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. 5Thà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.
Chief of Staff Agent — Điều phối multi-agent với Claude SDK

Xây dựng AI Chief of Staff điều phối nhiều subagents — học CLAUDE.md memory, output styles, plan mode, hooks, và multi-agent coordination.

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

#Agent SDK#CLAUDE.md#Multi-Agent#Plan Mode#Subagents

관련 글

코인 & VIP

코인으로 에피소드를 열거나 VIP로 모든 시리즈를 전부 감상하세요.

안전한 결제

계좌이체

QR
금액

유효 시간 30:00

  1. 은행 앱 열기
  2. QR을 스캔하거나 아래 정보로 송금
  3. 금액과 참조 번호를 그대로 유지
은행
계좌번호
예금주
금액
참조 번호

은행 앱으로 QR을 스캔하세요. 금액과 참조 번호가 자동 입력됩니다. 결제가 확인되면 코인 / VIP가 자동 지급됩니다.

결제를 기다리는 중…

어떤 작품을 좋아하세요?

좋아하는 장르를 고르면 홈에 “추천 작품”이 생겨요. 이 브라우저에 저장됩니다.

좋아하는 장르
표시
색상 테마

로그인

아직 계정이 없나요?

또는