PTENES
MODULE 2.1 · Track 2 · Building in practice

📋 The complete frontmatter

O frontmatter is your subagent's control panel—the YAML fields that sit between --- e --- at the top of the file .md. Each field has a specific responsibility: configure what, with what, how, and where the agent runs.

7
Topics
~30
Minutes
Basic
Level
Practice
Type

Imagine the frontmatter as the spec sheet of a collaborator: name, available tools, cognitive model, memory, and general behavior pattern. Claude Code reads frontmatter only to decide whether to call this agent — the full body is loaded only when the agent is actually invoked. Every field you omit becomes a default value; every field you fill in becomes a deliberate decision.

code-reviewer.md --- frontmatter (YAML) name: code-reviewer description: Reviews the diff for bugs and flaws tools: Read, Grep, Glob model: claude-sonnet-4-5 --- body (Markdown — agent instructions) You are a senior code reviewer… 1. Run git diff to see changes 2. Flag bugs, security holes… … 🏷️ name 🎯 description (trigger) 🔧 tools (permissions) 🧠 model (which Claude) 📝 body (brain)

↑ Anatomy of a file .md: frontmatter (YAML) + body (Markdown). Claude Code reads the frontmatter to decide; the body defines the behavior.

Detailed content

1

🏷️ name — the agent’s identity

The field name defines the unique identifier of your subagent. This is the name the conductor uses to call it — and the name that appears in the status line while the agent is running. Think of it as the professional nickname from the collaborator.

📐 Format rules

  • •Lowercase letters e hyphens — never spaces, underscores, or uppercase letters.
  • •Must be unique within the project or global folder ~/.claude/agents/.
  • •Must be role description, not the technology — prefer code-reviewer a typescript-checker.
  • •Practical maximum: 30–40 characters — appears in the UI and needs to be readable.
name examples YAML frontmatter
# BOM — papel claro, minúsculas, hífens
name: code-reviewer
name: doc-writer
name: sql-optimizer
name: security-auditor

# RUIM — espaço, maiúscula, underscore
name: Code Reviewer     # espaço + maiúscula
name: code_reviewer     # underscore
name: TypescriptChecker # camelCase
What it is:

unique agent identifier — lowercase and hyphens, no spaces.

Why learn:

a wrong name makes Claude Code ignore the file or fail silently when loading the agent.

Key concepts:

kebab-case · uniqueness by scope · readability in the UI · role > technology.

2

🎯 description — the invocation trigger

A description is the field more strategic from the frontmatter. It's the text the conductor reads to decide whether to call this agent. Think of it as the consulting room entrance sign: "cardiologist — chest pain, cardiac checkup". Without the right sign, the orchestrator walks through the door and doesn't know what's inside.

How the conductor uses the description

1

You make a request

"Review the code I just wrote and point out bugs."

2

The conductor reads the name + description of all agents

Doesn't read the body — only the header. It's fast and cheap in tokens.

3

Does the semantic matching

If the description of the code-reviewer says "review the diff for bugs," the request matches. The agent is called.

4

Only then load the entire body

The body’s token cost only exists when the agent is invoked — not during the “selection process.”

💡 Tip: explicitly include “when to use”

The most effective description names the trigger: "Use after any code change" or "Use when the user asks to optimize an SQL query". This direct instruction removes ambiguity from the orchestrator's match.

What it is:

the text the conductor reads to decide whether to call this agent — the invocation trigger.

Why learn:

a vague description means the agent is never called; a specific description ensures it's invoked at the right moment.

Key concepts:

semantic matching · explicit “when to use” · zero selection cost · progressive disclosure.

3

🔧 tools — declared permissions

The field tools é a tool allowlist that the subagent can use. If you don't declare anything, it inherits all the orchestrator's tools — which may be too many. Restricting tools is a security and focus: a reviewer who only reads cannot accidentally write files.

✓ Principle of least privilege

  • ✓code-reviewer: only Read, Grep, Glob
  • ✓doc-writer: Read, Write (without Bash access)
  • ✓sql-runner: only Bash (for psql)
  • ✓Declare only what the task actually requires

