Back to all concepts

Externalized Scratchpad Architecture for AI-Native Development

Brief

An AI-native development architecture where reasoning, planning, testing, and decision-making are externalized into persistent, structured documentation artifacts (scratchpads, spikes, ADRs, journals, test backlogs) that function as a distributed cognitive memory system. These artifacts form a navigable graph that acts as both long-term memory and control surface for AI-assisted software development.

WHY THIS MATTERS

Traditional software development assumes that “thinking happens in heads or transient context,” while code is the durable artifact. This architecture inverts that assumption:

  • Code becomes derived output, not primary cognition.
  • Documentation becomes executable intent, not passive explanation.
  • AI becomes a long-horizon cognitive agent, operating over persistent reasoning traces instead of short context windows.

This matters because AI systems are:

  • stateless across sessions
  • prone to context loss
  • weak at long-horizon coherence without external memory

Externalized scratchpads solve this by turning development into a persistent reasoning graph rather than a session-bound interaction.

The result is a shift from:

“write code → debug → document”

to:

“externalize intent → reason → validate → implement → reflect → update memory graph”

Deep synthesis

Operating Logic

1. Documentation-as-State Machine

Development artifacts move through a lifecycle:

Idea → Scratchpad → Spike → ADR → Implementation Guide → Code → Test Reports → Review → Knowledge Base

Each stage is:

  • typed (has structure)
  • linked bidirectionally
  • transition-controlled

This prevents “knowledge drift” between design and implementation.

2. Externalized Cognition Loop

Instead of relying on ephemeral model context:

  1. AI writes or updates scratchpad
  2. Reasoning is stored externally
  3. AI re-reads structured memory
  4. Updates understanding
  5. Produces next artifact or action

This forms a closed cognitive loop anchored in persistent artifacts.

3. Documentation as Control Surface

Docs are not passive—they govern:

  • whether implementation is allowed
  • what abstraction layer is appropriate
  • when experimentation is required (spike)
  • when decisions are locked (ADR)
  • how testing is executed (backlog + async queue)

This makes documentation a runtime epistemic layer.

4. Graph-Based Cognitive Architecture

All artifacts form a graph:

  • Nodes: scratchpads, ADRs, spikes, tests, reviews
  • Edges:
  • supports
  • contradicts
  • implements
  • derives_from
  • validates

This enables:

  • causal reasoning (“why was this built?”)
  • impact tracing (“what breaks if this changes?”)
  • semantic navigation (“show all reasoning behind this feature”)

5. AI as Co-Orchestrator (Not Author)

AI responsibilities shift to:

  • drafting structured artifacts
  • detecting inconsistencies across docs/code
  • proposing missing spikes or ADRs
  • linking fragmented reasoning
  • summarizing long evolution histories

But:

  • humans retain authority over final decision commits (ADRs)
  • AI does not become sole source of truth

Pattern Language

direct implementation from prompts.

AI creates feature scratchpad (uncertainties, goals).

Boundary Conditions

Key boundaries include Risks and Failure Modes.

Patterns

1. Scratchpad-First Workflow Pattern

All non-trivial work begins with a structured scratchpad.

Avoid:

  • direct implementation from prompts
  • unrecorded reasoning

Enforce:

  • explicit hypothesis + constraints + alternatives
  • persistent versioning

2. Spike → ADR Separation Pattern

  • Spike = exploration (uncertain, experimental)
  • ADR = decision (validated, constrained)

This separation prevents:

  • premature architectural certainty
  • conflation of exploration and commitment

3. Documentation Graph Navigation Layer

Replace folder-based thinking with:

  • “why did we do this?”
  • “what depends on this decision?”
  • “what alternatives were rejected?”

Docs become a queryable reasoning network, not a file tree.

4. Async Testing as Cognitive Extension

Testing becomes:

  • queued
  • distributed
  • partially human-driven

