<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sai Tarrun</title>
    <description>The latest articles on DEV Community by Sai Tarrun (@saitarrun).</description>
    <link>https://dev.to/saitarrun</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F964265%2Fd071dcb7-1ea9-4c8b-870c-bc9d00b729cd.gif</url>
      <title>DEV Community: Sai Tarrun</title>
      <link>https://dev.to/saitarrun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saitarrun"/>
    <language>en</language>
    <item>
      <title>Building an Agentic OS: A Complete End-to-End Guide for Autonomous AI Engineering Workflows</title>
      <dc:creator>Sai Tarrun</dc:creator>
      <pubDate>Wed, 08 Jul 2026 04:11:31 +0000</pubDate>
      <link>https://dev.to/saitarrun/building-an-agentic-os-a-complete-end-to-end-guide-for-autonomous-ai-engineering-workflows-25dk</link>
      <guid>https://dev.to/saitarrun/building-an-agentic-os-a-complete-end-to-end-guide-for-autonomous-ai-engineering-workflows-25dk</guid>
      <description>&lt;p&gt;Most developers still use AI like a chatbot.&lt;/p&gt;

&lt;p&gt;They open a model, type a prompt, copy the output, fix mistakes, and repeat.&lt;/p&gt;

&lt;p&gt;That works for small tasks. It does not scale.&lt;/p&gt;

&lt;p&gt;If you want AI to operate like a real engineering teammate, you need more than prompts. You need an operating system around the model: rules, routing, verification, memory, budgets, trust, and rollback paths.&lt;/p&gt;

&lt;p&gt;This guide shows how to build an Agentic OS: a lightweight automation layer that can inspect your repo, decide what work matters, assign tasks to models, verify the output, enforce budgets, and gradually earn autonomy.&lt;/p&gt;

&lt;p&gt;This is not tied to one vendor. You can adapt it to Claude, GPT, Gemini, local models, OpenRouter, or any coding agent CLI.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Are Building
&lt;/h2&gt;

&lt;p&gt;By the end, your repo will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;your-repo/
  AGENTS.md
  Makefile
  agent-os/
    cycle.sh
    policy.md
    router.md
    intake.md
    workers/
      execute.md
      audit.md
    gates/
      verify.sh
    scripts/
      trust.sh
      cost-log.sh
      cost-check.sh
      init.sh
    assertions/
      example.md
    memory/
      STATE.md
      trust.tsv
      assertion-ledger.tsv
      usage.tsv
      queue.md
      incidents.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system has five layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Signals
  ↓
Router
  ↓
Executor
  ↓
Auditor
  ↓
Deterministic Gate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The core principle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AI can suggest. AI can execute. AI can review. But a deterministic command decides whether work is done.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why Build an Agentic OS?
&lt;/h2&gt;

&lt;p&gt;A single AI agent doing everything is fragile.&lt;/p&gt;

&lt;p&gt;Common failure modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It plans poorly.&lt;/li&gt;
&lt;li&gt;It overbuilds.&lt;/li&gt;
&lt;li&gt;It edits unrelated files.&lt;/li&gt;
&lt;li&gt;It claims success before tests pass.&lt;/li&gt;
&lt;li&gt;It grades its own work.&lt;/li&gt;
&lt;li&gt;It burns tokens on low-value tasks.&lt;/li&gt;
&lt;li&gt;It repeats mistakes because nothing tracks reliability.&lt;/li&gt;
&lt;li&gt;It breaks old behavior that was previously "done."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An Agentic OS fixes this by separating responsibilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One component reads signals.&lt;/li&gt;
&lt;li&gt;One component decides.&lt;/li&gt;
&lt;li&gt;One component executes.&lt;/li&gt;
&lt;li&gt;One component reviews.&lt;/li&gt;
&lt;li&gt;One shell script validates.&lt;/li&gt;
&lt;li&gt;One ledger tracks trust.&lt;/li&gt;
&lt;li&gt;One assertion system keeps old wins from rotting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Design Rules
&lt;/h2&gt;

&lt;p&gt;Before writing files, define the laws.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rule 1: No agent verifies itself
&lt;/h3&gt;

&lt;p&gt;The executor should not approve its own output. A fresh auditor must review the diff independently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rule 2: Every task needs a check
&lt;/h3&gt;

&lt;p&gt;Bad: "Improve the login flow."&lt;/p&gt;

&lt;p&gt;Better: "Update login error copy and verify &lt;code&gt;npm test -- tests/login&lt;/code&gt; passes."&lt;/p&gt;

&lt;p&gt;Best: "Change only login error messaging. Done when &lt;code&gt;npm test -- tests/login&lt;/code&gt; and &lt;code&gt;npm run lint&lt;/code&gt; both pass."&lt;/p&gt;

