How I built mechanical enforcement for AI coding agents —…
    Neura MarketNeura Market/Stable Diffusion
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityStable DiffusionStable Diffusion
    DeepSeekDeepSeekCoPilotCoPilotMidjourneyMidjourney
    View All Directories
    OverviewPromptsBlogVideosGuidesCoursesCommunityModelsLoRAsComfyUI WorkflowsTrending
    Stable DiffusionBlogHow I built mechanical enforcement for AI coding agents — and why prompts aren't enough
    Back to Blog
    How I built mechanical enforcement for AI coding agents — and why prompts aren't enough
    opensource

    How I built mechanical enforcement for AI coding agents — and why prompts aren't enough

    David Emilio Sierra Puentes June 25, 2026
    0 views

    I spent months watching AI coding agents produce impressive demos that couldn't survive...

    I spent months watching AI coding agents produce impressive demos that couldn't survive production.

    The code looked right. It compiled. It even passed the first test.

    Then it hit edge cases. Forgotten constraints. A rule the agent agreed to five minutes ago, now gone — overwritten by the next context window.

    The root cause wasn't capability. It was process.

    "A raw model is not an agent. It becomes one once a harness gives it state, tool execution, feedback loops, and enforceable constraints." — Osmani, Saboo & Kartakis, The New SDLC With Vibe Coding, 2026 [1]


    The problem: capable but undisciplined

    AI agents are brilliant at generating code. They have zero built-in discipline:

    • They commit without tests
    • They push without review
    • They overwrite each other's work
    • They produce output that looks correct but breaks silently

    A METR study (Becker et al., July 2025 [2]) found something counterintuitive: developers using AI took 19% longer while feeling 20% faster. The speed was an illusion. The debugging cost was real.

    The industry's response has been more skills, more prompts, bigger context windows. But the problem isn't intelligence — it's accountability.

    A rule that lives only in a prompt is a suggestion. An agent that "knows" the rules will eventually forget them. Context degrades. Attention drifts. The question isn't if your agent will break a rule — it's when.


    The insight: memory is not enforcement

    Three incidents in 48 hours taught me this lesson.

    My agent bypassed its own commit approval system in under 30 seconds. Not because it was malicious — because the "gate" was just another rule in a file. Another thing to remember. Another thing to forget.

    I had built a SHA256 token system for commit approval. Thought it was bulletproof. Then my agent ran with --auto and the tokens became theater.

    The fix wasn't a better token system. The fix was changing the architecture.

    Rules that depend on memory fail. Rules that depend on visible blocks succeed.

    This is the core insight behind mechanical enforcement: gates that run at the infrastructure level, not the agent level. The agent cannot bypass what it cannot ignore.


    The solution: Agent = Model + Harness

    I built this project as a complete open-source implementation of the Harness architecture [3] — the mechanical infrastructure that turns raw AI intelligence into reliable output.

    ComponentWhat It Is
    Instructions & RulesWho the agent is, what it cares about, what it must never do
    Tools57 composable skills loaded on demand (lazy-loaded, ~250 lines each)
    Sandboxes & ExecutionTerminal, git workspace, CI
    OrchestrationWhen each tool fires, how agents coordinate
    Guardrails & HooksDeterministic enforcement at lifecycle points — pre-commit, commit-msg, approval
    ObservabilityMetrics, health checks, drift detection

    What makes this different: Most "agent frameworks" are just prompt libraries. This one adds 12 mechanical pre-commit gates, a three-gate commit approval system, and a context engineering layer that saves ~45% of always-loaded tokens.


    The code: a commit-msg hook that can't be bypassed

    Here's the heart of mechanical enforcement — a commit-msg git hook (v6) [4] that blocks unstamped commits:

    #!/usr/bin/env bash
    # commit-msg — Three-Gate Approval Check (v6)
    set -euo pipefail
    
    REPO_ROOT=$(git rev-parse --show-toplevel)
    APPROVAL_FILE="${REPO_ROOT}/.git/COMMIT_APPROVED"
    MANIFEST_FILE="${REPO_ROOT}/.git/COMMIT_MANIFEST"
    TEST_LOG="${REPO_ROOT}/.git/TEST_LOG"
    CURRENT_MSG=$(head -1 "$COMMIT_MSG_FILE" | tr -d '\n')
    NOW_EPOCH=$(date +%s)
    
    # Gate 1: Tests passed recently?
    if [[ -f "$TEST_LOG" ]]; then
      STATUS=$(grep "^status=" "$TEST_LOG" | cut -d= -f2-)
      if [[ "$STATUS" == "PASS" ]]; then
        TS_EPOCH=$(date -d "$(grep "^timestamp=" "$TEST_LOG" | cut -d= -f2-)" +%s)
        AGE=$((NOW_EPOCH - TS_EPOCH))
        [ $AGE -le 3600 ] && GATE1=true
      fi
    fi
    
    # Gate 2: Commit manifest exists and has content?
    [[ -f "$MANIFEST_FILE" ]] && \
      [ $(wc -c < "$MANIFEST_FILE") -gt 20 ] && GATE2=true
    
    # Gate 3: Approval fresh (<5 min) and message matches?
    if [[ -f "$APPROVAL_FILE" ]]; then
      TIMESTAMP=$(grep "^timestamp=" "$APPROVAL_FILE" | cut -d= -f2-)
      STORED_MSG=$(grep "^message=" "$APPROVAL_FILE" | cut -d= -f2-)
      TS_EPOCH=$(date -d "$TIMESTAMP" +%s 2>/dev/null || echo 0)
      AGE=$((NOW_EPOCH - TS_EPOCH))
      [ $AGE -le 300 ] && [ "$STORED_MSG" = "$CURRENT_MSG" ] && GATE3=true
    fi
    
    # All three must pass
    if [ "$GATE1" = true ] && [ "$GATE2" = true ] && [ "$GATE3" = true ]; then
      echo "✓ All 3 gates passed. Commit allowed."
      exit 0
    else
      echo "✗ Commit blocked — missing gates:"
      [ "$GATE1" != true ] && echo "  - Tests not run or expired"
      [ "$GATE2" != true ] && echo "  - Commit manifest missing"
      [ "$GATE3" != true ] && echo "  - Approval missing or expired"
      exit 1
    fi
    

    Three conditions must be met before any commit goes through:

    1. Tests passed (within the last hour) — no blind commits
    2. Commit manifest exists (the agent writes what changed) — no silent mutations
    3. User approved (within 5 minutes, message matches) — no stale approvals

    The agent writes the approval file after the user says "yes commit" in chat. The hook verifies the file is fresh (<5 min) and matches the exact commit message. If the agent tries to commit without approval, the hook blocks it — every time.

    This isn't a rule the agent remembers. It's a gate the agent cannot bypass.


    The results: 57 skills, 12 gates, zero shortcuts

    After months of iteration, the project ships [5]:

    MetricCount
    Composable skills57
    Lazy-loaded guides54
    Pre-commit gates9 (v8) + 3 commit-msg gates
    Enforcement levels4 (process → manifest → time-window → manifest gate)
    Agent compatibilityOpenCode, Claude Code, Cursor, Kiro, any git agent [6]
    Context tokens saved~45% vs eager loading [7]
    Stack supportNode, Python, Rust, Go, Ruby, any language with git
    PriceFree (MIT)

    What I learned

    Prompts are instructions. Gates are guarantees.

    If you're building with AI agents, ask yourself:

    • Does your agent run tests before every commit? Mechanically, not as a suggestion?
    • Does your agent present changes for review before pushing? Every time, not just when it remembers?
    • Can your agent bypass its own rules? If yes, those aren't rules — they're suggestions.

    The gap between an "impressive demo" and "production-grade" isn't intelligence. It's the harness around it.


    Try it:

    git clone https://github.com/juandelossantos/another-agent-skills.git
    cd another-agent-skills
    bash install.sh
    init-agents   # Activates skill-driven mode in any project
    

    MIT. Free. Zero subscriptions. 57 skills. 12 gates.

    juandelossantos.github.io/another-agent-skills


    What patterns have you found for keeping AI agents disciplined in production? I'd love to hear what's working (or not working) in your stack.


    References

    1. <a id="ref1"></a> Osmani, A., Saboo, S., & Kartakis, S. (2026). The New SDLC With Vibe Coding: From ad-hoc prompting to Agentic Engineering. — Harness architecture paper
    2. <a id="ref2"></a> Becker, S. et al. (2025). When Developers Use AI: Productivity and Perception. METR (Model Evaluation and Threat Research). — arxiv.org/abs/2507.09089
    3. <a id="ref3"></a> Another Agent Skills. Harness Architecture — The Six Components. — docs/HARNESS.md
    4. <a id="ref4"></a> Another Agent Skills. commit-msg hook (v6) — Three-Gate Approval Check. — scripts/git-hooks/commit-msg
    5. <a id="ref5"></a> Another Agent Skills. Repository and Documentation. — github.com/juandelossantos/another-agent-skills
    6. <a id="ref6"></a> Another Agent Skills. Agent Adapters — Compatibility Matrix. — docs/AGENT-ADAPTERS.md
    7. <a id="ref7"></a> Another Agent Skills. Context Budget — Lazy Loading Architecture. — README.md
    8. <a id="ref8"></a> Singhal et al. (2026). Agent Skills: Evaluation-Driven Development for AI Coding Agents. Google Research. — Paper
    9. <a id="ref9"></a> Osmani, A. (2026). The Factory Model: From Conductors to Orchestrators. — addyosmani.com
    10. <a id="ref10"></a> Another Agent Skills. SOUL.md — Project Identity and Principles. — SOUL.md

    Tags

    opensourceaiproductivitytooling

    Comments

    More Blog

    View all
    Context bankruptcy: The case for strategic forgetting for AI Agentsai

    Context bankruptcy: The case for strategic forgetting for AI Agents

    Most of us have seen a coding agent fail to complete a task we know it can do. We just don't...

    J
    James O'Reilly
    Parallel Compliance Engine: Drive-to-Sheets Multi-Agent Orchestrationgooglecloud

    Parallel Compliance Engine: Drive-to-Sheets Multi-Agent Orchestration

    When building Generative AI applications, developers often encounter a massive bottleneck: sequential...

    A
    Aryan Irani
    Is It Ethical to Post and Ask About Circuits on Dev.to?discuss

    Is It Ethical to Post and Ask About Circuits on Dev.to?

    I’ve been thinking about sharing some electronic circuit posts on Dev.to — small circuits, DIY...

    C
    codebunny20
    The One-Click Exporter: AI Studio Antigravity, Probed to Its Limitsagents

    The One-Click Exporter: AI Studio Antigravity, Probed to Its Limits

    What nobody tells you about exporting your multi-agent prototype to a local workspace. Every...

    L
    leslysandra
    Guarding the till while autonomous data agents do the diggingagenticarchitect

    Guarding the till while autonomous data agents do the digging

    Autonomous agents are genuinely good at answering messy business questions. Give one an LLM and a set...

    S
    Sireesha Pulipati
    Return on Attention: Why AI Code Reviews Are Wearing Us Outai

    Return on Attention: Why AI Code Reviews Are Wearing Us Out

    PR volume went up, ticket quality didn't, and the gap got filled with LLMs on both sides of the review: bots reviewing, bots replying, bots occasionally arguing with bots about priorities that only existed in a teammate's head. Our CEO named the actual problem, and it's bigger than code review.

    C
    christine

    Stay up to date

    Get the latest Stable Diffusion prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Stable Diffusion and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Stable Diffusion resource

    • Awork Time Tracking Enforcement & Cleanup Automationn8n · $19.99 · Related topic
    • Automate Time Tracking Enforcement & Cleanup for Work Tasksn8n · Free · Related topic
    • Create a WHOIS API Interface for AI Agents with 8 Domain Management Operationsn8n · Free · Related topic
    • Build AI Agents with Think-Plan-Act Architecture Using Llama-4 Reasoningn8n · Free · Related topic
    Browse all workflows