Chapter 6 - Layer 2a: Working Memory and the Scaffolding Loop
Last updated 2026-07-13. Explore the seven design commitments, the NOTES.md externalized-scratchpad pattern, and the loopmaxxing failure mode that appears when the discipline degrades.
Companion activity
Open the working-memory worked example or NOTES.md template, then draft a scratchpad contract for one multi-iteration task.
What this chapter argues
Working memory in the brain is small, fast, and lossy. Working memory in the AI partner is the model's context window - also small, fast, and lossy. The scaffolding loop is the discipline that extends usable working memory across that limit: an externalized scratchpad (NOTES.md), seven operational commitments that make the loop verifiable, and a cadence that prevents thrash. Without the scaffolding loop the AI hits its context limit and either silently drops earlier context or starts to confabulate. With it, sessions hours longer than the raw window become reliable.
Key sources
Chapter 6 cites in the print book: D8, D9, D24, D25, D30, D32, D33, D34, D57, D58, D60. Entries below are the sources this page draws on; some are related literature cited elsewhere in the book rather than in this chapter.
- D8 - Huntley, G. (2025). Ralph Wiggum as a Software Engineer. ghuntley.com/ralph/
- D11 - Willison, S. (2025). Designing agentic loops. simonwillison.net/2025/Sep/30/designing-agentic-loops
- D22 - Anthropic. (2025). Effective context engineering for AI agents. anthropic.com/engineering/effective-context-engineering-for-ai-agents
- D23 - Runkle, S. (2026). The Art of Loop Engineering. LangChain. langchain.com/blog/the-art-of-loop-engineering
Primary-source links
- Huntley, "Ralph Wiggum as a Software Engineer" - the original scaffolding-loop pattern: a stupidly simple bash loop that out-performs more sophisticated harnesses because the loop is verifiable and the per-iteration cost is bounded.
- Willison, "Designing agentic loops" - names the discipline as the successor skill to prompt engineering.
- Anthropic, "Effective context engineering for AI agents" - first-party vendor guidance on what the working-memory layer should look like.
- LangChain, "The Art of Loop Engineering" - framework-vendor framing that operationalizes the loop pattern.
Chapter contents
- The loop as motion, the primitives as contract.
- The seven design commitments in operational shape, with the verifiable-stop check at every iteration.
- Loop engineering and harness engineering: how the agent = model + harness framing maps onto the primitives. Harness engineering foregrounds component decomposition; this book foregrounds contract obligations. The primitives are the contract; the harness is one way to enforce it.
NOTES.mdas the canonical externalized-scratchpad pattern: what goes in, when, and how it survives a/compact.- The Ralph-loop archetype and why "stupidly simple" wins - with the loop controls that make it safe to run.
- Loopmaxxing: when more iterations make the result worse, not better.
Related resources
The seven-commitments deep treatment on the companion site goes further into each commitment's failure mode and four-practice mapping. A working-memory worked example with a full NOTES.md trace and per-iteration state captures lives in the worked-examples section.
Practitioner prompts: the working-memory prompts page hosts the NOTES.md template, the scaffolding-loop contract, and the verifiable-stop checklist as copy-paste-ready text.