DEV Community

Cover image for How to add mechanical enforcement to any AI coding agent
David Emilio Sierra Puentes
David Emilio Sierra Puentes

Posted on

How to add mechanical enforcement to any AI coding agent

The problem

AI coding agents generate code at impressive speeds. But they also commit untested code, hallucinate APIs, and forget your instructions the moment context fills up. If you've ever reviewed an AI-generated PR and thought "this looks right but I don't trust it," you've experienced the gap this framework fills.

github.com/juandelossantos/another-agent-skills

Prompts (CLAUDE.md, .cursorrules) work until they don't. The agent remembers until context degrades. Then it forgets. Mechanical enforcement via git hooks doesn't have that problem, hooks run regardless of what the agent remembers.

What you'll build

By the end of this tutorial, you'll have:

  • 14 pre-commit gates running on every commit
  • A TDD gate that blocks code without tests
  • 57 composable skills your agent loads on demand
  • A 6-phase development lifecycle (Define → Plan → Build → Verify → Review → Ship)

Step 1: Install (10 seconds)

git clone https://github.com/juandelossantos/another-agent-skills.git
cd another-agent-skills
bash install.sh
Enter fullscreen mode Exit fullscreen mode

That's it. The installer copies the framework to ~/.config/opencode/ and sets up the skill loader.

Step 2: Initialize in any project

cd your-project
init-agents
Enter fullscreen mode Exit fullscreen mode

This creates:

  • STACK_CONFIG.md — auto-detected test/lint/build commands
  • Git hooks in .git/hooks/ (pre-commit v11, commit-msg v4)
  • .gitignore and .env.example if missing

Step 3: How the gates work

The pre-commit hook runs 14 checks before every commit:

# Example: a commit is blocked
$ git commit -m "add feature"
⛔ BRANCH CHECK: on main — create a feature branch
⛔ STAGED CHECK: nothing staged — use git add
⛔ REMOTE SYNC: 3 unpulled commits — run git pull
Enter fullscreen mode Exit fullscreen mode

Each gate must pass before the commit proceeds. The agent cannot use --no-verify unless you explicitly allow it (and that override is tracked).

# Example: a commit passes all gates
$ git commit -m "feat: add user auth"
✅ BRANCH CHECK: on feat/user-auth
✅ STAGED CHECK: 4 files staged
✅ REMOTE SYNC: up to date
✅ HTML INTEGRITY: all markers present
✅ SKILL GATE: skills were consulted
✅ ANTI-SLOP: no generic patterns detected
✅ TDD GATE: test files match code files
✅ TEST RUNNER: 29/29 tests passing
✅ All 14 gates passed → commit allowed
Enter fullscreen mode Exit fullscreen mode

Step 4: The 6-phase lifecycle

Every project follows the same disciplined flow:

DEFINE → PLAN → BUILD → VERIFY → REVIEW → SHIP
Enter fullscreen mode Exit fullscreen mode

Each phase has corresponding skills:

  • DEFINE: spec-driven-development, architecture-analysis, interview-me
  • PLAN: planning-and-task-breakdown
  • BUILD: incremental-implementation, test-driven-development, doubt-driven-development
  • VERIFY: test-driven-development, debugging-and-error-recovery
  • REVIEW: code-review-and-quality, security-and-hardening, performance-optimization
  • SHIP: git-workflow-and-versioning, ci-cd-and-automation, shipping-and-launch

The agent loads skills on demand. 57 total, each with a declared Output Contract (artifact, format, location, quality criteria).

Step 5: Customizing for your stack

The framework auto-detects your stack from lockfiles:

$ init-agents
🔍 Detected: Node.js (package.json)
📝 Created: STACK_CONFIG.md with npm test, npm run lint, npm run build
🔗 Installed: 57 skills ready for agent
Enter fullscreen mode Exit fullscreen mode

Supports Node, Python, Rust, Go, Ruby, Dart, any stack with git.

Why this matters

Most "AI agent frameworks" are prompt collections. They teach the agent. They don't enforce.

This is a harness. Mechanical infrastructure around the model. The difference between "please follow the rules" and "you literally cannot commit without passing 14 gates."

57 skills. 14 gates. 6 harness components. 0 lint errors. MIT. Free.

If you're building with AI agents and want production-grade guardrails:

github.com/juandelossantos/another-agent-skills, clone, run bash install.sh, and star the repo ⭐

10 seconds to your first gate.

Top comments (0)