PLUGIN brewcode / Agents
On this page
Agent Creator
View agent file on GitHub (opens in a new tab)
Agents with vague descriptions trigger on the wrong requests, or never. A bad description makes Claude pick the wrong agent or fall back to the main conversation. Hand-written agents also leak CLAUDE.md rules into the body and forget the Triggers: keyword list that drives auto-selection.
Quick reference
| Field | Value |
|---|---|
| Triggers | ”create agent”, “improve agent”, “scaffold agent” |
| Model | inherit: runs on the session’s model |
| Tools | Read, Write, Edit, Glob, Grep, Bash, WebFetch, WebSearch |
| Output | Agent file path, validation verdict, assumptions |
Describe the role, allowed files and expected result. Agent Creator drafts frontmatter and a system prompt, validates them, and returns paths and a verdict. Its references were checked against Claude Code documentation through 2.1.309.
When to use
- New agent: a specialized subagent (reviewer, code generator, security scanner).
- Agent not triggering: it exists but Claude does not select it reliably.
- Trigger collisions: two agents compete for one request and need
<commentary>disambiguation. - Vague system prompt: prose instead of dense tables and checklists.
- Post-update drift: naming or available tools changed after a plugin update.
Examples
"Create an agent for code review — reads only, outputs severity table"
"My reviewer agent doesn't trigger when I say 'check this PR'"
"Improve the description of my tester agent, it keeps clashing with developer"
How it works
- Clarify intent
Resolves role, tools and model; records a safe assumption; reads the existing file when improving.
- Analyze and synthesize
Reads the closest well-built agent, extracts conventions and anti-patterns, picks the description format.
- Write
Complete
.mdwith frontmatter, role, return contract and scope, plus a role-sizedmaxTurnsand checkpoint instructions. - Validate
Name format (
[a-z0-9-]+), keyword density, least-privilege tools, no duplicated CLAUDE.md rules,Return Contractpresent,Scope Fitpresent exactly when the agent writes code. - Hand back
Returns paths and evidence; the main caller runs
brewtools:text-optimize(see the handoff below).
It refuses a brief that bundles several agents (“Create six agents for my team” returns a split proposal, one agent per subtask) and never invents scope. It has no Agent tool, so independent research and optimization are requested from the main caller (delegation). Generic rules: scope guard.
Guardrails in generated agents #
Return Contract lands in the body of every generic agent Agent Creator writes; Scope Fit only in agents that write code or config. Both are output contract, not advice.
| Guardrail | Applies to | What it says |
|---|---|---|
| Return Contract | Every generic agent | Verdict first, <=30 lines, path:line; bulk material goes to a file under .claude/reports/<YYYYMMDD-HHMMSS>_<name>/ and only the path returns. With the agent-return guard installed, a return over ~2500 est-tokens (chars/4) is blocked for compression, over ~6000 it must file the detail. |
| Scope Fit | Agents that write code, scripts, SQL, schemas, infra or config | Build for today’s scale, then one pass: fewer files, less config, less indirection. Omitted for research, docs and review-only work. |
Team profiles use the teams-setup exception: shared return and scope rules live in team.md.
Optimization handoff #
The main caller invokes the Brewtools text-optimize skill on the returned paths:
Skill(skill: "brewtools:text-optimize", args: "<created paths> medium --allow-dirty")--allow-dirty covers the files just written. The skill owns the snapshot, RUN_DIR, optimizers and verify --no-restore; the main caller then spawns a fresh read-only verifier that compares original and current files for 100% meaning preservation, repairs losses, and reruns the gates. Optimization stays requested or pending until gate evidence returns; without Brewtools it is skipped and the agent remains usable. Manual start: /brewtools:text-optimize Optimize .claude/agents/reviewer.md in Medium mode, preserving all meaning.
Frontmatter reference: all fields #
---
name: agent-name # REQ: lowercase-hyphens; no leading `-`, no `:`
description: "..." # REQ: action verb + Triggers: keyword list
model: sonnet # OPT: fable|opus|sonnet|haiku|inherit or a full model ID
effort: high # OPT: low|medium|high|xhigh|max
maxTurns: 20 # OPT: max turns before abort
tools: Read, Glob, Grep # OPT: omit = inherit all
disallowedTools: Write, Edit # OPT: explicit deny list
skills: skill1, skill2 # OPT: full content injected at startup
color: cyan # OPT: 8 valid values, magenta is NOT one
memory: project # OPT: user|project|local, auto-adds Read/Write/Edit
background: true # OPT: errors when an in-process teammate spawns it
omitClaudeMd: true # OPT: skips CLAUDE.md and project rules; ignored as main
isolation: worktree # OPT: `worktree` only; `remote` is invocation-level
permissionMode: default # LOCAL-ONLY: ignored + warn in plugin agents; main's mode may override
mcpServers: [server1] # LOCAL-ONLY: ignored + warn in plugin agents
initialPrompt: "..." # LOCAL-ONLY: first prompt for a main-session agent
hooks: {} # LOCAL-ONLY: ignored for plugin agents
experimental: {cacheTtl: "5m"} # OPT: file definitions only
---
| Scope | Fields |
|---|---|
| Local + plugin | model, effort, maxTurns, tools, disallowedTools, skills, memory, background, omitClaudeMd, isolation: worktree |
| Local only | permissionMode (main’s mode may still override), hooks, mcpServers, initialPrompt (once inside a hook is ignored in any agent; it works only in skills) |
| File definitions only | color, experimental.cacheTtl (ignored in --agents JSON) |
| Unconfirmed | Any field the references do not list: do not emit |
omitClaudeMd: true still loads managed policy; pass essential constraints in the delegation prompt.
| What a subagent really gets | Rule |
|---|---|
| Permission mode | The main session’s mode decides. Main in bypassPermissions, acceptEdits or auto: the frontmatter permissionMode is ignored, even for local agents. Main in plan: the agent stays in plan. Main in default or dontAsk: the frontmatter value applies, except bypassPermissions (2.1.267+) and auto where auto mode is unavailable, which keep main’s mode. It is no grant and no restriction: narrow with tools:. |
| Fork mode | On by default in the interactive terminal since 2.1.232, and in -p, the Agent SDK, desktop and VS Code since 2.1.302. Never in claude mcp serve. CLAUDE_CODE_FORK_SUBAGENT=0 turns it off. A fork keeps its parent’s permission mode. |
Empty tools: | An empty list (or disallowedTools removing every entry) launches the agent with no tools and no refusal. Omitting tools: inherits all. A non-empty list where nothing resolves is refused. |
Do not set isolation or permissionMode: bypassPermissions by default. A worktree per spawn costs setup and disk, with a known data-loss bug alongside bypassPermissions (#29110). bypassPermissions equals --dangerously-skip-permissions: use it only in sandboxed CI. permissionMode is local-only, and the main session’s mode can override it (table above).
House description budget: at most 150 tokens (~600 characters), lead sentence at most 160 characters, 3-7 English trigger terms.
| Overlap | Format | Example |
|---|---|---|
| None | Single-line action + Triggers | "Implements features, fixes bugs. Triggers: implement, fix bug, add feature" |
| 1-2 other agents | Single line + detailed Triggers | "Creates bash scripts. Triggers: create script, bash script, shell script" |
| High | Block scalar plus one <example> (a second needs the budget exception) | See agent-template.md |
Plugin agent paths resolve through ${CLAUDE_PLUGIN_ROOT}. The known-issues reference lists changes 2.1.234-2.1.309 and debugging steps.
Subagent resource limits: turns, timeouts, checkpointing #
A subagent has no wall-clock timeout. It is bounded by turns, API-call timeouts and token caps. An agent stuck in one long Bash call (up to BASH_MAX_TIMEOUT_MS, 10 minutes by default) is one turn; maxTurns will not touch it.
A turn is one model inference plus its tool calls; parallel calls in one message count once. maxTurns is an emergency anti-loop stop, about 2-3x the role’s typical run. Every generated agent gets an explicit value:
| Role | maxTurns |
|---|---|
| explorer / quick search | 40 |
| reviewer / architect / tester | 60 |
| docs / generator | 80 |
| developer / orchestrator | 120 |
On exhaustion the caller sees a result marked partial (since 2.1.246) with a SendMessage continuation hint; written files are the only guaranteed survivor, so every generated body gets a checkpoint instruction: record progress to a report file per milestone, read it first on resume.
Variable (under env in settings.json) | Bounds | Default |
|---|---|---|
CLAUDE_CODE_MAX_TURNS | Turn cap for all agents | unset |
API_TIMEOUT_MS | One API call | 10 min |
CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS | Background-agent stall | 10 min |
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS | Concurrent subagents | 20 |
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH | Nesting depth; 1 turns nesting off | 3 |
CLAUDE_CODE_MAX_OUTPUT_TOKENS | Output tokens per response | model max |
MAX_MCP_OUTPUT_TOKENS | MCP result size | 25k |
BASH_DEFAULT_TIMEOUT_MS / BASH_MAX_TIMEOUT_MS | Bash tool | 120s / 600s |
No total-per-session spawn cap exists: CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION was removed in 2.1.224. For a soft wall-clock budget install Agent Deadline Setup: warn at 80%, deny non-finalization tools at 100%, checked at tool boundaries only.
| Recover a partial result | Use |
|---|---|
.claude/projects/{project}/{sessionId}/subagents/agent-{agentId}.jsonl | Full transcript (retention: cleanupPeriodDays) |
run_in_background: true + Read | Read the output file (TaskOutput removed in 2.1.277) |
TaskStop | Kill a running subagent |
SendMessage | Resume a stopped subagent with context intact |
Reference files (read on demand) #
All under brewcode/skills/agents/references/:
| File | What it holds |
|---|---|
agent-frontmatter-fields.md | Required/optional fields, omitClaudeMd, plugin exclusions, file-only cache TTL |
agent-scope-and-tools.md | Deciding tools:, file location, model precedence, delegation patterns |
agent-context-and-execution.md | What a subagent inherits, execution modes, turn/token/concurrency limits |
agent-template.md | Description budget, prompt structure, Guardrails block, Validation Checklist |
agent-known-issues.md | Changes 2.1.234-2.1.309, architectural limits, debugging |
Return contract #
Verdict first, <=30 lines, path:line; no agent bodies or analysis transcripts. Per generated agent: file path, one-line role, model/maxTurns/tools on one line, validation verdict, text-optimize run or skipped, assumptions. Longer material goes to .claude/reports/<YYYYMMDD-HHMMSS>_agent-creator/, path only. /brewtools:agent-return-setup enforces ~2500 / ~6000 est-tokens when installed.
Related
Skill Creator
Agent Deadline
Brewcode overview
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