PTENES
MODULE 4.6 · Track 4 · Advanced & cross-environment

🏭 Building your system

Everything you’ve learned becomes a real factory: a library of specialists, a starter pack, ready-made templates, a production checklist — and a big recap of the entire course.

10
Blocks
7
Topics
~35 min
Duration
Finale
Final module

You've reached the end of the track — and the course. Now is not the time to learn more concepts: it's time to build your system. In this module, you'll build your personal subagent library, start from a ready-made starter pack, learn templates that save hours, and review in a screen everything the course taught. At the end, a final project: create your own agent suite from scratch.

🤖 ORCHESTRATOR your main session delegates → gathers → synthesizes 🔒 security-auditor analyzes vulnerabilities 🧪 test-runner runs and interprets tests 📝 doc-writer documents code and APIs 🗄️ db-expert optimizes queries and schema 🔥 plan-roaster critiques plans and decisions ✅ Integrated result unified report + actions Your Specialist Factory — each agent is a .md in your library

Detailed content

1

🗄️ Your library of specialists

Agents are files. Files can be organized. Organization becomes power.

What it is

A library of specialists is a set of files .md with subagent definitions that you maintain and evolve. Each file is an “employee” with a clearly defined name, scope, tools, and restrictions. The library lives in two places: ~/.claude/agents/ (available in all projects) and .claude/agents/ within each project (repository-specific).

Why build your library

  • ▸Avoids rewriting the same system prompt every time—call the agent by name
  • ▸Well-defined agents make fewer scope errors — they know what they should not do
  • ▸Improves over time: fix a bad agent once and every project benefits
  • ▸Teams can share the library via git — an emerging organizational standard

Key concepts

Global (~/.claude/)
Available in any project. Ideal for universal specialists (security, docs, test).
Local (.claude/ in the project)
Domain specialists: a db-expert for your stack, a reviewer for your style guide.
Version-controlled (git)
Commit .claude/agents/ along with the code. An agent change = a PR like any other.
2

📦 Starter pack — 5 agents to get started today

security-auditor · test-runner · doc-writer · db-expert · plan-roaster

What it is

A set of five agents covering the most common use cases in software development. They’re generic enough for any stack, but specific enough to be useful without customization. Copy them, adjust the details for your project (database names, frameworks, testing conventions), and you have a functional suite in minutes.

Why these five

🔒
security-auditor
Vulnerabilities, exposed secrets, SQL injection, XSS—reads code, never executes it.
🧪
test-runner
Runs tests, interprets failures, and suggests fixes without touching production code.
📝
doc-writer
JSDoc, docstrings, README, changelog — writes, never refactors the code.
🗄️
db-expert
Explains queries, suggests indexes, reviews migrations — never executes DDL/DML.
🔥
plan-roaster
Critiques implementation plans, points out risks, plays devil’s advocate — without modifying code.

Key concepts

