Flows category icon
Harness Engineering
Intermediate

Rule-File Code Review Gates

Run deterministic policy checks on everything your agent produces: rule files reviewing plans, diffs, and evidence before anything merges.

4 steps12 verify checks60-90 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
Reviewing agent output by eye does not scale, and asking another LLM to review is probabilistic on top of probabilistic. Guardrail research shows the deterministic layer: versioned rule files (AST checks, patterns, diff analysis) gating agent-generated changes.

GOAL:
Build a rule-file gate: versioned deterministic rules evaluated against agent plans and diffs, wired into the loop and the merge path.

REQUIREMENTS:
- Rules as versioned files: pattern rules, AST-level checks, and diff-shape rules
- Gate points: post-plan (before execution) and post-diff (before completion/merge)
- Deterministic verdicts with rule IDs, locations, and fix guidance
- Severity levels: block, warn, and info - each handled distinctly
- Rule authoring workflow: incidents become rules with tests

CONSTRAINTS:
- Rules are deterministic - no LLM in the verdict path
- Every blocking rule needs a documented rationale and at least one test case

DEFINITION OF DONE:
- A diff violating a blocking rule cannot complete/merge until fixed
- Verdicts cite rule ID, file:line, and remediation guidance
- The plan gate catches policy violations before execution wastes work
- The last incident produced a new rule with a test proving it fires

COMMON FAILURES TO AVOID:
- Prose guidelines nobody enforces mechanically
- Regex-only rules missing structural violations an AST check catches
- Verdicts without locations or guidance, teaching the model nothing
- Rules accumulating without tests, rotting into false-positive noise

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More Harness Engineering flows that share ground with this one.

Flows category icon
Harness Engineering

Pair Every Prompt Rule with a Code Backstop

Prompts guide, code enforces: inventory your agent's soft rules, back each critical one with an independent deterministic check, and define the allow/ask/deny escalation.

01Inventory soft rules and classify enforcement needs
02Implement checks independent of the prompt
03Wire the escalation path

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps120-180 minutesAdvanced
Flows category icon
Harness Engineering

Assemble Tool Prompts Dynamically per Environment

Stop shipping one static mega-prompt: generate tool prompts from environment conditions, inject blocks only when features are on, and dedupe config to save tokens.

01Identify conditional blocks
02Build the prompt generator
03Dedupe and budget every block

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced
Flows category icon
Harness Engineering

Cost Control: Model Routing and Effort Tiers

Route work to the cheapest model that can do it and match reasoning effort to task difficulty - with quality guardrails.

01Profile spend by call class
02Build the routing table and wire it
03Add escalation on failure

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-120 minutesAdvanced

Made with Emergent