aider
Edit code with AI assistance collaboratively
TLDR
Start a new project or work with an existing code base
Add new features or test cases to specific files
Describe a bug and let aider fix it
Refactor code in a specific file
Update documentation
Display help
SYNOPSIS
aider [options] [file_or_directory ...]
Examples:
aider main.py tests/test_main.py
aider --diff my_feature_branch
aider --model gpt-4o src/
PARAMETERS
file_or_directory ...
Specifies one or more files or directories for Aider to analyze and edit.
-m MODEL, --model MODEL
Selects the AI model to use (e.g., gpt-4o, gpt-3.5-turbo).
--api-key API_KEY
Sets the API key for the chosen Large Language Model provider.
--map-tokens MAP_TOKENS
Controls the maximum number of tokens for mapping source files into the LLM's context.
--no-map
Disables mapping source files to the LLM, reducing context but saving tokens.
--diff DIFF_BRANCH
Generates a diff against a specified Git branch to inform the AI's editing process.
--message MESSAGE
Provides an initial prompt or instruction to the AI, allowing non-interactive use.
--dry-run
Simulates the AI's changes without actually writing them to disk or committing.
--no-auto-commit
Prevents Aider from automatically committing changes to Git.
--yes
Answers 'yes' to all prompts automatically, enabling non-interactive execution.
--dir DIR
Specifies the working directory for the Aider session.
--root ROOT
Sets the root directory of the project, typically the Git repository root.
--verbose
Enables verbose logging for detailed output and debugging information.
DESCRIPTION
Aider is an innovative AI pair programming assistant designed to enhance your coding workflow directly from the command line. Unlike simple code completion tools, Aider functions as an interactive chat interface where you can describe your coding tasks, ask questions, or request changes.
It understands the context of the files you provide, allowing it to intelligently modify existing code, generate new functions, fix bugs, or refactor sections of your project. A core feature of Aider is its deep integration with Git. When Aider makes changes to your files, it automatically stages and commits them, creating clean, descriptive commits that capture the AI's contributions. This ensures that your version control history remains clear and manageable. It supports various Large Language Models (LLMs) and is highly configurable, making it a powerful tool for developers looking to leverage AI in their day-to-day coding tasks, from prototyping to debugging complex systems.
CAVEATS
As an AI-driven tool, Aider is subject to the limitations of Large Language Models (LLMs). This includes potential for hallucinations (generating incorrect or nonsensical code), reliance on the quality of the prompt and context provided, and the need for human review of its suggestions. It requires an active internet connection and an API key from a supported LLM provider (e.g., OpenAI, Anthropic), which typically incurs usage costs based on token consumption. While Aider integrates well with Git, users should still be mindful of the changes it makes and utilize Git's capabilities for review and rollback.
INSTALLATION AND SETUP
Aider is typically installed via Python's package manager, pip:pip install aider-chat
Before use, you usually need to set an API key for your chosen Large Language Model provider (e.g., OpenAI) via an environment variable (e.g., export OPENAI_API_KEY='your_key_here'
) or using the --api-key
option.
INTERACTIVE MODE
When invoked without the --message
option, Aider enters an interactive chat mode. Here, you can converse with the AI, provide new instructions, ask for explanations, or request further modifications to the files. Type /help
for in-chat commands or /exit
to quit.
HISTORY
Aider emerged in the wake of significant advancements in Large Language Models (LLMs), particularly with the widespread adoption of models like GPT-3.5 and GPT-4. Developed by Michael Green, it was designed to bridge the gap between powerful conversational AI and practical, direct code manipulation within a developer's existing workflow. Its initial releases focused on robust Git integration and an intuitive chat interface, distinguishing it from browser-based AI coding tools. Since its inception, Aider has seen rapid development, continually adding support for new LLMs, enhancing its context awareness, and refining its ability to make precise, diff-based edits, solidifying its position as a leading command-line AI pair programming tool.