LEAP: LLM Engineered Application Pattern. Use when the user says 'build the app', 'Read master.md', 'rewrite this project', or when you find a master.md in the project root. Generates all code from prompts, runs tests, serves the app. Can also convert existing codebases into LEAP format.
You are operating in a LEAP project. Code is not the product — prompts, schemas, and tests are. You are the compiler.
src/ and is gitignored.The guardrails hierarchy (most to least valuable):
When you encounter a LEAP project (has at root):
master.mdmaster.md — it contains the app description and generation instructionsschemas/ — these are the contractsparts/*/master.md has a prompt, each parts/*/schema.ts has a contractsrc/ — satisfy every contractnpm install (or equivalent)master.md has a "Running the app" section, execute itsrc/. Prompts, schemas, and tests are human-authored. You only generate code.src/ must be self-contained. No imports from outside src/. Copy type definitions inline if needed.The whole point of LEAP is that AI generates code from prompts, schemas, and tests. If you copy code from somewhere else, the experiment is invalid and the project's value is destroyed.
Forbidden:
_original/, _reference/, or any other reference folder in the projectnpm pack, git clone of the upstream, etc.)WebFetch or WebSearch to look up the implementationAllowed inputs for generation:
master.md (root and per-part)schemas/ (the contracts)tests/ (the guardrails)Why this matters: If you copy the reference, you've proven nothing — you've just laundered existing code through a prompt-shaped wrapper. LEAP's thesis is that prompts + schemas + tests are sufficient to produce correct code. Copying invalidates the experiment.
If a prompt is ambiguous: Make your best guess from the tests. If tests don't disambiguate, ask the user. Never resolve ambiguity by reading the original source.
If _original/ exists in the project: It is the user's reference, NOT yours. Treat it as if it doesn't exist during generation. You may only read it during rewrite mode setup (extracting schemas, porting tests) — never during code generation.
A LEAP project follows this structure:
master.md # Root prompt — read this first
schemas/ # Shared contracts between parts (human-authored)
parts/ # One folder per component
{name}/
master.md # Prompt for this part
schema.ts # Contract for this part
parts/ # Optional: recursive sub-parts
tests/ # Human-authored behavioral tests
src/ # GITIGNORED — you generate this
src/ is empty — generate everythingBefore writing any spec file, open master.md (or spec/overview.spec.md for multi-surface targets) with three required sections:
External contracts are not specs. Manpages understate reality. Reference tools behave wrong-by-design (Apple Calculator chains 2 + 3 × 4 = 20). ARIA patterns admit multiple orthogonal variants. Spec must encode what the artifact does, not what the docs claim.
For any multi-surface or platform-specific target:
spec/engine/ — pure. No platform vocabulary. The algorithm, the state machine, the contract.spec/platform/<target>/ — allowed to name platform types (SwiftUI, DOM, ANSI, clap). Thin adapter to the engine.The engine is testable without the platform. Any value that is a function of engine state belongs in the engine, not the view/adapter. View looks up; view does not compute.
A string type is rarely enough. A combobox id must be CSS-selector-safe (:r1: is a valid HTML id but breaks selectors). A path must be canonical. Declare refinements — branded types in TS, enums and structs in Swift/Rust, validators in Python.
On unfamiliar terrain, first-draft specs are wrong. Tests routinely force the spec to be rewritten, not just the code. This is correct LEAP behavior, not a process violation.
The commit sequence spec → tests → spec' → src is expected. If tests fail because the spec is wrong, fix the spec first, then regenerate code. If tests fail because the code is wrong, fix the code. Never silence a test to make code pass.
Test-artifact class is part of the spec. Declare the class, pin the tooling:
| Surface | Required test class | Notes |
|---|---|---|
| Web | Playwright e2e + axe-core a11y + visual regression | pin browser version |
| Native (macOS/iOS) | Accessibility-tree snapshot | pixel snapshots are fragile on SwiftUI; prefer structural |
| TUI | PTY-based snapshot | stream mocks silently pass real bugs |
| CLI | Byte-exact golden diff + checked-in regenerator script | pin reference tool version |
"No test-artifact class declared" = not LEAP-compliant.
When the user asks to "rewrite" or "convert" an existing codebase into LEAP format:
schemas/ with type definitions covering the full public APItests/parts/ with one folder per natural componentmaster.md prompt describing what that component doesschema.ts with its specific contractmaster.md describing the project, its purpose, and how parts connectsrc/ to .gitignoremaster.md and buildAll UI surfaces follow the general spec-authoring rules above: engine/platform split, test-artifact class declared, refined schemas, derived values in the engine (not the view). Surface-specific rules follow.
Web projects have a design/ directory at the root.
design/tokens.json — design system (colors, spacing, typography). Consume these.design/references/ — reference images. Test fixtures, not documentation.design/figma.json — optional Figma export for traceability.Web test types (all must pass):
tests/visual/ — pixel-diff tests against reference images. Primary correctness signal.tests/interaction/ — Playwright behavior (click, hover, type, focus).tests/a11y/ — axe-core + keyboard nav + screen reader compliance.Banned patterns (web):
React.forwardRef")When generating web code:
master.md constrains youdesign/tokens.json — do not hardcode colors, spacing, fontsdesign/references/*.png — visual tests verify thismaxDiffPixelRatio (typical: 0.01), not exact pixel matchesBanned patterns (native):
@State — rebadging, formatting, filtering live in Core@main App struct holding business logic — App is adapter; logic is in Coreschema/keymap.schema.* or spec/keyboard.spec.md. First-class artifact, not buried in code.render-loop.spec.md + render-frame.schema.* (frame = lines + final flag) collapses per-widget render pipelines into one.node-pty (via @homebridge/node-pty-prebuilt-multiarch on Node 22 + darwin-arm64) or the equivalent in your runtime.NO_COLOR — disable styling but keep terminal control codes. They are different things.clap, argparse, commander) is a disposable adapter. Otherwise the framework IS the spec and the schema drifts silently.tree(1)'s output is a classic).gen-golden.sh that regenerates fixtures from the reference tool at a pinned version.Banned patterns (CLI):
This skill is portable. The LEAP pattern works with any AI coding agent. To adopt it outside Claude Code, inject these instructions into your agent's system prompt or configuration file.
The core contract is simple:
master.md