Examples
Real-world examples showing how AgentBrain gives your agent full context before every task — no guessing, no wrong patterns.
Example 1
Run preflight_check before any task
One tool that loads everything your agent needs before starting. Codebase context, Playbook (Blueprint, Guardrails, Standards, Decisions), and active spec — all in one call.
What You Say
"Add OAuth login with GitHub"
What Agent Does
agent runs preflight_check
preflight_check({ repo_path: "/path/to/repo", task: "add OAuth login with GitHub" })
Result
Agent received full context before writing a single line: • Auth: Supabase Auth (from Blueprint) • Never modify: src/lib/db (from Guardrails) • Tests required before PR (from Standards) • GraphQL rejected — too complex (from Decisions) Agent immediately knew to use Supabase's built-in OAuth, not a third-party library. Zero wrong implementations.
Example 2
postflight_check catches what the agent shouldn't have done
After your agent codes, run postflight_check to verify the output before merging. It checks guardrail violations, missing tests, spec compliance, and scope creep.
What You Say
"postflight_check — did the agent follow the rules?"
What Agent Does
agent runs postflight_check
postflight_check({ repo_path: "/path/to/repo", task: "add OAuth login with GitHub" }) # Postflight Check ## Verdict: 🚫 BLOCK ## Violations — Fix Before Merge 🚫 Protected file modified: src/lib/db/users.ts (Protected by Playbook Guardrails) 🚫 No test files in diff (Playbook Standards: tests required before every PR) ## Passed ✓ No sensitive data detected ✓ Commit format correct Risk: HIGH Do not merge until violations fixed.
Result
Agent modified src/lib/db/users.ts — a protected file. Without postflight_check, this merges and breaks production. With postflight_check: caught before it ever reached a PR. Agent fixes the violation, runs postflight_check again. Verdict: SAFE. Now it can merge.
Example 3
Playbook prevents wrong implementations
Fill out your Playbook once. Your agent follows your team's conventions automatically — no more correcting the same mistakes.
What You Say
"Add a settings page for user preferences"
What Agent Does
agent runs preflight_check
preflight_check({ repo_path: "/path/to/repo", task: "add settings page" }) ✓ Blueprint: New features → src/features/ ✓ Blueprint: State → React internal (80%) ✓ Guardrails: Never modify src/lib/db ✓ Standards: Tests required before PR
Result
Without Playbook: Agent would have used Redux, put the page in /pages/, and skipped tests. With Playbook: Agent used React state, placed it in src/features/settings/, and wrote Playwright tests before saying done. Zero corrections needed.
Example 4
Load spec before implementing complex feature
Before building a new Stripe webhook handler, preflight_check loads the spec automatically along with your full Playbook.
What You Say
"Build a Stripe webhook handler"
What Agent Does
agent runs preflight_check
preflight_check({ task: "add stripe webhook handler" }) ✓ Active spec loaded: Stripe Webhook Handler - Verify signatures - Handle idempotency - Support subscription events ✓ Guardrails: Never modify src/billing/
Result
Agent reads spec and Guardrails in one call. Understands requirements and constraints before writing a single line. Implements correctly on first try without touching protected billing code.
Example 5
Catch agent stuck in a loop
Agent keeps modifying the same file without fixing the issue. You ask it to check for doom loops.
What You Say
"Check if we're stuck in a doom loop"
What Agent Does
agent runs preflight_check
detect_doom_loop({ repo_path: "/path/to/repo" }) ⚠ Doom loop detected auth.service.ts - 6/10 commits database.ts - 4/10 commits
Result
Agent identifies the problem: stuck modifying auth.service.ts repeatedly. You stop, investigate the root cause, and fix the real issue instead of wasting another hour.
Example 6
Team workflow with session handoffs
End your session by saving a handoff. Teammate picks up exactly where you left off.
What You Say
"Create a handoff for the next session"
What Agent Does
agent saving handoff
save_handoff({ content: "..." }) ✓ Saved to .agentbrain/handoff.md Next session: Agent auto-loads context + handoff instantly
Result
No lost context between sessions. No repeated questions. Next person picks up immediately without reading 50 commit messages.
Ready to try it yourself?