&lt;h3&gt;
  
  
  Rule 3: Expensive models decide, cheap models execute
&lt;/h3&gt;

&lt;p&gt;Use high-capability models where branching decisions matter. Use cheaper models for repetitive, scoped implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rule 4: Trust is earned per skill
&lt;/h3&gt;

&lt;p&gt;Do not give global autonomy. A model may be reliable at docs but unsafe for migrations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rule 5: Finished work becomes an assertion
&lt;/h3&gt;

&lt;p&gt;If something matters, keep checking it. A bug fixed once can return later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You need: bash, git, jq, make, gh, npm.&lt;/p&gt;

&lt;p&gt;Optional: &lt;code&gt;llm&lt;/code&gt;, an OpenRouter key, Claude Code, the OpenAI CLI, a local coding agent CLI, cron.&lt;/p&gt;

&lt;p&gt;This guide uses placeholder commands like &lt;code&gt;ai-router&lt;/code&gt;, &lt;code&gt;ai-exec&lt;/code&gt;, &lt;code&gt;ai-audit&lt;/code&gt;. Replace them with your preferred CLI, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt;
llm &lt;span class="nt"&gt;-m&lt;/span&gt; openrouter/model-name &lt;span class="s2"&gt;"..."&lt;/span&gt;
openai responses create ...
aider ...
cursor-agent ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The architecture matters more than the specific provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create the Folder Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; agent-os/&lt;span class="o"&gt;{&lt;/span&gt;workers,gates,scripts,assertions,memory&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;touch &lt;/span&gt;agent-os/memory/STATE.md
&lt;span class="nb"&gt;touch &lt;/span&gt;agent-os/memory/queue.md
&lt;span class="nb"&gt;touch &lt;/span&gt;agent-os/memory/incidents.md
&lt;span class="nb"&gt;touch &lt;/span&gt;agent-os/memory/trust.tsv
&lt;span class="nb"&gt;touch &lt;/span&gt;agent-os/memory/assertion-ledger.tsv
&lt;span class="nb"&gt;touch &lt;/span&gt;agent-os/memory/usage.tsv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create the Operating Policy
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;AGENTS.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# AGENTS.md&lt;/span&gt;

&lt;span class="gu"&gt;## Non-Negotiable Rules&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Never change more than 200 lines without human approval.
&lt;span class="p"&gt;-&lt;/span&gt; Never edit authentication, payments, secrets, migrations, or production configuration unattended.
&lt;span class="p"&gt;-&lt;/span&gt; Never add dependencies without approval.
&lt;span class="p"&gt;-&lt;/span&gt; Never delete, weaken, skip, or rewrite tests to make a change pass.
&lt;span class="p"&gt;-&lt;/span&gt; Never claim work is complete unless the validation gate passes.
&lt;span class="p"&gt;-&lt;/span&gt; Never invent secrets, APIs, file paths, or conventions.
&lt;span class="p"&gt;-&lt;/span&gt; Never perform destructive actions without approval.
&lt;span class="p"&gt;-&lt;/span&gt; Never continue after two verifier failures on the same task.

&lt;span class="gu"&gt;## Definition of Done&lt;/span&gt;
&lt;span class="p"&gt;1.&lt;/span&gt; The requested change is implemented.
&lt;span class="p"&gt;2.&lt;/span&gt; The diff stays within scope.
&lt;span class="p"&gt;3.&lt;/span&gt; A fresh auditor approves the diff.
&lt;span class="p"&gt;4.&lt;/span&gt; agent-os/gates/verify.sh exits successfully.
&lt;span class="p"&gt;5.&lt;/span&gt; The result is logged in the trust ledger.

&lt;span class="gu"&gt;## Routing Rules&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Planning and prioritization use the strongest reasoning model available.
&lt;span class="p"&gt;-&lt;/span&gt; Low-risk implementation uses cheaper execution models.
&lt;span class="p"&gt;-&lt;/span&gt; Large reading tasks use cheap long-context models.
&lt;span class="p"&gt;-&lt;/span&gt; Sensitive work is queued for human review.
&lt;span class="p"&gt;-&lt;/span&gt; Shell commands decide final status.

&lt;span class="gu"&gt;## Protected Areas&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; authentication
&lt;span class="p"&gt;-&lt;/span&gt; authorization
&lt;span class="p"&gt;-&lt;/span&gt; billing
&lt;span class="p"&gt;-&lt;/span&gt; database migrations
&lt;span class="p"&gt;-&lt;/span&gt; deployment scripts
&lt;span class="p"&gt;-&lt;/span&gt; environment variables
&lt;span class="p"&gt;-&lt;/span&gt; secrets
&lt;span class="p"&gt;-&lt;/span&gt; production configuration
&lt;span class="p"&gt;-&lt;/span&gt; destructive filesystem operations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file is the constitution. Make it enforceable, not poetic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Create the Contract
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/policy.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Agent OS Policy&lt;/span&gt;

&lt;span class="gu"&gt;## Can Act Alone&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; documentation fixes
&lt;span class="p"&gt;-&lt;/span&gt; typo fixes
&lt;span class="p"&gt;-&lt;/span&gt; formatting
&lt;span class="p"&gt;-&lt;/span&gt; lint cleanup
&lt;span class="p"&gt;-&lt;/span&gt; small test fixes
&lt;span class="p"&gt;-&lt;/span&gt; small refactors under 100 changed lines
&lt;span class="p"&gt;-&lt;/span&gt; issue labeling
&lt;span class="p"&gt;-&lt;/span&gt; draft pull requests

&lt;span class="gu"&gt;## Must Queue&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; authentication
&lt;span class="p"&gt;-&lt;/span&gt; authorization
&lt;span class="p"&gt;-&lt;/span&gt; billing
&lt;span class="p"&gt;-&lt;/span&gt; payments
&lt;span class="p"&gt;-&lt;/span&gt; database migrations
&lt;span class="p"&gt;-&lt;/span&gt; production configuration
&lt;span class="p"&gt;-&lt;/span&gt; secrets
&lt;span class="p"&gt;-&lt;/span&gt; dependency installation
&lt;span class="p"&gt;-&lt;/span&gt; diffs over 200 changed lines
&lt;span class="p"&gt;-&lt;/span&gt; unclear requirements

&lt;span class="gu"&gt;## Must Alert&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; validation fails twice
&lt;span class="p"&gt;-&lt;/span&gt; budget is exceeded
&lt;span class="p"&gt;-&lt;/span&gt; protected file touched
&lt;span class="p"&gt;-&lt;/span&gt; standing assertion violated
&lt;span class="p"&gt;-&lt;/span&gt; model refuses the task
&lt;span class="p"&gt;-&lt;/span&gt; tool output contradicts agent claim
&lt;span class="p"&gt;-&lt;/span&gt; executor and auditor disagree twice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Create the Validation Gate
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/gates/verify.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Running validation gate..."&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; package.json &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;npm run typecheck &lt;span class="nt"&gt;--if-present&lt;/span&gt;
  npm &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--if-present&lt;/span&gt;
  npm run lint &lt;span class="nt"&gt;--if-present&lt;/span&gt;
&lt;span class="k"&gt;fi
if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; pyproject.toml &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; requirements.txt &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; pytest &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true
&lt;/span&gt;&lt;span class="k"&gt;fi
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Validation gate passed."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make it executable with &lt;code&gt;chmod +x agent-os/gates/verify.sh&lt;/code&gt;, then customize it for your stack (&lt;code&gt;go test ./...&lt;/code&gt;, &lt;code&gt;cargo test&lt;/code&gt;, &lt;code&gt;pytest&lt;/code&gt;, &lt;code&gt;mvn test&lt;/code&gt;, &lt;code&gt;gradle test&lt;/code&gt;, &lt;code&gt;npm run build&lt;/code&gt;, etc). The gate must be deterministic — it should never depend on AI judgment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Create the Intake Prompt
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/intake.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;You are the intake layer for an autonomous engineering system.

You receive recent repository signals:
&lt;span class="p"&gt;-&lt;/span&gt; git commits
&lt;span class="p"&gt;-&lt;/span&gt; open issues
&lt;span class="p"&gt;-&lt;/span&gt; pull requests
&lt;span class="p"&gt;-&lt;/span&gt; CI runs
&lt;span class="p"&gt;-&lt;/span&gt; local validation output

Your job is only to decide whether anything requires action.

Output one of these:

status: quiet

or

status: actionable
finding: &lt;span class="nt"&gt;&amp;lt;one-line&lt;/span&gt; &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
evidence: &lt;span class="nt"&gt;&amp;lt;commit&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;issue&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;PR&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="na"&gt;or&lt;/span&gt; &lt;span class="na"&gt;command&lt;/span&gt; &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
risk: low | medium | high
sensitive: yes | no

Rules:
&lt;span class="p"&gt;-&lt;/span&gt; Do not propose fixes.
&lt;span class="p"&gt;-&lt;/span&gt; Do not write code.
&lt;span class="p"&gt;-&lt;/span&gt; Do not speculate.
&lt;span class="p"&gt;-&lt;/span&gt; If authentication, billing, secrets, migrations, or production config are involved, set sensitive: yes.
&lt;span class="p"&gt;-&lt;/span&gt; If evidence is weak, output status: quiet.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The intake layer should be cheap. Most cycles should end here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Create the Router Prompt
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/router.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;You are the router for an autonomous engineering system.

You do not write code.
You do not edit files.
You only decide what should happen next.

Read:
&lt;span class="p"&gt;-&lt;/span&gt; current state
&lt;span class="p"&gt;-&lt;/span&gt; policy
&lt;span class="p"&gt;-&lt;/span&gt; trust ledger
&lt;span class="p"&gt;-&lt;/span&gt; latest intake finding

Return ONLY valid JSON:

{
  "action": "execute|queue|stop",
  "skill": "stable-kebab-case-name",
  "summary": "one-line task summary",
  "scope": ["paths or areas allowed"],
  "blocked_paths": ["paths or areas not allowed"],
  "instructions": "specific implementation instructions",
  "done_when": [
    "machine-checkable condition 1",
    "machine-checkable condition 2"
  ],
  "risk": "low|medium|high"
}

Decision rules:
&lt;span class="p"&gt;-&lt;/span&gt; If risk is high, queue.
&lt;span class="p"&gt;-&lt;/span&gt; If the task touches protected areas, queue.
&lt;span class="p"&gt;-&lt;/span&gt; If requirements are unclear, queue.
&lt;span class="p"&gt;-&lt;/span&gt; If the diff is likely above 200 lines, queue.
&lt;span class="p"&gt;-&lt;/span&gt; If there is no valuable task, stop.
&lt;span class="p"&gt;-&lt;/span&gt; Otherwise execute.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The router is the only agent that chooses work. It should be smart, brief, and conservative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Create the Executor Prompt
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/workers/execute.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;You are the executor.

You receive one work order JSON.

Your job:
&lt;span class="p"&gt;-&lt;/span&gt; implement exactly the requested task
&lt;span class="p"&gt;-&lt;/span&gt; make the smallest useful change
&lt;span class="p"&gt;-&lt;/span&gt; stay inside scope
&lt;span class="p"&gt;-&lt;/span&gt; avoid unrelated refactors
&lt;span class="p"&gt;-&lt;/span&gt; avoid new dependencies
&lt;span class="p"&gt;-&lt;/span&gt; stop if blocked by missing information
&lt;span class="p"&gt;-&lt;/span&gt; never touch blocked paths

Do not:
&lt;span class="p"&gt;-&lt;/span&gt; add features
&lt;span class="p"&gt;-&lt;/span&gt; redesign architecture
&lt;span class="p"&gt;-&lt;/span&gt; change unrelated files
&lt;span class="p"&gt;-&lt;/span&gt; delete tests
&lt;span class="p"&gt;-&lt;/span&gt; weaken tests
&lt;span class="p"&gt;-&lt;/span&gt; invent secrets or config

When finished, write a short IMPLEMENTATION.md containing:
&lt;span class="p"&gt;-&lt;/span&gt; what changed
&lt;span class="p"&gt;-&lt;/span&gt; why it changed
&lt;span class="p"&gt;-&lt;/span&gt; how to verify it

Keep IMPLEMENTATION.md under 10 lines.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The executor should be constrained. The less freedom it has, the easier it is to verify.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: Create the Auditor Prompt
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/workers/audit.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;You are the auditor.

You receive:
&lt;span class="p"&gt;-&lt;/span&gt; the work order
&lt;span class="p"&gt;-&lt;/span&gt; the git diff

You do not know the executor's reasoning. You judge only the diff against the work order.

Check:
&lt;span class="p"&gt;1.&lt;/span&gt; Does the diff satisfy every done_when condition?
&lt;span class="p"&gt;2.&lt;/span&gt; Is the diff inside scope?
&lt;span class="p"&gt;3.&lt;/span&gt; Are blocked paths untouched?
&lt;span class="p"&gt;4.&lt;/span&gt; Were tests deleted, skipped, weakened, or bypassed?
&lt;span class="p"&gt;5.&lt;/span&gt; Was unnecessary functionality added?
&lt;span class="p"&gt;6.&lt;/span&gt; Is the change small enough to review?

Output exactly one line:

PASS: &lt;span class="nt"&gt;&amp;lt;short&lt;/span&gt; &lt;span class="na"&gt;reason&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

or

FAIL: &lt;span class="nt"&gt;&amp;lt;short&lt;/span&gt; &lt;span class="na"&gt;reason&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The auditor should be fresh-context. Do not include executor notes unless necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 9: Create Cost Logging
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/scripts/cost-log.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;STAGE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;unknown&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;COST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;2&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;0&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/../memory"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-Is&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="nv"&gt;$STAGE&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="nv"&gt;$COST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/../memory/usage.tsv"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make executable: &lt;code&gt;chmod +x agent-os/scripts/cost-log.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now create &lt;code&gt;agent-os/scripts/cost-check.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;BUDGET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"5"&lt;/span&gt;
&lt;span class="nv"&gt;USAGE_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/../memory/usage.tsv"&lt;/span&gt;
&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USAGE_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$# &lt;/span&gt;&lt;span class="nt"&gt;-gt&lt;/span&gt; 0 &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    &lt;span class="nt"&gt;--budget&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;BUDGET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;shift &lt;/span&gt;2 &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="nt"&gt;--report&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;'\t'&lt;/span&gt; &lt;span class="s1"&gt;'{cost[$2]+=$3; total+=$3} END {for (s in cost) printf "%-12s $%.2f\n", s, cost[s]; printf "%-12s $%.2f\n", "TOTAL", total}'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USAGE_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      &lt;span class="nb"&gt;exit &lt;/span&gt;0 &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;shift&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="k"&gt;done
&lt;/span&gt;&lt;span class="nv"&gt;TODAY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%F&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;SPENT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;'\t'&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;today&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TODAY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s1"&gt;'$1 ~ today {sum+=$3} END {printf "%.2f", sum}'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USAGE_FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;spent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SPENT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;budget&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BUDGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN {if (spent &amp;gt;= budget) exit 1; exit 0}'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Budget exceeded: spent &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="nv"&gt;$SPENT&lt;/span&gt;&lt;span class="s2"&gt; of &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="nv"&gt;$BUDGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make executable: &lt;code&gt;chmod +x agent-os/scripts/cost-check.sh&lt;/code&gt;. This lets your loop fail closed once spending crosses the limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 10: Create the Trust Ledger
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/scripts/trust.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-euo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/../memory/trust.tsv"&lt;/span&gt;
&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

tier_of&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;runs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;passes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$runs&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$passes&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s1"&gt;'
    BEGIN {
      rate = (r &amp;gt; 0) ? p / r : 0
      if (r &amp;gt;= 20 &amp;amp;&amp;amp; rate &amp;gt;= 0.95) { print "auto" }
      else if (r &amp;gt;= 10 &amp;amp;&amp;amp; rate &amp;gt;= 0.90) { print "review" }
      else { print "watch" }
    }
  '&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
  &lt;span class="nt"&gt;--render&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%-24s %6s %6s %8s %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"skill"&lt;/span&gt; &lt;span class="s2"&gt;"runs"&lt;/span&gt; &lt;span class="s2"&gt;"pass"&lt;/span&gt; &lt;span class="s2"&gt;"rate"&lt;/span&gt; &lt;span class="s2"&gt;"tier"&lt;/span&gt;
    &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;$'&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; skill runs passes&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;skill&lt;/span&gt;&lt;span class="k"&gt;:-}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;continue
      &lt;/span&gt;&lt;span class="nv"&gt;rate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$runs&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$passes&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN { printf "%.0f%%", (r &amp;gt; 0) ? (p / r) * 100 : 0 }'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%-24s %6s %6s %8s %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$skill&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$runs&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$passes&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$rate&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;tier_of &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$runs&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$passes&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;done&lt;/span&gt; &amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="nt"&gt;--tier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;skill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nv"&gt;line&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-P&lt;/span&gt; &lt;span class="s2"&gt;"^&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;skill&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;0&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
    &lt;/span&gt;&lt;span class="nv"&gt;runs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-f2&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nv"&gt;passes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-f3&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    tier_of &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$runs&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$passes&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
  record&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;skill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;skill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$skill&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;'\t'&lt;/span&gt; &lt;span class="s1"&gt;'
      BEGIN { OFS = "\t"; found = 0 }
      $1 == skill { found = 1; runs = $2 + 1; passes = $3 + (result == "pass"); print skill, runs, passes; next }
      { print }
      END { if (!found) print skill, 1, (result == "pass") ? 1 : 0 }
    '&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;.tmp"&lt;/span&gt;
    &lt;span class="nb"&gt;mv&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;.tmp"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: trust.sh --render | trust.sh --tier &amp;lt;skill&amp;gt; | trust.sh record &amp;lt;skill&amp;gt; pass|fail"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
    &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make executable: &lt;code&gt;chmod +x agent-os/scripts/trust.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Trust tiers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;watch&lt;/code&gt; = new or unreliable&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;review&lt;/code&gt; = can draft, human reviews&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;auto&lt;/code&gt; = can ship after validation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes autonomy measurable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 11: Create Persistent Assertions
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/assertions/example.md&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;name: example
status: active
born: 2026-07-07
predicate: test -f AGENTS.md
on_fail: queue for review
retire_when: only by human decision
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create &lt;code&gt;agent-os/verify-assertions.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-uo&lt;/span&gt; pipefail
&lt;span class="nv"&gt;BASE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;LEDGER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASE&lt;/span&gt;&lt;span class="s2"&gt;/memory/assertion-ledger.tsv"&lt;/span&gt;
&lt;span class="nv"&gt;VIOLATIONS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="nb"&gt;touch&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$LEDGER&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;file &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;/assertions/&lt;span class="k"&gt;*&lt;/span&gt;.md&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;continue
  if &lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s1"&gt;'^status: retired'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
  &lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; .md&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nv"&gt;predicate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s1"&gt;'^predicate:'&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="s1"&gt;':'&lt;/span&gt; &lt;span class="nt"&gt;-f2-&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s/^ //'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nv"&gt;start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%s%3N&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;timeout &lt;/span&gt;60 bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$predicate&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&amp;gt;&amp;amp;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"pass"&lt;/span&gt;
  &lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"FAIL"&lt;/span&gt;
    &lt;span class="nv"&gt;VIOLATIONS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;VIOLATIONS &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
  &lt;span class="k"&gt;fi
  &lt;/span&gt;&lt;span class="nv"&gt;duration&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%s%3N&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; start &lt;span class="k"&gt;))&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-Is&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;duration&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;ms"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$LEDGER&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"FAIL"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Assertion failed: &lt;/span&gt;&lt;span class="nv"&gt;$name&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
