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.0.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.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whybroke-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 5e99c7e30ffe14d681e12d6b1db4779b2e2c5bb870a7d919fcfbe5ceda0edf40
MD5 8db7340b16d7183b93dc16f5930452e4
BLAKE2b-256 5c1e9d826b98745d3188a1b956ddd0e2baa96cffb9bd2569edcf8e384c51762f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whybroke-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66ca8c698861291935cea91dc7d9e30afd66ef7c25eab3e1fdce21dd5a2b5f2e
MD5 029ee93c56591a7fad608df7cf1f4b4c
BLAKE2b-256 6a12f258d3c578df72c21349524f5a107fa29ab0168b7222faf082c20c9a569a

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