Leverage AI

Stage-relative source · AI-native software

The Prompt Is Source Before Source Code

When intent, prompts, context, tests, and starting state can regenerate equivalent behaviour, generated code is intermediate representation — and the durable asset is the package above it.

By Scott Farrell · LeverageAI · Extends Your Life Compiles to One Language and Goal Formation: The Scarce Resource

TL;DR

Here is a pattern I keep seeing on AI-generated software projects. The team treats the repository as sacred. Every module is committed. Pull requests look orderly. Six weeks later nobody can answer a simple question: why does the retry path wait exactly that long, and would a second agent run make the same choice? The chat is gone. The agent instructions were never filed. The acceptance criteria lived in someone’s head. The code remains. The judgment that produced it does not.

We say we have source control. We have intermediate-representation control. The earlier stage — the one that actually encoded the decisions — was discarded because it looked like “just prompting.”

We have a new earlier compiler now: idea and prompt → AI agent → code. That means there is source before the source code.

That sentence is the whole thesis. The rest of this article makes it operational: what belongs in the upstream package, when generated code honestly becomes intermediate representation, how to run a falsifiable Delete Test on a real module, and how to answer the two objections that kill the idea when left unstated.

What the parents already settled

This piece is an extender. Two parent arguments are load-bearing and will not be re-derived here.

Your Life Compiles to One Language established the compiler frame for archives: heterogeneous material becomes joinable when meaning is lowered into a common text surface; the wiki functions as intermediate representation; agents are the runtime.1

Goal Formation: The Scarce Resource established the scarcity inversion above execution: when machines can run goals cheaply and in parallel, the limiting reagent is clear intent — forming and stewarding goals rather than merely dispatching work.2

What this article adds is narrower and sharper: the stage-relative source rule for AI-generated software, and a maturity test you can run on Monday morning without buying a new platform.

Source was always relative to a compiler stage

In a classical toolchain, “source” is the earliest human-edited representation the build accepts. Everything after that is intermediate or target. Compilers have used intermediate representations for exactly that reason: a form between source and machine code where structure can be transformed without pretending the IR is the original program.34

The old software chain looked like this:

source code ↓ conventional compiler machine code / bytecode ↓ runtime behaviour

The AI-native chain inserts an earlier stage:

human thought / intention ↓ specification + prompts + context + tests + start state ↓ AI agent (semantic compiler) generated source code ↓ conventional compiler / interpreter runtime behaviour

So generated source code is simultaneously:

That dual status is not wordplay. It is why teams get confused. Relative to gcc or the TypeScript compiler, the generated files are source. Relative to the agent that wrote them, they are already a lower stage — unless the upstream package cannot reproduce them, in which case judgment is trapped in the “IR” and the IR is still partly source.

The maturity rule

Code becomes an intermediate representation only to the extent it can be regenerated from the upstream source package. Until then, parts of it are still the source of truth — whether you admit it or not.

Semantic Decompilation develops the recovery method when you must reverse-engineer design from prose, prompts, and code after the fact.5 This article is about the forward discipline: treat the package as source before you need heroic recovery.

What belongs in the upstream source package

If “the prompt” meant a one-line chat message, the thesis would be false. A one-line request is not a complete specification. The durable package is larger:

intent # what great looks like; who it is for; non-goals + design / specification # interfaces, constraints, invariants + prompts and agent instructions + relevant worldview / context # the judgment the model will not invent + tests and acceptance criteria # behavioural oracle + starting repository state # commit-zero, pinned deps, config shape + non-inferable decisions # anything regeneration must not re-guess

That list is deliberate. Intent without tests is a speech. Tests without intent are brittle snapshots. Prompts without starting state regenerate into a different project. Context without non-inferable decisions leaves the agent free to invent policy where you needed a decision recorded once.

Two prior strands sit quietly under this inventory. The Intent Compiler line treats high-level objectives as inputs that must be compiled into operational instructions rather than hoped into existence as perfect first prompts.6 North Star prompting separates tight purpose from loose method — purpose belongs in the package with more force than step-by-step procedure.7

Goal Formation’s scarcity claim shows up here as package quality. Execution is cheap. Forming and retaining the goal, constraints, and acceptance surface is not.2