done
if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$VIOLATIONS&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-gt&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then &lt;/span&gt;&lt;span class="nb"&gt;exit &lt;/span&gt;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi
&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"All assertions passed."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make executable: &lt;code&gt;chmod +x agent-os/verify-assertions.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Examples of useful assertions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;predicate: npm test -- tests/auth&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;predicate: grep -R "sk_test_" . --exclude-dir=node_modules | wc -l | grep -q '^0$'&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;predicate: npm run lint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;predicate: test -f docs/api.md&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea: important completed work becomes a permanent check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 12: Build the Main Cycle
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/cycle.sh&lt;/code&gt; — the main loop that ties every layer together. Each iteration it gathers recent repo signals (commits, issues, CI runs), runs the intake prompt to decide if anything is actionable, runs the router prompt to produce a work order, creates an isolated git worktree, runs the executor prompt inside it, diffs the result, runs the auditor prompt against that diff, runs the deterministic validation gate, and records a pass or fail in the trust ledger — shipping a pull request automatically only once a skill has earned the &lt;code&gt;auto&lt;/code&gt; tier, otherwise leaving the change queued for human review. The loop respects a maximum iteration count (&lt;code&gt;MAX_ITERS&lt;/code&gt;) and a daily budget (&lt;code&gt;DAILY_BUDGET_USD&lt;/code&gt;), calling &lt;code&gt;cost-check.sh&lt;/code&gt; before and after each iteration and exiting early if the budget is exceeded. Make the script executable, and replace the placeholder commands &lt;code&gt;ai-router&lt;/code&gt;, &lt;code&gt;ai-exec&lt;/code&gt;, and &lt;code&gt;ai-audit&lt;/code&gt; with your actual model CLIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 13: Example Adapter Scripts
&lt;/h2&gt;

