How I use AI for programming

Sharing my setup of Aider, an open-source CLI for AI programming, with tips on configuration and useful commands.
How I use AI for programming

After experimenting with various AI code editors including Cursor, I have settled with Aider for most of my programming needs.

Aider is an open-source CLI program that works with any Large Language Model (LLM) via API keys. Its strong Git integration fits seamlessly into my existing workflow. Aider is feature-rich, capable of scraping web pages, processing image and PDF files, and analyzing the output of shell commands.

Installation

Installing Aider is straightforward.

Using pip:

python -m pip install aider-install
aider-install

Using one-liner script:

curl -LsSf https://aider.chat/install.sh | sh

Configuration

Aider can be configured in multiple ways including command-line switches, .aider.conf.yml file, environment variables and .env file.

I currently use Gemini 2.5 Pro as the primary model for most programming tasks. Previously, I used Claude Sonnet, but I've found Gemini to be more cost-effective while delivering comparable (if not superior) results.

Here's my current configuration:

AIDER_MODEL=openrouter/google/gemini-2.5-pro-preview-03-25
AIDER_WEAK_MODEL=openrouter/openai/gpt-4o-mini
AIDER_AUTO_COMMITS=false
AIDER_CACHE_PROMPTS=true
AIDER_CACHE_KEEPALIVE_PINGS=12
AIDER_WATCH_FILES=true
AIDER_ANALYTICS_DISABLE=true
AIDER_DARK_MODE=true
AIDER_CODE_THEME="one-dark"

# API Keys
OPENAI_API_KEY=<openai_api_key>
GEMINI_API_KEY=<gemini_api_key>
ANTHROPIC_API_KEY=<anthropic_api_key>
OPENROUTER_API_KEY=<openrouter_api_key>
FIREWORKS_AI_API_KEY=<fireworks_api_key>

Usage

Within Aider, you can issue commands using the /<command> syntax directly in the chat.

Chat modes

Aider supports several chat modes. The ones I use most often are:

  • /ask: Discuss code and ask questions without modifying files.
  • /code: Instruct Aider to make changes to your code files.

Ask-Code workflow

I frequently utilize the Ask-Code workflow. Use ask mode to discuss what you want to do, get suggestions or options from aider and provide feedback on the approach. Once aider understands the mission, switch to code mode to have it start editing your files. All the conversation and decision making from ask mode will help ensure that the correct code changes are performed.

Managing files and chat history

  • /add <file_path>: Add a specific file to the chat context, allowing Aider to read and edit it.
  • /drop <file_path>: Remove a specific file from the chat context.
    • /drop: Remove all files from the chat context.
  • /clear: Clear the chat history while keeping the current files in context.
  • /reset: Remove all files from the context and clear the entire chat history.

IDE mode / watch-files mode

I leverage the watch-files mode for an in-place editing experience, similar to using Cmd-K in Cursor. When Aider runs in this mode, it monitors all files in the repository for AI coding instructions added via any IDE or text editor. Specifically, Aider searches for single-line comments that start or end with AI, AI!, or AI?.

  • AI!: Triggers Aider to gather all AI comments and apply the requested code changes, similar to the /code chat mode.
  • AI?: Triggers Aider to collect all AI comments and answer the posed question, similar to the /ask chat mode.

This feature offers significant flexibility. You can insert multiple AI comments (without the ! or ?) across various files before finally triggering Aider with a concluding AI! or AI?.

A workflow I use often is to start with the AI comments first and then switch to the terminal chat for follow-up questions or refinements. The chat history conveniently includes the context from these AI comments as well.

Other useful in-chat commands

Here are some other commands I frequently use:

  • /commit: Commit edits to the repository. It automatically reviews the git diff and generates a suggested commit message.
  • /model <model_name>: Switch the main LLM used for the chat.
  • /run <shell_command>: Execute a shell command and optionally add its output to the chat context.
  • /tokens: Display the token count for the current chat context.
  • /think-tokens <budget>: Set the thinking token budget, particularly useful for models like Claude 3.7 Sonnet that support this feature.
  • /web <url>: Scrape the content of a webpage, convert it to Markdown, and add it to the chat context.

Additional tools

Besides Aider, I utilize several other tools for my work:

  • Open WebUI: For straightforward programming questions that don't require repository access, I use my self-hosted instance of Open WebUI combined with LiteLLM. This setup provides a single interface for interacting with multiple LLMs.
Building a Unified AI Playground
My Weekend Project with Open WebUI and LiteLLM. How I leveraged open-source tools to create a unified interface for multiple AI models.
  • Perplexity: I rely on Perplexity for AI-powered web searches.

Conclusion

Aider appeals to me because it is open-source, flexible, and CLI based, avoiding lock-in to any specific proprietary IDE.

While this combination suits my current needs, the main point is really about finding the tools and workflow that fit your own style. Everyone works differently, so it's worth experimenting to see which AI tools help you be more productive.

Subscribe to my newsletter

I share my learnings, discoveries and insights through my writing. Receive exclusive content delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!