LEADING GUIDE · FLAGSHIP COURSE

Loop Engineering with Claude Code and Fable 5

A complete hands-on course for building self-improving AI agents. Interactive modules, a live loop simulator, working code you can execute, charts, and 4 real projects.

8
Modules
~6h
Runtime
12
Live examples
4
Projects
Your progress0%
MODULE 01Architecture · 25 min

How Claude Code Works Under the Hood

Claude Code is Anthropic's command-line assistant that reads your codebase, plans changes, runs tools, runs tests, and iterates autonomously. To engineer good loops on top of it, first look inside.

Persistent context

CLAUDE.md, file @mentions, memory files. What Claude sees on turn N.

Tool system

File ops, shell, git, MCP, web skills. Every tool is one verb.

Agentic foundation

Observe → Plan → Act → Verify → Iterate. The atomic loop.

The atomic loop
Observe
Plan
Act
Verify
Iterate

Observe: Reads files, tests, prior context, tool outputs.

Practical setup — project-level CLAUDE.md

CLAUDE.md
# Global Policies for This Project
- Always create a git worktree for experiments: git worktree add ../temp-$(date +%s)
- Run relevant tests after every code change
- Use low effort for routine tasks, high effort for planning
- Document all changes clearly
- Never execute destructive commands without confirmation
- Prefer secure, minimal changes

Basic commands

claude
/init
Read the entire src/ directory and provide a high-level architecture summary.
claude · file manipulation
Edit utils.py to implement caching for the get_data function.
Then execute: python -c "from utils import get_data; print(get_data())"
Pro tip
Use subagents for specialized tasks (verifier, researcher, tester) to keep the main context clean and cheap.
MODULE 02Core concept · 40 min

The Agentic Loop Explained

Loops replace one-shot prompts with a system: trigger, goal, executor, verifier, memory, stop condition. Below is a live simulator — tune the rubric and watch convergence.

Trigger

manual · cron · webhook · event

Goal + rubric

measurable success criteria

Executor

Fable 5 for complex, Sonnet for routine

Verifier

separate agent · scores 1–10

Memory

progress.md · CLAUDE.md

Stop condition

max iters · pass · budget cap

Live loop simulator

Tune the rubric. Watch convergence.

3
2
2
1
10
Iterations
1
Score
68.4
Tokens
4,757
Cost
$0.071
AWAITING RUN
Rubric score by iteration
Rubric coverage
Tokens burned

Basic goal-driven loop

claude · /goal
/goal: Refactor the authentication module for security and performance.
Success criteria (verify each iteration):
1. All unit tests pass (pytest auth/)
2. No security issues detected
3. Performance benchmark improved >=15%
4. Code style compliant and documented

Use a dedicated worktree. Maximum 5 iterations. Summarize final changes.

Self-improving loop with a verifier subagent

~/.claude/agents/verifier.md
model: sonnet
effort: low

You are a strict code verifier. Score the output 1-10 against the provided rubric.
Only approve if score >=9. Provide specific fix suggestions otherwise.
claude · main session
Use the verifier subagent after every major change.
/loop every 30 seconds until goal is met or max 10 iterations reached.
Log progress to progress.md

Dynamic parallel agents

claude
Spawn parallel subagents:
- Researcher (haiku, low effort): Collect latest best practices
- Implementer (Fable 5): Apply changes to code
- Tester: Run full test suite

Only merge after all subagents reach consensus.
MODULE 03Skills · Hooks · MCP · 35 min

Advanced Features Most Devs Overlook

Skills — reusable workflows

skills/auto-review.skill.md
# Automatic Code Review Skill
Triggers: File edits in src/ or PR creation

Instructions:
- Review for tests, edge cases, security, performance, readability
- Suggest improvements in JSON format: {"issues": [...], "suggestions": [...]}
- Auto-apply safe fixes when confidence >80%

Invoke with @auto-review in prompts.

Hooks — event-driven glue

