- Introduction
- Installation
- Most used features (integrated into the aider menu)
- FAQ
- Future work
- Other Emacs AI coding tool
- Want AI-powered coding like Cursor AI Code Editor but inside Emacs?
- Aider is a proven AI pair-programming tool for the terminal.
- aider.el provides a lightweight Emacs UI for Aider—minimizing setup and, after eight months of development, now offering:
- AI-driven agile workflows (TDD, refactoring; legacy code handling)
- Diff extraction and AI code review tools
- Code / module reading AI assistant
- Software planning / brainstorming discussion capabilities
- Automated Flycheck error fixes
- Context expansion (current file’s dependencies & dependents)
- Code/repo evolution analysis with git blame & log (Code / repo evolution analysis)
- Bootstrapping utilities for new files & projects (Utilities for bootstrapping new files and projects)
- Repo-specific prompt files (Aider prompt file)
- Community & workflow snippets (Snippets)
- Simplicity remains core: minimal configuration, clear documentation, and a streamlined menu.
- Designed as a stable, daily productivity tool with each feature thoroughly tested. Most Elisp here was generated by Aider or aider.el.
- Aider.el is under active development. Current version is v.0.13.0. Release history, Recent new features
- Emacs need to be >= 26.1
- Install aider
- Install the emacs dependency library Transient (version >= 0.9.0), Magit, and Markdown-mode using your package manager.
- Install aider.el with the following instruction:
Enable installation of packages from MELPA by adding an entry to package-archives after (require ‘package) and before the call to package-initialize in your init.el or .emacs file:
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
- Use M-x package-refresh-contents or M-x package-list-packages to ensure that Emacs has fetched the MELPA package list
- Use M-x package-install to install aider package
- Import and configure aider.el in your init.el or .emacs file:
(use-package aider
:config
;; For latest claude sonnet model
(setq aider-args '("--model" "sonnet" "--no-auto-accept-architect")) ;; add --no-auto-commits if you don't want it
(setenv "ANTHROPIC_API_KEY" anthropic-api-key)
;; Or chatgpt model
;; (setq aider-args '("--model" "o4-mini"))
;; (setenv "OPENAI_API_KEY" <your-openai-api-key>)
;; Or use your personal config file
;; (setq aider-args `("--config" ,(expand-file-name "~/.aider.conf.yml")))
;; ;;
;; Optional: Set a key binding for the transient menu
(global-set-key (kbd "C-c a") 'aider-transient-menu) ;; for wider screen
;; or use aider-transient-menu-2cols / aider-transient-menu-1col, for narrow screen
(aider-magit-setup-transients)) ;; add aider magit function to magit menu
- aider-args just passed directly to aider CLI, aider options reference
- to avoid introducing unnecessary complexity and learning cost, configuration in aider.el side is minimized.
- if aider-args is empty (default), it will use ~/.aider.conf.yml file. In this way, aider CLI and aider.el share same configuration
- The example models: sonnet, gemini, o4-mini, they charge money, and you need to ask for api key add fund to your api account firstly
Helm enables fuzzy searching functionality for command history prompts. Since it is very possible that we use prompt written before, it could potentially save lots of time typing. This plugin is recommended if you use helm.
If you used installed aider.el through melpa and package-install, just need to (require 'aider-helm)
- aider-run-aider (C-c a a)
- Creates a comint-based, git repo-specific Aider session for interactive conversation.
- Git repository identification is based on the current file’s path
- Multiple Aider sessions can run simultaneously for different Git repositories
- When being called with the universal argument (
C-u
), a prompt will offer the user to change the content ofaider-args
for this session. - When run it in a dired, eshell, or shell buffer, it will ask you if you want to add –subtree-only flag, which only consider files in that directory, to make it faster
- aider-switch-to-buffer (C-c a z)
- Switch to the Aider buffer.
- use
^
in the menu to toggle open aider session in other window inside current frame, or open a dedicate frame for aider session. This is useful when there is more than one monitor, and one frame / monitor is used to hold multi buffers for code, and another frame / monitor hold aider session.
- use
- aider-reset (C-c a s)
- Reset the aider session, drop all files and clear the chat history.
- It is recommended before start a new task in your repo, without restart session. So the old discussion / context won’t interfere the new task.
- aider-open-prompt-file (C-c a p)
- Open the repo specific aider prompt file. This is a good place to write prompt / organize tasks. Prompt can be sent to the Aider session with shortcut.
- aider-add-current-file-or-dired-marked-files (C-c a f)
- Add the current buffer file. If it is used in dired buffer, add all dired marked files.
C-u
prefix to add files read-only.
- aider-add-files-in-current-window (C-c a w)
- Add all buffers in the current window. Good for add 2-3 files
- aider-add-module (C-c a M)
- Recursively add all files with certain suffix list (eg. *.py and *.java) for given directory. You can specify a regex pattern to match the file content to be added. Useful to add files for given topic.
C-u
prefix to add files read-only.
- aider-drop-file (C-c a O)
- Drop a file from the Aider session.
- when it is triggered on a code buffer, it will drop that file
- when the cursor is on a filename in the repo, it will drop that file
- /drop command in aider session buffer or aider prompt file will have file completion on current added files
- aider-implement-todo (C-c a i)
- Implement requirement in comments in-place, in current context.
- If cursor is on a comment line, implement that specific comment in-place.
- If there is a selection region of multi-line comments, implement code for those comments in-place.
- If cursor is inside a function, implement TODOs for that function, otherwise implement TODOs for the entire current file.
- The keyword (TODO by default) can be customized with the variable
aider-todo-keyword-pair
. One example is to use AI! comment, which is as same as aider AI comment feature.
- The keyword (TODO by default) can be customized with the variable
- aider-code-change (C-c a c)
- If a region is selected, ask Aider to change the selected region. Otherwise, ask Aider to change / change the function under the cursor, or general code change on all added files.
- A couple common used prompts provided when you are using aider-helm.el
- It supports inline comment based existing code change requirement. To use this feature, trigger the command when:
- The current line is a comment describing the change
- the current selected region is multi-line comments describing the change
- All the above commands follows code review / apply process
- aider-refactor-book-method (C-c a r)
- for code refactoring using techniques from Martin Flower’s Refactoring book, you can also let AI make the decision on how to refactor, example: this commit addressing this comment
- aider-write-unit-test (C-c a U)
- If the current buffer is main source code file, generate comprehensive unit tests for the current function or file. If the cursor is in a test source code file, when the cursor is on a test function, implement the test function. Otherwise, provide description to implement the test function (or spec).
- If main source code break and test function fails, use
aider-function-or-region-change
on the failed test function to ask Aider to fix the code to make the test pass.
- If main source code break and test function fails, use
- aider-pull-or-review-diff-file (C-c a v)
- let aider to pull and review the code change, it support pull diff for staged files, branch comparison, commits.
- aider-ask-question (C-c a q)
- Ask Aider a question about the code in the current context. If a region is selected, use the region as context.
- You can ask any question on the code. Eg. Explain the function, review the code and find the bug, etc
- A couple common used prompts provided when you are using aider-helm.el
- aider-go-ahead (C-c a y)
- When you are asking aider to suggest a change using above command, maybe even after several round of discussion, when you are satisfied with the solution, you can use this command to ask Aider to go ahead and implement the change.
- aider-code-read (C-c a d)
- Choose the method from the book, Code Reading: The Open Source Perspective, by Diomidis Spinellis, to analyze the region / function / file / module.
- aider-start-software-planning (C-c a P)
- Start an interactive software planning discussion session with Aider, through a question-based sequential thinking process.
- / key to trigger aider command completion
- file path completion will be triggered automatically after certain command
- use TAB key to enter prompt from mini-buffer, or helm with completion
- Syntax highlight, aider command completion, file path completion supported
- Use
C-c a p
to open the repo specific prompt file. You can use this file to organize tasks, and write prompt and send them to the Aider session. multi-line prompts are supported. - People happy with sending code from editor buffer to comint buffer (eg. ESS, python-mode, scala-mode) might like this. This is a interactive and reproducible way
C-c C-n
key can be used to send the current prompt line to the comint buffer. Or batch send selected region line by line (C-u C-c C-n
). To my experience, this is the most used method in aider prompt file.C-c C-c
key is for multi-line prompt. The following example showsC-c C-c
key pressed when cursor is on the prompt.
- start aider session in a sub-tree inside aider prompt file:
- Use
subtree-only <dir>
to start aider session in a sub-tree, where <dir> is the directory to start the session. - This is useful when you want to work on a sub-directory of a large mono repo, and don’t want to wait for aider to scan the entire repo.
- Use
- transient-define-group undefined error:
- Please install latest stable transient package (version >= 0.9.0), so that it have transient-define-group macro
- How to review / accept the code change?
- Comparing to cursor, aider have a different way to do that. Discussion
- Note: Aider v0.77.0 automatically accept changes for /architect command. If you want to review the code change before accepting it like before for many commands in aider.el, you can disable that flag with “–no-auto-accept-architect” in either aider-args or .aider.conf.yml.
- How to disable to aider auto-commit?
- add –no-auto-commits to aider-args. aider-args is passed to aider CLI directly. aider options reference
- in ~/.aider.conf.yml file, add auto-commits: false
- What kind of model aider support? Can aider support local model?
- Yes. Aider support it through LiteLLM. Please refer aider document.
- How to add file to aider session using menu?
- single file, in that file buffer, C-c a f
- two or three files, open all of them in current window as different buffer, C-c a w
- a few files, in same directory, or have same regex pattern: mark them in dired buffer (or find-grep-dired result with regex), C-c a f.
- whole project / module, certain types of suffix file (eg. *.py, *.java), C-c a M
- In large mono repo, aider take long time to scan the repo. How to improve?
- Aider use .aiderignore file to handle this, detail, or, you can turn off git with –no-git in aider-args.
- Or, use the –subtree-only with following way in emacs:
- Used dired, eshell, or shell buffer to go to the directory (subtree) to be included
- C-c a a to trigger aider-run-aider
- Answer yes about –subtree-only question, it will add the flag
- Or, in aider prompt file, use
subtree-only <dir>
to specify where to start, and use C-c C-n to start aider session at that directory, it start with –subtree-only
- How to let aider work with your speaking language?
- use aider coding conventions. In my case, I added “- reply in Chinese” to the CONVENTIONS.md file, and load work through .aider.conf.yml. Or, put sth like following into aider-args variable.
- “–read” (expand-file-name “~/.emacs.d/.emacs/aider/CONVENTIONS.md”)
- use aider coding conventions. In my case, I added “- reply in Chinese” to the CONVENTIONS.md file, and load work through .aider.conf.yml. Or, put sth like following into aider-args variable.
- How to enter multi-line prompts in aider session buffer?
- aider itself support that, doc.
- C-c RET: MatthewZMD/aidermacs#139
- use aider prompt file (
aider-open-prompt-file
,C-c a p
) to write multi-line prompts
- Can aider.el work with tramp? (aider running on remote machine)
- My screen is narrow, the transient menu is too wide, how to make it more readable? (#157)
- Use
aider-transient-menu-1col
oraider-transient-menu-2cols
to use 1 column or 2 columns transient menu.
- Use
- How to customize the aider-comint-mode prompt and input color?
- Spike-Leung said add hook to it will help
- Why aider-code-change got disabled in transient menu?
- It bypass code review and is not recommended. The code quality is not as good as /architect. Discussed here: #128
- More thinking on improving code quality tool such as unit-test [4/4]
- [X] Code refactoring functions
- [X] TDD functions
- [X] Code reading functions
- [X] Legacy code support
- [X] Bootstrap code or document from scratch
- [-] Import useful MCP feature to aider [1/2]
- [X] Software planning discussion
- [ ] Other
- [ ] Learn and migrate useful feature from popular AI coding tool / MCP
- [-] Better way to batch add relevant files from repo to aider session [1/2]
- [X] Dependencies and dependent on current file
- [ ] Relevant files for current context
- [-] Consider AI + solid / widely used package [1/4]
- [-] magit [5/6]
- [X] show last commit
- [X] show commits history
- [X] git-blame analysis
- [X] git-log analysis
- [X] diff pull / code review
- [ ] suggest code change given code review feedback
- [X] flycheck
- [ ] compile / test output
- [ ] projectile
- [-] magit [5/6]
- [ ] Thinking on how to simplify the menu / commands
- Only keep frequently used items in the first level
- Better unit-test / integration test of this package. Hopefully it is automated.
The following books introduce how to use AI to assist programming and potentially be helpful to aider / aider.el users.
- AI-Assisted Programming , by Tom Taulli, April, 2024
- Coding with AI For Dummies, by Chris Minnick, March 2024
- Learn AI-Assisted Python Programming, Second Edition: With GitHub Copilot and ChatGPT, by Leo Porter etc, Oct 29, 2024
- AI-Powered Developer, by Nathan Crocker, September 2024
- Software Testing with Generative AI, by Mark Winteringham, Dec 2024
- Generative AI for Software Development, by Sergio Pereira, will be published in August, 2025
- Vibe Coding, Coming Fall 2025
- Beyond Vibe Coding, by Addy Osmani, will be published in August, 2025
- Inspired by, and Thanks to:
- ancilla.el: AI Coding Assistant support code generation / code rewrite / discussion
- chatgpt-shell: ChatGPT and DALL-E Emacs shells + Org Babel, comint session based idea
- copilot.el: Emacs plugin for GitHub Copilot
- copilot-chat.el: Chat with GitHub Copilot in Emacs
- gptel: Most stared / widely used LLM client in Emacs
- Package depends on this
- ob-aider.el: Org Babel functions for Aider.el integration
- Other tools
- Contributions are welcome! Please feel free to submit a Pull Request.