Skip to main content

Pipe any Python stack trace, get the fix in 8 seconds.

Project description

💥 WhyBroke

Stop copy-pasting stack traces. Fix Python bugs in 8 seconds.

CI codecov PyPI Python License

WhyBroke is a terminal-native CLI that reads your broken output, finds the exact failing function on your disk via Python's ast module, and prints a copy-pasteable fix. No dashboards. No SaaS. Just a Unix pipe that actually understands your code.

demo


🚀 Quickstart

uv pip install whybroke    # or: pip install whybroke
whybroke auth              # stored locally at ~/.whybroke/credentials.json
python my_buggy_script.py 2>&1 | whybroke

That's it. Pipe anything.

🧠 Why not just paste into ChatGPT?

When you paste an error into ChatGPT, the conversation goes:

"Can you share the contents of api.py?"

WhyBroke automates that away:

  1. AST context extraction — parses the traceback, finds the local file, walks the AST, and pulls the exact failing function. Not a ±10 line guess.
  2. Noise reduction — strips the 500 lines of framework boilerplate before the trace.
  3. Structured output — the LLM returns a confidence score, evidence lines, and a unified diff. No conversational fluff.
  4. Time travel — every debug session is saved locally. Run whybroke view 12 to re-read yesterday's fix for free.

⚙️ Commands

Command What it does
whybroke auth Set up your provider API key (stored at ~/.whybroke/credentials.json)
<cmd> 2>&1 | whybroke Pipe a trace. Default behaviour.
whybroke --file trace.txt Analyze a saved traceback file
whybroke --model gpt-4o Override the default model for your provider
whybroke history Rich table of your last 10 debug sessions
whybroke view 42 Re-render session 42 from local cache (no API call)
whybroke --note "flaky in CI" Attach a short note while analyzing (shown in history and view)
whybroke note 42 "fixed by pinning numpy" Add, update, or clear (pass "") the note on a past session
whybroke clear Delete all saved debug sessions (prompts; use -y to skip)
whybroke logout Remove stored API credentials from ~/.whybroke/credentials.json

🤖 Providers

BYOK (bring your own key). Supported at V1:

Provider Default model Notes
openai gpt-4o-mini JSON-mode enforced
anthropic claude-sonnet-4-5
gemini gemini-2.5-flash Via google-genai SDK
grok grok-4-fast xAI — OpenAI-compatible endpoint (api.x.ai/v1)
openrouter openrouter/free Free tier — OpenRouter's meta-router picks a live free model (Gemma 4, Nemotron 3, etc.) and whybroke auto-falls back on rate-limit / 404 / bad JSON. See docs/free-models.md.
litellm (set with --model) Universal router — works with Ollama, Bedrock, Groq, etc. Use --model ollama/llama3 for fully local.

🗣️ Language Support

Language Status
Python ✅ Deep (AST extraction)
JavaScript / TypeScript 🗳️ Vote with 👍
Go 🗳️ Vote with 👍
Rust 🗳️ Vote with 👍
Ruby 🗳️ Vote with 👍

Pipe any trace — languages without deep support fall back to LLM-only analysis so the pipe always works. V2's scope is determined by the leaderboard above.

🔒 Privacy

V1 sends the stack trace and extracted source to whichever provider you configured. Nothing is logged anywhere else. If you don't want your code leaving your machine, use the litellm provider with an Ollama model:

whybroke auth  # choose "litellm"
python my_script.py 2>&1 | whybroke --model ollama/llama3

🛠️ Contributing

V1's codebase is deliberately boring. The seams for language expansion live in three places:

See docs/ROADMAP.md for what's next.

🧩 Install as an Agent Skill

WhyBroke is available as an Agent Skill — drop it into any skills-aware AI assistant (Claude Code, Cursor, and others) and it'll trigger automatically when you hit a traceback.

npx skills add FireBolt922/whybroke

The skill works in two modes:

  • With the CLI installed and authenticated — invokes whybroke --file <trace> and returns a unified diff.
  • Without it — falls back to in-skill root-cause analysis (walks the traceback, reads the failing file, explains the root cause, proposes a fix). You'll see a one-time nudge to pip install whybroke && whybroke auth for the richer experience.

Skill source: skills/whybroke/.

💻 Platform support

Tested on macOS and Linux. Windows is untested in V1 and may need adjustments to credential-file permissions or path handling — PRs welcome.

📄 License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whybroke-0.2.1.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whybroke-0.2.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file whybroke-0.2.1.tar.gz.

File metadata

  • Download URL: whybroke-0.2.1.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for whybroke-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1f4a3bcac5b226ec26c0bbd5f8c52f8ca4ec52501ead2cd5eaa337a4bdb8dde6
MD5 2db440984a2f722754ec042255bc1862
BLAKE2b-256 d159feb483db222b0cdc0e4362dffea06c1f4e05ecbd2ccb9ffb4aeaf476b0ce

See more details on using hashes here.

File details

Details for the file whybroke-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: whybroke-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for whybroke-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bf740346f69716ef41956e44103e3d765a36f6156eaab1b6df82e70a1153e5b
MD5 f5a0fed4ff713bf1246d360fa96def3e
BLAKE2b-256 3f633e476073e2f15b4f27839eb3c7b1dc2801995d27898bb704403db586ebde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page