The Delete Test

The operational diagnostic is almost insultingly simple. I have used versions of it for kernel-first content and generated artefacts generally; the software form is the same question with a sharper oracle.8

Can I delete the generated implementation and regenerate equivalent behaviour from the frozen package? No → code is still partly the source Yes → code has become a compiled artefact / IR

“Equivalent behaviour” does not mean identical text. Models are nondeterministic. A regenerate that rewrites a helper, renames a private function, or reorders pure logic can still be the same program if the acceptance surface says so. Compilers already taught us this: optimised IR is not judged by string equality with the previous IR.

Three outcomes, applied to a service module:

AnswerMeaningAction
Yes, cleanly Package holds the judgment; implementation is regenerable IR Treat code as build product; improve the package, not local patches that never flow up
Mostly Some decisions live only in the code or in unfiled chat Extract those decisions into the package; re-run the test
No The implementation has become the source of truth Stop calling it disposable. Either promote judgment upstream or accept that you own IR as source

The “mostly” answer is where teams learn. A failed regenerate is not a reason to abandon the doctrine. It is a lint finding: a decision was trapped.

Worked case: the trapped retry policy

Take a concrete shape — generalised from AI-generated software work, not a single named product launch.

A small internal service is built with an agent: ingest webhooks from a payment provider, verify signatures, write an event log, and enqueue downstream work. The team freezes what they believe is the source package: a North Star intent, an OpenAPI-ish sketch, a system prompt with coding standards, a handful of pytest cases for happy-path signatures, and the empty repository template the agent was started from.

The first agent run produces working code. Tests pass. It ships. Two weeks later someone notices a subtle policy: on signature failure the service retries three times with a long backoff before rejecting, and it logs a vendor-specific error code that is never mentioned in the package. That behaviour was negotiated in a side chat with the agent while debugging a flaky sandbox. It never made it into the intent, the prompts, or the tests. It lives only in the generated module.

Run 1 — honest Delete Test

  1. Freeze the package as a release artefact (hash the intent, prompts, tests, start commit, dependency pins).
  2. In a safe clone, delete the implementation (leave package and test harness).
  3. Regenerate twice with the same package, different seeds / sessions.
  4. Score by acceptance tests and a thin characterisation suite around the public behaviour — not by diffing the two trees for textual identity.9

Both regenerations implement signature verification and enqueue paths. Both fail the new characterisation for “three retries with long backoff and vendor code on signature failure.” The happy-path tests still pass. The package looked complete until the oracle asked about the edge the chat invented.

Verdict: No — code is still partly source. The retry policy is trapped judgment.

Promotion, then Run 2

The team does not “fix the code” as the permanent home of the policy. They promote the decision upstream:

They re-freeze the package, delete the implementation again, regenerate twice. Both runs now satisfy the characterisation. Private helpers differ. File layout differs slightly. Behaviour matches.

Verdict: Yes — for this module, generated code has become IR relative to the package.

What the case shows

Repair cost follows the same shape. Patching IR without promotion is fast once and expensive forever — every future regenerate reintroduces the bug. Promoting once costs a short packaging pass and then compounds: model upgrades improve regenerations without re-litigating the policy in chat.

Equivalence, nondeterminism, secrets, and the hand-owned boundary

Four definitions keep the doctrine from becoming slogans.

1. Equivalence

Equivalence is defined by the acceptance and characterisation surface you are willing to own — public contracts, invariants, performance budgets you care about, and explicit non-goals. It is not “looks similar to the previous tree.” If you cannot say what equivalent means, you cannot claim IR status.

2. Nondeterminism tolerance

Allow variance in structure, naming, and pure refactors. Disallow variance in the behaviours under test. If a behaviour is load-bearing and untested, it is not yet in the package — it is ambient luck.

3. Secrets and configuration

Secrets do not belong in prompts committed to a shared package. Pins do. Record which configuration shape is required (env var names, rotation policy, “secret injected at runtime”) without storing the secret material. A regenerate that fails because someone pasted a key into chat is not a Delete Test failure of the doctrine; it is a packaging boundary error.

4. Generated IR versus hand-owned source

