Skip to main content

AI-powered CLI tool that turns stack traces into root cause analysis instantly

Project description

๐Ÿ› DebugAI

PyPI version Python 3.9+ License: MIT CI

AI-powered CLI tool that turns any stack trace into a root cause analysis โ€” in seconds.

No dashboard. No account. No SDK to integrate. Just pipe in a log and get answers.

cat production.log | debuai --ai

Demo

https://github.com/user-attachments/assets/5771164c-865e-4c95-aff8-3cc7e2dae0f2


Install

pip install debuai

Quickstart

# Analyse a log file
debuai error.log

# Pipe from any source
cat error.log | debuai
kubectl logs my-pod | debuai
docker logs my-container | debuai

# With AI analysis
debuai error.log --ai

# Machine-readable JSON output
debuai error.log --json
debuai error.log --ai --json | jq .

# Choose your AI provider
debuai error.log --ai --provider openai
debuai error.log --ai --provider anthropic
debuai error.log --ai --provider nvidia

# Analyse the last N errors in a log
debuai error.log --top 3

What It Does

Given a stack trace like this:

Traceback (most recent call last):
  File "server.py", line 10, in handle_request
    result = process_data(payload)
  File "processor.py", line 25, in process_data
    value = parse_input(raw)
  File "parser.py", line 8, in parse_input
    return int(raw)
ValueError: invalid literal for int() with base 10: 'abc'

DebugAI gives you this:

๐Ÿ”ฅ Exception Type   ValueError
๐Ÿ“ Failure Origin   parse_input
๐Ÿ”— Execution Chain  handle_request โ†’ process_data โ†’ parse_input

๐Ÿค– AI Root Cause    The function receives a string that cannot be
                    converted to int โ€” 'abc' is passed where a
                    numeric string is expected.

๐Ÿ›  Suggested Fix    Validate input before conversion:
                    if not raw.isdigit(): raise ValueError(...)

๐Ÿ›ก Prevention       Add input validation at the API boundary so
                    invalid types never reach the parsing layer.

๐ŸŸข Confidence: HIGH

Supported Languages

Language Detection Parser
Python Traceback (most recent call last) โœ…
Java .java: in frames โœ…
Go goroutine / panic: โœ…
C# / .NET at Namespace.Class.Method() โœ…
Node.js .js: in frames โœ…

Language is auto-detected โ€” no --lang flag needed.


AI Providers

DebugAI works with whichever key you already have. Set one environment variable and it just works.

export OPENAI_API_KEY=...       # Uses gpt-4o-mini
export ANTHROPIC_API_KEY=...    # Uses claude-haiku
export NVIDIA_API_KEY=...       # Uses NVIDIA inference

Auto-detection order: OpenAI โ†’ Anthropic โ†’ NVIDIA. Override with --provider.


JSON Output

The --json flag outputs clean, pipeable JSON โ€” no Rich formatting, no colour codes.

debuai error.log --ai --json
{
  "exception": "ValueError",
  "failure_origin": "parse_input",
  "execution_chain": ["handle_request", "process_data", "parse_input"],
  "source_file": "parser.py",
  "language": "python",
  "ai": {
    "root_cause": "...",
    "fix": "...",
    "prevention": "...",
    "confidence": "high"
  }
}

Pipe into jq, Slack bots, Jira integrations, or CI pipelines.


CI / CD Integration

Add DebugAI to your GitHub Actions workflow to get AI analysis on every failed build:

- name: Analyse failure
  if: failure()
  run: |
    pip install debuai
    cat logs/error.log | debuai --ai --json
  env:
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Setup for Development

git clone https://github.com/kanhaiya-bhayana/debugai.git
cd debugai
python -m venv venv
source venv/bin/activate        # Mac/Linux
venv\Scripts\activate           # Windows
pip install -e ".[dev]"

Run tests:

python -m pytest tests/ -v

Set your API key:

export OPENAI_API_KEY=your_key_here

Project Structure

debugai/
โ”œโ”€โ”€ parser/
โ”‚   โ”œโ”€โ”€ python.py        # Python traceback parser
โ”‚   โ”œโ”€โ”€ java.py          # Java / Spring parser
โ”‚   โ”œโ”€โ”€ go.py            # Go panic parser
โ”‚   โ”œโ”€โ”€ csharp.py        # C# / .NET parser
โ”‚   โ”œโ”€โ”€ node.py          # Node.js parser
โ”‚   โ””โ”€โ”€ registry.py      # Language auto-detection router
โ”œโ”€โ”€ providers/
โ”‚   โ”œโ”€โ”€ openai_provider.py
โ”‚   โ”œโ”€โ”€ anthropic_provider.py
โ”‚   โ””โ”€โ”€ nvidia.py
โ”œโ”€โ”€ analyzer.py          # Core extraction logic
โ”œโ”€โ”€ ai_analyzer.py       # Provider selection + AI orchestration
โ””โ”€โ”€ cli.py               # Typer CLI entry point
tests/
โ”œโ”€โ”€ test_parsers.py      # 50 parser tests
โ”œโ”€โ”€ test_analyzer.py     # 28 analyzer tests
โ””โ”€โ”€ test_safeguards.py   # 13 edge case + safeguard tests

Roadmap

  • Python, Java, Go, C#, Node.js parsers
  • Multi-provider AI backend (OpenAI, Anthropic, NVIDIA)
  • Structured JSON output
  • CI/CD pipeline
  • PyPI publish
  • GitHub issue search โ€” link traces to known issues automatically
  • Kubernetes / Docker log stream support
  • VS Code extension
  • Web UI for team sharing

Contributing

Contributions are welcome. Please read CONTRIBUTING.md before opening a PR.

# Run the full test suite before submitting
python -m pytest tests/ -v

License

MIT โ€” see LICENSE for details.


Built with โค๏ธ for developers who are tired of Googling stack traces.

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

debuai-0.1.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

debuai-0.1.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file debuai-0.1.1.tar.gz.

File metadata

  • Download URL: debuai-0.1.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for debuai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 68dd0b3767e2279842820d9e08c78365522a3b44d5c8307e11488c3eef704296
MD5 f5c8eea18b4de983b7a21189092897a6
BLAKE2b-256 aa66f59d983295769c2ffd84c5d8458224968baa6c6ddc31edfe09d19888eb9c

See more details on using hashes here.

File details

Details for the file debuai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: debuai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for debuai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b91913186fbfc37bad182187162a8fea666124b57d2fddd84b1bdc04ba944d2
MD5 f0a6800198623b46deb4347bb1106950
BLAKE2b-256 05d8b721bf91e68b3743220b5f9f2231fc4581c24e7fe49d6c87ae6c93e76375

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