Test artifacts encode:

  • UX signals
  • bias observations
  • probabilistic behavior evaluation

5. Implementation as Derived Artifact

Code is generated only after:

  • scratchpad convergence
  • spike validation
  • ADR commitment

Code is treated as:

compiled execution layer of documented intent

6. Feedback-Driven Documentation Evolution

Post-implementation results feed back into:

  • scratchpads (update hypotheses)
  • ADRs (add consequences)
  • knowledge base (stabilize learning)

This forms a self-correcting memory system.

EXAMPLES AND SCENARIOS

Scenario 1: Feature Development

  1. AI creates feature scratchpad (uncertainties, goals)
  2. Runs spike comparing architectures
  3. Produces ADR with tradeoffs
  4. Generates implementation guide
  5. Code is generated
  6. Tests executed asynchronously
  7. Results feed back into journal + KB

Scenario 2: Debugging System Drift

  • A bug appears
  • System queries:
  • related ADRs
  • original scratchpad assumptions
  • test history
  • Root cause identified as outdated assumption in scratchpad chain

Scenario 3: AI Memory Recovery

  • New session starts with no context
  • AI reconstructs:
  • system state from documentation graph
  • decision lineage
  • active hypotheses
  • Continues work without re-derivation

Primitives

1. Scratchpad (External Working Memory)

  • Pre-decision reasoning buffer
  • Holds ambiguity, competing approaches, hypotheses
  • Feature-scoped and iterative
  • Evolves over time rather than being replaced

2. Technical Spike

  • Experimental validation unit
  • Converts uncertainty into evidence
  • Produces constraints and feasibility boundaries

3. Architecture Decision Record (ADR)

  • Immutable decision artifact
  • Encodes rationale, alternatives, consequences
  • Functions as “compressed epistemic history”

4. AI Development Journal

  • Temporal reasoning trace of system evolution
  • Captures what changed, why, and how understanding evolved

5. Implementation Guide

  • Execution-oriented specification layer
  • Bridges intent (docs) to code structure

6. Test Backlog / Test Report System

  • Structured validation queue
  • Includes behavioral, unit, E2E, and asynchronous human evaluation
  • Encodes “what correctness means” in observable terms

7. Documentation Graph

  • Cross-linked system of artifacts:
  • scratchpads ↔ spikes ↔ ADRs ↔ tests ↔ reviews
  • Acts as navigable cognitive topology

8. AI Service / Execution Layer (Conceptual Boundary)

  • Stable interface between:
  • intent (documentation)
  • execution (code, APIs, models)

HOW THE CONCEPT WORKS

1. Documentation-as-State Machine

Development artifacts move through a lifecycle:

Idea → Scratchpad → Spike → ADR → Implementation Guide → Code → Test Reports → Review → Knowledge Base

Each stage is:

  • typed (has structure)
  • linked bidirectionally
  • transition-controlled

This prevents “knowledge drift” between design and implementation.

2. Externalized Cognition Loop

Instead of relying on ephemeral model context:

  1. AI writes or updates scratchpad
  2. Reasoning is stored externally
  3. AI re-reads structured memory
  4. Updates understanding
  5. Produces next artifact or action

This forms a closed cognitive loop anchored in persistent artifacts.

3. Documentation as Control Surface

Docs are not passive—they govern:

  • whether implementation is allowed
  • what abstraction layer is appropriate
  • when experimentation is required (spike)
  • when decisions are locked (ADR)
  • how testing is executed (backlog + async queue)

This makes documentation a runtime epistemic layer.

4. Graph-Based Cognitive Architecture

All artifacts form a graph:

  • Nodes: scratchpads, ADRs, spikes, tests, reviews
  • Edges:
  • supports
  • contradicts
  • implements
  • derives_from
  • validates

This enables:

  • causal reasoning (“why was this built?”)
  • impact tracing (“what breaks if this changes?”)
  • semantic navigation (“show all reasoning behind this feature”)