&lt;p&gt;If you want a simple adapter layer, create thin wrapper scripts named &lt;code&gt;ai-router&lt;/code&gt;, &lt;code&gt;ai-exec&lt;/code&gt;, and &lt;code&gt;ai-audit&lt;/code&gt; inside &lt;code&gt;agent-os/scripts/&lt;/code&gt;. Each should parse &lt;code&gt;--model&lt;/code&gt;, &lt;code&gt;--system&lt;/code&gt;, and &lt;code&gt;--input&lt;/code&gt; flags and forward them to whatever CLI you use, for example a generic &lt;code&gt;llm -m "$MODEL" -s "$SYSTEM" "$INPUT"&lt;/code&gt; call. Make them executable with &lt;code&gt;chmod +x agent-os/scripts/ai-*&lt;/code&gt;, then add &lt;code&gt;export PATH="$(pwd)/scripts:$PATH"&lt;/code&gt; near the top of &lt;code&gt;cycle.sh&lt;/code&gt; so the main loop can call generic command names no matter which provider is behind them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 14: Add the Makefile
&lt;/h2&gt;

&lt;p&gt;Add targets: &lt;code&gt;tick&lt;/code&gt; (run one cycle), &lt;code&gt;queue&lt;/code&gt; (show queued work), &lt;code&gt;state&lt;/code&gt; (tail recent state), &lt;code&gt;trust&lt;/code&gt; (render the trust table), &lt;code&gt;audit&lt;/code&gt; (show the cost report), &lt;code&gt;assert&lt;/code&gt; (run assertions), &lt;code&gt;verify&lt;/code&gt; (run the validation gate), and &lt;code&gt;clean-worktrees&lt;/code&gt; (remove leftover agent worktrees). Now you can run &lt;code&gt;make tick&lt;/code&gt;, &lt;code&gt;make queue&lt;/code&gt;, &lt;code&gt;make trust&lt;/code&gt;, &lt;code&gt;make audit&lt;/code&gt;, &lt;code&gt;make assert&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 15: First Manual Test
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;make verify&lt;/code&gt; first — if it fails, fix your repo before building anything agentic on top of it. Then run &lt;code&gt;make tick&lt;/code&gt;. Expected outcomes: no actionable work, a queued skill, or a change ready for review. Do not automate yet; run manually for the first several cycles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 16: Add a Real Assertion
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;agent-os/assertions/login-tests.md&lt;/code&gt; with a predicate that re-runs your login test suite, retiring only once the login module itself is removed. Run &lt;code&gt;make assert&lt;/code&gt; — if it passes, that fix is now continuously protected; if it fails, either the predicate is wrong or there's a real regression.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 17: Cost Formula
&lt;/h2&gt;

