Speaker Notes

Full Walkthrough: Workflow for AI Coding — Matt Pocock

Effective AI coding workflows require managing context degradation through frequent resets, rigorous upfront planning, vertical slicing, test-driven development, and deep modular design.

AI Engineer and Matt Pocock · 1:36:30 · YouTube ↗

Workshop · solo speaker  Intermediate · concepts and live coding workflow

Highlights

10 clips · 19 min of 96 min
    • LLM attention relationships scale quadratically with token count, reducing output quality over long sessions.
    • Intelligence noticeably degrades around 100K tokens regardless of maximum context window sizes.
    • Tasks must be strictly sized to stay within the initial smart zone.
    • Treat LLMs like the character from Memento by frequently resetting to a clean base state.
    • Compacting conversation history preserves baggage, whereas starting fresh keeps the initial state predictable and small.
    • The specs-to-code approach fails because ignoring the codebase leads to deep misalignment.
    • A relentless grilling skill forces the AI to surface hidden dependencies and edge cases like retroactive data handling.
    • The primary goal of early planning is achieving a shared design concept rather than generating premature code.
    • AI workflows split into collaborative human-in-the-loop phases for planning and autonomous away-from-keyboard phases for execution.
    • Attempting to fully automate architectural alignment bypasses critical human judgment.
    • Massive context windows are great for retrieval but expand the coding dumb zone.
    • Claude's 1 million token window is less effective for active code generation.
    • Sticking to a tighter 100k context maintains higher output quality.
    • AI naturally codes layer-by-layer horizontally, delaying integration feedback.
    • Vertical slices cross all system layers to provide near-instant feedback.
    • Traceable bullets help agents test end-to-end functionality early.
    • Kanban boards define blocking relationships between independent tasks.
    • Structuring tasks as a directed acyclic graph enables multi-agent parallelization.
    • Sequential plans limit execution to a single agent loop.
    • Enforces red-green-refactor loops to prevent AI from cheating on tests
    • Establishes guardrails by instrumenting code before writing implementation
    • Warrants warping your entire workflow around test-driven development
    • Deep modules expose simple interfaces with heavy functionality inside
    • Shallow file structures confuse AI agents and complicate test boundaries
    • Deep modules create clear test perimeters that dramatically improve AI reliability
    • Push instructions to automated reviewers to enforce strict coding standards
    • Allow implementer agents to pull reference skills from the repository as needed
    • Separating push and pull workflows optimizes token context and agent performance

Questions this video answers

12 · every answer cites the moment it was said
01 Why do LLMs get dumber as a conversation progresses? 2 sources · 3:40

As tokens are continuously added to a single context window, the attention relationships scale quadratically and strain the system. This pushes the model past its smart zone into the dumb zone around 100K tokens. Developers should keep tasks small to avoid this performance degradation.

02 Should I compact context or clear it entirely? 2 sources · 8:42

Matt prefers clearing the context entirely to return the AI to a base state, comparing it to the character from Memento who continually forgets. Compacting squeezes previous conversation into a written history record, but resetting ensures the system prompt and starting state remain consistently fresh.

03 How do I prevent requirements misalignment when starting a feature with AI? 2 sources · 12:27

Instead of relying solely on a specs-to-code approach, you should use an interactive technique like the grill me skill. This skill has the AI interview you relentlessly about every aspect of the plan to reach a shared design concept. It walks down decision tree branches one by one to resolve dependencies.

04 When should I step away from the keyboard during an AI workflow? 2 sources · 26:39

Workflows can be split into human-in-the-loop tasks like strategic planning and requirement alignment that require active participation. In contrast, tasks like implementation can be treated as away-from-the-keyboard once the destination is mapped out. You must stay involved for crucial design choices but can let the model handle execution steps.

05 Why do you avoid reviewing AI-generated product requirements documents? 1 source · 35:36

LLMs excel at summarization, and since you already share a design concept from the grilling session, reading the PRD only tests the LLM's summarization skills. Therefore, skipping this review saves time without risking alignment.

06 Why is the 1 million token context window less ideal for coding? 2 sources · 37:53

Larger context windows often just provide more dumb zone rather than improved reasoning for coding tasks. A smaller context window around 100k tokens is considered the optimal smart zone for code.

07 What are vertical slices, and why are they preferred over horizontal coding? 2 sources · 43:44

Vertical slices represent thin functionality chunks crossing all system layers instead of coding layer by layer. This approach provides rapid feedback because you can immediately test that all integrated layers work properly together.

08 How do you transition from planning to autonomous agent execution? 2 sources · 49:45

You convert the PRD into a Kanban board of independent issues with blocking relationships that allow agents to process tasks sequentially or in parallel. Once this backlog is queued up, the human steps back and lets the AI handle the implementation phase AFK.

09 Why is test-driven development essential when working with AI agents? 2 sources · 1:06:48

TDD forces the agent to write a failing test first using red-green-refactor before writing the implementation, which prevents it from cheating by generating tests that match faulty logic. Because feedback loops set the quality ceiling for AI outputs, having strong automated tests ensures the agent does not code blind.

10 How do deep modules help AI agents navigate codebases? 2 sources · 1:17:07

Deep modules expose a small, simple interface while encapsulating a large amount of functionality internally, making it much easier to wrap them in test boundaries. In contrast, shallow modules create a complex web of tiny files and dependencies that confuse AI agents and make testing difficult.

11 How should I enforce coding standards during different phases of agent execution? 2 sources · 1:28:18

You should use a pull strategy for implementers, allowing them to pull coding standards via skills when they need guidance. Conversely, you should use a push strategy for automated reviewers by pushing the coding standards directly to them alongside the written code.

