This article is part of the “Building with AI” series documenting my journey using multi-agent AI workflows to build production systems.All examples are from personal projects and do not represent employer technologies.
The Challenge
By December 2025, my platform had 20+ Rust crates, each one built by asking AI to “implement feature X.” The result? Architectural inconsistency everywhere. Some crates used capsule isolation. Some didn’t. Some followed naming conventions. Some invented their own. The Problem: How do you maintain architectural consistency when AI agents build your code? AI Focus: Can architecture documentation serve as enforceable constraints for AI implementation? System Example: Architecture Decision Records (ADRs) that AI reads, understands, and automatically complies with during code generation.The Turning Point
I discovered ADRs aren’t just decision logs—they’re architectural contracts that AI can enforce. Here’s what changed: Instead of telling AI “build it this way,” I wrote ADR-0010 (Capsule Isolation) defining table naming, partition key patterns, and scope rules. Then I told AI: “Implement this feature. Follow ADR-0010.” The result? AI generated code that perfectly followed the isolation patterns because it could parse the ADR’s structured constraints.- What AI Did
- What Human Did
- Result
Read ADR-0010 and extracted 4 enforceable rules:
- Table names must use capsule prefix:
{CAPSULE_CODE}_{table} - Partition keys must include capsule:
TENANT#...#CAPSULE#... - EventEnvelope.capsule_id is required (not Optional)
- All GSI patterns include capsule boundary
How ADRs Guide AI
Traditional ADRs document decisions. AI-friendly ADRs define constraints in structured formats.Before (Decision Log):
After (Constraint Definition):
- Exact naming patterns to follow
- Code examples to reference
- Validation rules to enforce
The ADR Workflow
Here’s how ADRs integrate with multi-agent development: 1. Problem DetectionWhat Went Wrong
The 4 ADRs That Changed Everything
During Dec 31, 2025 - Jan 30, 2026, we wrote 4 critical ADRs:ADR-0010: Capsule Isolation Enforcement
ADR-0010: Capsule Isolation Enforcement
Problem: Dev data leaking to production environments.Constraint: All capsule-scoped entities must:
- Use capsule-prefixed table names
- Include capsule in partition keys
- Require capsule_id (not optional)
ADR-0016: Foreign Keys & Cascading Operations
ADR-0016: Foreign Keys & Cascading Operations
Problem: Deleting a parent entity leaves orphaned children.Constraint: Use SagaStep macro for multi-entity operations with compensation logic.Impact: Enabled complex workflows like account merges with automatic rollback.
ADR-0018: Unified AWS Client Management
ADR-0018: Unified AWS Client Management
Problem: 16 AWS SDKs used inconsistently, no scope enforcement.Constraint: 4 client types (Platform, Tenant, Capsule, Operator) with mandatory scope parameters.Impact: Eliminated 600 lines of boilerplate per crate, enforced isolation at SDK level.
ADR-0019: Comprehensive Testing Standards
ADR-0019: Comprehensive Testing Standards
Problem: Inconsistent test coverage across crates.Constraint: 4-level test pyramid (Unit, Integration, E2E, Contract) with coverage targets.Impact: Increased platform test coverage from 60% to 85%.
Key Learnings
AI Strength
AI excels at following structured constraints. Give it a table of partition key patterns, and every entity it creates will match exactly. No drift, no variance.
AI Weakness
AI can’t write good ADRs. It doesn’t know your pain points or operational constraints. ADR authorship must be human-driven.
Human Role
Humans write ADRs capturing architectural constraints and operational learnings. AI implements features following those constraints automatically.
Process Insight
The best process is: Human writes ADR → AI reads ADR → AI generates code → Human verifies ADR compliance. This scales to any number of AI agents.
Actionable Takeaways
If you’re building with AI assistants:- Write ADRs before coding - Define your constraints as ADRs before asking AI to implement features. ADRs become the “specification” AI codes against.
- Use structured formats - Code blocks, tables, bullet lists. Avoid prose. AI parses structure better than narratives.
- Reference ADRs in commits - We enforce
ADR-XXXXreferences in commit messages via pre-commit hooks. This creates an audit trail.
Metrics
- Compliance
- Velocity
- Quality
- ADRs written: 4 major architectural decisions
- Commits referencing ADRs: 67 in 30 days
- ADR compliance rate: 100% (after pre-commit hooks)
- Architectural drift incidents: 0
The ADR Template We Use
Resources & Further Reading
- Architectural Decision Records (ADRs)
- When to Write an ADR
- Related article: AWS Runtime Adoption (Week 5)
Next in This Series
Week 6: How we used ADR-driven middleware to eliminate 100% of manual configuration lookups.Week 6: Configuration Governance
The middleware pattern that made configuration hierarchical and automatic
Discussion
Share Your Experience
Do you use ADRs? How do you keep AI implementations consistent with architecture?Connect on LinkedIn or comment on the YouTube Short
Disclaimer: This content represents my personal learning journey using AI for a personal project. It does not represent my employer’s views, technologies, or approaches.All code examples are generic patterns or pseudocode for educational purposes.