PLUGIN brewcode / Agents

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

FieldValue
Triggers”create agent”, “improve agent”, “scaffold agent”
Modelinherit: runs on the session’s model
ToolsRead, Write, Edit, Glob, Grep, Bash, WebFetch, WebSearch
OutputAgent 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

  1. Clarify intent

    Resolves role, tools and model; records a safe assumption; reads the existing file when improving.

  2. Analyze and synthesize

    Reads the closest well-built agent, extracts conventions and anti-patterns, picks the description format.

  3. Write

    Complete .md with frontmatter, role, return contract and scope, plus a role-sized maxTurns and checkpoint instructions.

  4. Validate

    Name format ([a-z0-9-]+), keyword density, least-privilege tools, no duplicated CLAUDE.md rules, Return Contract present, Scope Fit present exactly when the agent writes code.

  5. 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.

GuardrailApplies toWhat it says
Return ContractEvery generic agentVerdict 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 FitAgents that write code, scripts, SQL, schemas, infra or configBuild 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
---
ScopeFields
Local + pluginmodel, effort, maxTurns, tools, disallowedTools, skills, memory, background, omitClaudeMd, isolation: worktree
Local onlypermissionMode (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 onlycolor, experimental.cacheTtl (ignored in --agents JSON)
UnconfirmedAny 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 getsRule
Permission modeThe 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 modeOn 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.

OverlapFormatExample
NoneSingle-line action + Triggers"Implements features, fixes bugs. Triggers: implement, fix bug, add feature"
1-2 other agentsSingle line + detailed Triggers"Creates bash scripts. Triggers: create script, bash script, shell script"
HighBlock 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:

RolemaxTurns
explorer / quick search40
reviewer / architect / tester60
docs / generator80
developer / orchestrator120

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)BoundsDefault
CLAUDE_CODE_MAX_TURNSTurn cap for all agentsunset
API_TIMEOUT_MSOne API call10 min
CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MSBackground-agent stall10 min
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSConcurrent subagents20
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTHNesting depth; 1 turns nesting off3
CLAUDE_CODE_MAX_OUTPUT_TOKENSOutput tokens per responsemodel max
MAX_MCP_OUTPUT_TOKENSMCP result size25k
BASH_DEFAULT_TIMEOUT_MS / BASH_MAX_TIMEOUT_MSBash tool120s / 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 resultUse
.claude/projects/{project}/{sessionId}/subagents/agent-{agentId}.jsonlFull transcript (retention: cleanupPeriodDays)
run_in_background: true + ReadRead the output file (TaskOutput removed in 2.1.277)
TaskStopKill a running subagent
SendMessageResume a stopped subagent with context intact
Reference files (read on demand) #

All under brewcode/skills/agents/references/:

FileWhat it holds
agent-frontmatter-fields.mdRequired/optional fields, omitClaudeMd, plugin exclusions, file-only cache TTL
agent-scope-and-tools.mdDeciding tools:, file location, model precedence, delegation patterns
agent-context-and-execution.mdWhat a subagent inherits, execution modes, turn/token/concurrency limits
agent-template.mdDescription budget, prompt structure, Guardrails block, Validation Checklist
agent-known-issues.mdChanges 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.

Skill Creator

Same design process for skills instead of agents.

Agent Deadline

Soft-deadline hooks for subagent runs.

Brewcode overview

All brewcode agents, skills, and hooks in one place.

Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