12 How do you run parallel agent loops safely? 2 sources · 1:30:07

You can use tools like Sandcastle to run agents in isolated Docker work trees and Git branches in parallel. A planner chooses issues from the backlog, separate sandbox implementers write the code, and a merger agent resolves any test or type conflicts before merging.

Section-by-section summary

20 parts

LLM context windows degrade quadratically

LLMs operate in a smart zone initially, but as tokens accumulate, attention relationships scale quadratically and intelligence drops. Developers must keep tasks small and scoped to avoid hitting this dumb zone.

Multi-phase plans naturally evolve into loops

Static multi-phase plans for large tasks act like loops, which can be operationalized via continuous execution patterns like the Ralph loop. However, open-ended loops require structural guidance to prevent compounding errors.

Clear context entirely instead of compacting

LLM sessions mirror the character from Memento by repeatedly resetting to a clean base state with a minimal system prompt. Compacting conversation history is often inferior to maintaining a pristine, predictable initial state.

The grill me skill prevents requirement misalignment

The specs-to-code movement fails because developers lose touch with the underlying codebase when relying purely on static specifications. The grill me skill forces an interactive, relentless Q&A session to establish a true shared design concept before coding.

Separate human-in-the-loop and AFK tasks

AI tasks must be categorized into those requiring heavy human collaboration, like architectural alignment and planning, and those that can run autonomously away from the keyboard. Conflating these two modes leads to friction and poor oversight.

Summarize alignment into a destination PRD

Once a rigorous grilling session concludes, the valuable conversational output must be distilled into a product requirements document. This destination document acts as the definitive roadmap for user stories and definition of done.

Writing PRDs as destination documents

After a grilling session, the design concept is summarized into a product requirements document to lock in the destination. This PRD outlines problem statements, user stories, and key implementation decisions.

Why reviewing AI-generated PRDs is unnecessary

Developers do not need to read the generated PRDs because they already share a design concept with the LLM from the grilling session. Reviewing them only tests the LLM's summarization capability rather than validating core logic.

Context windows and the AI dumb zone

While 1 million token context windows are great for retrieval tasks, they introduce a larger dumb zone for coding. Operating within a tighter 100k smart zone yields much better results for software development.

Enforcing vertical slices over horizontal coding

AI naturally tends to code horizontally by building entire layers like databases before touching the frontend. Developers must enforce vertical slices and traceable bullets crossing all layers to ensure continuous feedback loops.

Using Kanban boards for agent parallelization

Transforming PRDs into local Kanban boards creates directed acyclic graphs of issues with clear blocking relationships. This structure allows multiple independent agents to run in parallel rather than being locked into a sequential plan.

Executing the night shift with AFK agents

Once planning is complete, the human steps out of the loop to let an agent execute tasks via a script. Running this Ralph loop iteratively in a sandbox automates the implementation phase using local markdown issues.

Coping with increased code review overhead

Delegating all coding to AI inevitably leads to a massive increase in code review volume for developers. Teams must accept this overhead or find new ways to handle agent-generated pull requests efficiently.

Clear context to review code in the smart zone

Instead of letting the AI review its own code using up token history in the dumb zone, clear the context first. Reviewing in a fresh context ensures the agent operates with maximum reasoning capability.

Test-driven development is essential for agent success

TDD using the red-green-refactor cycle prevents AI from writing superficial tests after the fact. Enforcing failing tests first establishes robust guardrails and significantly improves generated code quality.

Manual QA preserves human taste and prevents slop

Automated pipelines alone can lead to generic or broken software lacking human intention. Manual QA serves as the critical touchpoint to inject developer taste and ensure high-quality output.

Deep modules make codebases navigable for AI

Shallow modules with intricate file dependencies confuse AI agents and complicate testing boundaries. Designing deep modules with simple interfaces and rich internal functionality makes the codebase vastly more testable.

Avoid doc rot by discarding outdated markdown plans

Keeping obsolete PRDs and design documents in the repository leads to documentation rot that misleads AI agents. Deleting completed temporary plans prevents agents from referencing stale architecture.

Push versus pull strategies for enforcing coding standards

Push instructions to force global rules onto automated reviewers while allowing implementers to pull reference skills as needed. This hybrid approach optimizes token usage and maintains strict coding standards.

Running parallel agent loops with isolated sandboxes

Using dedicated TypeScript orchestration tools like Sandcastle allows developers to run multiple agent tasks in parallel inside Docker containers. This automates planning, implementation, and merging across isolated branches.

0:00 / 1:36:30
k play/pause · f fullscreen · m mute
n next · p previous clip · t highlights/full
< > slower/faster · / search what was said
  • Smart zone8× · first 3:23

    The initial state of an LLM conversation where attention relationships are least strained and it does its best work.

  • Grill me skill12× · first 12:21

    A custom prompt skill that has the AI interview the developer relentlessly to resolve dependencies and build a shared design concept.

  • PRD20× · first 7:01

    A product requirements document used as a destination document to summarize design concepts.

  • Kanban board8× · first 40:10

    A set of tickets with blocking relationships used to organize multi-phase tasks.

  • Vertical slices4× · first 42:04

    Thin slices of functionality that cross all system layers to provide rapid feedback.

  • TDD4× · first 57:23

    Test-driven development is a practice where failing tests are written before the implementation to guide code creation.

  • Deep modules4× · first 33:36

    Modules that expose a simple interface while containing a large amount of internal functionality.

  • Sandcastle3× · first 1:29:57

    A TypeScript library created by the speaker for running AI agent loops in isolated Docker sandboxes.