Access Granted

    Loop Engineering
    Playbook

    The practical guide to designing AI loops that stop only when a real check passes.

    Quick Start (5 Steps)

    1. 1. Pick one repeated task you already trust AI with
    2. 2. Write the goal, context, action, check, and retry limit
    3. 3. Choose the lowest verifier rung that proves the task worked
    4. 4. Add a cost cap and a human gate for anything risky
    5. 5. Run the 7-day track at the bottom of this guide
    Core Idea

    A loop is five plain steps

    A useful AI loop has a goal, the context it needs, an action it takes, a check on whether the action worked, and a retry rule if it failed.

    Goal

    What result should exist?

    Context

    What must the agent read first?

    Action

    What does it do?

    Check

    What proves it worked?

    Retry

    What happens if it fails?

    The whole job
    The loop is cheap to write. The valuable work is deciding what counts as done, then turning that decision into a check that runs outside the agent's own story.
    closed-loop skeleton
    Goal: [specific output]
    Context: [files, data, rules, examples]
    Action: [what the agent does]
    Verifier: [lowest check that proves the output is valid]
    Retry: [max attempts + what changes each retry]
    Stop: [time, spend, attempt, or human gate]
    Verifier Design

    The verifier ladder

    Verifiers sit on a ladder from dumb and certain to smart and arguable. Your goal is to stay as low as the task allows.

    Use this when the loop's first promise is simple: create a report, export a CSV, write a summary file, produce an invoice, save a screenshot.

    example check
    test -s deliverables/report.html

    This does not prove quality. It proves existence. That is still better than accepting the agent's word.

    Eval Patterns

    Two eval backbones

    Scorer with threshold

    Best for content and knowledge work where quality is graded. The score must clear a hard line before output moves forward.

    • Newsletter and essay: 80+
    • LinkedIn: 75+
    • Email: 70+ plus binary reject gates

    Binary proof gate

    Best for code, security, data integrity, and anything where one failure should block shipping.

    • PROVEN, NOT_PROVEN, or INCONCLUSIVE
    • Artifact on disk for each claim
    • Any fail blocks ship
    Build story
    yalla uses a proof contract, not a mood. A separate reviewer answers one yes/no question per check and points at the artifact. No composite score can hide a failed security or build gate.
    Loop Shape

    Open vs closed loops

    Closed loop

    Known input, known steps, known check, clear stop condition. Start here.

    good first loop
    Each morning:
    1. Read inbox notes
    2. Extract tasks
    3. Rank by deadline and value
    4. Verify every task has an owner and next action
    5. Stop after one daily plan is written

    Open loop

    Broad goal, fuzzy finish line, lots of exploration. Useful, but expensive and harder to trust.

    convert it before automating
    Bad: Research the market until you find something interesting.
    
    Better: Find 10 recent examples, discard dead links,
    score each against 5 criteria, and stop.
    Default rule
    If you cannot name the stop condition before the loop starts, it is not ready to run unattended.
    Risk Control

    Understanding debt

    A self-running system can produce more than you can read. That feels productive until you approve work you no longer understand.

    Spot-check cadence

    Review a random sample from every loop run, even when the gate passes.

    Rule ownership

    Keep the verifier rules in a human-owned file the agent cannot quietly rewrite.

    Cost cap

    Set max attempts, time, spend, or tokens before the loop starts.

    Recovery path

    Write restart, replay, and rollback instructions before the first unattended run.

    loop safety card
    Loop name:
    Owner:
    What it may change:
    What it may never change:
    Max attempts:
    Max spend:
    Verifier:
    Human gate trigger:
    Rollback path:
    Last spot-check date:
    Build Track

    Build your first closed loop in 7 days

    Day 1

    Pick one repeated task with a clear output.

    Day 2

    Write the loop skeleton: goal, context, action, check, retry, stop.

    Day 3

    Choose the lowest verifier rung and write the exact check.

    Day 4

    Add the context pack: files, examples, rules, and source data.

    Day 5

    Run once with a human gate. Record every failure.

    Day 6

    Turn the failures into rules, tests, or checklist items.

    Day 7

    Run again with a cost cap and spot-check the output.

    Reference

    Where this fits in your AI system

    AI Work Cycle

    Use the companion skill when you want a reusable Plan, Work, Review, Triage, Learn loop.

    Get the skill

    yalla proof contract

    Study a real binary gate in code: PROVEN, NOT_PROVEN, or INCONCLUSIVE, backed by artifacts.

    Open GitHub

    Want the Full System?

    The playbook gives you the loop discipline. Second Brain 2.0 gives you the configured repo, memory layer, specialist agents, and tool setup to run it every day.

    Second Brain 2.0

    The complete Claude Code system. 30+ agents, memory that compounds, pre-configured MCPs.

    DIY $197 / Kickstart $597 / DWY $2,497

    See Packages
    MemoryOS

    The memory layer your loop writes lessons into. Patterns persist and recall across future sessions.

    Free / Standard $199/yr / Pro $349/yr

    Get MemoryOS