Skip to content

Lesson 4: AFK Agents — Stay Out the Loop

Tactical Agentic Coding

The one tactic: Stay out the loop — build AFK (away-from-keyboard) agents wrapped in AI Developer Workflows so your codebase ships work autonomously, from prompt to PR, while you focus on building the system that builds the system.

Overview

Lesson four is where you step out of the loop and let your product build itself. There are two modes of agentic coding. Human-in-the-loop is what most engineers do now — sitting at the device, prompting back and forth, burning time on chores, bugs, and features that don't actually need their expertise. Out-loop (off-device) agentic coding is when you send a high-to-low-level prompt into your own agentic pipeline and walk away — or were never there at all. The prompt might arrive from a phone, GitHub, Slack, Notion, Jira, or a text message.

Staying out the loop is the tactic that lets you ride the fact that models improve and tools change: over time your agents solve more and more problems, so your leverage compounds if you invest in the system rather than the work. This directly serves the KPIs — Presence down, Size up, Streak up, Attempts down.

Cloud-based coding agents (Copilot, Devon, Jules, Codex) are useful but limited by design: they're built for everyone's codebase, not yours. They don't run your templates, your prompts, or your engineering practices. Your agentic pipeline is too valuable to outsource — you want to own it.

The vehicle is the ADW (AI Developer Workflow): the highest leverage point and highest composition level of agentic coding. This lesson runs two ADWs to automate the plan and build steps of the SDLC — prompt to PR — using the four elements of AFK agents.

Key concepts

PETER — the four elements of AFK agents

To run agents while you're away from the keyboard you need four elements, remembered with the mnemonic PETER:

ElementWhat it isExample in the lesson
Prompt inputThe source of the work — a high-to-mid-level prompt that defines what you wantGitHub Issue (title + body = the prompt)
TriggerWhat kicks the workflow offGitHub webhook (via a Cloudflared proxy) — or a local script
EnvironmentA dedicated place the agent runs and controlsA Mac mini the agent fully controls — or your local device
ReviewHow you inspect the resultGitHub Pull Request

PETER is Dan's memory hook for the four elements — Prompt input, Trigger, Environment, Review. They can be any tools; the framework matters, not the specific stack.

ADW — AI Developer Workflow

A reusable agentic workflow that combines deterministic code, agentic prompts, and agents to deliver results autonomously. It is the synthesis of old-generation deterministic scripts and new-generation non-deterministic language models, prompt chains, and agents. Think of it as an agentic pipeline — a new agentic layer wrapped around your codebase. In the future these will simply be called "scripts" that assume agentic behavior by default.

The agentic layer

Two directories form the agentic layer around your codebase, kept completely separate from the app itself:

  • .claude/commands/ — your reusable prompts, templates, and meta-prompts.
  • adws/ — your ADWs (single-file scripts run with uv, or Bun/shell).

The app/ stays untouched; the agentic layer sits on top of it.

Micro-agents inside an ADW

An ADW is a chain of small, isolated agents each solving one problem well: an issue classifier, a branch generator, a planner, an implementer, committers, and a PR creator. Isolating the core four per step keeps each context window free. No ad-hoc prompt strings live in the code — every prompt is an isolated slash command you can improve.

The plan-build ADW flow

flowchart TD
    A[Prompt input: GitHub Issue] --> B[Trigger: webhook or local script]
    B --> C[Fetch issue details]
    C --> D[Classify: chore / bug / feature]
    D --> E[Create feature branch]
    E --> F[Plan agent: /feature meta-prompt writes spec]
    F --> G[Commit plan]
    G --> H[Build agent: /implement passes plan as arg]
    H --> I[Commit implementation]
    I --> J[Create Pull Request]
    J --> K[Review: engineer reviews PR]
    F -.live comments.-> A
    H -.live comments.-> A

How to apply it

  1. Pick your four PETER elements. Start with great defaults: GitHub Issues (prompt input), GitHub PRs (review), and a local trigger/environment first.
  2. Install into a reusable state. Run /install — unset the origin remote, point at your repo, copy .env, install deps. Add a report step so the agent tells you what's done and what action you must take.
  3. Set the required env vars. The Agent SDK currently needs ANTHROPIC_API_KEY; set your Claude Code path via which claude.
  4. Run a health check first. Validate env path, repo, and that Claude Code runs before firing the real workflow.
  5. Write the prompt input. Create a GitHub Issue whose title/body is a high-to-mid-level prompt (e.g. "add JSON-L support: stdlib only, concat nested fields, handle arrays, update the UI").
  6. Fire the ADW. Locally: uv run adws/adw_plan_build.py <issue#>. The agent branches, plans, builds, and opens a PR autonomously while posting live comments to the issue.
  7. Review the PR, then run a quick regression + feature smoke test.
  8. Fix the system, not the issue. When something's wrong, improve the template or the ADW so future runs don't repeat it.
  9. Offload to a dedicated environment. Move the trigger to a webhook (via a proxy like Cloudflared) and the environment to a separate always-on device so you can fire work from anywhere.
  10. Climb the trust ladder: automate chores first, then bugs, then features.

Commands & conventions

Command / pathPurpose
/installReusable setup (remote, .env, deps) + report step
adws/Home of AI Developer Workflows (single-file scripts)
adws/adw_plan_build.pyThe plan+build ADW: fetch → classify → branch → plan → build → PR
/classifyMicro-agent prompt mapping an issue to chore/bug/feature
/feature, /bug, /choreTemplates the planner runs based on classification
/implement <plan>HOP the builder runs with the plan as its argument
health-check scriptValidates env, repo, and Claude Code before a run
Claude Code hooksEmit per-session log files for observability
bash
# Validate the environment, then run the ADW on issue #33
uv run adws/adw_health_check.py 33
uv run adws/adw_plan_build.py 33
python
# Inside the ADW, the build step calls Claude Code in programmable mode.
# It runs dangerously-skip-permissions, but safely — inside its own environment.
claude -p "/implement specs/<plan>.md" --dangerously-skip-permissions

Key takeaways

  • Two modes: human-in-the-loop (early game) vs. out-loop / off-device (the goal).
  • PETER = Prompt input, Trigger, Environment, Review — the four elements of AFK agents.
  • An ADW combines deterministic code + agentic prompts + agents to run autonomously.
  • The agentic layer lives in .claude/commands/ (prompts) and adws/ (workflows), separate from app/.
  • An ADW is a chain of isolated micro-agents: classifier, brancher, planner, implementer, committers, PR creator.
  • Give the plan/build steps your most powerful model; keep every prompt isolated and improvable.
  • Own your pipeline — cloud tools don't run your templates or solve your classes of problems.
  • When an agent misses, fix the system (templates/ADW), not the individual output.
  • Add logging, hooks, and reporting so the whole workflow is observable and reviewable.

Notable quotes

"You build the system that builds the system. This is where we need to focus."

"Out-loop agentic coding is off-device agentic coding… you go AFK, away from keyboard."

"Every time you miss something, you don't fix the issue. You fix the system that caused the issue."

"Success is absolutely planned. You can plan success into your codebase by templating your engineering."