Spec-Driven Development
by Nader Dabit

The Agent Loop Workflow

Build effective long-running coding agents in 7 minutes. From spec to PRD to autonomous execution.

7:00

How to Build an Effective Long Running Coding Agent Loop

Nader Dabit walks through the entire process from creating a spec, building and polishing a PRD, to running the agent autonomously.

The Core Insight

The Agent Loop is an iterative process where an AI repeatedly: decides what to do next → executes that action → observes the result → repeats until the task is complete. The key is that state persists in the file system, not in the AI's memory.

The 3-Phase Workflow

Nader Dabit's workflow breaks down into three clear phases that transform vague ideas into shipped code.

1
Create the Spec

Start with a high-level description of what you want to build and why. Focus on goals, constraints, and user needs—not implementation details.

A good spec answers:

  • • What problem are we solving?
  • • Who is the target user?
  • • What are the core features (v1)?
  • • What's explicitly out of scope?
  • • What are the constraints (tech stack, budget, timeline)?

2
Build & Polish the PRD

Transform the spec into a detailed Product Requirements Document. The PRD becomes the source of truth that the agent references on every iteration.

PRD Structure

  • • Overview & objectives
  • • User stories with acceptance criteria
  • • Technical requirements
  • • API contracts & data models
  • • Non-goals (explicit boundaries)

Polish Tips

  • • Use AI to expand initial draft
  • • Add "DO NOT CHANGE" sections
  • • Include verification steps
  • • Define success metrics
  • • Create testable checkpoints

3
Run the Agent Loop

Execute the agent using Claude Code, Codex, or OpenCode. The agent reads the PRD, implements tasks, commits progress, and continues until complete.

# The Agent Loop

while task_not_complete:

1. Read PRD & check git history

2. Decide next action

3. Execute (read/write/edit/bash)

4. Commit changes with message

5. Verify against acceptance criteria

Claude Agent SDK Tools

The Claude Agent SDK (the infrastructure behind Claude Code) provides these built-in tools for agents:

Read

Read any file

Write

Create new files

Edit

Modify existing files

Bash

Run terminal commands

Glob

Find files by pattern

Grep

Search file contents

WebSearch

Search the web

WebFetch

Fetch web pages

Advanced Capabilities

Subagents

Create specialized agents for specific tasks: a "security-reviewer" to audit code, a "test-analyzer" to verify coverage, or a "performance-optimizer" to profile bottlenecks.

Permission Controls

Control what the agent can do: default (prompts for approval), acceptEdits (auto-approve file edits), or bypassPermissions (fully autonomous).

Session Management

Capture and resume sessions for multi-turn conversations. The agent remembers previous context and can answer follow-up questions or continue interrupted work.

Structured Output

Configure agents to return JSON Schema-validated output. Perfect for code review reports, audit logs, or any structured data that downstream systems consume.

The Secret: Backpressure

Tests

Unit, integration, E2E tests verify functionality

Linters

ESLint, Prettier catch style issues

Type Checkers

TypeScript ensures type safety

Quick Start

1. Install Claude Agent SDK

npm install @anthropic-ai/claude-agent-sdk

2. Create your spec file

# SPEC.md
## Goal
Build a REST API for task management

## Features (v1)
- CRUD operations for tasks
- User authentication
- Due date reminders

## Out of Scope
- Mobile app
- Team collaboration

3. Run the agent

claude --dangerously-skip-permissions "Read SPEC.md and implement the API"

How It Compares

AspectAgent LoopRalphGSD
FocusSDK-first developmentShell script simplicityContext engineering
StateGit + file systemprogress.txt + git.planning/ directory
ComplexityMedium (SDK setup)Low (shell script)High (multi-agent)
Best ForCustom agents, integrationsQuick automationLarge projects

Resources