JOURNAL
Part 6/6: Operating the workflow: cost, security, learning loop and measuring
The last part: where agent money goes and how to cap it, a threat table mapped to files in the repo, a learning loop that turns every correction into a rule, skill, hook or test, five metrics that show whether agents help, and spec 0002 shipped end to end.

On this page
Prefer to watch first? The whole series in one video (25 minutes) walks the full loop on the sample repo.
By the end of part 5 the workflow runs: specs go in, agents plan and build in worktrees, two model families review, CI gates the merge. The questions that come next are operational ones. How much did last week cost, and which runs paid for themselves? What happens when a PR body contains instructions aimed at your reviewer agent? Why does the agent keep making the same mistake you corrected on Tuesday? Is any of this actually faster than before?
This last part answers those questions with things you can do this week: cost controls that already sit in the sample repo, a threat table where every row points at a file, a learning loop that turns each correction into a rule, a check or a hook, and five numbers you can collect without buying any tooling. Then we take the same loop outside code, and you finish spec 0002 end to end with everything from the series.
What you will have at the end
- A clear picture of where agent money goes, the controls for each place, and a 15-minute weekly cost review.
- A threat table for agent workflows, mapped to the controls and files in
agentic-shortlink, plus commands that prove the controls work. - A habit, and a place, for every correction:
AGENTS.md, a skill, a hook or deny rule, or a test. - Five metrics and a quarterly rerun of the 20-task eval from part 1.
- A rollout plan for a team, and the same loop applied to content, data and operations.
- Spec 0002 shipped end to end and compared with the reference solution.
Prerequisites
You have the repo from part 2 with the workspace trusted in Claude Code, the scripts from part 4, and the CI and review workflows from part 5. If you skipped part 5, the cost and security sections still apply locally; only the CI rows will be theory for you.
Cost: where the money goes and how to cap it
Where the money goes
In my own runs, the bill is rarely driven by the code-writing step. It comes from three places:
- Planning and review with strong models. The planner and the reviewer read a lot (spec,
AGENTS.md, every touched file, the diff) and they run on the most expensive model on purpose. That is the right trade, but it means a review costs more than you expect. - Long contexts. Every turn re-sends the conversation. A session that wanders through twenty files before doing anything pays for those files again on each later turn. A tight spec and a task table with named files are the cheapest optimisation you have.
- Loops. Review finds something, the agent fixes it, review runs again, the fix breaks a test, another run. Each lap is a full context. Loops are where a 1-dollar task turns into a 10-dollar task.
So the levers are: pick the model per role, keep the context small, and put a hard stop on every automated run.
The controls you already have
| Control | What it does | Where it is used in the repo |
|---|---|---|
--max-turns N | Stops a Claude Code run after N turns | agent-task.sh (40), cross-review.sh (20, 30), review workflow (15), mention workflow (30) |
--max-budget-usd N | Stops a headless run when the client-side cost estimate reaches N | agent-task.sh (3) |
--output-format json | Writes .total_cost_usd next to .result and .session_id | agent-task.sh writes agent-runs/<name>/claude.json |
| Model per role | Strong model where judgement matters, cheaper model for execution | --model sonnet for tasks, opus for review, reviewer.md on opus, refuter.md on sonnet |
| Effort level (Codex) | model_reasoning_effort per project or profile | medium in .codex/config.toml, high in examples/codex/deep-review.config.toml |
| CI concurrency | A new push cancels the running review of the old commit | cancel-in-progress: true in all review and CI workflows |
| CI timeouts | Kills a stuck job | timeout-minutes: 10 (CI), 15 (reviews), 30 (mentions) |
| Opt-in switch | AI review only runs when the repo variable is set, and never on drafts or forks | vars.ENABLE_AI_REVIEW == 'true' |
| Gateway | One place for keys, logs and budgets across tools | gateway/litellm.config.yaml |
The headless task runner from part 4 combines the first four rows:
scripts/agent-task.sh
case "$tool" in
claude)
claude -p "$prompt" \
--model sonnet \
--permission-mode acceptEdits \
--allowedTools "Read,Edit,Write,Glob,Grep,Bash(pnpm *),Bash(git status),Bash(git diff *),Bash(git add *),Bash(git commit *)" \
--max-turns 40 \
--max-budget-usd 3 \
--output-format json >"$runs/claude.json"
node -e 'const r=require(process.argv[1]);console.log(r.result);console.error(`cost_usd=${r.total_cost_usd}`)' \
"$runs/claude.json" >"$runs/summary.md"
;;
// ...
Two details matter. First, --max-budget-usd is an estimate the client computes, not a limit the API enforces, so treat it as a soft stop: a run can end a little above it. Set it to roughly three times what a normal task costs, so it only fires on runaway loops. Second, the script prints cost_usd to stderr, which you see in the terminal but which is not saved in summary.md. The number is kept in claude.json, and that file is what the weekly review reads.
Note: cross-review.sh sets --max-turns but no --max-budget-usd, because it runs in the foreground while you watch. If you schedule it, add --max-budget-usd to both claude -p calls.
Codex: control through model and effort
In the Codex documentation I found no official per-run turn cap or dollar cap for codex exec. Your controls are the model and the reasoning effort. The project config keeps everyday work at medium; the deep-review profile raises it to high and drops to read-only, so the expensive setting can only read:
examples/codex/deep-review.config.toml
model = "gpt-6.1-sol"
model_reasoning_effort = "high"
approval_policy = "never"
sandbox_mode = "read-only"
For a hard ceiling on Codex spend, use the provider’s project budget or route Codex through the gateway (the litellm profile in examples/codex/) and set the budget there. In CI, the job timeout is the cap: timeout-minutes: 15 in ai-review-codex.yml.
CI: let only the latest commit spend money
Every review workflow starts with the same block. When you push three fixes in five minutes, only the last one gets reviewed:
.github/workflows/ai-review-claude.yml
concurrency:
group: ai-review-claude-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
# Secrets are not available to fork PRs, and drafts are not ready for review.
if: >-
vars.ENABLE_AI_REVIEW == 'true' &&
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 15
The draft rule doubles as a cost rule: open the PR as a draft while the agent is still iterating, and mark it ready once. One review per ready PR, not one per push.
Gateway budgets
Flags cap one run. A gateway caps a person, a team or a project across all tools. gateway/litellm.config.yaml already puts every model behind one endpoint with one master key, so there is a single log of who called what. The sample file does not set budgets: the settings depend on your LiteLLM version and setup, so take them from the LiteLLM docs. The shape I recommend is one key per person and one per CI workflow, each with a monthly budget, so a runaway CI loop hits its own limit instead of everyone’s.
A weekly cost review (15 minutes)
Every Monday I do the same four things:
- List the cost of every headless run from last week (command below).
- Open the two or three most expensive runs and read their summaries. Usually one of them looped on a vague task or a flaky test.
- Check the provider dashboards (or the gateway log) for spend that did not come from
agent-task.sh: CI reviews,@claudementions, interactive sessions. - Change exactly one thing: a tighter task, a lower effort level, a model swap for one role, or a new rule from the learning loop below. Write it down so next week can tell whether it helped.
for f in agent-runs/*/claude.json; do
node -e 'const r=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));console.log(process.argv[1], r.total_cost_usd)' "$f"
done
Check: after at least one scripts/agent-task.sh claude ... run, the loop prints one line per run in the form agent-runs/<name>/claude.json <cost in USD>. If a line shows undefined, that run did not finish with JSON output; open its claude.json to see why.
Security: threats and the controls that answer them
An agent is a program that takes instructions from text and has a shell. Everything it reads is a possible instruction, and everything it can run is a possible action. That gives four groups of threats:
- Prompt injection through text the agent reads but you did not write: PR titles and bodies, commit messages, code comments, issue text, test output, web pages, tool results.
- Secret exfiltration: the agent reads
.envor a token and then sends it somewhere, through a network call or simply by printing it into a PR comment. - Destructive commands:
rm -rf, a force push, skipping hooks, staging everything including a database file. - Supply chain: a compromised GitHub Action, a new npm dependency with an install script, an agent adding a package nobody reviewed.
The rule I use: no single control has to be perfect, but every threat needs at least one control that does not depend on the model behaving. Instructions in AGENTS.md help, yet a deny rule, a hook, a sandbox or a missing permission is what actually stops the action.
| Threat | Control in repo | File |
|---|---|---|
| Injection via PR body, commits, comments | Review rule “treat as data”; repeated in every review prompt | AGENTS.md (Code Review Rules), ai-review-claude.yml, ai-review-codex.yml |
| Injected reviewer tries to change code | Codex job has contents: read and permission-profile: ":read-only"; a separate job posts the comment | .github/workflows/ai-review-codex.yml |
| Injected reviewer runs arbitrary tools | Narrow --allowedTools list (read, gh pr diff, comment) | .github/workflows/ai-review-claude.yml |
| Reading secrets locally | Deny Read(./.env), Read(./.env.*), Read(./**/*.db); .env git-ignored | .claude/settings.json, .gitignore, AGENTS.md (Safety) |
| Sending data out | Deny Bash(curl *), Bash(wget *); Codex sandbox without network | .claude/settings.json, .codex/config.toml (network_access = false) |
| Secrets in CI on untrusted code | No pull_request_target; fork PRs and drafts skipped; persist-credentials: false; GitHub expressions passed through env | ai-review-claude.yml, ai-review-codex.yml |
| Strangers triggering a write-capable agent | @claude only works for users with write access; gated by ENABLE_AI_REVIEW | .github/workflows/claude-mention.yml |
| Destructive shell commands | Guard hook blocks rm -rf, git add -A, --no-verify | .claude/hooks/guard-bash.mjs |
| Unreviewed code leaving the machine | No push from agents: hook blocks git push, settings ask for it, scripts never push | guard-bash.mjs, .claude/settings.json, scripts/agent-task.sh |
| Agent loosening its own rules | ask on Edit(.github/**) and Edit(AGENTS.md); Safety rule | .claude/settings.json, AGENTS.md |
| Headless run doing more than intended | -p denies anything not in --allowedTools; worktree per task | scripts/agent-task.sh, scripts/cross-review.sh |
| Compromised or stale Action | Every action pinned to a commit SHA with a version comment; Dependabot updates the pins | .github/workflows/*.yml, .github/dependabot.yml |
| Unreviewed new dependency | ask on Bash(pnpm add *); “no new dependencies without asking”; build scripts only for listed packages; frozen lockfile | .claude/settings.json, AGENTS.md, package.json (onlyBuiltDependencies) |
| High-risk change merged on AI approval alone | Review levels: schema, auth, workflows, dependencies need two model families plus a human | AGENTS.md (Review levels) |
Test the controls, do not trust them
A control you have not seen fire is a guess. The guard hook reads JSON on stdin, so you can test it without starting an agent:
echo '{"tool_input":{"command":"git add -A"}}' | node .claude/hooks/guard-bash.mjs; echo "exit=$?"
echo '{"tool_input":{"command":"rm -rf dist"}}' | node .claude/hooks/guard-bash.mjs; echo "exit=$?"
echo '{"tool_input":{"command":"git add src/app.ts"}}' | node .claude/hooks/guard-bash.mjs; echo "exit=$?"
Check: the expected output is
Blocked by .claude/hooks/guard-bash.mjs: stage files explicitly: git add <paths>
exit=2
Blocked by .claude/hooks/guard-bash.mjs: recursive force delete is not allowed
exit=2
exit=0
Then check that every action in the workflows is pinned to a full SHA with a version comment. The command prints the lines that are not:
git grep -nE "uses: " .github/workflows | grep -vE "@[0-9a-f]{40} # v"
Check: no output. Any line printed is an action pinned to a tag or a branch.
The hook test proves the script works. It does not prove Claude Code runs it. For that, open the repo in Claude Code interactively, ask it to run git add -A, and confirm you see the “Blocked by” message. If the agent simply runs the command, the workspace is not trusted yet and your whole .claude/settings.json is being ignored (Real lesson 1, below).
Known gaps, written down
Name the gaps so nobody assumes they are covered. The Read(./.env) deny rule covers the Read tool, not a shell cat .env. Here cat is not on the allow list, so an interactive session asks first and a headless -p run denies it, but a broad Bash(*) allow rule would open that door. And claude-mention.yml has contents: write and keeps checkout credentials because it is meant to push on request; that is why only users with write access can trigger it.
The learning loop: every correction goes somewhere

Agents do not remember last Tuesday. If you correct one in chat, the correction lives exactly as long as the session. The only memory that lasts is the repo. So every time you correct an agent, or repeat an instruction for the second time, ask one question: will this happen again? If yes, the answer goes into one of four places, picked by how strong the guarantee needs to be:
AGENTS.mdfor a rule that applies to every task (“time comes from the injectednow()“). Cheapest, weakest: the model can still ignore it.- A skill for a procedure with steps (
new-spec,implement-spec). It saves you from re-typing the procedure and makes it the same each time. - A hook or a deny rule for something that must never happen. It does not depend on the model at all.
- A test or a CI step for anything a machine can check. It catches the mistake whichever agent or human makes it.
When in doubt, go one level stronger. A rule that the agent broke once will be broken again; a test will not let it through.
The real lessons from this repo, and where each fix lives
| Lesson | What happened | Where the fix lives | Type |
|---|---|---|---|
| 1 Trust | Claude Code ignored all of .claude/settings.json, permissions and hooks, until the workspace was trusted. A test git add -A ran. | Onboarding step “open interactively once, accept trust, try git add -A” (team rollout below) | Procedure, checked by a hook test |
| 2 Frontmatter | Biome’s markdown formatter inserted a blank line after the opening --- of skill and agent files. | biome.json: "!.claude" in files.includes; verified with claude -p "list skills" | Config plus a check |
| 3 Silent migration | biome migrate rewrote the recommended rules to "preset": "none", turning lint off. | biome.json now says "preset": "recommended"; the review rule is “read the diff of any automated config change” | Config plus human gate |
| 4 Line endings | On Windows with core.autocrlf=true, lint failed on CRLF. | .gitattributes with * text=auto eol=lf; core.autocrlf false in the repo | Config, enforced by the lint step in CI |
| 5 Stale pins | Dependabot opened 4 PRs within minutes: checkout v5 to v7, setup-node v4 to v7. | .github/dependabot.yml (weekly, github-actions and npm); pins updated in one commit, CI green in 24 s | CI automation |
| 6 Hook path | The format hook did nothing when tested with a Git Bash path (/d/...); it works with the path Claude actually sends. | Habit: test hooks with the exact JSON the tool sends, as in the security section | Test procedure |
Two of these show the limit of the loop. Lesson 3 has no automated guard: nothing fails if someone sets the lint preset back to none, so a small CI step checking biome.json would be the stronger fix. Lesson 1 cannot be fixed inside the repo, because trust is decided per machine; that is why it lives in onboarding.
Make it a routine
The “Learn” step at the end of the loop from part 1 takes two minutes per merged PR. Read your own review comments and the agent’s “Done but not verified” and “Skipped” sections. For each item that could happen again, open a small PR that adds the rule, skill, hook or test. Changes to AGENTS.md already require approval in .claude/settings.json (ask), so those PRs get a human look by design.
Check: git log --oneline -- AGENTS.md .claude .github biome.json shows at least one commit per month that came from a correction. If it shows none for a quarter, either your agents are perfect or the loop is not running.
Measuring whether agents help
“It feels faster” is not a measurement. You do not need a platform to do better; five numbers kept in a spreadsheet are enough, and they can all be collected from git, GitHub and the run logs you already have.
| Metric | How to collect it | What it tells you |
|---|---|---|
| Lead time per spec | Date the spec became approved to date the PR merged (git log on the spec file, merge date on GitHub) | Whether the whole loop got faster, not just typing |
| Review minutes per PR | The human reviewer writes the minutes in the PR when approving | Whether cheap doing moved the cost to you |
| Rework rate | Share of PRs that needed a second agent run after review | Spec quality and task size |
| Escaped defects | Bugs found after merge that a Behaviour row or a test should have caught | Whether the checks are strong enough |
| Cost per merged PR | Sum of total_cost_usd for the PR’s runs plus its share of CI review spend | Whether the model mix is right |
Read them together. Lead time down while review minutes go up means you moved work from writing to reading. Low rework with rising escaped defects means review is waving things through. Rising cost per PR with flat rework usually means a role runs on a stronger model than it needs.
For lead time, the spec file history gives you the start date:
git log --format='%h %ad %s' --date=short -- docs/specs/0002-daily-click-stats.md
Check: one line per commit that touched the spec, newest first, each with a date. The commit that set Status: approved is your start; the merge of the feature PR is your end.
Rerun the 20-task eval every quarter
In part 1 you set up an eval of 20 tasks from your own backlog, each with a known good outcome, and used it to compare setups. Models, prices and tools change every few months, so the choice goes stale. Once a quarter:
- Run the same 20 tasks with the current setup, each through
scripts/agent-task.shso every run gets its own worktree, log andclaude.json. - Record per task:
check: PASSorFAILfromsummary.md, cost, and the minutes you needed to review the result. - Swap one variable (a cheaper model for execution, a different reviewer family, a lower effort level) and run again.
- Keep the change only if the pass count holds and either cost or review minutes go down.
Keep the 20 tasks fixed between quarters. If you swap tasks every time, you are measuring the tasks, not the setup.
Check: grep -l "check: PASS" agent-runs/*/summary.md | wc -l prints the number of passing runs. Compare it with last quarter’s number in your spreadsheet.
Rolling it out to a team
What I have seen work is narrow and slow at the start:
- Start with one repo. Pick one with a fast, trustworthy check command. The workflow only works if
pnpm check(or your equivalent) is quick and believable. In this repo the full check runs in about a second locally and 24 seconds in CI. - The team owns
AGENTS.md. It is code: changes go through PRs, get reviewed, and anyone can propose one. If you use CODEOWNERS (the sample repo does not), putAGENTS.mdand.claude/under the tech lead. - Review levels are agreed, not improvised. The table at the end of
AGENTS.mdsays what each kind of change needs before merge. Agree on it once, then point to it instead of arguing per PR. - Who can turn on AI review. Only repo admins can set the
ENABLE_AI_REVIEWvariable and the API key secrets. Only people with write access can trigger@claude. Keep it that way; it makes spend and permissions predictable. - Onboarding is a checklist, not a talk. Clone,
corepack enable,pnpm install,pnpm check; open Claude Code in the repo and accept the trust dialog; run the three hook tests; trygit add -Ain a session and see it blocked; readAGENTS.mdend to end; ship one small spec with a colleague reviewing the plan.
Check: a new team member can show you a blocked git add -A in their own Claude Code session on day one.
Beyond software
The loop does not care that the output is code. Spec, plan, execute, verify, review, gate, learn works for any work where an agent does the bulk and a check can be written down. Three examples from my own week.
Content publishing
This series was drafted with agents. The “tests” for a post are editorial checks, and each one is a line in the brief the agents follow: the post is in the right locale, it has an excerpt (summary) and an SEO description within the length limit, the body has no H1 (the theme renders the title), every image has descriptive alt text, and each post has its translation pair with the same structure. Most of these can be checked with grep before a human reads a word:
grep -c "<h1" p6.en.html
grep -c '<img[^>]*alt=""' p6.en.html
grep -c "wp:heading" p6.en.html p6.vi.html
Check: 0, 0, and the same heading count for both languages. A mismatch in the last number means the translation pair has drifted.
Data analysis
Two rules. First, every number comes with the query that produced it. An agent that says “retention dropped 4%” without the SQL has given you a claim, not a result; with the query you can rerun it, and a second model can review it like a diff. Second, the agent connects with a read-only user or connection. It cannot change data by mistake or because a comment in a table told it to. This is the deny rule from .claude/settings.json, moved to the database.
Operations
Runbooks become skills. A skill with “check the service, read the last 50 log lines, restart, confirm the health endpoint” is the same SKILL.md format as implement-spec, and the agent follows it the same way each time. The non-negotiable rule is a backup before any write: before an agent touches a database schema or data, it takes a dump (for Postgres, pg_dump -Fc into a dated folder) and says where it is. Production writes need an explicit human command for that specific write. That is the review-level table again, applied to infrastructure.
Final exercise: spec 0002 end to end
Spec 0002 (docs/specs/0002-daily-click-stats.md) adds a link_clicks table, records each redirect per UTC day, and adds GET /api/links/:slug/stats/daily?days=N. Its Risk section says “new table and a write on the hot redirect path”, so under the review levels in AGENTS.md it is a schema change: CI green, AI review from two model families, and a human approval. Use everything from the series:
- Plan (part 3). Open Claude Code in plan mode and run
/implement-spec 0002. Approve the task table indocs/tasks/0002-daily-click-stats.mdonly when every task has a check command and the parallel tasks share no files. - Execute in parallel (part 4). Run the code tasks and the README task in separate worktrees, using the task numbers from your table:
scripts/agent-task.sh claude 0002-repo "Do T1 and T2 from docs/tasks/0002-daily-click-stats.md"andscripts/agent-task.sh codex 0002-docs "Update the README API section for spec 0002". - Verify. Each
agent-runs/<name>/summary.mdends withcheck: PASS. Merge the branches into one feature branch and runpnpm checkyourself. - Cross-review (part 4). On the feature branch, run
scripts/cross-review.shand fix what survives inagent-runs/review-<branch>/final.md. - Human gate and CI (part 5). You push, you open the PR, mark it ready when the agent is done, and let CI and both AI reviews run. Approve only after reading the diff against every Behaviour row.
- Operate (this part). Record the five metrics for this PR, and add at least one learning-loop entry.
Compare with the reference solution
The branch solution/0002-daily-stats changes six files: the spec, src/app.ts, src/db.ts, a new src/lib/days.ts, src/repo.ts and a new test/daily-stats.test.ts. See how your branch differs:
git diff --stat solution/0002-daily-stats HEAD -- src test
git show solution/0002-daily-stats:test/daily-stats.test.ts > test/reference-0002.test.ts
pnpm vitest run test/reference-0002.test.ts
rm test/reference-0002.test.ts
Check: the HTTP tests in the second describe block pass against your code. The first block tests the reference helpers lastNDays and fillDays from src/lib/days.ts, and the last HTTP test calls repo.dailyClicks; if your agent named these differently, those tests fail on imports, not on behaviour. Delete them from the copy and keep the rest: the HTTP tests are the contract, the names are not.
One more comparison is worth doing by hand, and it caught a real defect while I was preparing this series. The first version of the reference branch had every Definition of done box ticked, including “README API section updated”, but README.md was not in the diff and had no row for the new endpoint. The reviewer that drafted this part found it by diffing the branch against main; the fix is commit b22d65b on solution/0002-daily-stats. A ticked box is a claim, not evidence. That makes a good first learning-loop entry: a reviewer rule that checks each ticked box against the diff.
Final checklist for the whole series
| Part | You have | Check |
|---|---|---|
| 1 Architecture and model roles | A model written down for each role, and a fixed 20-task eval list | The list exists and you reran it this quarter |
| 2 Repo setup | AGENTS.md, CLAUDE.md importing it, settings, hooks, Codex config | claude -p "list skills" shows new-spec and implement-spec; git add -A is blocked in a session |
| 3 Spec, plan, tasks | Spec 0002 approved, task table with a check per task | docs/tasks/0002-daily-click-stats.md exists and was approved before code |
| 4 Parallel work and providers | Worktree runs with Claude and Codex, cross-review | Every summary.md ends with check: PASS; final.md exists |
| 5 CI/CD with AI review | CI gate, two AI reviewers, pinned actions | The PR shows CI green and comments from both reviewers |
| 6 Operating it | Cost review, tested controls, learning loop, metrics | Cost loop prints your runs; hook tests return exit=2; one new rule, skill, hook or test merged |
Common mistakes
- Assuming settings are active. Until the workspace is trusted, Claude Code ignores permissions and hooks together. Test once per machine.
- Testing hooks with the wrong input. My format hook “did nothing” with a Git Bash path and worked with the path Claude sends. Use the exact JSON the tool sends.
- Treating
--max-budget-usdas a hard limit. It is a client-side estimate; use provider or gateway budgets for a real ceiling. Codex has no documented per-run cap at all. - Reviewing every push. Without
cancel-in-progressand the draft rule, an iterating agent pays for a full review per commit. - Trusting automated config changes.
biome migratesilently disabled every lint rule here. Read the diff of every migration and Dependabot PR. - Leaving lessons in chat. A correction that does not end up in a file will be needed again next week.
- Believing ticked boxes. Check each Definition of done item against the diff.
- Measuring feelings. Without lead time, review minutes and cost per PR, you cannot tell a faster team from a busier one.
Checklist
- Every headless run has
--max-turns, and every scheduled Claude run also has--max-budget-usd. - Each role has a deliberate model, and Codex effort is set per project and per profile.
- Review workflows have concurrency, timeouts, the draft rule and the opt-in variable.
- A weekly 15-minute cost review is on your calendar, and it ends with one change.
- The threat table is in your repo docs, and the hook and pinning checks pass.
- Every correction ends up in
AGENTS.md, a skill, a hook or deny rule, or a test. - Five metrics are recorded per merged PR; the 20-task eval reruns each quarter.
- One repo, team-owned
AGENTS.md, agreed review levels, an onboarding checklist. - Spec 0002 is merged and compared with
solution/0002-daily-stats.
Closing
Six parts later, the point is simple. Agents made doing cheap: writing code, drafts, queries and runbooks now costs minutes and a few dollars. That alone does not make you faster, because unchecked output just moves the work to whoever reads it. Speed comes from cheap doing plus cheap checking: specs with concrete rows, a check command you trust, reviewers from two model families, hooks that do not negotiate, and a habit of writing every lesson into the repo. Build the checking side with the same care as the doing side, and the speed stays.
Series
- Architecture and model roles
- Repo setup for Claude Code and Codex
- Spec, plan, tasks
- Parallel work and multiple providers
- CI/CD with AI review
- Operating it: cost, security, learning
- Part 7: Applying the agent workflow to a real project
All code in this series is in the sample repo luonghongthuan/agentic-shortlink, with the reference solution for spec 0002 on branch solution/0002-daily-stats. The principles behind it are in the prequel post.

Discussion
Comments are reviewed before publication. Your email is kept private.