lassence.net

Field notes from the AI frontier

My method for complex code changes with an agent

--- date: · theme: build · words: 341 ---

A more technical post today, apologies to those who don’t code.

When I need to make complex code changes, especially in an area where I’m no expert, here is the method I’ve worked out over the past few months to steer the LLM agent (usually Claude 4) in Visual Studio Code:

  1. First, I describe clearly the change I want (“the target end state”) and ask for a detailed plan, step by step. That lets me check it has understood what I’m after, and at the same time it narrows down the context (dependencies, constraints, and so on).

  2. If the plan holds up, I tell it to start on the changes, one step at a time. For functions that can be fleshed out later, I have it drop in placeholders so it doesn’t get overloaded.

  3. Once the changes are in: test, test, test again. If I find problems, we handle them one at a time, never as a catch-all list.

  4. When everything is stable, I commit. That way, if the next steps get bogged down, I can fall back to a working version.

  5. Then I turn to the quality of the generated code. The assistant tends to write new lines without caring whether it could reuse what’s already there, or remove what has become dead. So I ask it to refactor in two passes:

    • Is there any stale or redundant code? If so, we delete it.
    • Suggest overall improvements. It always comes up with some, but I only have it apply the ones that look genuinely useful to me.
  6. One last round of tests. If everything works and we haven’t broken anything on the way: final commit.

Focused, and with a coffee at the right temperature, I can get done in two hours what would have taken me whole days last year.