Skip to main content
prompt GP ChatGPT

04_stack_trace_debug — Claude Code prompt for Python traces

The 04_stack_trace_debug prompt asks Claude Code to find the cause of a Python stack trace, identify the failing call, and suggest a fix. Use it when you need a compact diagnosis.

MIT ★ 2,744 updated 2026-10-08

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/04_stack_trace_debug.md
Open on GitHub

What 04_stack_trace_debug does

The prompt directs Claude Code to identify the root cause in a Python traceback, point to the call where the failure occurs, and recommend a fix. The reply is capped at 200 output tokens. It asks for one concise paragraph, with no preamble, code block, or list.

Its example shows a missing gzip file followed by a KeyError while the application handles the first exception. That makes the prompt relevant to traces where error handling raises a second failure. Save the prompt as .claude/commands/04_stack_trace_debug.md to install it; the strict response cap rules out a detailed walkthrough.

What it helps with

  • trace the root cause of a Python exception
  • locate the call that triggered a failure
  • suggest a fix based on a traceback
  • separate an initial exception from a handler failure

Example prompts for the agent

  • Diagnose this Python traceback, identify the cause, and suggest a fix: [paste traceback]
  • Find the failing call in this trace and explain the correction briefly: [paste traceback]

How to install 04_stack_trace_debug

Manually: put the files in place

.claude/commands/04_stack_trace_debug.md

Questions about 04_stack_trace_debug

How do I install 04_stack_trace_debug in Claude Code?

Save the prompt at .claude/commands/04_stack_trace_debug.md.

What does 04_stack_trace_debug do?

It asks Claude Code to find the cause of a Python error, point to the failing call, and suggest a fix. The response limit is 200 output tokens.

What response format does the prompt request?

It prefers one short paragraph without a preamble, lists, or code blocks. The answer must stay within 200 output tokens.

Source text

04_stack_trace_debug.md · MIT
---
name: stack_trace_debug
content_shape: stack-trace
reference_tokens_per_char: 0.30
description: Diagnose a Python stack trace in at most 200 output tokens (~800 chars).
---

[session-metrics:compare-suite:v2:prompt=stack_trace_debug]

Diagnose the root cause of the Python stack trace below in 200 OUTPUT TOKENS OR FEWER. Prefer one tight paragraph. State the cause, point at the offending call, and suggest the fix. No code blocks, no lists, no preamble.

---

```
Traceback (most recent call last):
  File "/app/workers/ingest.py", line 87, in process_batch
    for record in batch_iter(file_path, chunk_size=chunk):
  File "/app/workers/ingest.py", line 34, in batch_iter
    with gzip.open(path, "rt", encoding="utf-8") as fh:
  File "/usr/lib/python3.12/gzip.py", line 74, in open
    binary_file = GzipFile(filename, gz_mode, compresslevel)
  File "/usr/lib/python3.12/gzip.py", line 174, in __init__
    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/ingest/2026-04-19/batch_0042.json.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/workers/ingest.py", line 132, in <module>
    main()
  File "/app/workers/ingest.py", line 128, in main
    process_batch(manifest_entry, chunk_size=CHUNK_SIZE)
  File "/app/workers/ingest.py", line 91, in process_batch
    metrics.record_failure(manifest_entry["id"])
KeyError: 'id'
```

<!-- PREDICATE -->

````python
def check(text: str) -> bool:
    # Approximate the 200-token budget by char length (~4 chars/token).
    # Allow a small margin for tokenizer variance.
    return 0 < len(text) <= 900
````

© centminmod · MIT · centminmod/my-claude-code-setup

Similar prompts

All prompts for Backend and APIs →

From the same set35

The whole set →
zai-cli Routes code analysis requests to the GLM 4.7 model via the z.ai CLI directly from your Claude Code workflow. CX Codex ★ 2,744repo stars 09_typescript_refactor 09_typescript_refactor is a Claude Code prompt that makes TypeScript functions easier to read. It asks for a code block and a short explanation. GP ChatGPT ★ 2,744repo stars 02_english_prose 02_english_prose rewrites an English paragraph to remove every comma. You can restructure sentences and use other punctuation while preserving the meaning. GP ChatGPT ★ 2,744repo stars 08_csv_transform 08_csv_transform aggregates tabular order entries into customer spending totals and returns raw CSV without conversational filler. GP ChatGPT ★ 2,744repo stars 07_json_reshape 07_json_reshape — a prompt that rebuilds a JSON sample against a fixed rubric and returns nothing but parseable JSON. GP ChatGPT ★ 2,744repo stars 03_code_review 03_code_review — a prompt for reviewing Python diffs. It forces Claude to return exactly three concrete issues as a bulleted list without conversational filler. GP ChatGPT ★ 2,744repo stars ccusage-daily This command runs ccusage daily -b and turns Claude Code usage figures into a Markdown report. Use it to review costs, token totals, and daily spending. CX Codex +1 ★ 2,744repo stars create-readme-section The create-readme-section command for Claude Code generates README sections based on project files. Create installation instructions, API references, or contribution guides. CX Codex +1 ★ 2,744repo stars

Project sponsors

Companies that keep this analytics open