Kaique Mitsuo Silva Yamamoto
IaDesenvolvimento com ia

Workflow Prático — Claude Code e Cursor na Produção

Passo a passo para configurar e usar Claude Code e Cursor em projetos reais. Setup, CLAUDE.md, skills, hooks, orquestração de subagentes e o loop de desenvolvimento diário.

Teoria sem prática é inútil. Esta página é o passo a passo operacional para usar Claude Code e Cursor no dia a dia — do setup inicial ao deploy.


Setup do Claude Code

Instalação

# macOS / Linux
curl -fsSL https://claude.ai/install.sh | bash

# Verificar
claude --version

Configuração inicial do projeto

cd seu-projeto

# Criar CLAUDE.md na raiz
claude init

# Criar estrutura de regras
mkdir -p .claude/rules .claude/skills

CLAUDE.md do projeto (template prático)

# Projeto: Meu SaaS

## Stack
- TypeScript, Next.js 16, React 19, Tailwind CSS v4
- Go 1.23 backend (Gin), MongoDB, Redis

## Convenções
- 2 espaços de indentação, aspas simples, trailing commas
- Componentes em PascalCase, arquivos em kebab-case
- Sempre usar <Link> do Next.js para navegação interna
- Sempre usar Vitest (nunca Jest) para testes

## Comandos
- pnpm dev: servidor de desenvolvimento
- pnpm lint:fix: corrige lint + formatação
- pnpm vitest run: roda testes unitários
- pnpm build: build de produção

## Após TAMBEM alteração de código:
1. pnpm lint:fix
2. pnpm format
3. pnpm vitest run
4. Se tudo passar, commit com Conventional Commits

## NUNCA commitar se:
- Qualquer teste falhar
- Lint tiver erros
- TypeScript tiver erros de tipo

## Estrutura
- src/app/ — rotas Next.js (App Router)
- src/components/ — componentes React
- src/lib/ — utilitários e helpers
- src/__tests__/ — testes unitários
- backend/api/ — API Go (Gin + MongoDB)
- content/docs/ — conteúdo MDX (Fumadocs)
- specs/ — especificações de features

O loop de desenvolvimento diário

Etapa 1: Definir a tarefa (você)

# Criar spec para a feature
cat > specs/nova-feature.md << 'EOF'
# Spec: Sistema de Notificações

## Objetivo
Notificar usuários quando há atualizações relevantes.

## Endpoints
### GET /api/notifications
- Input: { page: number, limit: number }
- Output: { items: Notification[], total: number, page: number }
- Auth: obrigatório (JWT)

### PATCH /api/notifications/:id/read
- Input: { }
- Output: { success: boolean }
- Auth: obrigatório

## Testes esperados
- [ ] Lista notificações paginadas
- [ ] Retorna 401 sem autenticação
- [ ] Marca notificação como lida
- [ ] Retorna 404 se notificação não existe
EOF

Etapa 2: Escrever testes (você ou a IA)

# Prompt para gerar testes
claude -p "Read specs/nova-feature.md and generate Vitest tests.
Write tests to src/__tests__/notifications.test.ts.
Do NOT implement the endpoint. Only write tests."

Etapa 3: Rodar testes (RED)

pnpm vitest run src/__tests__/notifications.test.ts
# Todos devem falhar (endpoint não existe ainda)

Etapa 4: Implementar com a IA

# Prompt para implementar
claude -p "Read specs/nova-feature.md and src/__tests__/notifications.test.ts.
Implement the notification endpoints so all tests pass.
Do NOT modify the tests.
After implementing, run: pnpm vitest run src/__tests__/notifications.test.ts
If any test fails, fix the implementation until all pass."

Etapa 5: Validar (GREEN)

pnpm lint:fix && pnpm format && pnpm vitest run

Etapa 6: Commit

claude -p "Run git status, review the changes, and commit with a
Conventional Commits message. Include the spec file in the commit."

Orquestração de subagentes

Para tarefas grandes, use subagentes para paralelizar leitura:

Prompt de orquestração

I need to implement the billing module (specs/billing.md).

Please:
1. First, spawn subagents to read and understand:
   - specs/billing.md (the spec)
   - src/db/schema.ts (current database schema)
   - src/models/user.ts (user model)
   - src/middleware/auth.ts (auth middleware)

2. After understanding the codebase, create a fix_plan.md with tasks

3. Implement one task at a time:
   - Write tests first
   - Implement until tests pass
   - Run pnpm lint:fix && pnpm vitest run
   - Commit if green

4. Update fix_plan.md after each task

Cursor — Composer 2

Fluxo de trabalho no Cursor

  1. Criar PRD — escreva feature-prd.md com requisitos
  2. Abrir ComposerCmd+K ou painel lateral
  3. Referenciar arquivos — use @file para incluir specs e código existente
  4. Gerar plano — peça para o Cursor criar task list do PRD
  5. Executar — Cursor implementa autonomamente
  6. Revisar diffs — revise cada alteração antes de aceitar

Prompt efetivo no Composer

@specs/auth.md @src/db/schema.ts @src/middleware/auth.ts

Implement the authentication module described in @specs/auth.md.

Requirements:
- Use the existing database schema from @src/db/schema.ts
- Follow the auth middleware pattern from @src/middleware/auth.ts
- Write tests for each endpoint BEFORE implementing
- Run lint:fix and vitest after each endpoint
- Commit after all tests pass

Hooks (Claude Code)

Hooks são comandos shell executados em eventos do ciclo de vida:

// .claude/settings.json
{
  "hooks": {
    "onEdit": "pnpm lint:fix",
    "onCommit": "pnpm vitest run",
    "onFinish": "pnpm build"
  }
}

Hooks garantem que back-pressure seja aplicado automaticamente — o agente não consegue pular etapas.


Skills (Claude Code)

Skills são workflows carregados sob demanda:

.claude/skills/
├── commit/
│   └── SKILL.md        # Como fazer commits
├── test/
│   └── SKILL.md        # Como rodar testes
└── deploy/
    └── SKILL.md        # Como fazer deploy

Exemplo de skill

# Skill: Commit

## Trigger
When the user says "commit" or stages changes.

## Steps
1. Run `git status` and `git diff --cached`
2. Analyze changes and draft a commit message
3. Follow Conventional Commits: feat:, fix:, refactor:, chore:
4. Subject line ≤ 50 chars
5. Body only when "why" isn't obvious
6. Run `pnpm lint:fix` before committing
7. Run `pnpm vitest run` before committing
8. If tests fail, fix before committing

Erros comuns no workflow

ErroSintomaCorreção
Sessão longa sem fresh contextIA repete código, ignora mudançasNova sessão a cada 30-60 min
CLAUDE.md giganteIA "esquece" regras importantes< 100 linhas, @imports para detalhes
Sem hooksIA pula lint/testesConfigurar hooks obrigatórios
Prompt genéricoCódigo que "funciona" mas não integraReferenciar specs + arquivos existentes
Subagentes para tudoCusto alto, paralelismo desnecessárioSubagentes só para search/read

Conteúdo Relacionado

On this page