| name | add-domain-agent |
| description | Scaffold a new domain agent for the Post-Op Care Platform following the BaseAgent / MessageBus / Scratchpad pattern, wire it into the coordinator and MultiAgentSystem, and add tests. Use when adding a new specialized agent role. |
Add a domain agent
Follow this checklist to add a new specialized agent consistently with the existing 12. Read the
referenced files first; mirror their structure rather than inventing new patterns.
-
Define the type. Add the new member to the AgentType enum in src/types/index.ts
(UPPER_SNAKE_CASE). If the agent produces a new domain object, add its interface here too —
this file is the single source of truth.
-
Create the agent at src/agents/<Name>Agent.ts, extending BaseAgent
(src/core/BaseAgent.ts). Implement the four abstract methods:
onInitialize() — register capabilities, set up any state.
onShutdown() — release resources.
executeTask(task) — the core work; return a typed result. (If LLM-backed, see
docs/llm/agent-architecture.md for the pattern and model/effort choice.)
onMessageReceived(message) — handle inbound MessageBus messages.
Communicate only via sendMessage(...) and share state via logToScratchpad(...). Never reach
into another agent's internals. Keep raw PHI out of scratchpad/audit content
(docs/llm/enterprise-governance.md).
-
Declare dependencies. Add the agent to the dependency graph in
src/coordination/DependencyResolver.ts so execution order is correct (most roles depend on
MEDICAL_ANALYSIS / CARE_PLANNING).
-
Register it. Wire the agent into src/services/MultiAgentSystem.ts (instantiate,
initialize(), and registerAgent(agent, [dependencies]) with the coordinator).
-
Test. Add a Vitest spec under the nearest __tests__/ covering executeTask happy path
and at least one edge case (missing/invalid input). Use synthetic patient data only.
-
Verify. Run npm run test:run and npm run lint (or delegate to the test-runner
subagent). Fix root causes, not symptoms. Then run the code-reviewer subagent on the diff,
and the compliance-reviewer if the agent touches patient data.
-
Document. If the agent changes the architecture, update docs/ and the agent roster in
the root CLAUDE.md.