How to Install Aider - AI Coding Assistant Chatbot

Taehyeong LeeTaehyeong Lee
3 min read

Introduction

  • Aider is an open-source AI coding assistant chatbot based on the console terminal. It outperformed Amazon Q Developer Agent in the SWE benchmark and is continuously being actively updated. In this post, I've summarized how to use Aider with the Azure OpenAI GPT-4o and Amazon Bedrock Claude 3.5 Sonnet models.

Installing Aider

  • Install Aider as follows: (Python is required before installation)
# Install Python
$ brew install python3 pipx

# Install Aider
$ pipx install aider-chat
$ pipx runpip aider-chat install boto3
$ playwright install --with-deps chromium

# Upgrade Aider to the latest version
$ pipx upgrade aider-chat

# [Optional] Activate dark mode
$ nano ~/.bashrc
export AIDER_DARK_MODE=true

# [Optional] Add an alias to quickly list files for the /add command
$ nano ~/.bash_aliases
alias aiderls="find . -type f | git check-ignore --stdin -v -n | grep '^::' | cut -f2- | sed 's|^\./||'"

Setting up Azure OpenAI GPT-4o

  • With the release of OpenAI GPT-4o on May 13, 2024, it became the recommended model for Aider. Here's how to set up the GPT-4o model deployed on Azure:
$ nano ~/.bashrc
export AZURE_API_BASE=https://{your-azure-open-ai-gpt-4o-deployment-name}.openai.azure.com
export AZURE_API_KEY={your-azure-openai-instance-api-key}
export AZURE_API_VERSION=2024-02-01

$ nano ~/.bash_aliases
alias aidero="aider --model azure/{your-azure-open-ai-gpt-4o-deployment-name}"

Setting up Amazon Bedrock Claude 3.5 Sonnet

  • With the release of Claude 3.5 Sonnet on June 20, 2024, it has become one of the most recommended models along with OpenAI GPT-4o. Personally, it has become my preferred model for coding at this point. Here's how to set up the Claude 3.5 Sonnet model on Amazon Bedrock:
$ nano ~/.bashrc
export AWS_ACCESS_KEY_ID={your-aws-access-key}
export AWS_SECRET_ACCESS_KEY={your-aws-secret-access-key}
export AWS_REGION_NAME={your-aws-region-name}

$ nano ~/.bash_aliases
alias aiders="aider --model bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 --no-stream --chat-mode ask"
alias aider="aiders"

Running Aider

  • Run Aider in the project root as follows:
# Run Aider in default console mode
$ aider

# Run Aider in default console mode + specify target files
$ aider {file-path-1} {file-path-2} {file-path-3}

# Run in Browser mode
$ aider --browser
  • The target project should be managed with Git to maximize Aider's coding assistant capabilities. This is because, in addition to the source code, it provides the LLM with the file map from Git as context to use related files in the assistant.

  • You can specify multiple existing files or new files to be written as coding targets when running. Or you can add them later using the /add command after execution.

Real-world Example

  • Below is an example of running Aider after creating a basic skeleton project for Spring Boot:
# Create a basic Kotlin, Spring Boot project
$ sdk install springboot
$ spring init --type gradle-project-kotlin --language kotlin --java-version 21 --dependencies=web demo
$ cd demo

# Start in /ask mode to provide answers to questions without code modifications
$ aider --chat-mode ask "build.gradle.kts"
ask> What language and framework was this project created with?

This project is built with the following technology stack:

 • Main programming language: Kotlin (version 1.9.25)
 • Framework: Spring Boot (version 3.3.5)

Looking at the build.gradle.kts file:

 • It uses Kotlin JVM and Kotlin Spring plugins.
 • It's based on the Spring Boot framework.
 • It's configured to use Java 21.

Key dependencies include:

 • spring-boot-starter-web
 • jackson-module-kotlin (module for JSON processing)
 • kotlin-reflect, etc.

This indicates that it's a Spring Boot web application written in Kotlin.

# Use /code mode to give instructions for code creation and editing
ask> /code Create a simple calculator program.

# Run build command in /run mode to check if the code works properly
ask> /run ./gradlew build -x test

# If build errors occur, give instructions for fixes
ask> /code Fix the build errors.

# Give instructions for modifications based on advanced reasoning
ask> /architect Are there any areas for improvement in the calculator program?

# Exit Aider
ask> /exit

References

2
Subscribe to my newsletter

Read articles from Taehyeong Lee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Taehyeong Lee
Taehyeong Lee