🗂️ Scaffold mínimo
init.sh
cria estrutura idempotente
tests.json
estado estruturado: todo/pass/fail
progress.txt
append-only log de decisões
spec.md
briefing permanente (ICCA)
🔬 init.sh completo
#!/usr/bin/env bash
# init.sh — idempotente, rodar 1x para criar scaffold
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
mkdir -p .agent
[ -f .agent/spec.md ] || cat > .agent/spec.md <<'EOF'
# Spec
## Intent
<descreva o objetivo em 2 linhas>
## Constraints
- <o que NÃO pode quebrar>
## Criteria
- [ ] todos os testes em .agent/tests.json passando
- [ ] nenhum arquivo fora do escopo modificado
## Files
- src/...
EOF
[ -f .agent/tests.json ] || cat > .agent/tests.json <<'EOF'
{
"tests": [
{ "id": "t1", "desc": "...", "status": "todo" }
]
}
EOF
[ -f .agent/progress.txt ] || echo "# progress.txt — append-only" > .agent/progress.txt
grep -q '^\.agent/$' .gitignore 2>/dev/null || echo ".agent/scratch/" >> .gitignore
echo "scaffold ok."📊 tests.json
{
"tests": [
{ "id": "t1", "desc": "POST /users cria usuário", "status": "passed", "last_run": "2026-04-20T13:05:00Z" },
{ "id": "t2", "desc": "GET /users/:id retorna 404", "status": "failed", "error": "returns 500" },
{ "id": "t3", "desc": "middleware valida JWT", "status": "todo" },
{ "id": "t4", "desc": "rate limit por IP", "status": "todo" }
],
"summary": { "total": 4, "passed": 1, "failed": 1, "todo": 2 }
}Estrutura > texto livre. Fácil de patching por humano e modelo.
🧠 Context awareness prompt
<context_awareness>
Your context window will be automatically compacted when it
approaches its limit. Treat this as inevitable — your job is
to ensure that a future instance (with a fresh or compacted
context) can resume your work from disk.
Before making non-trivial progress:
1. Read .agent/spec.md to re-anchor on the goal.
2. Read .agent/tests.json to see current status.
3. Read .agent/progress.txt to see what was already tried.
After meaningful progress:
1. Update .agent/tests.json (status transitions).
2. Append to .agent/progress.txt one line per decision:
`YYYY-MM-DD HH:MM <what> — <why>`.
3. If a new insight changes the plan, patch spec.md.
4. Commit with message starting `chore(agent): `.
Assume a compact can happen at any turn. Never keep critical
state only in memory — write it down.
</context_awareness>🔄 Workflow: janela 1 → N
| Janela | Foco | Entrada | Saída |
|---|---|---|---|
| 1 | scaffold + spec | briefing humano | spec.md + tests.json |
| 2 | primeiro ciclo | spec + tests + progress | 3 testes verdes |
| 3+ | fechar restantes | mesmo + git log | PR com tudo verde |
Entre janelas: /clear total. Briefing = "read .agent/* and continue."
🌿 Git como state tracker
- •Branch por tentativa:
attempt/20260420-migration - •Commit por checkpoint — fácil de
git checkoutpara rewind - •Commit msg semântico:
chore(agent): t2 green - •git log substitui memória em sessões novas
Rewind via git é mais seguro que rewind via sessão — estado explícito, no disco.
🏗️ Laboratório T3
Desafio final
Escolha uma tarefa real de 2–3h que obrigatoriamente passe de 200k tokens. Ex.: migrar módulo com 15+ arquivos, reescrever suíte de testes, integrar API desconhecida.
Entregáveis
- Branch
attempt/YYYYMMDD-*com scaffold aplicado - Pelo menos 1 compact atravessado sem perda de contexto
- tests.json com ≥80% dos testes verdes
- progress.txt com ≥20 entradas
- Relatório final: janelas usadas, compacts, commits, tempo humano real
Ao terminar, você sabe o que significa "sustenta tarefas multi-context". A Trilha 4 transforma isso em produção.
📋 Resumo da Trilha 3
Próxima Trilha:
T4 Expert — Migração e Produção (Amber)