Not every line should be regenerable sludge. Hardware interfaces, carefully proven algorithms, compliance-critical parsers, or performance kernels may be hand-owned by policy. Mark them. Put them outside the delete scope. The doctrine fails when teams pretend the whole monorepo is disposable while a few files quietly carry non-regenerable truth with no label. Honesty about the boundary is part of the source package.

Custom software’s hard problem was never only generation cost; verification is where cheap generation dumps its risk.10 The Delete Test is a verification stance: the package plus oracle must be strong enough that IR can be replaced without a prayer.

Source maps: transcripts, prompts, and bronze

Most reverse engineering is hard because binaries ship stripped. Names, comments, and intent were discarded at compile time. Teams recovering business logic from long-lived systems still reconstruct purpose from behaviour because the intent stream was never kept.11

AI-native work is different when you refuse to throw the intermediate representations away. Transcripts and prompts are not “process noise.” They are the source map — code is the what; the transcript is often the why.12 Keep-the-bronze discipline is the same argument in archive language: do not discard a representation a later pass may need.13

When every layer is retained, forward and reverse engineering both get cheaper. When only the generated files remain, you are back to the legacy predicament — with prettier syntax.

The same cascade appears in publishing

The software chain is not the only place stage-relative source shows up. The publishing toolchain has the same shape:

working thought ↓ AI-assisted authoring long-form argument ↓ semantic decomposition quotes / claims / excerpts ↓ contextual compilation post, card, proposal, answer

Thought is source relative to the long form. Long form is source relative to the quote. The quote is source relative to the feed interrupt. Attention-native publishing owns how those interrupts should behave in a scarce attention window.14 Semantic Refraction owns why meaning-complete pieces can form joins the undifferentiated pillar was too coarse to hold.15 Semantic Decompilation owns recovery of design from the compiled prose and the round-trip lint against implementation.5

The rhyme matters only so far: artefacts are stages in a toolchain, not a simple parent–child hierarchy of “real” versus “lesser.” The re-enterable thought remains source relative to the compiled long form — a correction already present in related work on keeping multiple best selves and representations alive rather than collapsing everything into one frozen artefact.16

This article does not re-teach those publishing methods. It uses the cascade as evidence that “source” has been stage-relative longer than the AI coding panic.

Objection 1: “A prompt is not source code — it’s just instructions.”

Correct — if by prompt you mean a casual one-liner. Incorrect — if by source you mean the earliest retained representation that still encodes the judgment required to reproduce behaviour.

Source code was never magic glyphs. It was the human-owned input to a compiler stage. When the compiler stage moves upstream to an agent, the human-owned input moves with it. Instructions wrapped around empty judgment are not source. A package that includes intent, constraints, tests, context, and start state is source in the only sense that ever mattered: it is what you edit when you want a different program next time.

The one-line fallacy also confuses activation with specification. A short intent can work when a large body of compiled context already sits in the package — worldview, prior decisions, interface contracts. The short string is a pointer into that package, not a replacement for it. That is goal formation meeting packaging, not a licence to ship vibes.

Objection 2: “Nondeterminism means regenerate can never replace code.”

Only if you demand bit-identical trees. Software engineering already abandoned that demand for optimising compilers, formatters, and many codegens. We demand behavioural contracts.

Nondeterminism is a reason to invest in better oracles, pins, and characterisation — not a reason to treat every generated line as irreplaceable craft. If your tests cannot express what must stay true, the problem is under-specified success, not the philosophy of IR.

There is an honest limit: some systems should not be regenerated from a loose package. Mark them hand-owned. The doctrine is not “delete everything.” It is “know which representation still carries judgment.”

What this is not

Relational meaning versus unary metadata, quote authority without a canon, publishing as sensor, and institutional memory that is not cognition — those threads continue under their own names. They are not required to apply the Delete Test to a service module this week.

The sentence to hold

The prompt package is source before source code. Generated code is intermediate representation only when the Delete Test says so — and transcripts are source maps, not optional debris.

If you already compile archives into a joinable IR and run agents as the runtime, you have half the compiler story.1 If you already treat goal formation as the scarce reagent above execution, you know where the real cost sits.2 What remains for AI-generated software is discipline at the new stage boundary: freeze the package, name the oracle, promote trapped decisions, and stop confusing a green first compile with source maturity.