✓ Starter package principles
  • ✓Minimal tools (only what's needed)
  • ✓Explicit restrictions (“never execute X”)
  • ✓Well-defined scope per agent
  • ✓Output format specified
✗ Avoid in this first package
  • ✗Agents that do everything (no focus)
  • ✗Writing permissions without a reason
  • ✗System prompts over 200 lines
  • ✗Circular dependencies between agents
3

📐 Ready-made templates for your suite

Frontmatter + body in minutes, not hours.

What it is

An agent template has three parts: the YAML frontmatter (metadata that Claude Code reads), the system prompt (how the agent should behave) and the usage examples (optional but very useful). A good template is a shortcut for creating new agents — fill in the variable parts and you have a working agent in 5 minutes.

Why use templates

  • ▸Consistency: all agents in the suite have the same output structure
  • ▸Speed: new agent in 5 min without thinking about the structure
  • ▸Onboarding: a new contributor understands the convention without extra documentation

Key concepts — template anatomy

YAML frontmatter
name, description, tools, model (optional), disallowedTools
System Prompt (# Section)
Role, objective, required constraints, expected output format
Usage examples
When to use, when NOT to use, edge cases — saves a lot of time
4

✅ Production checklist

Before putting an agent into real-world use, go through this list.

What it is

A checklist is the last filter before an agent becomes part of your permanent library. It covers security (minimum tools, no unnecessary permissions), quality (clear system prompt, defined output format), and operations (who calls it, when, what happens if it fails).

Why use a checklist

1. Safety first
Review each tool: is it really necessary? Can the agent cause harm if misinstructed?
2. Scope clarity
Can someone who’s never seen the agent understand what it does in 30 seconds?
3. Output format
Is the output parseable? Does the orchestrator know what to expect?
4. Test with a real case
Run it on a concrete case before considering it ready. Failures reveal gaps in the system prompt.
5. Minimal documentation
Add when to use and when NOT to use to the frontmatter. It saves questions later.
⚠️
Common pitfall
Agents with Bash without restrictions, subprocesses can create loops or consume resources unexpectedly. Always test in an isolated environment first.

Key concepts — the concise checklist

☑Tools are the minimum necessary
☑disallowedTools listed if applicable
☑System prompt ≤ 150 lines
☑Output format specified
☑Tested with a real-world case
☑When NOT to use, as documented
5

🔀 Project × Global in practice

What goes to ~/.claude/ and what goes in .claude/?

What it is

Claude Code resolves agents in two scopes: global (~/.claude/agents/) and local (.claude/agents/ in the project). If an agent exists in both places with the same name, the local one overrides the global one — allowing you to "override" generic specialists with project-adapted versions without removing the global one.

Why this matters in practice

~/.claude/agents/ (Global)
  • • generic security-auditor
  • • universal doc-writer
  • • default plan-roaster
  • • Agents for constant personal use
.claude/agents/ (Project)
  • • project stack db-expert
  • • test-runner with the right framework
  • • style-reviewer for the team guide
  • • Domain-specific agents
💡
Practical tip: override hierarchy
Start with the generic agent in the global scope. When a project has specific needs, create a local version with the same name. Claude Code uses the local one automatically — no configuration needed.

Key concepts

Override by name
Local overrides global when the filename is the same.
Version control
Local agents go in git. Global agents stay on the developer’s machine.
Naming convention
Use kebab-case. The name=identity. Avoid generic names like “helper.”
6

🧠 Overall recap — the course on one screen

Everything that matters, in one-line sentences.

What it is

This is slide 18—the course's closing screen. Each rule below summarizes an entire concept you studied. If one of them sounds unfamiliar, that's a sign of which module to revisit. If they all made immediate sense, you finished the course with the right mental map.

slide-18.md — Subagents: the course on one screen illustrative

🤖 Subagents: what stays

01 Quick task? → Direct chat. No overhead.
02 Heavy task? → Subagent. Isolate the context.
03 Shared team? → .claude/agents/
04 Only you use it? → ~/.claude/agents/
05 Save tokens? → Cheap fleet + smart leader.
06 Better result? → Fresh reviewer at the end.
07 Huge job? → Dynamic workflow — use with care.
08 When in doubt: "is this a pile I'll never reread?" → subagent.

— end of course · INEMA.CLUB/subagentes —

Why a recap on one screen works

  • ▸Compact mind map — when in doubt on the job, reread the 8 rules
  • ▸Each rule points to course modules for further study
  • ▸Makes it easy to share what you learned with a colleague in minutes
7

🚀 Next steps

What to do after the course ends.

What it is

The course gave you the map. The next steps are the territory. Real practice with subagents happens in real projects — with real mistakes, iterations, and discoveries that no course can simulate. This section points you toward where to go from here.

Why acting immediately matters

Subagent knowledge decays quickly if it isn’t applied. The best window for assimilation is the first 48h after the course. Use that momentum.

48h
Create your starter package
5 agents from the current project
1 week
Use in production
1 real task per day with a subagent
1 month
Review and refine
Which agents survived? Which died?

Key concepts — where to continue

→ Claude Code documentation: constant updates to hooks, MCP servers, and new forms of orchestration
→ Community: share your library—well-made agents become a reference for others
→ Experimentation: The field evolves quickly. What works today may have a better pattern in 6 months

📄 Real example — a package of 5 agents (.md)

Five files ready to copy to ~/.claude/agents/ or .claude/agents/:

# ~/.claude/agents/security-auditor.md
---
name: security-auditor
description: Audita código em busca de vulnerabilidades de segurança. Use para revisar PRs críticos, módulos de autenticação, inputs de usuário. NÃO use para refatoração.
tools:
  - Read
  - Bash  # somente leitura — sem escrita de arquivo
disallowedTools:
  - Write
  - Edit
---

# Security Auditor

Você é um especialista em segurança de aplicações. Sua única função é revisar código e apontar vulnerabilidades.

## O que você faz
- Identifica SQL injection, XSS, CSRF, secrets expostos, dependências com CVE
- Classifica cada achado: CRÍTICO / ALTO / MÉDIO / BAIXO
- Sugere correção específica para cada achado

## O que você NÃO faz
- Não modifica arquivos
- Não sugere refatoração fora do escopo de segurança
- Não executa código de produção

## Formato de saída
```markdown
## Relatório de Segurança — [arquivo/PR]
### Achados
| Severidade | Linha | Descrição | Correção sugerida |
```
# ~/.claude/agents/test-runner.md
---
name: test-runner
description: Roda suítes de teste, interpreta falhas e sugere correções. Ideal para CI debug e TDD. Use ANTES de mergear.
tools:
  - Bash
  - Read
disallowedTools:
  - Write
  - Edit
---

# Test Runner

Roda testes, lê a saída e explica cada falha em linguagem humana. Sugere correção mas não aplica.

## Regras
- Rode sempre com `--no-coverage` para velocidade na primeira passagem
- Agrupe falhas por módulo (não por arquivo)
- Priorize: build breaks > falhas de lógica > warnings
# ~/.claude/agents/doc-writer.md
---
name: doc-writer
description: Gera documentação técnica (JSDoc, docstrings, README, CHANGELOG). Use após implementação. NÃO faz refatoração.
tools:
  - Read
  - Write   # só para arquivos de documentação (.md, comentários)
---

# Doc Writer

Especialista em documentação técnica. Lê código e gera docs claros, concisos e atualizados.

## Convenções
- JSDoc para funções públicas
- Docstrings para funções com lógica não-óbvia
- README: instalação, uso, exemplos mínimos
- CHANGELOG: formato Keep a Changelog
# .claude/agents/db-expert.md   (local — adapte ao projeto)
---
name: db-expert
description: Especialista em banco de dados do projeto. Revisa queries, migrations e índices. NÃO executa DDL/DML.
tools:
  - Read
  - Bash    # apenas queries SELECT em banco de dev
disallowedTools:
  - Write
---

# DB Expert — [nome do projeto]

Stack: PostgreSQL 15, Prisma ORM, ambiente dev em localhost:5432.

## O que faço
- Analiso N+1, missing indexes, cartesian products
- Reviso migrations antes do deploy
- Explico planos de execução (EXPLAIN ANALYZE)

## Formato de resposta
Para cada problema: impacto estimado + query corrigida + índice sugerido.
# ~/.claude/agents/plan-roaster.md
---
name: plan-roaster
description: Critiques implementation plans with constructive skepticism. Use before any complex task. Does NOT modify code.
tools:
  - Read
disallowedTools:
  - Write
  - Edit
  - Bash
---

# Plan Roaster

You are the technical devil's advocate. You read plans and point out what will go wrong.

## How you work
1. Read the complete plan
2. List implicit assumptions (the most dangerous ones)
3. Point out failure points: edge cases, external dependencies, difficult rollback
4. Suggest questions the author should answer before starting

## Tone
Direct and useful. Not pessimistic by nature — just realistic.

💬 Ready-to-use prompts

Prompt 1 — Generate an initial suite for the current project
Analyze this project and create 5 custom subagents for me in .claude/agents/. For each one: identify the most-needed role, define the minimum tools and explicit restrictions. Format: one code block per .md file, ready to copy. Start with the most impactful.
Prompt 2 — review an existing agent with a production checklist
Leia o arquivo .claude/agents/[nome].md e aplique o checklist de produção: ferramentas são mínimas? restrições explícitas? escopo claro em 30s? formato de saída definido? Aponte problemas e sugira versão corrigida.
Prompt 3 — orchestrator dispatcher for the full suite
Usando os subagentes disponíveis (security-auditor, test-runner, doc-writer, db-expert, plan-roaster), monte um workflow para revisão completa antes de PR: rode os agentes relevantes em paralelo, colete resultados e gere um relatório unificado com ações prioritárias. Comece pelo plano antes de executar.
🎯

Final Project

Design and create your own subagent suite

What to do

  1. Choose a real project you have or are developing.
  2. Identify the 3 recurring bottlenecks in your workflow (examples: "I review security manually," "I test by hand," "it takes me too long to document").
  3. For each bottleneck, design a subagent: name, tools, constraints, output format.
  4. Create the files .md in .claude/agents/ from the project.
  5. Test each agent on a real-world case and document what worked and what you adjusted.
  6. Write one paragraph: "My suite does X. It used to take me Y. Now it takes me Z."

✓ Completion criteria

  • ✓≥ 3 .md files created and working
  • ✓Each agent passed the production checklist
  • ✓Each agent tested on a real case (not simulated)
  • ✓An honest, well-written impact paragraph
  • ✓At least 1 agent committed to the repository

✗ The exercise doesn’t count if

  • ✗The agents were only imagined, not created
  • ✗None were tested with a real task
  • ✗The "project" is a hello world created just for the exercise
  • ✗The impact paragraph was generated by AI without an honest review
🤖
⚡
🔧
🎯
🏆

You've completed the course Subagents!

You went from “what is a subagent” to building your own factory of specialists. This is one of the most valuable skill sets in AI development in 2026—and you have the complete roadmap.

T1
Fundamentals
What they are, how they work
T2
Practice
Creating and invoking
T3
Intermediate
Patterns and composition
T4
Advanced
Scale and your system

"A well-built subagent is a colleague who never forgets, never gets tired, and never exceeds their scope."

— The course’s central principle

🏠 Back to the course landing page

📋 What you learned in this module

✓How to organize a library of specialists
✓The starter pack: 5 ready-to-use agents
✓Templates that eliminate rework during creation
✓Production checklist for reliable agents
✓When to use global vs. local (project)
✓The course recap in 8 rules
✓Next steps over a 48-hour, 1-week, and 1-month timeframe
✓Final project: your real subagent suite