As artificial intelligence becomes more integrated into software development, some engineers express concern that developers are 'removing their brains' from the equation by delegating entire tasks to AI agents. To counter this trend, a framework called the 'Brain Sandwich' has been proposed as a method to leverage AI's speed without sacrificing the engineer's fundamental skills or oversight. The framework is built on a three-step sequence: human cognition, AI generation, and human review.
The first layer of the 'Brain Sandwich' requires the engineer to read and understand the existing codebase before prompting an AI agent. The goal is to establish a rough mental model of the problem and the intended direction. By doing this first, the engineer prevents the AI from biasing the project toward an incorrect solution or nudging the developer toward building a feature that doesn't actually solve the intended problem. Once this context is established, the engineer can fully delegate the implementation to the AI agent.
The final layer of the framework returns the responsibility to the human engineer. Before submitting any AI-generated code for peer review, the developer must ensure the work is 'reviewable.' This involves reading the diff, evaluating whether the complexity of the AI's solution is appropriate for the specific use case, and writing a clear pull request description. The core principle is that if an engineer cannot explain what is changing and why, the work is not ready for human colleagues to review. This approach aims to ensure that the human remains the primary architect of the logic, even when the AI handles the heavy lifting of the syntax and boilerplate code. [primary]