Run the Delete Test on one module

Pick one AI-generated service. Freeze intent, prompts, tests, start state, and pins. Delete the implementation in a safe clone. Regenerate twice. Promote the first decision that only the old code knew. That is the doctrine earning its keep — no platform purchase required.

Related: Your Life Compiles to One Language · Goal Formation Is the Scarce Resource · Semantic Decompilation · Stop Nursing Your AI Outputs

References

  1. Scott Farrell, LeverageAI. "Your Life Compiles to One Language." https://leverageai.com.au/wp-content/media/articles/104-life-compiles-to-one-language.html — archive as source, wiki as intermediate representation, agent as runtime.
  2. Scott Farrell, LeverageAI. "Goal Formation Is the Scarce Resource." https://leverageai.com.au/wp-content/media/articles/108-goal-formation-scarce-resource.html — clear intent as the scarce reagent above abundant execution.
  3. Wikipedia. "Intermediate representation." https://en.wikipedia.org/wiki/Intermediate_representation — IR as the form used internally by a compiler between source and target.
  4. Cornell CS 4120. "Intermediate Representations." https://www.cs.cornell.edu/courses/cs4120/2023sp/notes/ir/ — layered IR makes program structure explicit between source and runtime.
  5. Scott Farrell, LeverageAI. "Semantic Decompilation — Recover the Design Hidden Inside Prose and Code." https://leverageai.com.au/wp-content/media/articles/153-semantic-decompilation.html — recovery method, compiler cascade, retained debug symbols.
  6. Scott Farrell, LeverageAI. "The Intent Compiler: Deterministic Fusion of Fuzzy Priors." https://leverageai.com.au/wp-content/media/articles/141-intent-compiler.html — intent compiled into operational instructions rather than one-shot wording.
  7. Scott Farrell, LeverageAI. "The North Star Prompt." https://leverageai.com.au/wp-content/media/articles/70-north-star-prompt.html — tight intent, loose method; purpose constrained more tightly than procedure.
  8. Scott Farrell, LeverageAI. "Stop Nursing Your AI Outputs. Nuke Them and Regenerate." https://leverageai.com.au/wp-content/media/articles/33-compile-the-generator.html — Delete Test; extract trapped judgment into the kernel before treating output as disposable.
  9. Wikipedia. "Characterization test." https://en.wikipedia.org/wiki/Characterization_test — tests that capture existing behaviour as an oracle for detecting change.
  10. Scott Farrell, LeverageAI. "Custom Software Verification." https://leverageai.com.au/wp-content/media/articles/105-custom-software-verification.html — verification as the hard problem once generation is cheap.
  11. Scott Farrell, LeverageAI. "AI Legacy Takeover." https://leverageai.com.au/wp-content/media/articles/48-ai-legacy-takeover.html — behaviour as oracle when the intent stream was discarded.
  12. Scott Farrell, LeverageAI. "The Code Is the What; The Transcript Is the Why." https://leverageai.com.au/wp-content/media/articles/79-the-code-is-the-what-the-transcript-is-the-why.html — preserve transcripts as source maps the repository cannot reconstruct.
  13. Scott Farrell, LeverageAI. "Keep the Bronze." https://leverageai.com.au/wp-content/media/articles/92-keep-the-bronze.html — never discard a representation a later pass may need.
  14. Scott Farrell, LeverageAI. "Attention-Native Publishing — The Article Compiled for an Interrupt." https://leverageai.com.au/wp-content/media/articles/151-attention-native-publishing.html — quote as long-form compiled for an attention interrupt.
  15. Scott Farrell, LeverageAI. "Semantic Refraction — Why the Pieces Can Mean More Than the Pillar." https://leverageai.com.au/wp-content/media/articles/152-semantic-refraction.html — relational grain; meaning-complete pieces as interfaces.
  16. Scott Farrell, LeverageAI. "The Clasp: All Your Best Selves at Once." https://leverageai.com.au/wp-content/media/articles/106-the-clasp.html — re-enterable thought as source relative to compiled artefacts.