# Ag Corrigir Tipos

> Corrige erros TypeScript com auto-routing. Scan (diagnosticar), Fix (batch incremental), Sweep (varredura com ratchet), Audit-any (auditoria proativa de any/inferencias fracas). Substitui workflow manual de typecheck.

- **Type:** Skill
- **Install:** `agentstack add skill-andregusman-raiz-a-gusman-claude-ag-corrigir-tipos`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [andregusman-raiz](https://agentstack.voostack.com/s/andregusman-raiz)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [andregusman-raiz](https://github.com/andregusman-raiz)
- **Source:** https://github.com/andregusman-raiz/a-gusman-claude/tree/main/skills/ag-corrigir-tipos

## Install

```sh
agentstack add skill-andregusman-raiz-a-gusman-claude-ag-corrigir-tipos
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# ag-corrigir-tipos — Fix TypeScript

Spawn the `ag-corrigir-tipos` agent to handle TypeScript error correction — from diagnosis to large-scale sweeps.

## Auto-Routing

The agent auto-selects the best mode based on input:

| Input | Mode | Behavior |
|-------|------|----------|
| "diagnosticar tipos" / desconhecido | `--scan` | Categorizar erros, gerar plano (read-only) |
| 1-10 erros claros | `--fix` | Batch incremental, 5 arquivos/batch, commits |
| 10-50 erros | `--fix` | Multiplos batches com quality gates |
| 50+ erros / "limpar tipos" | `--sweep` | Varredura por categoria, ratchet threshold |
| "audit any" / "scan any" / "props sem tipo" | `--audit-any` | Auditoria proativa SEM precisar de erro TS |
| Pos-upgrade de lib | ag-depurar-erro first | Causa raiz, depois `--fix` |

## Invocation

Use the **Agent tool** with:
- `subagent_type`: `ag-corrigir-tipos`
- `mode`: `bypassPermissions`
- `run_in_background`: `true` (except `--fix` `, `Array`, `Promise`, `Record`
- Cross-check: variavel realmente nao tem tipo derivavel? (sugerir `unknown` ou tipo concreto)
- Excecoes legitimas: testes, mocks, type guards intencionais (anotar `// expected: any`)

### 2. Props sem interface/type
- Para cada componente React (function ou arrow), verificar:
  - Tem `Props` interface/type declarado?
  - OU usa `React.FC`?
  - OU destructura props sem tipo (`function Foo({ x, y }) {}` sem annotation)?
- Sugerir interface inferida a partir do uso de props no body

### 3. Inconsistencia interface vs type
- Contar uso de `interface X` vs `type X = { ... }`
- Se projeto tem > 70% de um e ` para responses de API (sugerir Zod schema)
- `Object`, `{}`, `Function` — anti-patterns conhecidos

### Pipeline --audit-any

```bash
# 1. Setup
bunx eslint --rule '@typescript-eslint/no-explicit-any: warn' \
  --rule '@typescript-eslint/no-unsafe-assignment: warn' \
  --rule '@typescript-eslint/no-unsafe-return: warn' \
  --rule '@typescript-eslint/explicit-module-boundary-types: warn' \
  --format json --ext .ts,.tsx src/ app/ components/ > any-audit.json

# 2. AST custom (props sem tipo)
# Spawn ag-corrigir-tipos com prompt especifico para coletar componentes sem Props interface

# 3. Contagem interface vs type
grep -c '^interface ' src/**/*.ts > interface-count
grep -c '^type .* = {' src/**/*.ts > type-count
```

### Output --audit-any

Escreve `docs/diagnosticos/typescript-audit-YYYY-MM-DD.md`:

```markdown
# TypeScript Audit — [projeto] — [data]

## Resumo
- Arquivos scanned: N
- `any` explicito: N ocorrencias em N arquivos
- Props sem tipo: N componentes
- Inconsistencia interface vs type: N% / N%
- Tipos pouco restritivos: N candidatos

## Top 10 ocorrencias de `any`
| Arquivo:linha | Snippet | Fix sugerido |
|---|---|---|

## Componentes sem Props interface
[path:linha + props destructured + interface sugerida]

## Tipos pouco restritivos
[path:linha + tipo atual + tipo sugerido + razao]
```

Apply mode (apos `--audit-any` + user approval): pode invocar `--fix` para casos HIGH-confidence (substituir `as any` por `unknown` + narrowing, adicionar Props interface inferida).

## Escalacao

### Erros nao-resolvidos
Se erro de tipo resiste a 3 tentativas de fix:
- Documentar em `errors-log.md`
- Escalar para ag-depurar-erro (depurar) se causa raiz nao-obvia
- Escalar para ag-registrar-issue (registrar-issue) se requer mudanca arquitetural

### Pos-Sweep
Apos sweep completo, spawnar ag-testar-codigo para validar que fixes nao quebraram funcionalidade.

## Sinais de Ativacao (para ag-0-orquestrador)

| Sinal do usuario | Modo |
|-------------------|------|
| "corrigir tipos", "fix typescript", "typecheck" | auto-detect |
| "diagnosticar tipos", "quantos erros TS" | --scan |
| "limpar tipos", "sweep typescript", "zerar erros" | --sweep |
| "erros de tipo no [arquivo]" | --fix (escopo limitado) |
| "reducir error budget", "ratchet" | --sweep |
| "audit any", "scan any", "props sem tipo", "interface vs type" | --audit-any |

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [andregusman-raiz](https://github.com/andregusman-raiz)
- **Source:** [andregusman-raiz/a-gusman-claude](https://github.com/andregusman-raiz/a-gusman-claude)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-andregusman-raiz-a-gusman-claude-ag-corrigir-tipos
- Seller: https://agentstack.voostack.com/s/andregusman-raiz
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
