Core principle: AI generates code at lightspeed. Your job is to conduct the orchestra, not play a single instrument. In an AI-native world, architectural thinking—not syntactic fluency—separates valuable builders from those building houses of cards.
Use this skill for:
Trigger keywords (use liberally):
Before shipping any logic, answer these three questions with certainty. If you cannot, your system is fragile.
The Question: What is the single source of truth for each mutable piece of data?
Why It Matters: Multiple components claiming ownership creates race conditions, sync bugs, and silent data corruption. AI-generated code often scatters state without a coherent strategy.
Audit Process:
Inventory mutable state: Every piece of data that changes (user profiles, order status, inventory counts, cache entries, feature flags, session tokens).
Identify authoritative owner: For each, which component is first to modify it?
Check for replicas: Do other components maintain copies? If yes:
Trace mutation paths: When data changes, does every replica update? How?
Architecture Patterns:
PatternUse WhenTrade-offsSingle Source of Truth (DB)Correctness is critical (payments, inventory, auth)Higher latency (must hit DB)Write-Through CacheHigh read volume, acceptable write latencyMust update cache after DBWrite-Back CacheLow write latency neededRisk of cache loss before syncEvent SourcingNeed audit trail and point-in-time recoveryComplexity, eventual consistencyCQRSRead/write patterns differ radicallyQuery model sync complexityDistributed ConsensusSync state across replicas (e.g., etcd, Raft)Complex, higher latency
Red Flags:
Code Review Checklist:
The Question: How do you know if your system is working? What alerts you to failures?
Why It Matters: A system without visibility is failing silently. By the time a user reports it, the damage may be irreversible.
Audit Process:
Identify critical operations: Data writes, API calls, job scheduling, external integrations, state syncs.
Define success and failure: What does "working" look like for each operation?
Instrument for visibility:
Test observability: Can you reconstruct a failure from logs alone?
Logging Strategy:
text
✅ GOOD: Structured, contextual
{
"timestamp": "2026-04-27T10:30:45Z",
"service": "order-processor",
"operation": "process_payment",
"orderId": "order_12345",
"customerId": "cust_67890",
"status": "failed",
"error": "payment_gateway_timeout",
"retries_attempted": 3,
"latency_ms": 5000,
"trace_id": "tr_abc123def456"
}
❌ BAD: Unstructured, no context
[ERROR] Payment failed. Retrying...
Metrics to Track:
Alerting Strategy:
Red Flags:
Code Review Checklist:
The Question: Can you trace the blast radius of every component?
Why It Matters: If you cannot articulate what happens when a piece is removed, you do not truly understand the system.
Audit Process:
Pick a component (service, module, function, data store, queue).
Simulate deletion:
Continue recursively: Trace cascading effects.
Identify single points of failure (SPOF): Components with no fallback.
Measure blast radius: How many users, transactions, or features are affected?
Blast Radius Analysis:
text
Scenario: Delete the cache layer
A: Web → Cache → DB
If cache is deleted:
- Reads go directly to DB (slower, but correct)
- Throughput drops 10x
- DB CPU spikes
- Users on slow connections timeout
- Blast radius: ALL users
- Mitigation: Circuit breaker (fail fast instead of timing out)
Scenario: Delete the notification service
Orders → Notification Service → Email / SMS
If notification service is deleted:
- Orders still process (good)
- Users don't get confirmation emails (bad UX)
- Blast radius: Marketing, customer trust
- Mitigation: Queue notifications, retry asynchronously
Dependency Mapping:
ComponentDepends OnDepended On ByFallback?SPOF?Auth ServiceDBAll servicesNoYESPayment GatewayExternal APIOrdersRetry + queuePartialCacheIn-memory storeAPIDirect DB readNoNotificationMessage queueOrders, UsersQueue messageNo
Red Flags:
Code Review Checklist:
These practices slow you down. They save you from building on sand.
Workflow:
Example Diagram:
text
Client
|
[API Gateway]
/ | \
Order User Payment
Service Service Service
| | |
[Order DB] [User DB] [Payment Gateway]
| |
[Cache] [Cache]
|
[Message Queue]
|
[Notification Service]
|
[Email / SMS Provider]
Blast radius analysis:
- If Order Service ↓: Can't create orders (orders = core feature)
- If User Service ↓: Can't login (cascade fail)
- If Cache ↓: Slower reads, but queries still work
- If Email Provider ↓: Orders process, confirmations queue, retried
Checkpoint: Can you sketch this in 5 minutes and explain it to someone else? If not, you don't understand it yet. Do not prompt AI.
Use design.md for visual design systems. Use architectural specs for system design.
DESIGN.md is a format specification that combines machine-readable design tokens (YAML front matter) with human-readable design rationale in markdown prose, allowing AI agents to generate on-brand interfaces without needing repeated explanations.
DESIGN.md Structure:
markdown
---
name: ProductName
colors:
primary: "#1A1C1E"
secondary: "#6C7278"
accent: "#B8422E"
success: "#2E7D32"
error: "#C62828"
neutral: "#F7F5F2"
typography:
h1:
fontFamily: "Public Sans"
fontSize: "3rem"
fontWeight: "700"
body:
fontFamily: "Public Sans"
fontSize: "1rem"
lineHeight: "1.5"
spacing:
xs: "4px"
sm: "8px"
md: "16px"
lg: "32px"
rounded:
sm: "4px"
md: "8px"
lg: "16px"
---
## Visual Intent
Describe the aesthetic and emotional tone: minimalist, bold, approachable, professional.
## Color Usage
Explain the semantic meaning of each color and when to use it.
## Typography
Explain font choices and when to use each scale.
## Component Patterns
Define behavior for buttons, cards, forms, modals, etc.
## Accessibility
Document WCAG AA/AAA compliance, contrast ratios, keyboard navigation.
Validation: Use Google's design.md CLI tool to validate the file, check WCAG contrast ratios, and export tokens to Tailwind or W3C DTCG format.
markdown
# [Component Name] Specification
## Purpose
One sentence. What does this do?
## Inputs
- Data structure(s), format, size limits, example payloads
## Outputs
- Data structure(s), format, example payloads
## State Ownership
- What state does this own?
- What state does it read (from where)?
- How are conflicts resolved?
## Critical Path
- Happy path: input → process → output
- Timeline and latency targets
## Failure Modes
| Failure | Probability | Impact | Detection | Recovery |
|---------|-------------|--------|-----------|----------|
| Network timeout | High | Partial | Timeout + log | Retry with exponential backoff |
| Disk full | Medium | Total | No space error | Alert, manual intervention |
| Invalid input | High | Partial | Schema validation | Reject + log |
| Cascade from dependency | High | Partial | Dependency error | Fallback or circuit break |
## Observability
- Logs: what events are logged?
- Metrics: what is measured?
- Alerts: what triggers escalation?
## Constraints
- Performance targets (latency p99, throughput)
- Scaling limits (max concurrent, max data size)
- Dependencies (what must be running first)
## Questions Answered
- Where does state live? [Describe single source of truth]
- Where does feedback live? [Describe observability]
- What breaks if I delete this? [Describe blast radius]
Checkpoint: If you cannot fill this out without guessing, the design is incomplete. Do not proceed.
For each component:
text
[ ] What calls this?
[ ] What does this output to?
[ ] What happens to those dependents if this is gone?
[ ] Are there fallbacks?
[ ] How many users are affected?
[ ] How long until they notice?
Workflow:
Frequency: Weekly for critical code, monthly for infrastructure.
Key distinction: Compilers are deterministic. LLMs are probabilistic.
A compiler follows provably correct rules. You trust it without auditing the machine code.
An LLM makes choices based on statistical likelihood. It can introduce:
Your role: Auditor and architect.
When Claude Code or another agent generates code, audit it against these criteria:
Anti-PatternFailure ModeFixNo State OwnershipRace conditions, sync bugs, data corruptionDesignate a single owner for each data typeScattered StateInconsistency, silent failures, hard to debugCentralize or use consensus protocolSilent FailuresUser reports bug hours later; data is corruptedInstrument everything; alert on anomaliesCircular DependenciesCan't isolate changes; cascading failuresRestructure to acyclic dependency graphSingle Point of Failure (SPOF)One component down = entire system downAdd redundancy, fallbacks, bulkheadsImplicit DependenciesHidden globals, env vars, side effectsMake dependencies explicit; inject themPremature OptimizationComplex code, fragile systems, maintenance nightmareSimplify first, optimize after measurementTight CouplingCan't change one service without affecting othersLoosen via async, contracts, versioningNo MonitoringSystem fails silently; rollbacks are expensiveInstrument every critical operationCache Invalidation"There are only 2 hard things in CS..."Explicit invalidation or TTL; measure hit ratio
These are the hardest problems. Think deeply.
Mutex / Lock:
Atomic Operations:
Immutable Data:
Channels / Queues:
Transactions:
Consensus (Raft, Paxos):
Eventual Consistency:
Event Sourcing:
CQRS (Command Query Responsibility Segregation):
Circuit Breaker:
Create a DESIGN.md (for UI consistency): bash
# Ask Claude Code to generate DESIGN.md
"Create a DESIGN.md file that defines our brand colors, typography, and component patterns."
Create architectural specs (for system design): bash
# Ask Claude Code to scaffold spec documents
"Generate spec templates for each major component: auth, payment, notifications."
Link specs to prompts: text
You are a CTO-level code generator.
When I ask you to build [feature], first:
Reference the spec at /specs/[feature].md
Verify your code satisfies all requirements.
Implement the failure modes listed.
Include structured logging for every operation.
If building UI:
### Prompting Claude Code for Architectural Code
**Good Prompt**:
text
Using the spec at /specs/order-processing.md:
**Why It Works**:
- Clear constraints (spec).
- Explicit error handling.
- Observability requirements (logs, metrics).
- Resilience pattern (circuit breaker).
- Failure modes enumerated.
* * *
## Part 10: Advanced Architectural Patterns (SOTA)
Move beyond simple client-server models into resilient, high-scale patterns.
### 10.1 Cell-Based Architecture (Bulkheading at Scale)
- **Concept**: Divide your system into "cells" (independent instances of the whole stack).
- **Benefit**: If one cell fails, only a fraction of users are affected.
- **Use When**: You hit the "blast radius" limit of a single global monolith/microservice set.
### 10.2 Sidecar / Service Mesh
- **Concept**: Offload cross-cutting concerns (logging, auth, retries) to a separate process.
- **Benefit**: Business logic stays clean; infrastructure logic is centralized and versioned.
- **Use When**: You have multiple languages/services needing consistent observability.
### 10.3 Strangler Fig Pattern
- **Concept**: Incrementally wrap legacy code with new services until the old ones are redundant.
- **Benefit**: Zero-downtime migration of massive legacy systems.
- **Use When**: Refactoring a system too large to "restart" from scratch.
### 10.4 Eventual Consistency & Sagas (Distributed Transactions)
- **Concept**: Use a sequence of local transactions (Sagas) to coordinate a distributed task.
- **Benefit**: No long-lived locks; high availability.
- **Use When**: You need atomicity across multiple databases/services.
* * *
## Part 11: The Cloud-Native Resilience Suite
Advanced techniques for self-healing systems.
### 11.1 Adaptive Throttling
- **Concept**: Instead of a hard rate limit, services reduce throughput based on backend latency.
- **Benefit**: Prevents "death spirals" where retries overwhelm a slow system.
### 11.2 Chaos Engineering (The Ultimate Test)
- **Concept**: Intentionally inject failures into production (latency, termination).
- **Benefit**: Proves the "Blast Radius" theory in real-world conditions.
- **Exercise**: If you can't run the Chaos Test, you haven't answered Pillar 3.
### 11.3 Graceful Degradation (Feature Toggles)
- **Concept**: When a dependency fails, switch to a "light" version of the feature.
- **Example**: If the "Recommendations" service is down, show "Popular Items" (static) instead.
* * *
## Part 12: Evaluation Rubric (Is This System Sound?)
Score yourself 0-3 on each:
Criterion0 - Fragile1 - Risky2 - Solid3 - Resilient**State Ownership**Multiple owners or scatteredSome replicas without strategySingle owner, clear replicasCentral authority + audit trail**Observability**No logging or metricsLogs exist but unstructuredStructured logs, basic metricsFull tracing, anomaly detection**Failure Handling**No fallbacks, cascades failSome fallbacks, partial coverageAll critical failures handledSelf-healing, circuit breakers**Blast Radius**Don't know what's coupledLoosely mappedWell documentedTested via chaos engineering**Testing**No testsHappy path onlyHappy + failure casesConcurrency, performance, chaos**Scaling**Doesn't scaleScales to 10xScales to 100x with planningHorizontal scaling built-in**Dependency Clarity**Hidden globals, side effectsSome explicit, some implicitAll dependencies injectedVersioned contracts, no surprises**Code Quality**Unreadable, no commentsReadable but denseClear intent, documentedSelf-documenting, easy to extend
**Target Score**: 2+ on all dimensions. Anything below 1 is a risk.
* * *
## Summary: What Remains Human in an AI-Native World
AI will replace typing. It will not replace thinking.
The most valuable builders will be those who:
- **Refuse to atrophy their judgment.**
- **Design before coding.**
- **Use AI as an amplifier for architecture**, not a substitute for understanding.
- **Build for resilience, not just functionality.**
- **Instrument everything; monitor relentlessly.**
- **Trace blast radius; understand coupling.**
The shift from "coder" to "conductor" is not optional. It is the price of remaining relevant.
* * *
## Quick Reference: The Three Pillars Checklist
### Pillar 1: Where Does State Live?
- Single owner for each data type
- Non-owners read from owner
- Conflict resolution rules exist
- Replicas are explicit and versioned
- Schema changes are migrations, not surprises
### Pillar 2: Where Does Feedback Live?
- Every critical operation is logged
- Logs are structured and searchable
- Metrics are emitted (latency, errors, throughput)
- Alerts are defined for SLO violations
- You can reconstruct a failure from logs
### Pillar 3: What Breaks If I Delete This?
- Dependencies are explicit
- No circular dependencies
- Fallbacks exist for external services
- Blast radius is documented
- You can trace impact mentally
**If you can answer yes to all 15, your system is sound.**