hooks/post-edit.js
const { execSync } = require('child_process');
try {
  execSync(`eslint --fix ${process.env.FILE}`);
  console.log(`Linting applied to ${process.env.FILE}`);
} catch (e) {
  console.log('Linting warnings present');
}

MCP + GitHub

claude · via MCP
Connect via MCP to GitHub.
Create a draft PR for the current branch.
Include:
- Clear title and description
- Test results summary
- Security checklist
Tool surface — which verbs Claude has
MODULE 04Ergonomics · 15 min

Why Voice Input Beats Pure Writing

Voice lets you specify complex, nuanced goals faster than typing. Best used in a hybrid workflow: dictate the intent, refine into a structured /goal loop.

Speak the idea

Claude mobile/web voice captures nuance and constraints.

Refine into a /goal

Paste transcript, ask Claude to produce a full rubric + verifier spec.

Ship the loop

Executor runs; verifier scores; you review the diff.

claude · refine transcript
Refine this voice transcript into a complete executable /goal loop with detailed rubric and verifier instructions.

[PASTE TRANSCRIPT HERE]
Why it works
Speech averages 150 wpm versus ~40 wpm typing — you offload spec drafting to Claude and keep your working memory for review.
MODULE 05CI-grade automation · 30 min

Automatic Code Review with Draft PRs

Checkout
Tests + Scan
Analyze
Fix
Draft PR
Iterate ×4
claude · /goal
/goal: Review, fix, and create draft PR for branch 'feature/new-feature'.
Loop steps:
1. Checkout in isolated worktree
2. Run full tests + linter + security scan
3. Analyze changes and generate improvements
4. Create/update draft PR with detailed summary, test report, and checklist
5. Iterate fixes up to 4 times

Use Fable 5 for orchestration.
Result
Draft PRs with test evidence and a security checklist attached — humans review the diff, not the setup.
MODULE 06Beyond programming · 40 min

Fable 5 for Non-Code Work

Fable 5 excels at long-horizon autonomous tasks: research reports, content pipelines, business ops.

Where teams point Fable 5

Market research loop

claude · /goal
/goal: Create a comprehensive Q3 market analysis report on AI coding assistants.
Requirements:
- Cover major players with citations
- Include SWOT analysis and recommendations
- Professional Markdown format with tables
- Verify all facts across multiple sources

Run as a daily Routine.

Content generation loop

claude
Create a detailed blog post on "Loop Engineering Best Practices".
Process: Outline → Draft sections with voice input → Self-critique → Revise → Format for publication.

Business automation

claude
Process leads from leads.csv:
- Personalize outreach emails using template
- Send via approved MCP integration
- Track responses in loop
- Generate daily summary report
MODULE 07Prod-grade · 25 min

Advanced Topics & Best Practices

Cost · latency · quality by model

Model routing config

agents.yaml
main: fable-5
workers:
  - name: scout
    model: haiku
    effort: low
  - name: executor
    model: sonnet

Memory management

progress.md
# Loop Progress
Current Goal: ...
Attempts: ...
Learnings: ...
Next Actions: ...
Do
  • Monitor tokens and cost per iteration.
  • Escalate to humans on high-risk changes.
  • Test in isolated worktrees.
  • Write rubrics with numeric thresholds.
Avoid
  • Vague goals — cause drift.
  • Infinite loops — set hard iter caps.
  • Auto-merging without a verifier.
  • Single-agent self-review (bias).
MODULE 08Build 4 real loops · 90 min

Hands-On Projects

PROJECT 01
Self-Healing Code Agent

Monitor lint/test issues in your repo and auto-fix in a worktree loop.

Start with a ready-made loop
PROJECT 02
Daily Research Assistant

Scheduled routine that gathers, summarizes, and emails key insights.

Start with a ready-made loop
PROJECT 03
Full Agentic Application

Combine loops + subagents into an autonomous content generator + publisher.

Start with a ready-made loop
PROJECT 04
Non-Code Business Workflow

Automate a real ops process end-to-end (leads, reports, follow-ups).

Start with a ready-made loop

Keep building loops.

Start with a simple loop, measure impact, then expand. The best way to master loop engineering is by shipping them.