Main Claude is a generalist with a full memory of this conversation. A subagent is a specialist with a clean memory and one job. For real-money trading code, the right specialist is a safety reviewer trained on 170+ live bugs.
order-execution-reviewer subagent that audits every order-code change against your playbook and bug log.--- name: order-execution-reviewer description: Use PROACTIVELY whenever order-related code is added or modified — entry, SL, exit, squareoff, cancel, partial fills, position tracking, crash recovery, double-leg, segment-quantity. Returns structured review. Read-only — never edits files. tools: Read, Grep, Glob, Bash model: opus --- # Order Execution Reviewer You are a specialist code reviewer for a live options-trading system handling real money. You enforce the order-execution playbook and the 170+ bug history… ## Required Reading 1. docs/order-execution-playbook.md 2. .claude/skills/order-execution-safety/… 3. docs/bug-log.md (now BUG-170+) 4. .claude/CLAUDE.md …
Read, Grep, Glob, Bash only — no Edit or Write. A reviewer that can't modify code can't break it.opus for judgment-heavy review. The rest of the file is the system prompt — instructions, rules, output template..claude/agents/ and ship with the repo. User-global agents live in ~/.claude/agents/.Agent. Subagent runs alone. One message back.[1] You: "review my changes to core/broker/order_manager.py" │ ▼ [2] Main Claude recognises an order-code review task. It dispatches: Agent(subagent_type="order-execution-reviewer", prompt=…) │ ▼ [3] A fresh Claude spins up. // new context window, model=opus Its system prompt = the body of order-execution-reviewer.md. It loads: docs/order-execution-playbook.md docs/bug-log.md .claude/CLAUDE.md .claude/skills/order-execution-safety/skill.md It reads: git diff, the changed files, related tests. │ ▼ [4] Subagent returns ONE structured markdown message: # Order Execution Review Verdict: GO-WITH-FOLLOWUPS ## Findings — CRITICAL × 0 · HIGH × 2 · MEDIUM × 1 … │ ▼ [5] Main Claude sees only that one message. Subagent's intermediate work, file reads, bug-log scan — all discarded. Your main window stays small. Subagent's context died with the call.
order-execution-reviewer — what it knows, what it returns.docs/order-execution-playbook.md — 12 sections, every rule has a bug number behind itdocs/bug-log.md — BUG-001 through BUG-170+.claude/CLAUDE.md — project conventions, isolation rules, segment-quantity rules.claude/skills/order-execution-safety/ — the checklist formGO, GO-WITH-FOLLOWUPS, or NO-GOCRITICAL · HIGH · MEDIUM · LOW · INFOtools: Read, Grep, Glob, Bash — no Edit, no Write.claude/agents/order-execution-reviewer.md. 308 lines. Read it once — you'll know everything it's looking for.A new strategy used LIMIT SELL at the breakout price expecting it to "wait" for the price to drop. LIMIT SELL fills above the limit immediately — the breakout never happens, you're already short.
SL-L order completed at the exchange before the tick reached the local code. The tick handler thought "SL didn't fire" and placed an emergency exit. Bought 120 against 60 sold.
Squareoff used the broker's aggregated netqty, which sums across tranches and strategies on the shared account. Exit qty came out wrong on multi-tranche days.
squareoff_all is a footgunThe base broker class shipped with a default squareoff_all() that closes everything on the account — including other strategies. Removed. The reviewer flags any reintroduction as automatic NO-GO.
.claude/agents/order-execution-reviewer.md contains and can edit it as your bug log grows.PostToolUse hook so it auto-runs after every edit to core/broker/, core/mcx/, core/equity/, or hedge_runner.py.Agent tool with a specific subagent_type and a fresh prompt. Spins up the subagent.name, description, tools, model. Tells Claude Code how to register it.tools: line restricts which tools the subagent can use. A reviewer with no Edit can't modify code by mistake..claude/agents/order-execution-reviewer.md. Read the frontmatter, the rule matrix by subsystem, the output template at the bottom. About 308 lines — 20 minutes.Agent tool.docs/bug-log.md, find the entry, confirm the rule matches. This teaches you to trust (and audit) what the subagent says.PostToolUse hook in .claude/settings.json that dispatches this reviewer whenever Edit|Write touches core/broker*/, core/mcx/, core/equity/, core/framework/, or hedge_runner.py.› Use the order-execution-reviewer subagent to review HEAD ⏺ Agent(order-execution-reviewer) ⎿ Reading docs/order-execution-playbook.md (387 lines) ⎿ Reading docs/bug-log.md (4006 lines, through BUG-170) ⎿ Reading .claude/CLAUDE.md ⎿ git diff HEAD~1..HEAD — 2 files changed ⎿ Running pytest tests/test_order_manager.py … # Order Execution Review **Scope:** HEAD (1 commit, 2 files) **Reviewed against:** playbook §2, §3, §4 · BUG-100, BUG-126, BUG-163 **Subsystems touched:** core/broker/order_manager.py, core/framework/sl_manager.py ## Verdict **GO-WITH-FOLLOWUPS** — SL re-place path correct, but capacity-gate uses broker units instead of lots (BUG-163 regression risk). ## Findings ### CRITICAL (none) ### HIGH 1. **Capacity gate counts broker units, not lots** — `core/framework/sl_manager.py:284` - What: `current_lots + new > MAX_LOTS` compares units to lot cap. - Rule violated: playbook §4 · BUG-163 - Required fix: divide broker qty by `instrument.lot_size` before comparing. ### MEDIUM 1. **No pytest coverage on the new SL re-place branch** — `tests/test_sl_manager.py` - The "rejected → re-place" path (BUG-081) is not exercised. Add a test. › _
Loads today's logs/*_$(date +%F).log, classifies CRITICAL/ERROR, cross-references the bug log. Read-only. Dispatched after any session with alerts.
Runs the pre-live-trading-audit checklist as a subagent so the (long) audit output never pollutes main context. Use at start of each trading month.
Project-aware exploration. Knows the equity ↔ MCX isolation, broker abstraction, framework parity. Answers "what calls X?" without polluting main context.
Delegates a stuck implementation or a second-opinion review to Codex. The "two-model" pattern your feedback_code_quality_priority.md memory already prescribes.
A short was protected by an SL-L order at the exchange. The exchange triggered the SL and filled it. The websocket tick carrying "price hit your trigger" arrived in our process a quarter-second later. By the time the tick handler ran, the SL was already done — but the handler didn't know yet.
filled or completed, skip the emergency exit.BUG-100 didn't happen because Claude (or the human) was careless. It happened because a 250ms race condition is hard to keep in your head while writing the next strategy six weeks later. A reviewer subagent loaded with BUG-100 will catch any SL jump path that's missing the "check status first" guard on the diff, before the code ever runs against real money.
The model is the same. The rules are the same. What changes is the attention — a fresh context window, no other concerns, one job. That's why the subagent catches what main Claude (juggling six other tasks in your current conversation) often misses.
Build it once, in fifteen minutes. It reviews every order-code change for as long as the repo lives. The money you don't lose is the money it earns.
PostToolUse hook → every edit to core/broker/ auto-fires the reviewer →