5. AI as Co-Orchestrator (Not Author)

AI responsibilities shift to:

  • drafting structured artifacts
  • detecting inconsistencies across docs/code
  • proposing missing spikes or ADRs
  • linking fragmented reasoning
  • summarizing long evolution histories

But:

  • humans retain authority over final decision commits (ADRs)
  • AI does not become sole source of truth

Product and business

1. AI-Native Development OS

A platform where:

  • all development flows through scratchpads + ADRs
  • AI continuously maintains documentation coherence
  • code is generated from validated intent graphs

2. “Documentation-as-Code Runtime”

  • CI validates not just code, but intent consistency
  • documentation becomes executable governance layer

3. AI Scratchpad Memory Layer (SaaS)

  • persistent reasoning storage for LLM workflows
  • session-independent memory graphs
  • cross-project reasoning reuse

4. Cognitive Git for AI Systems

  • version control for:
  • decisions
  • hypotheses
  • reasoning traces
  • not just code diffs, but thought diffs

5. Autonomous QA + Test Intelligence System

  • async human-in-loop testing platform
  • AI-generated test backlogs
  • structured UX evaluation pipelines

Research directions

  • Graph-native AI memory systems for software engineering
  • Documentation-as-runtime control planes
  • Scratchpad persistence models for stateless LLMs
  • Hybrid graph + vector cognition systems (Neo4j + embeddings)
  • AI-driven ADR generation and validation loops
  • Epistemic testing frameworks for probabilistic systems
  • Drift detection between code and documentation graphs
  • Meta-reasoning systems over development history
  • Self-updating institutional memory systems
  • AI orchestration layers over documentation ecosystems

Risks and contradictions

Risks

  • Documentation bloat
  • too many artifacts without pruning or synthesis
  • False authority of docs
  • outdated ADRs treated as immutable truth
  • Graph complexity explosion
  • reasoning graph becomes harder to navigate than code
  • Human compliance drift
  • skipping scratchpad/ADR steps under delivery pressure

Failure Modes

  • Scratchpads become dumping grounds instead of structured reasoning
  • ADRs written post-hoc to justify existing code
  • AI over-links artifacts, producing noisy cognitive graphs
  • Testing layer decouples from actual system behavior
  • “Documentation theater” replaces actual epistemic rigor

Open Questions

  • What is the minimal viable schema for scratchpad structure?
  • How should lifecycle transitions be enforced technically?
  • Can AI reliably detect missing scratchpads or ADRs?
  • What is the optimal graph representation for reasoning traces?
  • How do you prevent documentation from becoming a second unmaintained codebase?
  • Can this system scale beyond single-team cognition into organizational cognition?

Worldbuilding

  • “Documentation is law” civilizations
  • systems where governance is encoded in ADR-like memory structures
  • AI CTO entities
  • agents that manage entire software ecosystems via scratchpad graphs
  • Memory-as-infrastructure cities
  • infrastructure decisions are versioned cognitive artifacts
  • Self-reflective software ecosystems
  • systems that continuously rewrite their own documentation to evolve behavior
  • Graph minds
  • cognition distributed across interconnected decision + execution nodes

EXAMPLES AND SCENARIOS

Scenario 1: Feature Development

  1. AI creates feature scratchpad (uncertainties, goals)
  2. Runs spike comparing architectures
  3. Produces ADR with tradeoffs
  4. Generates implementation guide
  5. Code is generated
  6. Tests executed asynchronously
  7. Results feed back into journal + KB

Scenario 2: Debugging System Drift

  • A bug appears
  • System queries:
  • related ADRs
  • original scratchpad assumptions
  • test history
  • Root cause identified as outdated assumption in scratchpad chain

Scenario 3: AI Memory Recovery

  • New session starts with no context
  • AI reconstructs:
  • system state from documentation graph
  • decision lineage
  • active hypotheses
  • Continues work without re-derivation