# Add Agent

Add a single new agent to an existing pipeline.

**User request:** $ARGUMENTS

---

Read `CLAUDE.md` fully — it shows existing agents, their state contracts, and the current flow.
Read `skills/add-prompt/SKILL.md` before writing any prompt file.

## Step 1 — Fill gaps before proposing anything

Identify what cannot be confidently inferred from the request and `CLAUDE.md`.
Ask in a single focused message if any of these are unclear:

- **Placement**: where in the flow does this agent go? (after which agent, before which?)
- **Input**: what does it read from state? (which field from `context`, or directly from `tasks`?)
- **Output**: what should it produce? (fields, format — this becomes the JSON schema)
- **Volume**: how many items will it process per call? (needed for round estimation)

If everything is clear from `CLAUDE.md` and the request, skip this step.

## Step 2 — Show a mini-blueprint and confirm

Before writing any code, show:

```
## New Agent: {AgentName}

**Role:** one sentence
**Placement:** after {PreviousAgent} → {AgentName} → {NextAgent}

**Data contract:**
  Reads:  {state field} — e.g. context.research (dict with keys: ...)
  Writes: {state field} — e.g. context.plan (dict with keys: ...)
  (last agent writes to: results)

**Tools:** [tool names] or "none (single LLM call)"
**Est. rounds:** ~N  (N items × M tool calls × 2)
**MAX_ROUNDS needed:** yes/no — AGENTNAME_MAX_ROUNDS=X in .env

**Output schema:**
{"field1": "...", "field2": [...]}
```

Ask: **"Does this look right?"** Wait for confirmation before writing any file.

## Step 3 — Generate files

1. **`agents/{agent}.py`** — extends `arccrew.BaseAgent`, imports from `arccrew` only
2. **`prompts/{agent}.md`** — follow `skills/add-prompt/SKILL.md` rules exactly:
   - Every tool named explicitly with when-to-call instructions
   - Round budget hint if processing a list
   - JSON schema matching the data contract above
   - Closes with: `Output ONLY the JSON object. No explanation, no markdown, no text before or after.`
3. **`pipeline.py`** — add `async def` node wrapper, update flow
4. **`CLAUDE.md`** — add to "Agents in this project":
   ```
   - `AgentName` — one-line description → prompts/{agent}.md
   ```

After creating the agent, show:
```
Prompts active for {agent_name}:
  1. base.md     — arccrew universal rules (do not edit)
  2. global.md   — your project-wide rules (edit prompts/global.md)
  3. {agent}.md  — this agent's role and output schema
```
