This is Week 6 of “Building with AI” - a 10-week journey documenting how I use multi-agent AI
workflows to build a production-grade SaaS platform.This week: The perfect counter-example to Week 5. Instead of asking AI to fix cascading errors,
I showed it our architecture docs and asked “how should we design this?” The result: a complete
AWS client factory with 39 tests, 2,364 lines of code, in 3 days. When AI has good inputs, it excels.Previous: Week 5: When AI Fails
Watch the 60-Second Summary
Week 6: Breaking changes and macro evolution
The Setup: After Week 5’s Humbling
Coming off Week 5’s disaster (30 commits to fix one breaking change), I needed a win. But more importantly, I needed to understand when AI works and when it doesn’t. Week 5’s lesson: AI is terrible at reactive debugging of cascading errors. Week 6’s hypothesis: Maybe AI is good at proactive design when given proper constraints? The test case: Our SaaS platform had sprawled across 9 Rust crates using 16 different AWS SDKs. Each crate created AWS clients ad-hoc wherever they needed them. DynamoDB clients in auth handlers. S3 clients in upload endpoints. SQS clients scattered everywhere. The Problem: No consistent pattern for credential management, no scope enforcement, and worst of all—possible cross-tenant data access because clients had no concept of isolation boundaries. The experiment: Could multi-agent AI analyze our existing architecture decisions and design a unified client factory?What We Built This Week
The Challenge
By January 2026, the platform needed a unified way to manage AWS clients that:- Enforced our 4 operational scopes (platform, tenant, capsule, operator)
- Prevented cross-tenant data leaks automatically
- Handled cross-account assume-role properly
- Migrated 3 existing crates without breaking production
The Multi-Agent Discovery
Here’s what was different from Week 5: Week 5 (reactive): “Fix these 214 compilation errors” Week 6 (proactive): “Given our isolation constraints in ADR-0010, how should we manage AWS clients?”What AI Did
The Evaluator agent analyzed ADR-0010 (our data isolation architecture doc) and discovered we had 4 distinct operational scopes:- Platform-wide (metrics, logs, shared infrastructure)
- Tenant-scoped (customer-specific resources)
- Capsule-scoped (SDLC environments: dev/staging/prod)
- Operator (cross-account provisioning)
What Human Did
I provided the architectural constraints from ADR-0010, reviewed the proposed client hierarchy, and added one critical piece AI missed: credential caching for assume-role operations. AI doesn’t know that AWS STS assume-role calls add 200-500ms latency. That’s operational knowledge from production experience.The Four Client Types
The pattern AI discovered maps operational scopes to client types:The Capsule Pattern (AI’s Best Discovery)
The most interesting discovery was the capsule client. AI noticed our ADR required SDLC isolation (dev data shouldn’t appear in prod), and proposed automatic table prefixing:What Went Wrong (And How We Fixed It)
But notice: This was a design gap, not a cascading error. We caught it in review before any code was written. Week 5’s problems came from reactive fixing; Week 6’s problems were caught proactively.Migration Strategy
We migrated 3 crates in Phase 1 to validate the pattern: Before (auth crate):- auth crate: 14 files changed
- crm crate: 22 files changed
- catalog crate: 8 files changed
Week 6 vs Week 5: The Contrast
- Week 5: Reactive Fixing
- Week 6: Proactive Design
- The Lesson
Task: Fix 214 compilation errors from macro changeAI Approach: Fix one error at a time, commit after eachResult: 30 commits, 24 hours, still had errorsWhy it failed:
- AI had no global view of the problem
- Each fix created new errors
- Optimized locally, not globally
- Hallucinated solutions when stuck
Key Learnings This Week
Learning 1: ADRs Are AI's Best Input
Learning 1: ADRs Are AI's Best Input
What worked: Giving AI our ADR-0010 (data isolation architecture) let it design a solution that automatically complied with our constraints.Why it worked: ADRs are structured, complete, and describe “why” not just “what.” Perfect for AI analysis.New practice: Before asking AI to build infrastructure, write an ADR documenting the constraints. Then let AI design within those boundaries.Contrast with Week 5: Week 5 had no design doc. Just “fix these errors.” No wonder it failed.
Learning 2: Design Phase Prevents Cascades
Learning 2: Design Phase Prevents Cascades
What we did differently: Evaluator → design review → implementation → verification per crateWhy it worked: Caught the credential caching issue in design review, before any code was written.Week 5 mistake: Implement macro change, then try to fix all affected code reactively.Week 6 success: Design client factory, review with human, implement one crate at a time atomically.
Learning 3: AI Discovers Patterns Humans Miss
Learning 3: AI Discovers Patterns Humans Miss
The insight: No human would have looked at ADR-0010 and immediately thought “4 scopes = 4 client types.”Why AI saw it: AI is excellent at pattern matching between documentation and code structure.The value: We got a more elegant design than we would have built manually. The capsule client’s automatic prefixing was AI’s idea, not ours.Caveat: AI still needed human to add credential caching. Pure pattern, but missing operational optimization.
Learning 4: Atomic Migration Beats Big Bang
Learning 4: Atomic Migration Beats Big Bang
What we did: Migrate 3 crates one at a time, each fully tested before moving on.Why it worked: Each crate was either old (working) or new (fully migrated). No intermediate broken states.Contrast with Week 5: Tried to update 4 crates simultaneously. Created 30 commits of broken intermediate states.The principle: For systematic refactoring, migrate completely or not at all. No partial migrations.
Metrics: Week 6 By The Numbers
- Speed
- Quality
- Code Impact
Development time:
- Time without AI: ~2 weeks (design + implement + migrate)
- Time with AI: 3 days (1 day design, 2 days migration)
- Savings: 78%
- auth: 6 hours
- crm: 8 hours
- catalog: 4 hours
Actionable Takeaways
Based on Week 5’s failure and Week 6’s success:- Write ADRs before asking AI to design - Document your constraints, isolation boundaries, naming conventions. Let AI design within those constraints.
- Use Evaluator for design, not debugging - AI excels at “given constraints, propose solution.” AI fails at “fix these cascading errors.”
- Atomic migration strategy - Migrate one component completely, test, then move on. Never commit broken intermediate states.
- Add operational knowledge - AI designs pure patterns. Humans add caching, performance optimizations, production battle-tested improvements.
- Review before implementing - Catch design gaps (like credential caching) before writing code. Much cheaper than fixing post-implementation.
The Redemption Arc
Week 4: AI excels at systematic work (107 commits, everything green) Week 5: AI fails at reactive debugging (30 commits, cascading errors) Week 6: AI excels at proactive design (2,364 lines, 0 production bugs) The pattern:What’s Next
Week 7 Preview: Taking the AWS client factory and the multi-agent workflow, we’ll tackle configuration governance. Another proactive design challenge where AI can analyze our config hierarchy and generate middleware that enforces it automatically. The hypothesis: If ADR-driven design worked for AWS clients, it should work for config management too.Discuss This Week
Have you built multi-tenant infrastructure? How do you enforce isolation boundaries? Share your
AWS client patterns or ask questions about the ADR-driven design approach.
Disclaimer: All examples are from personal projects. No proprietary code or employer-specific
patterns included.