&lt;p&gt;Daily cost ≈ (quiet cycles × intake cost) + (active cycles × (router cost + executor cost + auditor cost)). Example: 20 quiet cycles at $0.01 = $0.20, plus 4 active cycles at ($0.25 + $0.10 + $0.15) = $2.00, for a total of about $2.20/day. Keep the quiet cycle cheap — only use your strongest model once intake finds something actionable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 18: Add Cron
&lt;/h2&gt;

&lt;p&gt;Only after manual testing, schedule the agent loop on weekdays and assertions daily, logging to a file. The loop drafts work; assertions catch regressions — keep those jobs separate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 19: The 30-Day Rollout Plan
&lt;/h2&gt;

&lt;p&gt;Do not start with full autonomy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Week 1: Manual Mode
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;make tick&lt;/code&gt;, &lt;code&gt;make trust&lt;/code&gt;, &lt;code&gt;make audit&lt;/code&gt;, &lt;code&gt;make assert&lt;/code&gt; yourself and review every decision. Goal: three correct routing decisions in a row.&lt;/p&gt;

&lt;h3&gt;
  
  
  Week 2: Draft Mode
&lt;/h3&gt;

&lt;p&gt;Enable cron, but disallow automatic PR creation. Goal: at least 10 successful runs for one skill.&lt;/p&gt;

