AIO APEX
Claude Sonnet 4.6 / GPT-4o / Gemini 2.5 ProDebug runtime errors faster — paste the error, stack trace, and relevant code snippet, and get a root cause diagnosis with a working fix and a clear explanation.Developer Tools

The Stack Trace Decoder: Cole qualquer erro, obtenha a causa raiz + correção em segundos

Compartilhar:
The Stack Trace Decoder: Cole qualquer erro, obtenha a causa raiz + correção em segundos

Why this prompt matters

Debugging is where developer time disappears. Reading a stack trace tells you where the crash happened, but not why. This prompt gives you both — a diagnosis that explains the root cause in plain language, the exact code change to fix it, and an explanation of the underlying mechanism so you don't hit the same bug twice. It works regardless of language or framework because it reasons from the error text and stack trace, not from memorized APIs.

What we use it for

Debug runtime errors faster — paste the error, stack trace, and relevant code snippet, and get a root cause diagnosis with a working fix and a clear explanation.

Prompt

I'm debugging an error. Please help me understand what went wrong and how to fix it.

**Error message:**
[PASTE ERROR MESSAGE HERE]

**Stack trace:**
[PASTE FULL STACK TRACE HERE]

**Relevant code (the function/file where the error originates):**
```
[PASTE CODE HERE]
```

**Context:**
- Language/runtime: [e.g. Python 3.11, Node.js 22, Go 1.22]
- What I was trying to do when the error occurred: [one sentence]
- What I've already tried: [or "nothing yet"]

Please provide:
1. **Root cause** — explain in plain language what actually went wrong and why
2. **The fix** — show the corrected code with inline comments explaining the change
3. **Why this happened** — the underlying mechanism or misconception that caused the bug, so I understand it rather than just copying the fix
4. **Prevention** — one sentence on how to avoid this class of error in the future

Result

The Prompt

I'm debugging an error. Please help me understand what went wrong and how to fix it.

**Error message:**
[PASTE ERROR MESSAGE HERE]

**Stack trace:**
[PASTE FULL STACK TRACE HERE]

**Relevant code (the function/file where the error originates):**
```
[PASTE CODE HERE]
```

**Context:**
- Language/runtime: [e.g. Python 3.11, Node.js 22, Go 1.22]
- What I was trying to do when the error occurred: [one sentence]
- What I've already tried: [or "nothing yet"]

Please provide:
1. **Root cause** — explain in plain language what actually went wrong and why
2. **The fix** — show the corrected code with inline comments explaining the change
3. **Why this happened** — the underlying mechanism or misconception that caused the bug, so I understand it rather than just copying the fix
4. **Prevention** — one sentence on how to avoid this class of error in the future

How to Use It

Copy the template above. Fill in the four sections — error message, stack trace, code, and context. The more complete the stack trace, the better the diagnosis. You don't need to edit or clean it up; paste it raw.

The context section is optional but worth filling in. "What I was trying to do" helps the model understand intent. "What I've already tried" prevents it from suggesting things you've already ruled out.

What You Get Back

The four-part response structure is designed specifically to avoid the two most common failure modes of AI debugging help:

  • The blind fix — giving you corrected code without explaining why the original was wrong. You apply it, it works, but you don't understand it and hit the same pattern in a different file next week.
  • The vague diagnosis — "it looks like there might be a null reference issue." No specifics, no fix, no path forward.

The structured output forces specificity: root cause first (what is actually broken), then the fix with inline comments (not just a code dump), then the mechanism (the why behind the why), then prevention (a rule you can internalize).

Works Across Languages

This prompt is language-agnostic. It works well with:

  • Python — great for tracebacks, import errors, type errors, async/await issues
  • JavaScript / TypeScript — handles Node.js errors, browser console exceptions, TypeScript compiler errors
  • Go — runtime panics, goroutine stack traces, interface assertion failures
  • Java / Kotlin — NullPointerException chains, JVM stack traces, Spring context errors
  • Rust — compiler error messages (which are already detailed but still benefit from explanation)
  • SQL — query parse errors, constraint violations, deadlock traces from PostgreSQL/MySQL

For compiled languages where the stack trace is less informative, paste the full compiler output along with the error.

Example Input and Output

Input (simplified):

Error message: TypeError: Cannot read properties of undefined (reading 'map')

Stack trace:
  at ProductList (ProductList.jsx:14:22)
  at renderWithHooks (react-dom.development.js:14985:18)

Relevant code:
function ProductList({ products }) {
  return (
    <ul>
      {products.map(p => <li key={p.id}>{p.name}</li>)}
    </ul>
  );
}

Context: React 18, Node 22. Trying to render a list fetched from an API.

What a good response looks like:

  • Root cause: products is undefined when the component first renders, before the API response arrives. .map() can't run on undefined.
  • Fix: Add a default value — function ProductList({ products = [] }) — or add a null guard before the map.
  • Why this happened: React renders synchronously before async data fetches resolve. The component renders with whatever initial value the parent passes, which is undefined if the parent hasn't set an initial state yet.
  • Prevention: Always initialize list props with a default empty array and handle loading/empty states explicitly in the component.

