README.org

January 10, 2026 · View on GitHub

[[file:./icon.png]]

#+TITLE: AI assisted programming in Emacs with Aider

[[https://melpa.org/#/aider][https://melpa.org/packages/aider-badge.svg]] [[https://stable.melpa.org/#/aider][https://stable.melpa.org/packages/aider-badge.svg]] [[https://github.com/tninja/aider.el/graphs/contributors][https://img.shields.io/github/contributors/tninja/aider.el.svg]]

[[file:README.zh-cn.org][中文版]]

  • Table of Contents
  • [[#introduction][Introduction]]

  • [[#installation][Installation]]

  • [[#frequently-used-features][Most used features (integrated into the aider menu)]]

  • [[#faq][FAQ]]

  • [[#future-work][Future work]]

  • [[#other-emacs-ai-coding-tool][Other Emacs AI coding tool]]

  • If you like the feature of this package, but wish to use Claude Code / Gemini CLI / OpenAI Codex / Github Copilot CLI / OpenCode / Grok CLI, please take a look at [[https://github.com/tninja/ai-code-interface.el][ai-code-interface.el]].

  • Introduction
  • Want AI-powered coding like [[https://www.cursor.com/][Cursor AI Code Editor]] but inside Emacs?

  • [[https://github.com/paul-gauthier/aider][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 ([[./aider-agile.el][TDD, refactoring]]; [[./aider-legacy-code.el][legacy code handling]])
    • [[./aider-git.el][Diff extraction and AI code review tools]]
    • [[./aider-code-read.el][Code / module reading AI assistant]]
    • [[./aider-software-planning.el][Software planning / brainstorming discussion capabilities]]
    • Automated Flycheck error fixes
    • Context expansion (current file’s dependencies & dependents)
    • Code/repo evolution analysis with git blame & log ([[./aider-git.el][Code / repo evolution analysis]])
    • Bootstrapping utilities for new files & projects ([[./aider-bootstrap.el][Utilities for bootstrapping new files and projects]])
    • Repo-specific prompt files ([[./aider-prompt-mode.el][Aider prompt file]])
    • Community & workflow snippets ([[./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.

  • Current version of aider.el is v0.13.1. [[./HISTORY.org][Release history]], [[./appendix.org#recent-new-features][Recent new features]]

[[file:./transient_menu.png]]

  • Installation
  • Emacs need to be >= 26.1

** Melpa + package-install (recommended)

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:

#+BEGIN_SRC emacs-lisp (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) #+END_SRC

  • 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 [[https://melpa.org/#/aider][aider]] package
  • Import and configure aider.el in your init.el or .emacs file:

#+BEGIN_SRC emacs-lisp (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" ) ;; 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 ;; auto revert buffer (global-auto-revert-mode 1) (auto-revert-mode 1)) #+END_SRC

** Helm Support

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)

** [[./appendix.org#other-ways-to-install-aiderel][Other ways to install aider.el]]

  • Frequently used features

*** Aider session management

  • 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 of aider-args for this session.
    • When run it in a dired, eshell, or shell buffer, it will ask you if you want to add [[https://aider.chat/docs/config/options.html#--subtree-only][--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.
  • 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.

*** More ways to add files to the Aider buffer

  • 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

*** Write code

  • 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.
  • 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

*** Support for Agile Development

*** Questions on code

*** Inside comint buffer

  • / 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

*** Aider prompt file - Good place to write and organize prompt

  • 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 shows C-c C-c key pressed when cursor is on the prompt.

[[file:./aider_prompt_file.png]]

  • start aider session in a sub-tree inside aider prompt file:
    • Use subtree-only to start aider session in a sub-tree, where 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.

*** [[./appendix.org#prompt-snippets][Prompt Snippets]]

  • [[./appendix.org#cons-of-aiderel][Cons of aider.el]]

  • [[./appendix.org#be-careful-about-ai-generated-code][Be careful about AI generated code]]

  • [[./best_practices.org][Best Practices]]

  • FAQ

  • TODO Future work

** Feature

  • More thinking on improving code quality tool such as unit-test [4/4]
    • Code refactoring functions
    • TDD functions
    • Code reading functions
    • Legacy code support
  • Bootstrap code or document from scratch
  • [-] Import useful MCP feature to aider [1/2]
    • 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]
    • Dependencies and dependent on current file
    • Relevant files for current context
  • [-] Consider AI + solid / widely used package [1/4]
    • [-] magit [5/6]
      • show last commit
      • show commits history
      • git-blame analysis
      • git-log analysis
      • diff pull / code review
      • suggest code change given code review feedback
    • flycheck
    • compile / test output
    • projectile
  • Thinking on how to simplify the menu / commands
    • Only keep frequently used items in the first level

** Code quality

  • Better unit-test / integration test of this package. Hopefully it is automated.
  • AI Assisted Programming related books

The following books introduce how to use AI to assist programming and potentially be helpful to aider / aider.el users.

  • Other Emacs AI coding tool
  • Contributing
  • Contributions are welcome! Please feel free to submit a Pull Request.