&lt;h3&gt;
  
  
  Week 3: Review Mode
&lt;/h3&gt;

&lt;p&gt;Let trusted skills open PRs; humans still merge. Goal: one skill reaches 20 runs at a 95% pass rate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Week 4: Limited Auto Mode
&lt;/h3&gt;

&lt;p&gt;Allow one safe skill (docs cleanup, lint fixes, typo fixes) to auto-PR after validation. Goal: one full week with no failed auto-created PRs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 20: Optional Extensions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Quorum Mode&lt;/strong&gt; — when intake wakes the router too often, have several cheap models vote and only escalate if a majority agree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ratchet Mode&lt;/strong&gt; — for a metric that should only ever improve (lint warnings, failing tests, bundle size, type errors): it may go down, never up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sparring Mode&lt;/strong&gt; — one agent writes a failing test, another fixes the code; the tester can't touch implementation, the fixer can't weaken tests, disputes go to a human.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compost Mode&lt;/strong&gt; — run weekly: review failed tasks, repeated auditor failures, broken assertions, rejected PRs, and cost spikes, then output at most three proposals (a new policy rule, a better prompt, a new assertion, a skill demotion, or dead code removal).&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 21: Runbook
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Budget exceeded&lt;/td&gt;
&lt;td&gt;The loop spent too much&lt;/td&gt;
&lt;td&gt;Run &lt;code&gt;make audit&lt;/code&gt;, reduce active cycles or use cheaper models&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Assertion failed&lt;/td&gt;
&lt;td&gt;Previously working behavior broke&lt;/td&gt;
&lt;td&gt;Check commits since the last pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skill demoted&lt;/td&gt;
&lt;td&gt;Reliability dropped&lt;/td&gt;
&lt;td&gt;Inspect the last three failures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Executor produced no diff&lt;/td&gt;
&lt;td&gt;Task unclear or impossible&lt;/td&gt;
&lt;td&gt;Improve router instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auditor failed repeatedly&lt;/td&gt;
&lt;td&gt;Scope or done_when is weak&lt;/td&gt;
&lt;td&gt;Rewrite the task spec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Protected path changed&lt;/td&gt;
&lt;td&gt;Boundary violation&lt;/td&gt;
&lt;td&gt;Reject the diff and queue human review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Worktree left behind&lt;/td&gt;
&lt;td&gt;Task needs review or cleanup&lt;/td&gt;
&lt;td&gt;Inspect the worktree, then clean up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validation gate failed&lt;/td&gt;
&lt;td&gt;Code is not done&lt;/td&gt;
&lt;td&gt;Fix manually or queue another task&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 22: Common Mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Using the best model for every step&lt;/strong&gt; — expensive and unnecessary; save strong models for decisions, cheap models for execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Letting the executor decide scope&lt;/strong&gt; — scope belongs to the router; the executor follows it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vague success conditions&lt;/strong&gt; — "make dashboard better" isn't testable; "update dashboard empty state copy, done when &lt;code&gt;npm test&lt;/code&gt; and &lt;code&gt;npm run lint&lt;/code&gt; pass" is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No persistent assertions&lt;/strong&gt; — a fix verified once can silently regress later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global trust&lt;/strong&gt; — a model can be great at docs and unsafe at infrastructure; track trust per skill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automating before observing&lt;/strong&gt; — manual first, draft second, autonomy last.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 23: Production Hardening
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub Actions&lt;/strong&gt; — run the validation gate on every agent PR in CI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt; — run agents in a container for isolation, installing git, jq, gh, make, defaulting to &lt;code&gt;make tick&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Branch Protection&lt;/strong&gt; — require CI pass, code owner review, no direct pushes to main, and signed commits if needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secret Isolation&lt;/strong&gt; — never expose production secrets to agent jobs; use read-only tokens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logging&lt;/strong&gt; — persist work orders, diffs, verdicts, validation output, cost reports, and trust changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 24: Security Rules
&lt;/h2&gt;

