How to Use Aider to Edit Code with AI in Your Terminal
You have probably used AI to chat about code, but Aider takes it further: it reads your actual files, edits them, and commits the changes to Git automatically. Aider is a free, open-source command-line pair programmer that works with your own choice of AI model. In this guide you will install Aider and use it to make your first real edits to a project.
Why Edit Directly Instead of Copy-Pasting
Copying AI suggestions back into an editor is slow and error-prone. Aider changes the workflow by operating on your repository directly: you describe a change, it plans the edit, applies it to the right files, and creates a commit. Because every change is git-tracked, you can review the diff and roll back if needed. This makes AI coding transparent instead of mysterious.
Step 1: Install Aider
Aider runs on Linux, macOS and Windows (via WSL). The fastest install is usually via your package manager or pip. For example, you can install it with pip in a virtual environment. You will also need an API key for the model you want to use — Aider works with models from Anthropic, OpenAI, Google and others, so pick the provider you already pay for.
Step 2: Open It Inside a Real Repository
Navigate into an existing project directory and launch Aider there. It will detect that the folder is a git repository. If it is not one yet, initialize Git first. Aider needs git context because it uses your repo history and diff to make precise edits and write useful commit messages.
Step 3: Add the Files You Want to Change
Tell Aider which files it is allowed to edit by adding them to the chat session. Add only the files relevant to your task; scoping files keeps the AI focused and prevents it from touching code you did not intend to change. You can add files with a simple command, and Aider will show you what is in its context.
Step 4: Describe Your Desired Change
Now describe what you want in plain language. For example, “add input validation to the signup form” or “fix the bug where the total is wrong when a discount is applied.” Aider will analyze the files in context, propose a plan, and apply the edits. Read the resulting diff carefully to make sure the change matches your intent.
Step 5: Test the Change and Let Aider Commit
Run your tests or the relevant part of your app to confirm the change works. Aider usually creates a commit automatically with a sensible message. If you are not happy, you can ask it to adjust or revert. Because Aider commits cleanly, your history stays reviewable and safe to share with a team.
Step 6: Iterate and Broaden the Edit
Work through your task in small, reviewable steps rather than one giant request. Add more files as the scope grows, ask follow-up questions, and use Aider’s ability to see the whole repo when a change spans many files. Over time you will build a rhythm where Aider handles the mechanical edits and you focus on direction and quality.
Tips for Effective AI Pair Programming
- Scope files tightly. Give Aider access only to what the task touches.
- Make changes incremental. Small commits are easier to review and roll back.
- Review every diff. AI is fast, but you are accountable for the code.
- Keep tests running. A solid test suite catches what a quick read misses.
- Write clear prompts. Good descriptions produce good, on-target edits.
AI pair programming becomes truly useful when the tool edits your codebase, not just your chat window. With Aider, you get that power free and open-source, right in your terminal. Install it, open a repository, and make your first tracked edit today — then let it grow into a regular part of how you build software.
