What are the design criteria and non-functional requirements that must be specified explicitly when AI generates code, so that the output is production-grade software an experienced engineer would trust?
Sign in to follow this trunk and contribute
This tree defines the non-functional requirements that must be specified explicitly when AI generates code. Companion resource to Designed to Fail (Substack).
It is NOT a checklist. It is a reference of the questions experienced engineers carry in their heads — the ones that get skipped when AI generates code too fast for the old forcing functions to work. Every leaf is framed as a question to ask or a requirement to specify, not a rule to follow.
Companion standard: SAM (Software Architecture Manifest). The questions in this tree have been formalized into a producer-signed, machine-readable manifest format. This trunk is the reasoning layer (what to ask during build); SAM is the declaration layer (what producers attest to on the shipped software). Spec: https://software-architecture-spec.github.io/sam/v0.2/SPECIFICATION.md · Schema: https://software-architecture-spec.github.io/sam/v0.2/schema.json
Step 1: Match the task to the branches. Not every branch applies. A schema task → Data Integrity, Scalability. An API endpoint → Performance, Security, Reliability, Observability, Testability, Interoperability. A UI component → Accessibility. Scale diligence to scope — don't dump all branches on a utility function.
Step 2: Check what's specified vs. missing. Compare the human's prompt against the what:requirement leaf for each relevant branch. What's stated? What's absent?
Step 3: Check the connections for tensions. Before generating code, check whether the relevant branches have connections flagging impossibilities or trade-offs. If the task touches Data Integrity AND Reliability AND Performance, the CAP/PACELC connections apply — you cannot promise strong consistency, high availability, and low latency simultaneously. Declare the posture. State which side the implementation chooses and why.
Step 4: Surface gaps, then proceed. Don't block on missing requirements. State a reasonable default and flag it: "No response time target specified — designing for <200ms at P95. Override if needed (see Performance & Efficiency branch)." Reference the branch name so the human can look it up.
Step 5: Apply the patterns. Use how:pattern leaves for structural decisions. These are architectural choices, not library recommendations. Follow them unless the human specifies otherwise.
Step 6: Respect the timing. when:trigger leaves say when a requirement must be addressed. "Before the first table" means do not generate a schema without it. "In the implementation prompt" means include it now, not later.
Non-negotiables while generating code:
<button>, <nav>, <label>), not <div> with click handlers. Include ARIA labels. Manage focus on state changes. Costs nothing extra.Do not:
When operating autonomously (chaining prompts without human review between steps), additional constraints apply. The risk of autonomous operation is that errors compound — each step builds on the previous step's assumptions without a human checkpoint.
The Agents Rule of Two (derived from Chrome's Rule of Two, extended by Meta 2025 and Simon Willison's "lethal trifecta"):
An AI agent must never simultaneously hold all three of:
Any two are acceptable. All three complete an attack chain: a prompt injection in untrusted input can hijack the agent to exfiltrate sensitive data via external communication.
Mitigation for autonomous agents:
Blast radius controls for autonomous operation:
Branches = quality attributes (non-functional requirement categories). Each quality-attribute branch contains three leaf types:
| Tag | Purpose | Example |
|---|---|---|
what:requirement |
Testable specification an AI can implement against | "P95 response time under 200ms" |
how:pattern |
Architectural pattern, tooling-agnostic | "Circuit breaker on every external call" |
when:trigger |
When to address it + cost of deferral | "Before the first table is created" |
Tags use lowercase:colon format.
Reading order for humans: when → what → how. Start with when:trigger — it tells you whether this branch is relevant to what you're doing right now. If the trigger applies, read what:requirement for the specifications to include in your prompt. Then optionally read how:pattern for implementation guidance. The trigger is the filter; most branches won't apply to most tasks.
Connections = declared tensions between leaves in different branches. These encode trade-offs, impossibilities, and coupling relationships. Read the rationale on each connection — it names the specific tension and the question to resolve.
Good: Concrete, implementable, tooling-agnostic. A what:requirement an engineer can paste into a prompt. A how:pattern that describes a structural decision. A when:trigger that names the moment and quantifies deferral cost.
Bad: Vague aspirations ("The system should be secure"). Tool-specific advice ("Use Redis" — say "implement a caching layer"). Leaves without tags. Content that reads like compliance rather than questions to ask.
Connections: A good connection names the specific trilemma or tension, states whether it is a true three-body problem or a soft tradeoff, and ends with the question the human must answer. A bad connection says "these are related."
Response time, throughput, resource utilization, and query efficiency. The difference between a page that loads and a page that loads in under 200ms.
Tag: when:trigger
Performance requirements must be specified before the first implementation prompt. Performance is an input to design, not a retrofit.
Every sprint of deferral compounds. Code generated without performance constraints becomes load-bearing before anyone measures it. By the time someone runs a profiler, the slow query is called from twelve places, the unbounded list endpoint is consumed by three downstream services, and the fix requires rewriting the data access layer.
The cost of deferral is not linear — it is exponential. A performance requirement specified in the first prompt costs one sentence. The same requirement specified after three months of AI-generated code costs a rewrite.
The question to ask: Have I defined performance targets before asking the AI to generate any implementation code?
Tag: what:requirement
Define response time targets at P50, P95, and P99. Specify the maximum number of database round trips per page load or API endpoint. Set memory and CPU budgets per request.
These are not stretch goals — they are acceptance criteria. Include them in the prompt so the AI optimizes against them. Without explicit targets, the AI will produce code that returns correct results with no regard for how long it takes or how many resources it consumes.
Example specification: "Each API endpoint must respond in under 200ms at P95 under expected load. No endpoint may execute more than 3 database queries. Memory allocation per request must not exceed 50MB."
The question to ask: What are the response time, throughput, and resource budgets for this endpoint, and are they in the acceptance criteria?
Tag: how:pattern
Specify the data access pattern before asking the AI to build the data layer. This means:
The question to ask: What is the data access pattern for this feature, and have I specified it before asking the AI to build the data layer?
What happens when things go wrong. Failure modes, graceful degradation, retry logic, circuit breakers, and the difference between an error the user sees and an error the system handles.
Tag: when:trigger
Resilience requirements belong in the acceptance criteria for every feature that touches an external dependency. The happy path is the feature. The failure path is the engineering.
AI will only build the happy path unless you specify the failures. If your prompt says "call the payment API and process the result," you will get code that calls the payment API and processes the result. You will not get timeout handling, retry logic, circuit breaking, or fallback behavior. Those are separate requirements that must be separately specified.
The cost of deferral: every feature shipped without failure handling is a production incident waiting for its trigger. The trigger is not "if" — it is "when." External services go down. Networks partition. Databases slow under load. The only question is whether your system handles it gracefully or pages someone at 3 AM.
The question to ask: Does the acceptance criteria for this feature specify what happens when every external dependency fails?
Tag: what:requirement
Define the expected behavior for every failure mode:
For each failure mode, specify: retry (how many times, with what backoff), degrade (what reduced functionality is acceptable), or fail (what error the user sees). Define recovery time objectives — how quickly must the system return to full function after a failure resolves?
The question to ask: For every external dependency this feature touches, what happens when that dependency fails?
Tag: how:pattern
Standardize resilience patterns across the codebase. Do not let the AI invent a different error handling strategy per module.
The question to ask: Is there a single, documented resilience strategy that every AI-generated module follows?
Input validation, authentication, authorization, data protection, and the principle that every boundary between systems is a trust boundary that must be explicitly defended.
Tag: when:trigger
Security requirements must be specified in the initial prompt, not as a hardening pass after launch.
Every week of deferral is a week the attack surface exists unprotected. An endpoint without input validation is exploitable from the moment it is deployed. An API without authentication is public from the moment it is reachable. A database with default credentials is compromised from the moment it is connected to a network.
Security cannot be a future sprint because the attack surface does not wait for your roadmap. Specify authentication, authorization, input validation, and data protection requirements in the first prompt for every feature.
The cost of deferral is not technical debt — it is risk exposure. Technical debt slows you down. Security debt can end you.
The question to ask: Are security requirements in the initial implementation prompt, or am I planning a 'security hardening sprint' that may never happen?
Tag: what:requirement
Define trust boundaries explicitly — where does validated data enter the system, and where must it be re-validated?
The question to ask: For every endpoint the AI generates, have I specified who can access it, what input it accepts, and what data it must protect?
Tag: how:pattern
The question to ask: Am I reviewing AI-generated code for security with the same rigor I would apply to code from an unknown contributor?
How the system behaves as load increases. Horizontal vs vertical scaling, statelessness, connection limits, and the difference between 'works for 10 users' and 'works for 10,000.'
Tag: when:trigger
Scalability is a data architecture decision, not an infrastructure decision. The time to specify scale targets is before the first table is designed.
AI will generate a schema that works for seed data. A table with 100 rows performs identically regardless of indexing strategy. A table with 100 million rows performs according to its indexes, partitioning, and query patterns. The AI cannot optimize for scale it does not know about.
Specify the scale targets — expected row counts, query patterns at scale, growth rate — and the AI will generate a schema that works for production data. Omit them, and the AI will generate a schema that works for the demo.
The cost of deferral: schema changes against live data at production scale require migrations that can take hours, lock tables, and require maintenance windows. Every constraint, index, and partition added after data exists is an order of magnitude more expensive than specifying it upfront.
The question to ask: Does the AI know how much data this system will hold in one year, and has it designed the schema accordingly?
Tag: what:requirement
Define the scale at which the system must operate:
Without these specifications, the AI will generate code that works for the demo dataset. It will use patterns that are correct at small scale and catastrophic at production scale — full table scans, unbounded joins, in-memory aggregations of growing datasets.
The question to ask: What are the scale targets for this system, and has the AI been told to design for them?
Tag: how:pattern
The question to ask: Is the data model designed for the expected scale, or for the seed data?
Logging, monitoring, alerting, tracing, and the ability to understand what the system is doing in production without reading the source code.
Tag: when:trigger
Observability requirements belong in the implementation prompt for every service. Observability is not a layer added after deployment — it is a property of the code.
If the AI generates a service without structured logging, the service is incomplete. If it generates an API without request tracing, the API is incomplete. If it generates a queue consumer without metrics, the consumer is incomplete. These are not enhancements — they are part of the definition of done.
Include observability requirements in acceptance criteria: "Every log entry must be structured JSON with correlation_id. Every external call must emit latency metrics. Every service must expose a health endpoint."
The cost of deferral: a service deployed without observability is a black box. When it fails — and it will fail — you will have no logs to diagnose the failure, no metrics to see the trend, and no traces to follow the request. You will diagnose by reading source code and guessing. Adding observability to a running service requires touching every code path, which means a rewrite with production risk.
The question to ask: Is observability in the acceptance criteria, or is it on a backlog labeled 'operational improvements'?
Tag: what:requirement
Define what must be observable in production:
The question to ask: Can I diagnose a production issue using only the logs, metrics, and traces — without reading the source code?
Tag: how:pattern
/health that reports liveness and dependency status. This is not optional — load balancers, orchestrators, and monitoring systems depend on it.The question to ask: Does every service the AI generates include structured logging, health checks, and metrics emission as part of the implementation — not as a follow-up task?
Code organization, duplication, dependency management, and the ability to change the system six months from now without rewriting it.
Tag: when:trigger
Maintainability is not a phase — it is a property of every prompt. Give the AI context about existing code patterns with every implementation request.
Maintainability is not refactoring — it is the absence of the need to refactor. Every module generated without context about existing patterns is a module that will need to be refactored for consistency. The cost of skipping this compounds with every generated module.
At 5 modules, inconsistency is annoying. At 50 modules, it is crippling. At 500 modules, the system is unmaintainable and the team is planning a rewrite.
The mitigation is simple but disciplined: before every implementation prompt, include the relevant existing patterns. Show the AI how error handling works in this codebase. Show it the data access pattern. Show it the logging format. The AI will follow the patterns it can see.
The cost of deferral: every module generated without context is a module that must be manually aligned later. The alignment cost grows linearly with module count, but the coordination cost grows quadratically — because every inconsistent module interacts with every other inconsistent module.
The question to ask: Am I including existing code context in every prompt, or am I generating a collection of modules that happen to be in the same repository?
Tag: what:requirement
Without these specifications, each AI-generated module will be internally consistent but inconsistent with every other module. The codebase will work but will be impossible to maintain because every module uses different patterns for the same problems.
The question to ask: Have I given the AI the existing code patterns and told it to follow them, or is each prompt generating code in isolation?
Tag: how:pattern
The question to ask: Does every implementation prompt include context about existing code patterns, or is each module generated in a vacuum?
Transactions, constraints, validation, backup, and the difference between data that exists and data you can trust.
Tag: when:trigger
Data integrity constraints must be specified before the first table is created. The AI will generate a schema that stores data. It will not generate a schema that protects data unless you specify the constraints.
Every constraint added after data exists requires a migration against live data. A NOT NULL constraint added to a column that already contains nulls requires a data backfill. A uniqueness constraint added to a column with duplicates requires deduplication. A foreign key constraint added to a table with orphaned references requires cleanup.
These migrations are expensive, risky, and require maintenance windows at scale. A constraint specified before the first row is inserted is free. The same constraint specified after a year of production data may require hours of downtime.
The cost of deferral is not just technical — it is data quality. Every day the system runs without constraints is a day it accumulates data that violates the rules you have not yet defined. The longer you wait, the more invalid data you must clean before the constraints can be applied.
The question to ask: Have I specified every data integrity constraint before asking the AI to generate the schema, or am I planning to 'add constraints later'?
Tag: what:requirement
The question to ask: Are the data integrity constraints in the database schema, or are they only enforced in application code that can be bypassed?
Tag: how:pattern
The question to ask: If two users update the same record simultaneously, what happens? If a payment webhook is delivered twice, what happens?
How you prove the system works. Unit tests, integration tests, contract tests, and the practice of writing the test before the prompt.
Tag: when:trigger
The test is the question. Write the test before the implementation prompt.
This is the single most effective practice for producing reliable AI-generated code. Writing the test first means specifying what the system must do before asking the AI to build it. The test becomes a machine-verifiable acceptance criterion.
This inverts the vibe coding pattern:
The test-first approach gives you three things the vibe coding approach does not: a precise specification of expected behavior, an automated way to verify the AI's output, and a regression safety net for future changes.
The cost of deferral: tests written after the code tend to verify what the code does rather than what the code should do. They become tautological — they pass because they were derived from the implementation, not from the requirements. They provide false confidence.
The question to ask: Is the test defining the expected behavior, or is it merely documenting the generated behavior?
Tag: what:requirement
Define coverage requirements not as line coverage percentages but as behavioral coverage:
Tests are the specification, not the afterthought. A feature without tests is an unverified hypothesis. Line coverage measures what code was executed, not what behavior was verified. A test that exercises a code path without asserting correct behavior provides coverage without confidence.
The question to ask: Can I look at the test suite and understand every behavior the system is supposed to exhibit?
Tag: how:pattern
The question to ask: Am I writing the test before the prompt, or generating the test after the code — and hoping the test tests what I intended?
How all users experience the system. WCAG compliance, keyboard navigation, screen reader support, semantic markup, error message clarity, and the difference between a UI that renders and a UI that everyone can use.
Tag: when:trigger
Accessibility requirements must be in the first prompt that generates any user interface. Accessibility is a structural property of the markup, not a styling pass applied later.
Retrofitting accessibility onto a generated UI means rewriting the HTML structure — replacing divs with semantic elements, adding label associations, restructuring tab order, managing focus. This is not CSS changes — it is DOM changes that can break functionality and require re-testing everything.
The cost of deferral is both technical and legal. Many jurisdictions require WCAG 2.1 AA compliance. Accessibility lawsuits have increased significantly. An inaccessible application excludes users and exposes the organization to regulatory risk.
But the deeper cost is simpler: accessibility specified upfront is nearly free. The AI will generate a <button> as easily as a <div onClick>. It will add <label htmlFor> as easily as a floating placeholder. It will use <nav> as easily as <div className="nav">. The difference is whether you asked.
The question to ask: Does the first UI prompt include accessibility requirements, or am I planning an 'accessibility audit' after launch?
Tag: what:requirement
Define who uses the system and how they access it:
<div> soup with click handlers unless you require semantic markup.The question to ask: Have I specified who will use this system, how they will access it, and what accessibility standard the AI must meet?
Tag: how:pattern
<button>, <nav>, <main>, <form>, <label> — not <div> with click handlers and ARIA roles bolted on. Semantic HTML gives you accessibility for free. The AI defaults to <div> and <span> unless you specify semantic elements.The question to ask: Is the AI generating semantic HTML with keyboard support, or am I getting div soup that will need an accessibility retrofit?
The gap between code that runs locally and code that runs in production. CI/CD pipelines, containerization, infrastructure as code, environment parity, secret management, rollback strategies, and the difference between 'it works on my machine' and 'it works in production.'
Tag: when:trigger
Deployment specifications belong before the first line of application code. The deployment target shapes the application architecture.
A service designed for a container orchestrator has different health check patterns, scaling behaviors, and configuration mechanisms than a service designed for a serverless platform. A service designed for blue-green deployment has different database migration requirements than a service designed for in-place updates. These are not details to resolve after the application works — they are constraints that determine how the application is built.
The AI will generate application code that runs in a development environment. Getting that code to production requires a container definition, a CI/CD pipeline, infrastructure configuration, secret management, and a deployment strategy. If these are not specified upfront, they become a separate project that blocks launch.
The cost of deferral: every day spent writing application code without a deployment pipeline is a day that code cannot be tested in a production-like environment. Bugs that only manifest in production — configuration mismatches, resource limits, network policies, DNS resolution — remain invisible until someone tries to deploy. The later that happens, the more code has accumulated that has never been production-tested.
The question to ask: Can I push a commit and have it deploy to a production-like environment automatically, or is deployment a manual process that nobody has attempted yet?
Tag: what:requirement
Define how the code gets from repository to production:
The question to ask: Can I deploy this code to production today, or did the AI only generate the application layer?
Tag: how:pattern
The question to ask: Is the deployment pipeline defined in code and part of the repository, or does it exist only as manual steps someone remembers?
How the system works with other systems. API versioning, backward compatibility, data format contracts, protocol negotiation, and the difference between a service that exposes an API and a service that honors a contract.
Tag: when:trigger
Interoperability requirements must be specified before any interface is exposed to another system — internal or external. Once a consumer depends on your API shape, that shape becomes a commitment.
The AI will generate an API that returns whatever data structure is convenient for the current implementation. Without a contract, that data structure becomes the de facto contract the moment another system starts consuming it. Changing it later requires coordinating with every consumer, which may include systems you do not control.
The cost of deferral is coupling. Every consumer that builds against an unversioned, undocumented API is tightly coupled to the current implementation. When the implementation changes — a field is renamed, a nested object is flattened, a date format changes — every consumer breaks simultaneously. The fix requires synchronized deployments across teams, which is the operational definition of a monolith distributed across the network.
A contract defined before the first consumer is a design decision. A contract defined after ten consumers is a negotiation.
The question to ask: Is there a published, versioned contract for this API, or is the implementation the contract?
Tag: what:requirement
Define how this system communicates with other systems:
The question to ask: Is there a versioned, machine-readable API contract that consumers can develop against independently, or are they reverse-engineering behavior from the implementation?
Tag: how:pattern
The question to ask: Can the provider deploy a change without coordinating with every consumer, and will consumers know if a change will break them before it ships?
Platform-specific well-architected frameworks and best practice references. The quality attributes in this tree are platform-agnostic, but every major cloud provider and enterprise platform maintains its own opinionated framework that maps these attributes to specific services, configurations, and trade-offs. Use these as the translation layer between what to ask and how to implement it on your platform.
TOGAF and ISO/IEC 25010 — Enterprise and Standards-Based Frameworks
For organizations that operate within formal enterprise architecture governance:
These frameworks operate at a different altitude than the cloud-specific well-architected frameworks. They define what quality means. The cloud frameworks define how to achieve it on a specific platform.
Microsoft Azure Well-Architected Framework https://learn.microsoft.com/en-us/azure/well-architected/
Five pillars: Reliability, Security, Cost Optimization, Operational Excellence, and Performance Efficiency. Includes the Azure Well-Architected Review assessment tool, Azure Advisor integration for continuous monitoring, service-specific guides for individual Azure components, and a learning path on Microsoft Learn. Strong emphasis on workload-specific guidance for IoT, SAP, SaaS, and mission-critical applications.
Google Cloud Architecture Framework https://docs.cloud.google.com/architecture/framework
Six categories: System Design, Operational Excellence, Security/Privacy/Compliance, Reliability, Performance Optimization, and Cost Optimization. Organized as pillars plus cross-pillar perspectives for specific industries (financial services) and technologies (AI/ML). Emphasizes DORA metrics for software delivery performance. Includes reference architectures and design patterns in the Architecture Center.
IBM Well-Architected Framework (Hybrid Cloud) https://www.ibm.com/think/architectures/well-architected
Six pillars: the standard five (Security, Reliability, Performance, Cost, Operations) plus a sixth — Hybrid and Portable — reflecting IBM's emphasis on workloads that span public cloud, private cloud, and on-premises infrastructure. Built around Red Hat OpenShift as the common deployment platform. Each pillar contains principles, practices, and guidance assets including anti-patterns and technology reference architectures. Particularly relevant for enterprises with mainframe and hybrid estate.
Oracle Cloud Infrastructure Well-Architected Framework https://docs.oracle.com/en/solutions/oci-best-practices/index.html
Five pillars: Security and Compliance, Reliability and Resilience, Performance and Cost Optimization, Operational Efficiency, and Distributed Cloud. Over 80 best practices gathered from hundreds of customer engagements. Includes the OCI Well-Architected Assessment tool and Landing Zones for baseline deployments. The Cloud Adoption Framework (https://www.oracle.com/cloud/cloud-adoption-framework/) complements it with migration and organizational change guidance.
IBM Z Mainframe Architecture and Security References https://www.ibm.com/docs/en/zosbasics/com.ibm.zos.zmainframe/zmainframe_book.pdf
Mainframe environments (z/OS, CICS, IMS, Db2) have their own architectural traditions that predate cloud well-architected frameworks by decades. The quality attributes in this tree still apply — performance, reliability, security, data integrity — but the implementation patterns differ fundamentally. Key references:
44 of the top 50 banks run on IBM Z. If your system integrates with mainframe workloads, these references define the non-negotiable patterns for transaction processing, data integrity, and security at scale.
Wikipedia: List of System Quality Attributes https://en.wikipedia.org/wiki/List_of_system_quality_attributes
The canonical reference list of ~100+ quality attributes (the 'ilities') from systems engineering. Use this as a checklist to identify attributes that may be missing from your requirements. Notable groupings: RASUI (Reliability, Availability, Serviceability, Usability, Installability), FURPS (Functionality, Usability, Reliability, Performance, Supportability), ACID (Atomicity, Consistency, Isolation, Durability), RAMS (Reliability, Availability, Maintainability, Safety). Not every attribute applies to every system — the skill is knowing which ones matter for yours.
AWS Well-Architected Framework https://docs.aws.amazon.com/wellarchitected/latest/framework/welcome.html
Six pillars: Operational Excellence, Security, Reliability, Performance Efficiency, Cost Optimization, and Sustainability. The most mature and widely adopted cloud well-architected framework, developed from thousands of architecture reviews. Includes the Well-Architected Tool (free in AWS Console) for self-assessment, domain-specific lenses (serverless, SaaS, ML, financial services), and a partner program for guided reviews. Start here if you are building on AWS.
SAM — Software Architecture Manifest
A producer-signed, machine-readable declaration of what software was designed to do and the operational envelope it was designed for. Companion to SBOM (contents) and SLSA (build provenance). SAM declares what the producer designed the software to be: tenancy model, scaling axis, privilege posture, network requirements, ISO/IEC 25010:2023 quality attributes, and chosen postures on declared tensions.
Where this trunk maps into SAM:
qualityAttributes keyed by ISO/IEC 25010:2023's nine characteristics — directly mirrors this trunk's Performance, Reliability, Security, Scalability, Maintainability, Data Integrity, Testability, Accessibility, Compatibility branches.extensions block holds branches without a clean ISO 25010 home: Observability, Data Lifecycle, Internationalization, Context Window Management.tensionsDeclared carries this trunk's five declared tensions (CAP/PACELC, observability cost trilemma, test suite tension, observability/PII, security/performance isolation) as machine-readable producer postures.subject.layer (artifact / service / product) makes manifest granularity explicit so consumers read at the right level.Reasoning vs. declaration:
Resources:
How the system behaves when multiple actors operate simultaneously. Race conditions, distributed consensus, eventual consistency, saga patterns, ordering guarantees, and the difference between code that works in a single-threaded test and code that works under concurrent production load.
Tag: when:trigger
Concurrency requirements must be specified before the first feature that involves multiple actors operating on shared state. This includes multiple users, multiple service instances, background workers, cron jobs, webhook handlers, and event consumers.
The AI will generate code that works perfectly in sequential tests. The test creates a record, updates it, reads it back — correct. In production, two requests arrive 3ms apart. Both read the record, both modify it, both write it back. One update is silently lost. This is not a bug the AI introduced — it is a bug the AI could not have avoided because the concurrency requirements were never specified.
Concurrency bugs are uniquely dangerous because they are non-deterministic. They pass every test, survive every code review, and manifest only under production load at production timing. By the time they are discovered, the data corruption may be unrecoverable.
The cost of deferral is not just technical — it is data integrity. A lost update in a financial system is not a bug to fix in the next sprint. A race condition in an inventory system means selling items that don't exist. A duplicate event processed twice means charging a customer twice.
The question to ask: Does this feature involve multiple actors modifying shared state, and have I specified what happens when they collide?
Tag: what:requirement
Define how the system behaves when multiple actors operate simultaneously:
Without these specifications, the AI will generate code that works correctly in sequential tests and fails unpredictably under concurrent production load. Race conditions are the hardest bugs to reproduce because they depend on timing, not logic.
The question to ask: What happens when two users edit the same record at the same time? What happens when the same event is processed by two workers simultaneously?
Tag: how:pattern
The question to ask: Is there a single, documented concurrency strategy, or is each module inventing its own approach to conflicts and ordering?
Documentation as a non-functional requirement of the code itself, not a follow-up task. API docs generated from contracts, architecture decision records, operational runbooks, README conventions, and the difference between a service that runs and a service a new team member can understand.
Tag: when:trigger
Documentation requirements belong in the same prompt that generates the code. The API doc, the ADR, and the README are deliverables alongside the implementation and the tests.
This is not an overhead problem — the AI generates documentation as easily as it generates code. The cost of including "generate the OpenAPI spec and README" in the prompt is one sentence. The cost of writing documentation after the fact is a separate project that competes with feature work and loses.
The unique risk with AI-generated code is context loss. A human developer who wrote a module six months ago can explain their reasoning. An AI conversation that generated a module six months ago is gone. The ADR, the inline comments explaining why, and the runbook are the only artifacts that preserve the decision context.
The cost of deferral: undocumented AI-generated code is a black box produced by a process that no longer exists. The code works, but nobody knows why it works the way it does, what assumptions it makes, or what alternatives were considered. When it needs to change, the team must reverse-engineer the AI's decisions from the implementation — which is reading the answer without knowing the question.
The question to ask: Is documentation in the prompt's acceptance criteria, or is it on a backlog called 'documentation sprint' that will never be prioritized over features?
Tag: what:requirement
Define which documentation artifacts are part of the definition of done:
The question to ask: If the entire team is replaced tomorrow, can the new team understand, operate, and extend this system from the documentation alone?
Tag: how:pattern
The question to ask: Is the documentation generated from the source of truth (contract, code, config), or maintained separately where it will drift?
How data ages, archives, and dies. Retention policies, GDPR right-to-deletion, soft delete vs hard delete, archival strategies, data classification driving retention rules, and the difference between a system that accumulates data forever and a system that manages data as a lifecycle.
Tag: when:trigger
Data lifecycle requirements must be specified before the first table is created — alongside data integrity constraints, not after them.
The AI will generate a schema that stores data. It will not generate a schema that manages data over time. Tables without partitioning strategies must be redesigned when they hit storage limits. Tables without soft delete must be retrofitted when the first user requests deletion. Tables without retention policies must be manually cleaned when the database reaches capacity.
The cost of deferral is operational. A system that has been accumulating data for two years without retention policies is expensive to fix: identify which data can be deleted (requires data classification that was never done), backfill deletion timestamps (requires a data migration against terabytes of live data), and build the purge pipeline (requires a new service that touches every table). This is a multi-sprint project that could have been a one-paragraph specification in the first prompt.
The unique risk for right-to-deletion: if the cascading deletion map is not built alongside the data model, fulfilling a GDPR deletion request requires a forensic investigation of every system that ever touched the user's data. The investigation itself may take longer than the regulatory deadline.
The question to ask: Has the AI been told how long each data type lives, and has it designed the schema with partitioning and deletion in mind?
Tag: what:requirement
Define what happens to data over time:
The question to ask: What happens to each data type after it is no longer actively used? Is there a retention policy, or does the system accumulate data indefinitely?
Tag: how:pattern
The question to ask: Is there an automated lifecycle that moves, archives, and purges data based on policy, or does the system rely on someone remembering to clean up?
How the system adapts to different locales, languages, and cultural conventions. String externalization, date/time/currency/number formatting, RTL support, pluralization rules, locale-aware sorting, and the difference between a UI that renders in one language and a UI that works for global users.
Tag: when:trigger
Internationalization requirements must be specified in the first prompt that generates any user-facing component — the same prompt that includes accessibility requirements.
Like accessibility, i18n is a structural property. A hardcoded string is not a styling issue — it is a code change to externalize. A layout that assumes LTR text direction must be restructured for RTL. A date formatter that uses the developer's locale must be replaced with a locale-aware formatter. Each of these is a find-and-replace across the entire codebase, touching every component and requiring re-testing.
The AI will generate a <button>Submit</button> as easily as a <button>{t('submit')}</button>. It will use new Date().toLocaleDateString(userLocale) as easily as new Date().toLocaleDateString('en-US'). It will use Intl.PluralRules as easily as a ternary on count === 1. The difference is whether you asked.
The cost of deferral is a retrofit. Retrofitting i18n onto a medium-sized application — extracting strings, adding locale context, replacing formatters, testing in each locale — is typically a multi-month project. The same requirements in the first prompt add zero time to generation.
The question to ask: Does the first UI prompt include the target locales and require string externalization, or am I planning an 'internationalization project' that will delay the next market launch?
Tag: what:requirement
Define which locales the system must support and what adaptation means:
The question to ask: Has the AI been told which locales this system will support, and has it externalized every user-visible string?
Tag: how:pattern
You have ${count} messages is not.The question to ask: If I switch the locale to Arabic or Japanese right now, what breaks? Is the answer 'nothing' or 'we don't know'?
The meta-problem of AI-assisted development: AI context windows are finite but codebases grow without bound. How to give the AI enough context to generate consistent code across a growing system — architecture decision records, pattern catalogs, code style exemplars, and the strategies that bridge the gap between what the AI can see and what the codebase contains.
Tag: when:trigger
Context window management must be designed at project inception — before the codebase grows beyond what a single context window can hold. For most AI-assisted projects, this threshold arrives faster than expected.
At 5 modules, context management is unnecessary — everything fits. At 50 modules, it is important — you must choose what to include. At 500 modules, it is critical — the AI's output quality is entirely determined by the context strategy. The transition from "everything fits" to "nothing fits" happens exactly once, and the team that hasn't prepared for it discovers the problem through inconsistent AI output.
The pattern catalog and exemplar modules must be created early and updated continuously. A pattern catalog written at project inception and never updated is a catalog of decisions that no longer reflect the code. The AI will follow it faithfully, generating code that matches the original patterns while the actual codebase has evolved.
The cost of deferral: at the point where context management becomes critical, the team has already generated hundreds of modules without a canonical pattern reference. Extracting the patterns from the existing code into a catalog is a reverse-engineering project. Building it from the start is a one-page document.
The question to ask: At what module count does this project exceed a single context window, and is the context strategy ready for that moment?
Tag: what:requirement
Define how the AI receives enough context to generate consistent code across a growing system:
The question to ask: What is the context strategy for this project? What fits in the window, what gets summarized, and what gets left out?
Tag: how:pattern
The question to ask: Is there a repeatable process for assembling the right context for each prompt, or does each developer improvise what to include?
CAP THEOREM TENSION. Data Integrity specifies strong consistency (transactional boundaries, referential integrity). Reliability specifies high availability (failure modes, graceful degradation). CAP proves these cannot coexist during network partitions — the tradeoff is binary, not a gradient. This is a TRUE THREE-BODY problem (Brewer 2000, Gilbert & Lynch 2002 proof). AI agents must not generate systems that promise both strong consistency AND high availability without declaring which side of CAP they choose. The question to surface: During a partition, does this system prioritize consistency (reject requests) or availability (serve potentially stale data)?
PACELC TENSION. Even without partitions, consistency and latency are coupled. Data Integrity specifies transactional boundaries and referential integrity. Performance specifies P95 latency targets. PACELC (Abadi 2012) proves the three-body dynamics persist in normal operation: synchronous replication for consistency adds latency; relaxing consistency for speed means reads may return stale data. This extends CAP — you are ALWAYS in a three-body problem, not just during failures. The question to surface: What is the acceptable staleness window? Does the P95 latency target assume eventual or strong consistency?
OBSERVABILITY COST TENSION (CANDIDATE TRILEMMA). Observability specifies per-endpoint latency distributions, correlation IDs, structured logging, and metrics emission for every significant operation. Scalability specifies data volume growth targets. At scale, full-resolution observability generates data volumes that dwarf the application data itself — the observability pipeline becomes the most expensive infrastructure component. The hypothesis: resolution, cost, and real-time freshness form a three-body problem. You must sample OR delay OR pay. The tree currently says "instrument everything" without acknowledging this cost curve. The question to surface: At the target scale, what is the observability budget? Which signals are sampled vs. full-fidelity?
TEST SUITE TENSION (CANDIDATE TRILEMMA). Testability specifies behavioral coverage — every API endpoint, error path, and business rule has a test. Maintainability specifies consistent patterns and the ability to change the system without rewriting it. These conflict when high-coverage tests are tightly coupled to implementation: 95% coverage with brittle tests that break on every refactor creates a codebase that cannot evolve. The coverage number is high but actual quality declines because the team stops refactoring. The hypothesis: coverage, speed, and maintainability form a three-body problem — high-coverage, fast, maintainable tests require fundamentally different testing architecture (contract tests, property-based tests) rather than more unit tests. The question to surface: Are the tests testing behavior or implementation? Will the test suite survive a refactor?
OBSERVABILITY-SECURITY TENSION. Observability specifies structured logging with context-specific fields and correlation ID propagation. Security specifies data classification — which fields are PII, which must never appear in logs. These directly conflict: rich, context-carrying logs improve diagnosability but increase the attack surface for data leakage. A structured log entry with user_id, email, IP, and request body is both excellent observability and a PII liability. This is not a theoretical concern — log aggregators (Splunk, Datadog, ELK) become secondary data stores with weaker access controls than the primary database. The question to surface: Which fields from the data classification are excluded from structured logging? Is there a log redaction strategy?
ISOLATION-PERFORMANCE TENSION (Chrome Rule of Two). Security specifies validation at the API layer, principle of least privilege, and treating AI-generated code as untrusted. Performance specifies P95 latency and resource budgets per request. Isolation costs real compute: sandboxing requires separate processes (Chrome's model), input validation on every boundary adds CPU cycles, least-privilege service accounts mean more network hops for privilege escalation checks. Google found the Rule of Two limits feature velocity because sandboxing (reducing privilege) requires new processes, which costs performance. This is a TRUE THREE-BODY problem — untrusted inputs + unsafe execution + high privilege cannot coexist, and eliminating any one has a performance cost. The question to surface: What is the performance budget for security boundaries? Does the latency target account for validation and isolation overhead?
Follow this trunk to stay updated.