&lt;p&gt;Add to your policy: never print environment variables, never read &lt;code&gt;.env&lt;/code&gt; files unless explicitly allowed, never send secrets to model prompts, never modify IAM/auth/billing/deployment policy unattended, never run destructive commands without approval, never install packages without approval, never execute downloaded scripts, never modify CI secrets. Also block paths like &lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;.env.*&lt;/code&gt;, &lt;code&gt;secrets/&lt;/code&gt;, &lt;code&gt;infra/&lt;/code&gt;, &lt;code&gt;terraform/&lt;/code&gt;, &lt;code&gt;migrations/&lt;/code&gt;, &lt;code&gt;.github/workflows/&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 25: Final Architecture Recap
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AGENTS.md
  ↓
policy.md
  ↓
intake.md
  ↓
router.md
  ↓
work-order.json
  ↓
execute.md
  ↓
git diff
  ↓
audit.md
  ↓
verify.sh
  ↓
trust.tsv + assertion-ledger.tsv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every layer is limited: intake doesn't fix, the router doesn't code, the executor doesn't decide success, the auditor doesn't run the repo, the shell gate has the final vote, and the ledger decides future autonomy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] AGENTS.md exists&lt;/li&gt;
&lt;li&gt;[ ] policy.md defines safe and unsafe work&lt;/li&gt;
&lt;li&gt;[ ] verify.sh passes on the current repo&lt;/li&gt;
&lt;li&gt;[ ] intake returns quiet on quiet repos&lt;/li&gt;
&lt;li&gt;[ ] router emits valid JSON&lt;/li&gt;
&lt;li&gt;[ ] executor stays inside scope&lt;/li&gt;
&lt;li&gt;[ ] auditor receives only work order and diff&lt;/li&gt;
&lt;li&gt;[ ] trust ledger updates after pass/fail&lt;/li&gt;
&lt;li&gt;[ ] cost logging works&lt;/li&gt;
&lt;li&gt;[ ] assertions run&lt;/li&gt;
&lt;li&gt;[ ] Makefile commands work&lt;/li&gt;
&lt;li&gt;[ ] cron is disabled until manual tests pass&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Principles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Laws beat suggestions.&lt;/li&gt;
&lt;li&gt;Cheap models read. Strong models decide.&lt;/li&gt;
&lt;li&gt;Executors make small diffs. Auditors get fresh context.&lt;/li&gt;
&lt;li&gt;Shell scripts decide done.&lt;/li&gt;
&lt;li&gt;Trust is per skill. Autonomy is earned.&lt;/li&gt;
&lt;li&gt;Assertions prevent silent regression.&lt;/li&gt;
&lt;li&gt;Budgets fail closed.&lt;/li&gt;
&lt;li&gt;Humans approve sensitive work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The future of AI engineering is not one giant agent with unlimited authority. It is a controlled system of small agents, each with a narrow role, measurable output, and strict validation. An Agentic OS turns AI from a chat window into an engineering process.&lt;/p&gt;

&lt;p&gt;Start small: create &lt;code&gt;AGENTS.md&lt;/code&gt;, add &lt;code&gt;verify.sh&lt;/code&gt;, run one manual cycle, track trust, add assertions, and automate only after the system proves itself. That is how you move from prompting an assistant to operating an autonomous engineering workflow.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>claude</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
