# Guardrails Beat Guidance: Negative AGENTS.md Rules Cut Diffs 12.7% & Cost 11.3%

> 💡 **AI Labo Benchmark Series — Experiment `E57` (Negative Scope Guardrails vs. Prescriptive Guidance)**
>
> Part of our controlled benchmark series testing AI coding agent harnesses inside network-isolated Proxmox VMs (`N=3` counterbalanced `AB`/`BA`/`AB` trials, `temperature=0.7`, 3-UID grading, 90% prefix-cache cost accounting).
> * 🚀 **[Master Benchmark Hub & All Pattern Rankings](https://tappers.hashnode.dev/ai-agent-harness-patterns-benchmark)**
> * 🛡️ **[Anti-Cheating Proxmox & systemd Sandbox Architecture](https://tappers.hashnode.dev/air-gapped-proxmox-systemd-agent-sandbox)**

Most `AGENTS.md` and `.cursorrules` files are packed with positive engineering advice: *"Write clean Python, apply the Boy Scout rule, extract typed helpers, and enforce strict checks everywhere."* Yet a large-scale empirical study of 679 real-world repos (`arXiv:2604.11088`) argued that negative scope guardrails outperform affirmative style guidance.

We ran a byte-matched (`1.007x` length) A/B test changing **only rule polarity in `AGENTS.md`** on a brownfield webhook-settlement repository (`models/gemini-4-carbon`, `MEDIUM`, `N=3`). Both modes passed `32/32`, yet negative guardrails won every efficiency and blast-radius metric in `3/3` trials.

---

## TL;DR — Key Empirical Findings

* **1. `32/32` Functional Parity—But `-12.69%` Smaller Diffs (`3/3` Trials):** Because `TICKET.md` (`PAY-418`) scoped the bugfix files, both `Baseline (Prescriptive Style Guidance, 2,292 bytes)` and `Candidate (Negative Scope Guardrails, 2,308 bytes)` passed **`32.00 ± 0.00 / 32` (`100.0%`)** with `0` unrelated file edits. Yet `Baseline` followed Boy-Scout guidance by rewriting docstrings and extracting new constants inside the 3 target files—bloating diffs to `378.33 ± 8.14` lines vs. `Candidate`'s **`330.33 ± 12.22` lines (`-48.00` lines / `-12.69%`, smaller in `3/3` trials: `-51`, `-65`, `-28`)**.
* **2. `-75.9%` Less Turn-1 Thinking & Zero Decoy Drift:** `Baseline`'s open-ended quality directives inflated Turn-1 thinking (`281.3` vs. **`67.7`** tokens, **`-75.9%`**), triggered a read of `deprecated_strict_schema_decoy.py` in Trial 2 (`47,600` uncached input tokens), and caused pre-edit test calls in Trials 1 & 3 (`1.67` vs. `1.00` verify attempts). `Candidate` converged in **`6.00 ± 0.00` calls** with `0` decoy reads across all 3 trials.
* **3. `-11.28%` Effective Cost & `-19.27%` Faster Execution (`3/3` Wins):** Total thinking dropped **`-12.36%`** (`18,079.0` ➔ `15,845.3`), total tokens fell **`-11.10%`**, standalone time improved **`-19.27%`** (`312.29s` ➔ **`252.12s`**), and effective cached cost dropped from `` `$0.3669 ± $0.0523` `` to **`` `$0.3255 ± $0.0383` `` (`-11.28%`, cheapest in `3/3` trials)**.

| Metric (`N=3` Trials, `Mean ± SD`) | Baseline: `Prescriptive Guidance` (`2,292B`) | Candidate: `Negative Guardrails` (`2,308B`) | Delta / Effect |
| :--- | :---: | :---: | :--- |
| **Hidden Grading Suite (`32` Cases)** | **`32.00 ± 0.00`** (`100.0%`) | **`32.00 ± 0.00`** (`100.0%`) | `100%` tie (`16` fix + `16` guard) |
| **Unrelated Files Modified** | `0.00 ± 0.00` | `0.00 ± 0.00` | All `3` adapters untouched |
| **Target File Diff Changed Lines** | `378.33 ± 8.14` (`[369–384]`) | **`330.33 ± 12.22` (`[317–341]`)** | **`-48.00` lines (`-12.69%`, `3/3`)** |
| **Decoy File Reads (`decoy_exposures`)** | `0.33 ± 0.58` (T2 hit decoy) | **`0.00 ± 0.00`** | **`-100%` decoy exposure** |
| **LLM Calls / Verify Attempts** | `6.33 ± 0.58` / `1.67 ± 0.58` | **`6.00 ± 0.00` / `1.00 ± 0.00`** | Deterministic `6`-call path |
| **Thinking Tokens (`thoughts`)** | `18,079.0 ± 3,113.4` | **`15,845.3 ± 2,788.5`** | **`-12.36%` (`-75.9%` on Turn 1)** |
| **Total Tokens (`total_tokens`)** | `135,136.7 ± 11,534.8` | **`120,131.0 ± 10,166.9`** | **`-11.10%` (`-15,005.7` tokens)** |
| **Standalone Elapsed (`elapsed_seconds`)** | `312.29s ± 43.49s` | **`252.12s ± 21.96s`** | **`-19.27%` (`-60.18s`, `3/3` wins)** |
| **Effective Cached Cost (90% OFF)** | `` `$0.3669 ± $0.0523` `` | **`` `$0.3255 ± $0.0383` ``** | **`-$0.0414` (`-11.28%`, `3/3` wins)** |
| **List-Price Upper Bound (No Cache)** | `` `$0.4991 ± $0.0520` `` | **`` `$0.4453 ± $0.0477` ``** | **`-10.78%` (`` `-$0.0538` ``)** |
| **Output Cap Hits (`MAX_TOKENS`)** | `0 / 3` | `0 / 3` | Zero truncation |

---

## 1. Experiment Design & Architecture

```text
+-----------------------------------------------------------------------+
| Proxmox VM261 (0 NICs, gemini-4-carbon MEDIUM, temp=0.7, N=3 AB/BA)   |
| Task: Brownfield Webhook & Settlement Repo (3 target + 3 live adapters)|
|                                                                       |
| Single Variable: Byte-Matched AGENTS.md Polarity (1.007x length)      |
|   |-- Baseline (AGENTS_PRESCRIPTIVE.md, 2,292B, 10 positive rules):   |
|   |     Boy Scout rule + clean helpers -> T1 281 thoughts, T2 decoy,  |
|   |     rewritten docstrings -> 378.3 diff lines | $0.3669 eff.       |
|   |-- Candidate (AGENTS_GUARDRAILS.md, 2,308B, 10 negative rules):    |
|         Do NOT touch adapters/keys/docstrings + check git_diff_stat   |
|         -> 6 calls fixed, 0 decoys -> 330.3 diff lines | $0.3255 eff. |
+-----------------------------------------------------------------------+
```

Both arms received identical `TICKET.md`, identical 6 tools (including `git_diff_stat` and `restore_file`), and identical `ReadWritePaths` permissions across all 6 editable Python files.

---

## 2. Drop-In Implementation Recipe: Negative-Scope Guardrail + Diff Gate

Replace vague Boy-Scout guidance in `AGENTS.md` with explicit non-modification boundaries, backed by a deterministic pre-submit diff check:

```python
import subprocess

ALLOWED_TARGET_FILES = {
    "signature_verifier.py",
    "idempotency_store.py",
    "settlement_rollup.py",
}


def check_blast_radius_diff(max_added_lines: int = 180) -> dict:
    """Rejects brownfield scope creep and excessive helper/docstring churn before submit."""
    stat = subprocess.check_output(["git", "diff", "--numstat"], text=True)
    touched, added_total = [], 0
    for row in stat.strip().splitlines():
        added_s, _, path = row.split("\t", 2)
        touched.append(path)
        added_total += 0 if added_s == "-" else int(added_s)
        if path not in ALLOWED_TARGET_FILES:
            raise PermissionError(f"SCOPE_VIOLATION: '{path}' is outside ticket boundary")
    if added_total > max_added_lines:
        raise ValueError(f"DIFF_BLOAT: {added_total} added lines exceeds {max_added_lines} cap")
    return {"status": "BLAST_RADIUS_OK", "touched": touched, "added_lines": added_total}
```

* **Why this works:** Concrete negative boundaries (*"do NOT touch `legacy_webhook_adapter.py`, `camelCase` keys, or existing docstrings"*) eliminate exploratory guesswork on frontier reasoning models—unlike abstract `"NEVER do X"` lists on weaker models (`E24`).

---

## 3. Threats to Validity & When NOT to Use This

1. **Ticket-Scoped Ceiling Effect (`32/32` Tie):** Because `PAY-418` already listed the 3 defective modules, `Baseline` did not modify the 3 untouched adapters (`0/3`). On underspecified brownfield tickets relying purely on `AGENTS.md` conventions, negative guardrails should show an accuracy gap as well.
2. **Model Tier & `E24` Pink Elephant Boundary:** Tested on `gemini-4-carbon (MEDIUM)` across `N=3` trials. On older/smaller `Flash` models (`E24` at `temperature=0.0`), purely negative rules without affirmative code templates can trigger the Pink Elephant effect—so pair negative scope boundaries with 1 short affirmative example when running small models.
3. **When Positive Guidance Helps:** In greenfield modules where you explicitly *want* refactoring, type annotations, and docstring normalization, affirmative style guides are appropriate.

<details>
<summary>📋 Experiment Metadata & Reproducibility</summary>

* **Experiment ID:** `E57` (`C053` / `arXiv:2604.11088` / Benchmark v2.1)
* **Run ID:** `e57-20261121-vm261-01` (`N=3` trials: `AB` ➔ `BA` ➔ `AB`, `temperature=0.7`)
* **Sandbox Environment:** Proxmox Isolated VM `VM261` (0 NICs, `PrivateNetwork=yes`, 3-UID isolation: `labexp57` / `labrunner57` / `labjudge57`)
* **Model & Thinking Level:** `models/gemini-4-carbon` (`thinkingLevel="MEDIUM"`, `max_output_tokens=32768`)
* **Cost Accounting:** Google 90% implicit prefix-cache discount (`effective_cached_micro_usd`) as primary metric; list-price upper bound reported alongside.

</details>

---

**Discussion:** Is your `AGENTS.md` mostly affirmative ("write clean, modular code") or negative ("never rename legacy keys or touch adjacent adapters")—and have you measured diff bloat between the two?

### 🔗 Continue Reading the Series
* 🚀 **Master Benchmark Hub:** [AI Agent Harness Patterns Benchmark](https://tappers.hashnode.dev/ai-agent-harness-patterns-benchmark)
* 🛡️ **Methodology & Sandbox Architecture:** [How to Benchmark AI Agents Without Eval Cheating or API Key Leaks: Designing a Proxmox & systemd Sandbox](https://tappers.hashnode.dev/air-gapped-proxmox-systemd-agent-sandbox)
* ⬅️ **Previous Post (`E56a`):** [Slashing Swarm Benchmark Cost 94.9%: Why Carbon LOW Failed and Flash LOW Won](https://tappers.hashnode.dev/e56a-plan-a-cost-ablation)
* ➡️ **Next Post (`E58`):** [When -67% Context Compression Backfires: Re-Reads & Thinking Raised Cost +22.3%](https://tappers.hashnode.dev/e58-minimal-compressed-target-context)
* ✨ **Related Positive Few-Shot (`E24`):** [Defeating the Pink Elephant Effect in Coding Agents: 25+ Negative 'NEVER DO X' Rules vs. 1 Positive Golden Code Template (2.85x Faster)](https://tappers.hashnode.dev/e24-positive-fewshot-template)
