All Toolsโ€บAI Debug Prompt Generator
๐Ÿ’ป AI Coding AssistantsJune 6, 2026โœ… Tests passing

AI Debug Prompt Generator

A Python tool that generates debugging prompts for AI coding assistants based on error logs and stack traces. The tool parses errors, extracts key details, and suggests concise prompts to help developers efficiently query AI models for solutions.

What It Does

  • Parses error logs and stack traces into actionable data.
  • Generates AI-compatible debugging prompts.
  • Supports multiple programming languages and frameworks.

Installation

Install the required dependencies:

pip install openai==0.27.0

Usage

Run the tool with an error log file as input:

python ai_debug_prompt_generator.py --error-log error_log.txt

Example output:

Generated Debugging Prompt:
I encountered an error in my code. The error type is 'ValueError' with the message: 'Invalid value'. Here is the stack trace: 
Traceback (most recent call last):
  File "example.py", line 10, in <module>
    raise ValueError('Invalid value')
ValueError: Invalid value
Can you help me understand what might be causing this issue and how to resolve it?

Source Code

import argparse
import traceback
import os
import openai

def parse_error_log(error_log):
    """
    Parses the error log and extracts key details such as error type, message, and stack trace.

    Args:
        error_log (str): The error log content.

    Returns:
        dict: A dictionary containing extracted error details.
    """
    try:
        stack_lines = error_log.strip().split('\n')
        last_line = stack_lines[-1] if stack_lines else ""
        error_type, _, error_message = last_line.partition(":")
        return {
            "error_type": error_type.strip(),
            "error_message": error_message.strip(),
            "stack_trace": stack_lines
        }
    except Exception as e:
        raise ValueError("Failed to parse error log: " + str(e))

def generate_debug_prompt(error_details):
    """
    Generates a debugging prompt for AI coding assistants based on error details.

    Args:
        error_details (dict): A dictionary containing error details.

    Returns:
        str: A debugging prompt tailored to the error.
    """
    try:
        prompt = (
            f"I encountered an error in my code. The error type is '{error_details['error_type']}' "
            f"with the message: '{error_details['error_message']}'. Here is the stack trace: \n"
            f"{os.linesep.join(error_details['stack_trace'])}\n"
            "Can you help me understand what might be causing this issue and how to resolve it?"
        )
        return prompt
    except KeyError as e:
        raise ValueError("Missing key in error details: " + str(e))

def main():
    parser = argparse.ArgumentParser(description="AI Debug Prompt Generator")
    parser.add_argument('--error-log', type=str, required=True, help="Path to the error log file")
    args = parser.parse_args()

    try:
        if not os.path.exists(args.error_log):
            raise FileNotFoundError(f"The file '{args.error_log}' does not exist.")

        with open(args.error_log, 'r') as file:
            error_log_content = file.read()

        error_details = parse_error_log(error_log_content)
        prompt = generate_debug_prompt(error_details)

        print("Generated Debugging Prompt:")
        print(prompt)

    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
ai_debug_prompt_generator
Category
AI Coding Assistants
Generated
June 6, 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-06-06/ai_debug_prompt_generator
cd generated_tools/2026-06-06/ai_debug_prompt_generator
pip install -r requirements.txt 2>/dev/null || true
python ai_debug_prompt_generator.py
AI Debug Prompt Generator โ€” AI Tools by AutoAIForge