The Downside of DRY for AI Agents

For decades, software development has championed the Don't Repeat Yourself (DRY) principle. This paradigm, deeply ingrained in developer education, dictates that every piece of knowledge or logic should have a single, unambiguous, authoritative representation. When code is repeated, it's refactored into a shared function or module, ensuring consistency and maintainability for human developers. This approach minimizes redundancy and makes updates easier when a human needs to modify a core piece of logic. A change in one place propagates everywhere it's used.

However, the rise of Agentic Large Language Models (LLMs)—AI systems capable of planning, writing, and testing entire projects—introduces a fundamental challenge to DRY. Agents like Claude Code, Open Code, and Devin operate differently from human developers. They excel at tasks that involve generating code from scratch based on prompts and context. When faced with a highly abstracted, DRY codebase, these AI agents can struggle to locate the precise piece of logic they need. The abstraction layers, while beneficial for human readability and maintainability, can become opaque barriers for AI, leading to increased complexity in prompt engineering and a higher chance of misinterpretation.

This is where the reconsideration of WET (Write Everything Twice, or Write Every Time) architecture becomes critical. Instead of striving for maximum abstraction and minimal repetition, WET embraces redundancy. The core idea is that by duplicating code snippets or logic where they are used, the AI agent has a more direct, explicit context. This makes it easier for the agent to understand the intent, find relevant code, and generate accurate outputs. While WET might seem counterintuitive to seasoned developers, it aligns better with the current capabilities and operational patterns of AI code generation agents.

Diagram illustrating the difference between DRY and WET code structures for AI collaboration

How WET Benefits Agentic LLMs

Agentic LLMs process information contextually. When code is duplicated, the relevant snippet is immediately present in the agent's working memory or prompt. This direct access reduces the cognitive load on the AI, akin to giving a student a textbook with all relevant pages bookmarked and highlighted, rather than just a reference to a library shelf. The AI doesn't need to navigate complex import statements, resolve dependencies across multiple files, or infer the purpose of a generic utility function. It sees the code it needs, where it needs it.

Consider a scenario where an AI agent needs to implement a specific data validation rule. In a DRY system, this rule might be buried within a utility class, requiring the agent to understand the class structure, the specific method signature, and the surrounding context of its usage. In a WET system, the validation logic might be duplicated directly within the function or module where it's applied. This explicit presence makes it trivial for the AI to grasp and replicate or modify the logic. The agent can more confidently generate code that integrates seamlessly because the necessary components are readily apparent.

Furthermore, WET can simplify prompt engineering for complex tasks. Instead of crafting elaborate prompts that guide the AI through an entire codebase to find a specific function, developers can provide more localized, self-contained code examples. This reduces the risk of the AI getting lost or misinterpreting instructions due to the vastness and abstraction of a DRY project. The AI can focus on the task at hand, leveraging the readily available, duplicated code as its primary reference.

The Practical Implications for Developers

Adopting a WET approach doesn't mean abandoning all principles of good code structure. It's a strategic shift in emphasis for projects heavily reliant on AI code generation. For teams building AI-powered development tools or integrating AI agents into their workflows, this means reconsidering how projects are organized. Instead of abstracting common logic into shared libraries too aggressively, developers might choose to duplicate specific, context-dependent code blocks. This could involve copying small utility functions or configuration snippets directly into the relevant modules or components.

This shift requires a new mindset. Developers accustomed to the elegance and efficiency of DRY might initially find WET to be wasteful or messy. However, the goal is not to create unmaintainable spaghetti code, but to optimize for AI comprehension and generation. The trade-off is a potential increase in code volume for enhanced AI collaboration. The