<!-- Template: CLAUDE.md.template -->
<!-- Purpose:  Team-wide operating manual injected into every agent's CLAUDE.md -->
<!-- Variables: team_name, orchestrator_name, frameworks -->
<!-- Rendered by: generate.py -->
# CLAUDE.md — {{TEAM_NAME}} Team Operating Manual

_Read by ALL agents. These are the shared rules of the {{TEAM_NAME}} system._

---

## 1. Team Roster

| ID | Name | Emoji | Model | Role |
|----|------|-------|-------|------|
{{AGENTS_TABLE}}

---

## 2. Communication Protocol

### Inboxes (receive tasks here)
`~/.openclaw/workspace/comms/inboxes/<agent-id>.md`

### Outboxes (write results here)
`~/.openclaw/workspace/comms/outboxes/<agent-id>.md`

### Broadcast (team-wide alerts)
`~/.openclaw/workspace/comms/broadcast.md`

**Rules:**
- Inboxes are append-only. Mark completed tasks `[DONE]`.
- {{ORCHESTRATOR_NAME}} reads all outboxes on synthesis cycles.
- All agents check broadcast.md on every heartbeat.
- Only write to broadcast for: critical alerts, learning sessions, process updates.

### Task Message Format ({{ORCHESTRATOR_NAME}} → Agent)
```markdown
---
TASK_ID: <uuid>
FROM: main
TO: <agent-id>
TYPE: implementation|research|debug|review|content|analysis
PRIORITY: immediate|normal|background
ASSIGNED_AT: <ISO timestamp>
---

## Context
## Task
## Expected Output
## Constraints
## Escalation
```

---

## 3. Quality Gate

Every output goes through quality review before delivery.

| Score | Meaning | Action |
|-------|---------|--------|
| 5 | Exceptional | Deliver |
| 4 | Good | Deliver |
| 3 | Acceptable | Deliver with notes |
| 2 | Needs work | Block, revise |
| 1 | Unacceptable | Block, reassign |

Score ≤2 blocks delivery and triggers retrospective.

---

## 4. Task State Machine

```
pending → in-progress → complete
                      → failed → retry → complete
                                       → escalate
```

All state transitions must be logged in TASKS.json.

---

## 5. Escalation Chain

| Trigger | Action |
|---------|--------|
| Same task fails 2× | Reassign to different specialist |
| Quality score ≤2 | Block, revise, trigger retrospective |
| Confidence <70% | HITL — escalate to user |
| Irreversible action | HITL — user must approve |
| Agent stuck >30min | Ping agent, log incident |
| Task stuck >1h | Escalate to {{ORCHESTRATOR_NAME}} |

---

## 6. Constitutional Rules (INVIOLABLE)

1. Never fabricate — if unsure, say so and escalate
2. Never skip quality gate
3. {{ORCHESTRATOR_NAME}} never does specialist work — always delegates
4. Never mark a task complete without actual output
5. Always update AGENT_STATUS.json on session start/end
6. MAX_GENERATION_DEPTH: 3
7. HITL before irreversible actions
8. **On task completion: update TASKS.json — set `status: complete` and `completed_at: <ISO>` for your task ID**

---

## 7. Memory System

- `MEMORY.md` — curated long-term memory (≤200 lines)
- `memory/YYYY-MM-DD.md` — daily session logs
- `TASKS.json` — task history and state
- `AGENT_STATUS.json` — agent availability

---

_Built with agi-farm on {{DATE}} | Team: {{TEAM_NAME}} | Preset: {{PRESET}} agents | Frameworks: {{FRAMEWORKS}}_
