Esta nota fecha a trilha com um exemplo end-to-end: como configurar context engineering num projeto real, do zero. Stack: AGENTS.md + .agent/ (skills + state) + memory layer + JIT retrieval + guardrails. O alvo é um agente de coding em projeto Python — mas o padrão se traduz para qualquer domínio. Cada peça encaixa nas anteriores: fundamentos → camadas → retrieval → memória → guardrails. Sem teoria — só checklist e arquivos.
O cenário
Projeto: API Python com FastAPI + Postgres
Time: 3 devs
Ferramenta principal: Claude Code (mas funciona com Cursor, Aider)
Modelo: Sonnet 4.6 com prompt caching
# Projeto Pagamentos APIAPI REST para processar pagamentos. Stack: FastAPI + Postgres + Redis.## Build & Test- Install: `uv sync`- Test: `pytest`- Lint: `ruff check`- Type check: `mypy src/`## Conventions- Pydantic v2 para todos os schemas- Async/await em endpoints; sync em utility code- Sempre type hints; sempre docstrings em funções públicas## Structure- `src/api/` — endpoints FastAPI- `src/services/` — lógica de negócio- `src/repositories/` — DB access (SQLAlchemy)- `src/schemas/` — Pydantic models## Security- Nunca log de PII (CPF, cartão); usar redact_pii() de src/utils- Validação de input em camada de schema, não service- Secrets via env, nunca em código## Workflow1. Antes de editar: ler .agent/STATE.md e TODO.md2. Após mudança significativa: atualizar .agent/NOTES.md3. Antes de commit: rodar pytest + ruff
Symlink Claude Code
ln -s AGENTS.md CLAUDE.md
Passo 2 — Skills (camada de conhecimento reusável)
Cada skill resolve um padrão recorrente:
# .agent/skills/adding-endpoint.md## When to useQuando o usuário pedir "adicione endpoint para X".## Pattern1. Criar schema em src/schemas/{feature}.py (Pydantic)2. Criar service em src/services/{feature}.py3. Criar repository se for novo recurso4. Criar router em src/api/{feature}.py5. Adicionar testes em tests/api/test_{feature}.py6. Atualizar src/api/__init__.py para incluir router## ExampleVer src/api/payments.py como template.## Checklist- [ ] Schema com validators (não só types)- [ ] Service tem teste unitário- [ ] Endpoint tem teste de integração- [ ] Tipos estritos (no `Any`)
Skills carregam só quando o agente decide que é relevante — não inflam o contexto base.
# .agent/STATE.md (volátil, gitignored)## Tarefa atualAdicionar endpoint POST /refunds## Arquivos modificados- src/schemas/refunds.py (criado, OK)- src/services/refunds.py (em progresso)## Próximo stepImplementar refund_payment() em service## BloqueiosNenhum
# .agent/TODO.md## In progress- [ ] Endpoint POST /refunds (responsável: agent + Maria)## Up next- [ ] Webhook de retry em pagamentos falhados- [ ] Migração de coluna currency