2026-03-146 phút đọcVI
Multi-agent và đa service
English title: Multi-Agent and Multi-Service Workflows
Bài 18 trong chuỗi 20 bài về Claude Code. Nhiều agent khi: role rõ (planner, coder, reviewer), domain tách (frontend vs backend), hoặc parallel task. Nhiều service (API, worker, frontend) cần start/stop/restart — tích hợp tool (vd. PM2). Bài này: khi nào nhiều agent, handoff artifact, và quản lý service an toàn.
1. Khi nào nhiều agent
Orchestrator nhận task → planner tạo plan → coder implement → reviewer verify. Bắt đầu 1–2 agent; thêm khi workflow ổn. Chi phí context và latency; handoff cần artifact rõ (goal, done steps, next steps). Agent A ghi PLAN.md; coder đọc và ghi IMPLEMENTED.md; reviewer đọc cả hai. Artifact: goal, done steps, current state, next steps; lưu file hoặc in-memory tùy platform.
2. Nhiều service (vd. PM2)
Dev có nhiều service; agent cần start/stop/restart, xem log. Tool hoặc MCP: list process, start/stop by name. Hook PreToolUse chặn lệnh nguy hiểm (vd. pm2 delete all). Chỉ cho agent lệnh an toàn (vd. pm2 restart api). Bài 19: Tài liệu nên đọc — shorthand vs deep-dive.
Bài tiếp: Tài liệu nên đọc — shorthand vs deep-dive (bài 19).