✗ Common pitfalls

  • ✗Leave without tools (inherits everything from the orchestrator)
  • ✗Give Bash to an agent that only reads files
  • ✗Give Write to a reviewer (can overwrite code)
  • ✗List tools the agent never uses (noise)

📊 Most-used built-in tools

Read

reads project files

Write

creates / edits files

Edit

edits specific sections

Bash

runs shell commands

Grep

search files

Glob

lists files by default

WebFetch

web search

Agent

launches nested subagents

Task

creates long-running tasks

What it is:

list of tools the subagent can use during execution.

Why learn:

limits what can go wrong; a reviewer without Write permission can't accidentally delete code.

Key concepts:

least privilege · allowlist · native tools · conductor inheritance (when omitted).

4

🧠 model — which Claude runs the task

The field model defines which language model will run the agent. This is the cost and quality decision: simple, repetitive tasks go to fast, inexpensive models; deep analysis goes to Opus. The topic of models by task is the Track 3 entire — here we learn the field syntax.

accepted values for model June 2026
model: haiku          # rápido, barato — triagem, classificação
model: sonnet          # equilibrado — maioria dos casos
model: opus            # profundo e caro — análises complexas

# IDs completos (mais estáveis em produção)
model: claude-haiku-4-5
model: claude-sonnet-4-5
model: claude-opus-4-5

# omitido: herda o modelo do maestro (padrão seguro)

💡 Practical rule for getting started

Always start with model: sonnet. If the agent handles simple triage, switch to haiku. If it does complex reasoning (architecture, auditing), switch to opus. T3 will give you the exact criteria for each case.

What it is:

field that determines which Claude model runs this agent — controls cost and depth.

Why learn:

without this field, all agents run on the most expensive model by default—unnecessary spending.

Key concepts:

haiku/sonnet/opus · full IDs vs. aliases · inheritance from the orchestrator · cost × quality.

5

🎨 color e 🧠 memory — identity and persistence

Two fields that complete the basic configuration: color defines the visual highlight color from the agent in the UI, and memory defines which memory files it accesses—controlling what it "knows" before the task even begins.

🎨 color

Hex color or color name displayed in the terminal’s status line next to the agent’s name.

color: "#34d399"   # verde
color: "#60a5fa"   # azul
color: "red"       # nome CSS

Optional — visual only. If omitted, Claude Code uses a default color.

🧠 memory

Controls which CLAUDE.md files the agent loads into context when it starts. Four possible values:

  • project — Project CLAUDE.md
  • user — global ~/.claude/CLAUDE.md
  • local — CLAUDE.local.md (private)
  • none — with no preloaded memory

📊 When to use memory: none

Triage or impartial analysis agents benefit from memory: none — they shouldn't be influenced by project preferences. A documentation agent, on the other hand, needs memory: project to learn the repository conventions.

What it is:

color = visual identity; memory = CLAUDE.md files that the agent loads at startup.

Why learn:

incorrect memory causes the agent to ignore project conventions or load irrelevant and costly context.

Key concepts:

color (visual) · memory: project/user/local/none · preloaded context · unbiased vs. context-aware agent.

6

🚫 disallowed-tools — the explicit blocking

