Danial Kalbasi

Notes on engineering leadership, building products, and figuring out what matters.

DRY principle with AI agents

DRY principle translates really well while working with AI agents. Beyond code reuse which can save you a lot of tokens, is "unit of work" reuse.

The idea is simple. Write a clear text file that instructs ai agent to do a single unit of work and let the agent handle the code under the hood.

For instance, if you are diagnosing your app instance on a remote machine, instead of writing an extensive script to fix every scenario, write a text document that is used by the AI agent to connect, diagnose the issue, propose solutions, and fix it. 

Next time when you face the same task, point your agent to the same doc.