How I Use LLMs (Sep 2024)

Aider is pretty cool

It feels a bit early to be writing an update to something I wrote 1.5 months ago, but we live in interesting times. Shortly after writing that post, I started trying out Aider with Claude 3.5 Sonnet. Aider’s an open source Python CLI app that you run inside a Git repo with an OpenAI/Anthropic/whatever API key1.

My Aider workflow

  1. I direct Aider toward a file or multiple files of interest (with /add src/main.rs or similar)
  2. I describe a commit-sized piece of work to do in 1 or 2 sentences
  3. Aider sends some file contents and my prompt to the LLM and translates the response into a Git commit
  4. I skim the commit and leave it as is, tell Aider to tweak it some more, tweak it myself, or /undo it entirely

This works shockingly well; most of the time, Aider+Claude can get it right on the first or second try. This workflow has a few properties that I really like:

  1. It’s IDE-agnostic (no need to switch to something like Cursor)
  2. It’s very low-friction, which encourages trying things out
    1. No need to copy code from a browser, write commit messages, etc.
    2. Undoing work is trivial (just delete the Git commit or run /undo)
  3. It’s pay-as-you-go (I pay Anthropic by the token, no monthly subscription)

Prompts

Here are some examples of the prompts I do in Aider:

  • Library updates should be streamed to all connected web clients over a WebSocket. Add an /updates websocket in the Rust code that broadcasts updated LibraryItems to clients (triggered by a successful call to update_handler). The JS in index.html should subscribe to the WebSocket and call table.updateData() to update the Tabulator table
  • Add a new endpoint (POST or PUT) for adding new items to the library. It will create a new LibraryItemCreatedEvent, save it to the DB, apply it to the in-memory library, then broadcast the new item over the websocket
  • add a nice-looking button that bookmarks the current song. don’t worry about hooking it up to anything just yet
  • Add a new “test-api” command to justfile. It should curl the API exposed by add_item_handler and check that the response status code is CREATED
  • Write a throwaway C# program for benchmarking the the same SQLite insert as create_item() in lib.rs

I’m still developing an intuition for how to write these, but with all of these examples I got results that were correct or able to be fixed up easily. Sometimes I am very precise about what I want, and sometimes I am not; it all depends on the task at hand and how confident I am that the LLM will do what I’m looking for.

What does all this mean?

I dunno! The world is drowning in long-winded AI thinkpieces, so I’ll spare you another one.

All I know for a fact is that if I have a commit-sized piece of work in mind, there’s a very good chance that Claude+Aider can do it for me in less than a minute — today. I’m still exploring the implications of that, but Jamie Brandon’s Speed Matters post feels very relevant. I can try out more ideas and generally be more ambitious with my software projects, which is very exciting.


  1. You can also point Aider at a locally-hosted LLM, which is cool, but in my experience the quality is nowhere near as good as Claude. ↩︎

headshot

Cities & Code

Top Categories

View all categories