While tools is an allowlist (only what's on it can be used), disallowed-tools is a explicit blocklist: "the agent can use everything except these". Use when you want to inherit most of the orchestrator's tools but specifically block one or two dangerous ones.

disallowed-tools in use YAML frontmatter
---
name: code-analyzer
description: Analisa a base de código. Nunca modifica arquivos.
model: sonnet
disallowed-tools:
  - Write    # não pode criar / sobrescrever
  - Edit     # não pode editar trechos
  - Bash     # não pode rodar comandos
---

⚖️ tools vs. disallowed-tools — when to use each one

Use tools when…

  • • The agent needs a set small and well-defined of tools
  • • You want to explicitly state what the agent can do
  • • The agent is new and you want full control

Use disallowed-tools when…

  • • The agent needs many tools but wants to block only a few
  • • You want to automatically inherit future tool expansions
  • • You only need to remove destructive tools from a generic agent
What it is:

tool blocklist — the agent can use everything except what's listed here.

Why learn:

alternative to tools when the allowlist would be huge — blocking is more concise than listing everything.

Key concepts:

blocklist · inheritance with exception · blocklist vs. allowlist · selective security.

7

🔌 Advanced fields — MCP and others

Beyond the basic fields, the frontmatter supports advanced settings for integrating MCP servers (Model Context Protocol) — which expand the available tools with external APIs, databases, services, and much more. These fields are optional and generally appear in production agents.

advanced MCP fields YAML frontmatter
---
name: db-analyst
description: Analisa dados no PostgreSQL. Use quando pedir
  insights de banco ou queries de análise.
model: sonnet
tools: mcp__postgres  # ferramenta via MCP
mcp_servers:         # servidores MCP disponíveis
  - postgres         # nome definido em .claude/mcp.json
---

✓ What MCP expands

  • ✓Direct database queries
  • ✓Integration with third-party APIs (Slack, GitHub, Jira)
  • ✓Your company's custom tools
  • ✓Remote file systems and S3

📌 Prerequisite

The MCP server needs to be configured in .claude/mcp.json before referencing in the frontmatter.

// .claude/mcp.json
{
  "postgres": {
    "command": "mcp-postgres",
    "args": ["postgresql://…"]
  }
}
What it is:

advanced fields that connect the agent to MCP servers — expanding beyond native tools.

Why learn:

MCP is the bridge for integrating subagents with real production systems (databases, APIs, services).

Key concepts:

MCP · mcp_servers · external tools · .claude/mcp.json · production integration.

📄

Real example: fully commented frontmatter

One security-auditor.md of production using all the fields we've covered — with comments explaining each design decision. This is the reference point you can copy and adapt.

.claude/agents/security-auditor.md Complete frontmatter
---
name: security-auditor        # kebab-case, papel claro

description: |               # bloco multiline para descrições longas
  Audita o código em busca de vulnerabilidades de segurança:
  SQL injection, XSS, dependências desatualizadas, segredos
  expostos e falhas de autenticação.
  Use quando o usuário pedir revisão de segurança, antes
  de qualquer PR para produção, ou após mudanças em auth.
                               # ↑ "quando usar" explícito = gatilho preciso

tools: Read, Grep, Glob      # só leitura — auditor nunca modifica

model: claude-opus-4-5       # análise crítica → modelo mais capaz

color: "#f87171"              # vermelho = segurança (visual na UI)

memory: project             # carrega CLAUDE.md do projeto
                               # → conhece as convenções de segurança do repo

disallowed-tools:           # bloqueio explícito de ferramentas destrutivas
  - Write                      # não pode alterar arquivos
  - Edit                       # não pode editar trechos
  - Bash                       # não pode executar scripts
---

# Corpo do agente (cérebro) — carregado só quando invocado

You are a senior application security engineer.
Your role is to audit code for vulnerabilities — never to fix them.

When invoked:
1. Run Grep to find patterns: SQL queries, eval(), innerHTML, passwords, tokens.
2. Read each flagged file in full context.
3. Classify each finding by severity: CRITICAL / HIGH / MEDIUM / LOW.

Output format:
- One table: Severity | File | Line | Issue | Recommendation
- Summary paragraph with the 3 most critical risks
- Do NOT rewrite code — only report.

🔒 tools + disallowed

Uses tools for allowlist and disallowed-tools redundantly for clarity — a defense-in-depth approach.

🧠 model: opus

Security auditing is critical — this is where the most expensive model is worth it. Simple triage agents can use haiku.

📝 multiline description

The pipe | in YAML, you can use multiple lines. Use it for long descriptions with explicit triggers.

⌨️

Ready-made prompts (copy and paste)

Three prompts to use in Claude Code now: create an agent via /agents, inspect an existing agent and generate a custom frontmatter for a specific role.

Prompt 1 — generate frontmatter via /agents creates the entire .md
Crie um subagente chamado "doc-writer" que escreve
documentação técnica em Markdown. Ele deve usar apenas
Read e Write, rodar em sonnet, e ter memória do projeto.
Escreva o frontmatter completo e um corpo de 5 linhas.
Prompt 2 — inspect an existing agent understand what is configured
Leia o frontmatter de todos os arquivos .md em
.claude/agents/ e me diga: quais modelos estão sendo
usados, quais ferramentas cada agente tem, e se algum
agente tem description vaga que pode atrapalhar o match.
Prompt 3 — front matter for a specific role custom generation
Quero um agente que otimize queries SQL pesadas.
Escreva o frontmatter completo incluindo: name kebab-case,
description com o gatilho "quando usar", tools mínimas,
model adequado ao tipo de análise, e color de destaque.
Depois explique cada campo escolhido e por quê.
🖥️

Simulated screen: /agents and the loaded frontmatter

This is how Claude Code displays your agents after loading the files .md. The UI shows the name, a brief description, the tools e o model of each agent. The field color appears as the colored dot next to the name.

claude code · /agents · 4 agents found 📋 list
security-auditor claude-opus-4-5 Read Grep Glob
Audit code for vulnerabilities. Use before production PRs…
code-reviewer claude-sonnet-4-5 Read Grep Glob
Reviews the current diff for bugs and security flaws. Use after a code change…
doc-writer claude-sonnet-4-5 Read Write
Writes technical documentation in Markdown. Use when asked for a README, docstrings, or guides…
sql-optimizer claude-haiku-4-5 Read Bash
Analyzes and optimizes slow SQL queries. Use when you identify queries taking > 500ms…
↑↓ navigate · enter select · esc close 4 agents · 2 project · 2 global

↑ Illustrative recreation of the panel /agents. O color appears as a dot; the description is truncated but sufficient for the semantic match.

🎯

Exercise

Write the complete frontmatter for a subagent named test-writer — an agent that reads source code and writes unit tests in vitest/jest. Use all required fields and at least one advanced field.

How to do it

  1. Decide the name: must be kebab-case, and describe the role.
  2. Write the description: include “when to use” and trigger situations.
  3. List the tools minimums: what does a test writer actually need?
  4. Choose the model: Is writing tests simple or complex? Explain.
  5. Add color e memory with a justification for each.

✅ Verification criteria — how to know you got it right

  • →name is in kebab-case, with no spaces or uppercase letters.
  • →description contains at least one sentence of the type "Use when…" or "Use after…".
  • →tools includes Read e Write, and you justified why those two.
  • →model chosen with a cost × quality justification.
  • →The frontmatter opens and closes with --- and is valid YAML (with no mixing of tabs and spaces).

Solved example

---
name: test-writer
description: |
  Lê código-fonte e escreve testes unitários em vitest/jest.
  Use quando pedir "escreva testes para este arquivo" ou
  após implementar uma nova função ou classe.
tools: Read, Write, Glob   # lê fonte, escreve teste, lista arquivos
model: sonnet              # escrever testes exige raciocínio médio
color: "#4ade80"          # verde = "passou nos testes"
memory: project           # precisa conhecer o framework do projeto
---

✅ Module summary

✓
name — kebab-case, unique, descriptive of the role. It's the identifier in the UI and in the orchestrator's matching.
✓
description — the trigger: the orchestrator reads only this to decide whether to call the agent. Include "Use when…".
✓
tools — permission allowlist. Minimum necessary; a read-only agent doesn't need Write.
✓
model — haiku/sonnet/opus according to the task's complexity. Omitting it inherits the orchestrator's model.
✓
color + memory — visual identity and preloaded context (project/user/local/none).
✓
disallowed-tools — denylist when you want to inherit everything but block a few specific tools.
✓
MCP — mcp_servers connects the agent to databases, APIs, and services via the Model Context Protocol.

Next module:

2.2 — The description is the trigger. How to write descriptions the orchestrator recognizes and invokes accurately.