Debugr: An Agentic Coding Tool

Abayomi Popoola
4 min readJun 25, 2024

--

Software engineers know that writing tests and debugging often take longer than writing the initial code. Imagine having a tool that handles these tedious tasks, allowing you to focus on what truly matters — solving real business problems. Enter Debugr: your AI-powered coding sidekick that’s set to optimise your development workflow.

Introducing Debugr

Debugr is a command-line tool that leverages the power of Claude 3.5 Sonnet, an advanced AI model, to autonomously write tests and debug your code. By acting as an agentic coding assistant, Debugr aims to significantly reduce the time and effort developers spend on crucial but often time-consuming tasks. It can understand the context of your codebase, make decisions about what tests to write or which bugs to address, and perform these tasks with minimal human intervention, boosting productivity and letting you focus on the work that matters most.

Agentic coding is an emerging paradigm in software development where AI-powered tools act as autonomous agents to assist developers in various aspects of the coding process. These agents can understand context, make decisions, and perform tasks with minimal human intervention.

Here’s a closer look at how Debugr can transform your development workflow, starting with its code structure.

Code Overview

Debugr is built entirely in Go, using its libraries to ensure easy installation and maintenance. Its repo consists of three main components:

  • cmd/debugr/main.go: The entry point of the application, handling command-line arguments and orchestrating the overall process.
  • client/client.go: Manages communication with the Claude AI API, including request formatting and response parsing.
  • utils/util.go: Provides utility functions for logging and debugging.

Check out the README.md for more information.

Usage

After installation, you can run Debugr from anywhere in your terminal:

debugr [flags] <prompt>

Flags:

  • --context <file>: specify a single file as a context
  • --context-dir <directory>: specify a directory as context
  • --debug: enable debug mode
  • --dry-run: print suggested actions without executing

Examples

1. Writing a Test for a Simple Go Function
Consider a simple Go function in the adder package that adds two numbers.

Directory structure:

To write a test for this function using Debugr, set your ANTHROPIC_API_KEY environment variable: Run export ANTHROPIC_API_KEY=your_api_key_here.

Then run:

debugr --debug --context adder/adder.go "write test for the addNumbers function"

This command will guide you through the process of creating a test file and running the test, ultimately producing an adder_test.go file with comprehensive test cases.

See the output below:

2a. Fixing a Python code bug and testing, with directory context
Suppose you have a Python function that incorrectly solves the Leetcode “Two Sum” problem.

Directory structure:

To debug this code and maintain the current inefficient approach, run:

debugr --context-dir . "debug the twosum: maintain the inefficient solution for now"

Output:

Note the use of --context-dir ., so Debugr knows to use its current dir.

2b. Optimizing Code and Writing Tests

For an optimised solution and corresponding unit tests, Debugr can streamline the process.

Run:

debugr --context-dir . "optimise twosum function for time complexity, and write unit test"

Output:

Future Enhancements

There’s still some work to be done, especially on auto-formatting, leveraging code editor auto-format on save, and expanding support to more programming languages. Currently, Debugr supports Go, Python, and JavaScript.

By integrating Debugr into your development workflow, you can focus more on solving complex business problems and less on the repetitive tasks of writing tests and debugging code. Give Debugr a try and experience the productivity boost firsthand!

--

--