Automatically debug code from your terminal using AI
Project description
Always-On Debugger
Automatically debug code from your terminal.
Overview
Always-On Debugger is a tool that enhances your terminal experience by automatically detecting errors and providing debugging assistance using AI. It acts as a wrapper around your existing terminal, intercepting commands and their outputs to offer real-time debugging support.
At present, we only support using Anthropic's Claude API. Let us know if you need OpenAI support.
Features
- Mimics the terminal for every command
- Automatically detects errors in command outputs
- Captures context and sends it to an AI language model for analysis
- Provides AI-generated debugging suggestions directly in the terminal
Setup
There are two ways to setup Always-On Debugger.
Option 1: Using npm
Step 1: Install the package
npm install -g aidebug
or
pip install ai-code-debugger
Step 2: Setup the API key for Anthropic
export ANTHROPIC_API_KEY=<PASTE_YOUR_OWN_API_KEY>
Step 3: Now you can use the debug command to debug your commands.
debug python average.py
Option 2: Manual Setup
Step 1: Clone the repo
cd ~
git clone git@github.com:samarthaggarwal/always-on-debugger.git
Step 2: Update ~/.bashrc Add the following to your ~/.bashrc or ~/.zshrc
alias debug="python ~/always-on-debugger/terminal.py"
export ANTHROPIC_API_KEY=<PASTE_YOUR_OWN_API_KEY>
Step 3: Source ~/.bashrc or ~/.zshrc . Alternatively, open a new terminal.
source ~/.bashrc
Usage
Just prefix any terminal command with debug. That's it, the debugger will automatically kick in when an error is detected and prints the error along with the suggested course of action. Here's an example:
Normally, the deverlop would only see the error.
[14:57:19] ➜ demo git:(main) ✗ python average.py
The average is: 3.0
Traceback (most recent call last):
File "/Users/samarthaggarwal/personal/always-on-debugger/demo/average.py", line 15, in <module>
average_of_empty = calculate_average(empty_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samarthaggarwal/personal/always-on-debugger/demo/average.py", line 7, in calculate_average
return total / count
~~~~~~^~~~~~~
ZeroDivisionError: division by zero
Prefixing the same command with
debugprints the error along with diagnosis and recommendations.
[14:57:21] ➜ demo git:(main) ✗ debug python average.py
Traceback (most recent call last):
File "/Users/samarthaggarwal/personal/always-on-debugger/demo/average.py", line 15, in <module>
average_of_empty = calculate_average(empty_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/samarthaggarwal/personal/always-on-debugger/demo/average.py", line 7, in calculate_average
return total / count
~~~~~~^~~~~~~
ZeroDivisionError: division by zero
---------------------------------------------------------------------
Debugging...
---------------------------------------------------------------------
To fix this error and improve the calculate_average function, follow these steps:
1. Modify the calculate_average function to handle empty lists:
def calculate_average(numbers):
if not numbers: # Check if the list is empty
return 0 # or you could return None, or raise a custom exception
total = sum(numbers)
count = len(numbers)
return total / count
2. This modification checks if the input list is empty before performing any calculations. If it is empty, it returns 0 (or you could choose to return None or raise a custom exception, depending on how you want to handle this case).
3. Test the function with both non-empty and empty lists to ensure it works correctly in all cases.
4. If you want to keep the original loop structure, you can modify it like this:
def calculate_average(numbers):
total = 0
count = 0
for num in numbers:
total += num
count += 1
if count == 0:
return 0 # or None, or raise an exception
return total / count
5. Choose the implementation that best fits your needs and coding style.
By implementing one of these solutions, you will prevent the ZeroDivisionError and handle empty lists gracefully.
How it works?
- Prefix your terminal commands with
debug. - If an error occurs, Always-On Debugger automatically captures the context.
- The error context is sent to an AI language model for analysis.
- Debugging suggestions are printed directly to your terminal.
Project Structure
debugger.py: Core Python script that orchestrates the debugging flowllm.py: Handles LLM interaction (prompt generation and response parsing)- (Additional files for terminal wrapping and packaging)
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_code_debugger-0.1.1.tar.gz.
File metadata
- Download URL: ai_code_debugger-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e22f694d153876348e2d8ed849a32bcee363a92e69372cf8ffcb484b070af48
|
|
| MD5 |
4de95c7e9220b4d56161fd1336b557c3
|
|
| BLAKE2b-256 |
f9e8cbda612528d0814e57241e92094f572361a867bbccadcdffe6e1c0d64d70
|
File details
Details for the file ai_code_debugger-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ai_code_debugger-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42f3b3d8bcaf05ccf081603b2430a1eb1d4bceeddfc9a7fe13ad6e1e02b9f2aa
|
|
| MD5 |
55768bd00c9f399a9581032facc4d3af
|
|
| BLAKE2b-256 |
4bd477e52e01fc828eebb117c1bdfd52c1bc98806ec8237b881f6dbc4f01144a
|