Loop Engineering

A Better Way to Think, Create, and Work with AI - Second Edition

← All chapters

Chapter 6 - Layer 2a: Working Memory and the Scaffolding Loop

Loop Engineering by Fabio Correa, the Applied AI foundation volume on working with AI through framing, feedback, verification, memory, and human judgment.

Last updated 2026-10-25. This page hosts the seven primitives (the cover's design commitments), the NOTES.md externalized-scratchpad pattern, and the loopmaxxing failure mode that appears when the discipline degrades.

The question this chapter takes up

How does work survive a context limit, a compaction, or a brand-new session without starting over?

Put it to work

Open the working-memory worked example, then draft a scratchpad contract for one multi-iteration task.

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.

Primary-source links

Tooling note. Huntley's original sketch piped to claude-code. The book substitutes the current Amp CLI, amp, so the canonical loop reads while :; do cat PROMPT.md | amp -x ; done. Amp's -x execute mode runs a one-shot prompt, prints the response, and exits; it can also receive piped input.

Dates. Huntley published the Ralph pattern in July 2025. By June 2026, Osmani's loop engineering framing had popularized the term in trade-press language. The label changed quickly; the underlying mechanics did not.

Related resources

The book's Figure 6.1 is the translation table for the seven primitives: each primitive's failure mode and its mapping across the four practices. A working-memory worked example with a full NOTES.md trace and per-iteration state captures lives in the worked-examples section.