All Toolsโ€บCode Debug AI Assistant
๐Ÿ”ง AI Coding AgentsJuly 5, 2026โœ… Tests passing

Code Debug AI Assistant

Code Debug AI Assistant is a CLI tool that takes error messages, stack traces, or problematic code as input and uses AI to suggest debugging steps or code corrections. It also explains potential causes, empowering developers to learn from the debugging process.

What It Does

  • Analyze Python error messages and stack traces.
  • Suggest debugging steps and fixes.
  • Provide educational explanations for errors.
  • Output results to the console or save them to a YAML file.

Installation

1. Clone the repository:

git clone <repository_url>
   cd code_debug_ai_assistant

2. Install dependencies:

pip install -r requirements.txt

Usage

Input (via file or stdin):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero

Output (console or YAML file):

suggestions: Here are some debugging suggestions.

Source Code

import openai
import click
import yaml
import sys

# Function to interact with OpenAI API
def get_debugging_suggestions(input_text):
    """
    Sends the input text to OpenAI's API and retrieves debugging suggestions.

    Args:
        input_text (str): The error message, stack trace, or problematic code.

    Returns:
        dict: A dictionary containing debugging suggestions and explanations.
    """
    try:
        response = openai.ChatCompletion.create(
            model="gpt-4",
            messages=[
                {"role": "system", "content": "You are a helpful assistant for debugging Python code."},
                {"role": "user", "content": input_text}
            ]
        )
        suggestions = response['choices'][0]['message']['content']
        return {"suggestions": suggestions}
    except Exception as e:
        return {"error": str(e)}

@click.command()
@click.option('--input', 'input_file', type=click.File('r'), required=False, help='Path to the input file containing error message, stack trace, or code.')
@click.option('--output', 'output_file', type=click.File('w'), required=False, help='Path to the output YAML file to save suggestions.')
def main(input_file, output_file):
    """
    Code Debug AI Assistant CLI tool.

    Takes error messages, stack traces, or problematic code as input and uses OpenAI to suggest debugging steps or fixes.
    """
    # Read input from file or stdin
    if input_file:
        input_text = input_file.read()
    else:
        click.echo("Enter your error message, stack trace, or problematic code (end with Ctrl+D):")
        input_text = sys.stdin.read()

    if not input_text.strip():
        click.echo("Error: No input provided.", err=True)
        sys.exit(1)

    # Get debugging suggestions
    result = get_debugging_suggestions(input_text)

    # Handle errors from the API
    if "error" in result:
        click.echo(f"Error communicating with OpenAI API: {result['error']}", err=True)
        sys.exit(1)

    # Output results
    if output_file:
        yaml.dump(result, output_file)
        click.echo(f"Suggestions saved to {output_file.name}")
    else:
        click.echo("Debugging Suggestions:")
        click.echo(result["suggestions"])

if __name__ == "__main__":
    main()

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
code_debug_ai_assistant
Category
AI Coding Agents
Generated
July 5, 2026
Tests
Passing โœ…

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-07-05/code_debug_ai_assistant
cd generated_tools/2026-07-05/code_debug_ai_assistant
pip install -r requirements.txt 2>/dev/null || true
python code_debug_ai_assistant.py
Code Debug AI Assistant โ€” AI Tools by AutoAIForge