I Added Session Management to Aider

Aider is my favorite AI coding assistant. It lives in the terminal, commits directly to Git, and actually understands my codebase. But it was missing one thing: the ability to save and restore chat sessions. So I built it. The PR never got merged, but I've been running my fork for months now. Here's the story.

WORDS: 755 | CODE BLOCKS: 1 | EXT. LINKS: 3

I’ve been using aider as my primary AI coding assistant for a while now. It’s the one tool that actually fits my workflow: terminal-based, Git-native, and it works directly on my local files. No copy-pasting into web forms. No context windows that forget everything. And not waiting for agents to keep thinking.

But it was missing one thing that drove me crazy.

The Problem: Context Evaporates

Here’s the scenario. I’m deep into a complex refactor. I’ve added 15 files to the chat, built up tons of context with the model, and we’re making real progress.

Then one of these happens:

  • I need to step away for a meeting
  • I merge a big feature branch (need to change branches, aider detects repo changes and resets, loosing all context)
  • My terminal session dies
  • I accidentally hit /clear

Poof. All that context is gone. The conversation history, the files I’d carefully curated, everything. Starting over every time was killing my momentum.

I kept thinking: tmux has sessions. Why doesn’t aider?

So I built it.

The /session Command

I added a full session management system to aider. Five simple commands:

bash
 1# Save your current session
 2/session save my-feature-work
 3
 4# List all saved sessions
 5/session list
 6
 7# Peek inside a session without loading it
 8/session view my-feature-work
 9
10# Load a session (clears current chat and restores the saved one)
11/session load my-feature-work
12
13# Delete a session you don't need anymore
14/session delete my-feature-work

That’s it. Now I can save context before stepping away, after hitting a good milestone, or just because I’m paranoid about losing progress.

How It Works

When you run /session save, here’s what happens:

  1. A .aider/sessions/ directory gets created in your repo root
  2. The current state is captured: chat history, editable files, read-only files
  3. Everything gets bundled into a JSON file with metadata (timestamp, aider version)

Loading is the reverse, read the JSON, reset state, restore everything.

The sessions are project-specific (stored in each repo), so you don’t get cross-contamination between projects. And since it’s just JSON files, you can even version control them if you want.

I put the implementation in aider/commands.py and added a full test suite in tests/test_session.py. The tests spin up a temporary Git repo and run all the subcommands.

The PR Situation

Here’s the honest part: my PR never got merged into upstream aider.

I’m not entirely sure why. Maybe the maintainers are busy with other things, or maybe upstream is not in active development. These things happen in open source. Thanks to it being open source, I can still fork and build my own version to use it daily.

But here’s the thing: I’ve been running my fork daily for months now.

Check it out: github.com/vk4s/aider

The feature works great. I use it constantly. Every time I’m about to do something risky or need to step away, I hit /session save. It’s muscle memory now.

Why I’m Still Happy About It

Even without the merge, this contribution taught me a lot:

  1. I got to dive deep into aider’s codebase - Understanding how it manages state, handles commands, and integrates with Git was fascinating.

  2. I scratched my own itch - The best open source contributions come from actual pain points. This wasn’t a theoretical improvement; it was something I really needed.

  3. I use it every day - The feature exists. It works. I benefit from it. That’s a win.

  4. Forking is fine - There’s sometimes stigma around maintaining a fork, but if the upstream isn’t taking your changes and the feature is valuable to you, why not? Keep your fork in sync with upstream, apply your patches, and move on. I’m leaving my pr open in the upstream and when it’s merged I’ll use the upstream version. (:

If You Want Session Management

If you’re an aider user who wants this feature:

  1. Clone my fork: git clone https://github.com/vk4s/aider
  2. Install it: pip install -e .
  3. Use /session save|load|list|view|delete

Or just grab the relevant commits and cherry-pick them into your own setup.


Contributing to open source isn’t always about getting merged. Sometimes it’s about solving your own problems, learning a codebase, and sharing the solution for others who might want it too.

The code is there. The feature works. And I’m still waiting for the day I can delete my fork because it landed upstream.

Until then, /session save peace-of-mind is my new best friend.


PS: I wrote this about 4 months ago, and a lot has changed, we have claude-code, antigravity. But aider is still my favorite AI coding assistant for working with monoliths.