This article discusses the critical importance of defining hard module boundaries, data ownership, and clear contracts in software architecture, especially when leveraging AI for internal module implementation. It highlights how urgency can lead AI to take low-friction shortcuts, blurring boundaries, and proposes a minimal set of practices to maintain architectural integrity and prevent systemic failures.
Read original on Dev.to #architectureThe article emphasizes that while AI can assist with internal module implementation, critical human attention must remain focused on higher-level architectural concerns. This includes defining clear business problems, core domains, system cuts, module boundaries, and explicit contracts. Failing to solidify these foundational aspects can lead to significant architectural debt, regardless of the 'prettiness' of AI-generated code.
A key pitfall highlighted is when teams delegate almost all in-module implementation to AI without clearly defined boundaries. This can lead to modules quietly coupling through shared resources (like a common database table), where a change in one module's data interpretation or transaction boundary can cause data divergence and system failures in another. The problem isn't AI's internal implementation but the lack of a truly hard boundary enforced beforehand.
AI's Shortcut Tendency under Urgency
The article presents an experiment showing that under conditions of urgency ('ship soon / change little'), AI models are significantly more likely to choose 'soft boundaries' (e.g., direct SQL access to another module's table) over 'hard boundaries' (e.g., using an API or event). This underscores the need for explicit architectural guardrails.
To counter the tendency towards soft boundaries, especially under pressure, the article advocates for a minimal sufficient set of practices to establish hard boundaries early in the development process:
| Means | When | Role |
|---|
The article stresses that these practices should be established upfront, particularly in a rules file (e.g., `.cursorrules`, `CLAUDE.md`), to ensure that constraints are enforced by tools and not solely by human memory. This proactive approach helps to block the low-friction shortcuts AI might take under pressure.
Humans should focus their review on seams and contracts, rather than every line of AI-generated code. This involves watching for abnormal signals that indicate architectural erosion, such as a single pull request touching multiple modules, breaking changes without versioning, unchecked core invariants, rising reverse dependencies or cycles, multiple writers on a single table, and cross-module SQL queries.