Skip to content

The Spec as the New Source Code: Why AI Makes Architecture Non-Negotiable

On Friday night, an engineer opens an empty repository, types a sentence into an AI coding assistant, and watches a working SaaS dashboard materialize in three hours. Authentication, database tables, Stripe checkout, responsive charts: everything runs smoothly on localhost:3000. The experience feels intoxicating. "Vibe coding" at its peak makes traditional software engineering look archaic.

On Monday morning, the same engineer opens their team's primary production repository. It contains 140,000 lines of TypeScript, an eight-year-old database schema with legacy triggers, three background job workers, and strict tenant isolation rules.

The engineer types a simple prompt into the assistant:

"Add organization-level workspace switching to the billing dashboard."

Fifteen seconds later, the model outputs 450 lines of idiomatic code across six files. The code compiles without errors. Basic unit tests pass. The developer merges the pull request and deploys to staging.

By Wednesday, the staging environment grinds to a halt:

  1. The query plan broke: The generated code queried active subscriptions inside a render loop, introducing an N+1 database pattern that pushed database CPU to 98%.
  2. Audit trails vanished: The model wrote its own database mutation helper instead of routing updates through the shared compliance pipeline.
  3. Tenant boundaries leaked: The assistant invented an ad-hoc tenant identifier in the session token that clashed with the platform's claims format, displaying workspace names to unauthorized users.
  4. Soft-delete rules failed: The new query filtered by status = 'active', but omitted deleted_at IS NULL, resurfacing accounts removed two years ago.

The assistant did not fail because its code was sloppy. It failed because writing code was never the primary challenge of software engineering.

The Greenfield Mirage

"Vibe coding" succeeds on greenfield toys because an empty canvas has no preexisting invariants to protect. In an enterprise system, prompting an AI without hard specifications acts as an ambiguity multiplier.


The Greenfield Mirage vs. Brownfield Reality

On a weekend side project, you carry the entire domain in your head. More importantly, there is nothing in the repo to break:

  • No legacy schemas to preserve.
  • No distributed transactions or eventual consistency lag.
  • No compliance audits, access control lists, or tenant boundaries.
  • No traffic load to expose subtle concurrency bugs.

If an assistant selects SQLite instead of Postgres, or invents an unusual authentication wrapper, the project still runs. The developer experiences high velocity because the system has zero constraints.

In a production codebase, constraints represent 90% of the engineering work. Real systems survive because they enforce invariants: data stays isolated, mutations leave audit trails, transactions remain atomic, and network calls handle partial failure.

When you prompt an AI assistant without explicit constraints, you ask it to play Russian roulette with those invariants.


The Ambiguity Multiplier

Under uncertainty, human engineers and language models behave in fundamentally different ways.

When a human developer receives a ticket that says "Add organization-level switching to billing", they pause. They know the billing service has quirks. They check how authentication tokens carry organization context. They ask the team lead whether deactivated workspaces should appear in the selector dropdown. They surface unspoken assumptions before typing code.

An LLM never pauses. It has no mechanism for hesitation. It resolves ambiguity by fabricating whatever conventions minimize token perplexity, presenting arbitrary architectural choices with complete confidence:

graph TD
    classDef prompt fill:#f5f5f5,stroke:#333,stroke-width:2px;
    classDef human fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    classDef ai fill:#ffebee,stroke:#c62828,stroke-width:2px;

    P["Underspecified Prompt:<br/>'Add workspace switching to billing'"]:::prompt

    P -->|Human Engineer| H1["Pauses & Identifies Ambiguity"]:::human
    H1 --> H2["Checks existing tenant isolation rules"]:::human
    H2 --> H3["Asks PM about deactivated accounts"]:::human
    H3 --> H4["Writes bounded, safe implementation"]:::human

    P -->|Prompt-and-Pray AI| A1["Generates 450 lines instantly"]:::ai
    A1 --> A2["Silently invents session format"]:::ai
    A2 --> A3["Bypasses shared audit middleware"]:::ai
    A3 --> A4["Latent production bug merged"]:::ai

A short, ambiguous prompt does not produce a short, ambiguous response. It produces hundreds of lines of plausible code containing silent architectural decisions you never approved.

As I pointed out in The AI Review Paradox, human comprehension is the true bottleneck. Spotting missing audit logic or an N+1 query buried inside 450 lines of pristine syntax takes twice as much cognitive effort as writing the code by hand.


The Spec as the High-Level Language

In 1957, John Backus and his team delivered Fortran. Before Fortran, programming meant mapping operations directly to CPU registers and memory addresses. When compilers arrived, many programmers argued that real engineers needed to write assembly to maintain performance and control.

Compilers did not eliminate software engineering; they moved it up one layer of abstraction. Assembly became an implementation detail. Fortran, and later C, became the language of intent.

We are watching that exact transition happen again.

1950s:  Human writes Machine Code / Assembly
1970s:  Human writes C / Pascal       --> Compiler emits Assembly
2000s:  Human writes Java / Python    --> Runtime / JIT emits Bytecode
2020s:  Human writes Specifications   --> AI Agent emits Code

