AI Coding Workflow: From Idea to Implementation
Summary of the video “Full Walkthrough: Workflow for AI Coding — Matt Pocock” by AI Engineer.
Matt Pocock walks through a complete workflow for using AI to code: start with a grilling session to align on requirements, create a PRD as your destination document, break it into parallelizable vertical-slice issues on a Kanban board, then run AFK agents to implement while you QA and code review. The key insight is that software engineering fundamentals—small tasks, deep modules, good tests, feedback loops—work just as well with AI as with humans.
LLM Constraints: The Smart Zone and Memory
Smart Zone vs. Dumb Zone
LLMs perform best at the start of a conversation when attention relationships are least strained. As you add tokens, performance degrades quadratically (like adding teams to a league). Around 100K tokens, the LLM enters the 'dumb zone' and makes poor decisions. Keep tasks small enough to stay in the smart zone.
LLMs Forget Like the Guy from Memento
Every LLM session resets to the system prompt when you clear context. This is a feature, not a bug—it means you can optimize for predictable state resets rather than trying to compact and preserve messy conversation history.
System Prompt Should Be Tiny
Keep your system prompt as small as possible. If you load 250K tokens of context into the system prompt, you immediately enter the dumb zone before doing any work. Minimize static context to preserve tokens for actual task work.
Session Phases and Compacting
Every Session Has Four Stages
Sessions follow: (1) system prompt (static context), (2) exploratory phase (agent explores codebase), (3) implementation phase (builds features), (4) testing phase (runs feedback loops). When you clear context, you reset to the system prompt.
Compacting vs. Clearing
Compacting squeezes conversation history into a summary to preserve tokens. Clearing deletes everything and resets to the system prompt. Clearing is preferable because it guarantees consistent state; compacting introduces sediment and unpredictability.
The Grill Me Skill: Reaching Shared Understanding
Avoid Specs-to-Code: Keep Code in the Loop
The specs-to-code movement says write specs, turn them into code, and iterate on specs if something is wrong. This ignores the code itself. Instead, keep code in mind throughout planning. The code is your battleground and you must understand it.
Grill Me Skill: Interview Until Alignment
The Grill Me skill relentlessly asks questions about every aspect of a plan until you reach shared understanding with the AI. It walks down decision trees, provides recommended answers, and asks one question at a time. This creates a design concept—a shared idea between all participants.
Grilling Sessions Can Last Hours
A single grilling session can involve 40, 80, or even 100+ questions. You sit with the AI for an hour or more, building alignment. The conversation history becomes a valuable asset documenting the design concept.
Pair Programming with AI for Planning
Involve domain experts, developers, and the AI in the same grilling session. The AI acts as a third person who relentlessly quizzes everyone. This works for both planning decisions and implementation questions.
From Idea to PRD: Destination Document
PRD Summarizes the Design Concept
After grilling, write a PRD (product requirements document) that summarizes your shared understanding. It documents the destination: problem statement, solution, user stories, implementation decisions, and testing decisions. Don't review it obsessively—you already aligned during grilling.
PRD Structure: Problem, Solution, Stories, Decisions
A PRD includes: (1) problem statements, (2) proposed solution, (3) user stories defining what the feature does, (4) implementation decisions made during grilling, (5) testing decisions. This becomes your reference for the journey ahead.
Don't Over-Review the PRD
You've already reached alignment during grilling. The PRD is just a summary. Reading it again only tests the LLM's summarization ability, which it's already good at. Skip detailed review and move to implementation planning.
Breaking Into Vertical Slices: Kanban Board
Horizontal Slices vs. Vertical Slices
Horizontal slicing does all database work, then all API work, then all frontend work. You don't get feedback until phase 3. Vertical slicing crosses all layers in thin, testable chunks. You get feedback immediately and can iterate faster.
Traceable Bullets: Feedback on Every Slice
A traceable bullet is like a glowing bullet fired by an anti-aircraft gunner—you see where it's going. Each vertical slice should produce visible, testable output so you get immediate feedback on the entire flow, not just one layer.
Kanban Board with Blocking Relationships
Convert the PRD into a Kanban board of independently grabbable issues with blocking relationships. Some tasks must complete before others; some can run in parallel. This enables parallelization across multiple agents.
Directed Acyclic Graph: Phases and Parallelization
A well-structured Kanban board becomes a DAG where tasks are grouped into phases. Phase 1 tasks run first, then phase 2 tasks (which may run in parallel), then phase 3. This is far better than a sequential numbered plan that only one agent can follow.
Human in the Loop vs. AFK Tasks
Planning Is Human in the Loop
Grilling, PRD writing, and Kanban board creation require human judgment and alignment. These are not automatable. A human must be in the loop making decisions about what to build.
Implementation Can Be AFK
Once you have a clear Kanban board, implementation becomes an AFK (away from keyboard) task. Agents can work through issues in parallel, run tests, and produce code without human intervention. Humans return for QA and code review.
Day Shift (Planning) and Night Shift (Implementation)
Humans do the day shift: planning, grilling, PRD, Kanban board. Then agents do the night shift: implementation, testing, commit. This queues up work and lets agents work independently.
AFK Agent Loop: Ralph
Ralph Loop: Pick Task, Implement, Repeat
The Ralph loop (named after Ralph Wiggum) is a simple agent loop: (1) read all issues from the Kanban board, (2) pick the next task based on priority and dependencies, (3) implement it, (4) run tests and type checks, (5) commit, (6) repeat until no more AFK tasks.
Task Prioritization: Bugs, Infrastructure, Slices, Wins
The Ralph prompt prioritizes tasks in order: critical bug fixes, development infrastructure, traceable bullets (vertical slices), polishing, quick wins, and refactors. This ensures the most important work gets done first.
TDD: Red, Green, Refactor
Use test-driven development: write a failing test first, then implement code to pass it, then refactor. This prevents AI from cheating by writing tests after implementation. TDD ensures good test coverage and catches bugs early.
Feedback Loops Are Essential
AI codes blind without feedback loops. After implementation, run tests and type checks. The quality of your feedback loops directly determines the quality of AI output. If you're getting bad code, improve your tests and type checking.
Separate Context for Review
After implementation, clear the context and run a separate review pass. The reviewer works in the smart zone, not the dumb zone. This catches bugs the implementer missed.
Parallelization: Multiple Agents
Sandcastle: Parallel Agent Framework
Sandcastle is a TypeScript library for running multiple agents in parallel. It creates a work tree for each issue, sandboxes it in Docker, runs an implementer, then a reviewer, then a merger. This scales beyond sequential loops.
Planner, Implementer, Reviewer, Merger
The parallel workflow: (1) planner reads backlog and picks issues to work on in parallel, (2) implementer runs on each issue in its own sandbox, (3) reviewer checks each commit, (4) merger integrates all branches and resolves conflicts.
Use Sonnet for Implementation, Opus for Review
Sonnet is fast and cheap for implementation. Opus is smarter and better for reviewing code against standards. Use the right model for each task.
Code Quality: Deep Modules vs. Shallow Modules
Deep Modules: Simple Interface, Rich Functionality
A deep module exposes a small, simple interface but contains a lot of functionality inside. It's easy to test because you wrap a test boundary around the whole thing. AI works well with deep modules.
Shallow Modules: Many Small Pieces, Hard to Test
Shallow modules are small with many dependencies between them. AI struggles to navigate the dependency graph. Testing is unclear—do you test each module individually or in groups? Shallow modules lead to bad AI output.
Bad Codebase = Bad AI Output
If your codebase is hard to understand, has poor tests, and lacks clear module boundaries, AI will produce bad code. The quality of your codebase is the ceiling for AI quality. Invest in architecture.
Design Module Interfaces, Delegate Implementation
You design the shape of your modules and their interfaces. You understand what they do and how they behave. But you delegate the implementation inside them to AI. This keeps you sane while moving fast.
Improve Code Base Architecture Skill
Use the 'improve code base architecture' skill to scan your codebase and find opportunities to deepen modules. It identifies clusters of related code that should be tested as a unit and suggests refactorings.
Coding Standards: Push vs. Pull
Push: Instructions in Claude.md
Push instructions are always sent to the agent via Claude.md or system prompt. Use push for coding standards you want enforced on every interaction.
Pull: Skills in the Repo
Pull instructions are available in the repo as skills. The agent can pull them when needed. Use pull for implementers so they can discover standards if they want.
Implementer Pulls, Reviewer Pushes
Implementers should pull coding standards (they can look them up if needed). Reviewers should have standards pushed to them so they actively check compliance. This balances flexibility with enforcement.
QA and Code Review
QA Imposes Taste and Quality
QA is where you manually test the feature and impose your taste. Without human QA, apps lack quality and taste. You need human eyes to ensure the feature works as intended and feels right.
QA Generates New Issues
During QA, you find bugs and improvements. These become new issues added to the Kanban board. The board grows dynamically as you discover more work.
Code Review: More Work Than Before
With AI generating more code, you'll do more code review than ever. There's no way around it. If you're delegating all coding to agents, you're accepting more review burden.
Review Tests First, Then Code
When reviewing, start with the tests. Make sure they test reasonable things. Then review the code itself. Good tests are a sign of good implementation.
Context Window Size and the Dumb Zone
1M Token Window Doesn't Eliminate Dumb Zone
Even with 1M token context windows, the smart zone is still around 100K tokens. The larger window is good for retrieval tasks (e.g., searching five copies of War and Peace), but less useful for coding.
Key Principles from Software Engineering
Software Fundamentals Work with AI Too
Old principles from books like 'The Pragmatic Programmer' and 'The Philosophy of Software Design' still apply. Don't bite off more than you can chew. Keep tasks small. Use vertical slices. Design deep modules. These work just as well with AI as with humans.
Own Your Planning Stack
Don't blindly use frameworks like Spec Kit or Taskmaster. Own your planning stack so you understand it, can debug it, and can fix it when things go wrong. Control gives you observability.
Avoid Doc Rot: Delete Old PRDs
Don't keep old PRDs in your repo. They become documentation rot—the code changes so much that the old PRD becomes misleading and influences agents badly. Mark issues as closed instead.
The Complete Workflow
Full Workflow: Idea to Deployment
Start with an idea. Grill to align. Write a PRD. Break into vertical slices on a Kanban board. Implement AFK with agents. QA and code review. Share with team for final review. This is the complete loop.
Keep Code Shape in Mind Throughout
From start to finish, think about the shape of your code. What modules are you creating? What are their interfaces? Don't let AI dictate the architecture—you design it, then delegate implementation.
Notable quotes
Software engineering fundamentals work super well with AI. — Matt Pocock
The code is your battleground. You need to keep a handle on it. — Matt Pocock
Bad code bases make bad agents. If you have a garbage code base, you're going to get garbage out. — Matt Pocock
Action items
- Try the Grill Me skill on your next feature idea. Ask the AI 40+ questions until you reach alignment.
- Write a PRD after grilling. Don't obsess over it—use it as a summary, not a spec.
- Break your PRD into vertical slices (traceable bullets) on a Kanban board, not horizontal layers.
- Run the Ralph loop (or Sandcastle) to implement issues AFK. Use TDD and feedback loops.
- Manually QA every feature. Impose your taste and generate new issues from bugs found.
- Review tests first, then code. Use separate context for review so the reviewer works in the smart zone.
- Run the 'improve code base architecture' skill on your codebase to find opportunities to deepen modules.
- Design module interfaces yourself, then delegate implementation to AI. Keep the architecture in your head.
- Delete old PRDs from your repo to avoid doc rot. Mark issues as closed instead.
- Read old software engineering books (The Pragmatic Programmer, The Philosophy of Software Design). The principles still apply to AI workflows.