Tips for Better Results

  • Paste the full stack trace, not just the top line. Lower frames often reveal the actual call that triggered the error.
  • Include the immediate surrounding code, not just the line that errored. A few lines of context above and below matter.
  • If the error is intermittent, say so — the model will consider race conditions and timing issues.
  • For TypeScript errors, include the tsconfig.json relevant settings if the error is about strictness or module resolution.

The Prompt

Estou depurando um erro. Me ajude a entender o que deu errado e como corrigir.

**Mensagem de erro:**
[COLE A MENSAGEM DE ERRO AQUI]

**Stack trace:**
[COLE O STACK TRACE COMPLETO AQUI]

**Código relevante (função/arquivo onde o erro se origina):**
```
[COLE O CÓDIGO AQUI]
```

**Contexto:**
- Linguagem/ambiente: [ex: Python 3.11, Node.js 22, Go 1.22]
- O que eu estava tentando fazer quando o erro ocorreu: [uma frase]
- O que já tentei: [ou "nada ainda"]

Por favor, forneça:
1. **Causa raiz** — explique em linguagem clara o que realmente quebrou e por quê
2. **A correção** — mostre o código corrigido com comentários inline explicando a mudança
3. **Por que isso aconteceu** — o mecanismo subjacente ou equívoco que causou o bug, para que eu entenda, não apenas copie a correção
4. **Prevenção** — uma frase sobre como evitar essa classe de erro no futuro

Como Usar

Copie o template acima. Preencha as quatro seções — mensagem de erro, stack trace, código e contexto. Quanto mais completo o stack trace, melhor o diagnóstico. Você não precisa editar ou limpar; cole como está.

A seção de contexto é opcional, mas vale a pena preencher. "O que eu estava tentando fazer" ajuda o modelo a entender a intenção. "O que já tentei" evita que ele sugira coisas que você já descartou.

O Que Você Recebe de Volta

A estrutura de resposta em quatro partes foi desenhada especificamente para evitar os dois modos de falha mais comuns da ajuda de depuração com IA:

  • A correção cega — dar código corrigido sem explicar por que o original estava errado. Você aplica, funciona, mas não entende e repete o mesmo padrão em outro arquivo na semana seguinte.
  • O diagnóstico vago — "parece que pode haver um problema de referência nula." Sem detalhes, sem correção, sem caminho a seguir.

A saída estruturada força especificidade: causa raiz primeiro (o que está realmente quebrado), depois a correção com comentários inline (não apenas um dump de código), depois o mecanismo (o porquê por trás do porquê), depois a prevenção (uma regra que você pode internalizar).

Funciona em Várias Linguagens

Este prompt é agnóstico em relação à linguagem. Funciona bem com:

  • Python — ótimo para tracebacks, erros de import, erros de tipo, problemas com async/await
  • JavaScript / TypeScript — lida com erros do Node.js, exceções do console do navegador, erros do compilador TypeScript
  • Go — pânicos em runtime, stack traces de goroutines, falhas em asserção de interface
  • Java / Kotlin — cadeias de NullPointerException, stack traces da JVM, erros de contexto do Spring
  • Rust — mensagens de erro do compilador (que já são detalhadas, mas ainda se beneficiam de explicação)
  • SQL — erros de análise de consulta, violações de constraint, traces de deadlock do PostgreSQL/MySQL

Para linguagens compiladas onde o stack trace é menos informativo, cole a saída completa do compilador junto com o erro.

Exemplo de Entrada e Saída

Entrada (simplificada):

Mensagem de erro: TypeError: Cannot read properties of undefined (reading 'map')

Stack trace:
  at ProductList (ProductList.jsx:14:22)
  at renderWithHooks (react-dom.development.js:14985:18)

Código relevante:
function ProductList({ products }) {
  return (
    <ul>
      {products.map(p => <li key={p.id}>{p.name}</li>)}
    </ul>
  );
}

Contexto: React 18, Node 22. Tentando renderizar uma lista obtida de uma API.

Como é uma boa resposta:

  • Causa raiz: products é undefined quando o componente renderiza pela primeira vez, antes da resposta da API chegar. .map() não pode executar em undefined.
  • Correção: Adicione um valor padrão — function ProductList({ products = [] }) — ou adicione uma guarda de null antes do map.
  • Por que isso aconteceu: React renderiza de forma síncrona antes que as chamadas assíncronas de dados sejam resolvidas. O componente renderiza com qualquer valor inicial que o pai passe, que é undefined se o pai não definiu um estado inicial ainda.
  • Prevenção: Sempre inicialize props de lista com um array vazio padrão e lide explicitamente com estados de loading/vazio no componente.

Dicas para Melhores Resultados

  • Cole o stack trace completo, não apenas a linha de cima. Quadros inferiores muitas vezes revelam a chamada real que disparou o erro.
  • Inclua o código imediatamente ao redor, não apenas a linha que deu erro. Algumas linhas de contexto acima e abaixo importam.
  • Se o erro é intermitente, diga — o modelo vai considerar condições de corrida e problemas de temporização.
  • Para erros de TypeScript, inclua as configurações relevantes do tsconfig.json se o erro for sobre strictness ou resolução de módulos.
developer toolsai-promptsdebuggingcodingstack-trace
Compartilhar: