all factors
XIimprovement

Fail-Safe Checks

Clear boundaries. Safe automation.

3 min read

XI. Fail-Safe Checks

XI
Clear boundaries

Nine Laws guide agent behavior. Guardrails help enforce them automatically.


The Problem

Without Guardrails

  • Agents skip validation to "move faster"
  • Guidelines get ignored when inconvenient
  • Risky behaviors slip through
  • Production issues from missed checks

With Guardrails

  • High compliance with the Nine Laws
  • Violations caught early, not late
  • Consistent quality across sessions
  • Defense in depth with multiple layers

The Nine Laws

1. Learn & Improve

Extract patterns, identify improvements

2. Document

Context commits, progress files, bundles

3. Git Discipline

Commit often, clean workspace

4. TDD + Tracers

Tests first, tracers for complex tasks

5. Guide

Suggest options, user chooses

6. Classify Level

Assess vibe level (0-5) before work

7. Measure

Track metrics, break spirals early

8. Session Protocol

One feature, review before end

9. Protect Definitions

Features unchanged, mark passes only


The Solution

Hope-Based Compliance

Agent: "Validation is slow, I'll skip it"

Agent: Deploys to production

Production: Breaks

Result: Guidelines followed when convenient

Automated Guardrails

Agent: Attempts commit without tests

Pre-commit hook: Catches the issue

Agent: Runs tests, then commits

Result: Guidelines reinforced by tooling


Defense in Depth

::: info Three Layers of Protection Layer 1: Pre-Execution

  • Agent wants to commit -> Hook validates first
  • Agent wants to deploy -> Pre-check runs
  • Context growing -> Warning at 35%

Layer 2: Runtime

  • Context approaching limit -> Suggest compression
  • Multiple fix commits -> Flag potential spiral
  • Session getting long -> Prompt for checkpoint

Layer 3: Post-Execution

  • Session complete -> Check for learnings
  • Week complete -> Review for improvements
  • Patterns emerging -> Suggest extraction :::

Implementation Patterns

Pre-Commit Hooks

#!/bin/bash
# .git/hooks/pre-commit

echo "Running guardrails..."

# Law 4: Validate before commit
if ! npm test --quiet 2>/dev/null; then
    echo "Tests didn't pass - consider fixing before commit"
    # Soft warning, not hard block
fi

# Law 2: Encourage documentation
if ! git diff --cached --name-only | grep -q "\.md$"; then
    echo "Tip: Consider documenting significant changes"
fi

echo "Checks complete"

Context Monitoring

class ContextGuardrail:
    def __init__(self, soft_limit=0.35, hard_limit=0.40):
        self.soft_limit = soft_limit
        self.hard_limit = hard_limit

    def check_context(self, utilization):
        if utilization > self.hard_limit:
            return "Consider resetting context or using bundles"
        elif utilization > self.soft_limit:
            return "Context getting full - good time to checkpoint"
        return None

Validation

  • Pre-commit hooks provide helpful feedback
  • Context warnings appear before issues
  • Session checkpoints happen regularly
  • Learnings captured most sessions
  • Spiral detection catches fix chains early

FactorRelationship
I. Automated TrackingGit hooks support Laws 2 & 3
IV. Continuous ValidationSupports Law 4
VI. Resume WorkContext management
IX. Mine PatternsSupports Law 1