When an agent can synthesize 500 lines of functional TypeScript, Go, or Python in fifteen seconds, imperative syntax is no longer the primary asset. Imperative code is the new assembly language. It is disposable. If a function contains bugs, you do not spend an hour editing its internals line by line; you refine the specification and regenerate it.

The durable asset is the specification: the data models, system boundaries, error semantics, and testable acceptance criteria that define what the software must do.


The Four Pillars of an AI-Ready Spec

Writing an engineering specification for an AI agent is not the same as writing an old-fashioned 40-page requirements document. It is a precise technical contract designed to eliminate the assistant's freedom to hallucinate architecture.

A working spec requires four distinct components:

1. Context and Invariants

Define the environment and the non-negotiables upfront.

  • Which existing modules must handle this work?
  • Which shared libraries (audit logging, authentication, database clients) must be used?
  • What invariants must remain untouched (e.g., "All database queries in this path must include tenant_id and respect soft-deletes via deleted_at IS NULL")?

2. Explicit Non-Goals

Tell the agent what not to do. LLMs love speculative generality. Without explicit boundaries, they will refactor adjacent functions, replace date utilities with different libraries, or add unneeded configuration parameters. Stating non-goals keeps the blast radius contained.

3. Data Contracts and Interfaces

Define your types, database migrations, and API schemas before asking for application logic. When data schemas and error models are concrete, the model cannot invent its own data structures.

4. Verifiable Acceptance Criteria

Define success with deterministic checks:

  • Specific test cases (inputs, expected outputs, error responses).
  • Database query benchmarks or constraints (e.g., "Must resolve in a single joined query without lazy-loading child records").
  • Commands the agent can run to verify its own work.

The Practical Spec-Driven Workflow

Treating specs as source code changes how engineers interact with AI assistants. Instead of treating the model as an oracle in a chat window, you use it within a disciplined four-step loop:

flowchart TD
    classDef step fill:#e3f2fd,stroke:#1976d2,stroke-width:2px;
    classDef gate fill:#fff3e0,stroke:#f57c00,stroke-width:2px;

    %%subgraph W1 [ ]
        S1["1. Interrogate Intent & Edge Cases"]:::step --> S2["2. Write Spec Artifact"]:::step
        S2 --> G1{"Human Review Gate"}:::gate
    %%end

    G1 -->|Approved| S3["3. Bounded Agent Execution"]:::step

    %%subgraph W2 [ ]
        S3 --> S4["4. Deterministic Verification"]:::step
        S4 --> G2{"Tests Pass?"}:::gate
        G2 -->|No: Error Log Feedback| S3
        G2 -->|Yes| Done["Ready for Human Review"]
    %%end

Step 1: Interrogate the Intent

Do not write code yet. Use the model as a sparring partner to stress-test your thinking:

  • "Here is the feature request. What edge cases and security risks exist for multi-tenant switching?"
  • "What database index changes will we need to support this query pattern?"
  • "What existing services in our dependency graph could be affected?"

Use AI to poke holes in your assumptions while changes are still free.

Step 2: Formalize the Spec

Capture the agreed requirements into a markdown document committed directly into the repository (for example, docs/specs/2026-09-28-workspace-billing.md). Include the schema changes, interface signatures, and acceptance tests.

Review this document yourself. If the spec contains ambiguity, fix the spec. Do not hand an ambiguous document to an execution agent.

Step 3: Bounded Agent Execution

Feed the agent the specification and strictly the files it needs to modify. Give it explicit instructions:

  • Implement only what the spec demands.
  • Do not modify files outside the specified scope.
  • Do not introduce new third-party dependencies.

Step 4: Deterministic Verification

Verify the agent's work against deterministic tools, not subjective prompts:

  • Run the compiler and linter.
  • Execute unit and integration tests.
  • Verify schema migrations against a local database container.

If a test fails, feed the exact compiler error or test output back to the agent: "Test test_workspace_switching_respects_soft_delete failed with AssertionError on line 42. Fix the query to filter soft-deleted records." The model loops against a concrete failure, not vague conversational feedback.


The Accidental Revival of Software Engineering

A decade ago, Agile development declared war on specifications. Teams threw out formal documentation in favor of user stories and sticky notes. In practice, that often degenerated into two-sentence Jira tickets and broken handoffs, a problem I explored in The Waterfall-in-Sprints Trap.

Developers hated specifications because writing 30-page documents in Microsoft Word was slow, tedious, and disconnected from code. By the time a spec made it through committee approval, the requirements had changed and the document was obsolete.

AI code generation creates an ironic twist: it makes specifications practical again.

Drafting, stress-testing, and refining a crisp technical specification with an AI assistant takes twenty minutes. That twenty-minute investment prevents three days of tracking down subtle production regressions caused by hallucinated architectural assumptions.

Typing syntax was never the core skill of a senior software engineer. Syntax recall is a commodity. The enduring craft of software engineering lies in systems thinking: defining boundaries, preserving invariants, anticipating failure modes, and deciding what not to build.

In the AI era, you do not direct systems by typing imperative statements one line at a time. You direct them by writing specifications that make failure impossible.


Share on Share on Share on