Get new AI skills and notes from Sujan by emailNew AI skills by emailAI skills by email

No Wind Days
← Back to the AI Skills Library

Coding Agent Guardrails

Sets up repo guardrails (.cursorignore, Cursor rules and build-agent deny lists) to block .env reads, migration edits and force-pushes, and runs lint and tests before review.

Skill fileIn testing

Web QA & Dev

Download .md

How to use this

  1. Add the skill to your AI assistant. Copy it or download SKILL.md, then follow the how-to guide for Claude, ChatGPT, Grok or Cursor.
  2. Give it what it needs: Your repository root, package manager and test or lint commands.
  3. Ask for the work. For example: Use the claude-code-guardrails skill to add .cursorignore, repo guardrail rules and automated pre-review checks to this project.
  4. What you get back: Ready-to-commit .cursorignore, guardrail rules and optional build-agent permissions, plus a pre-review lint, typecheck and test routine.

When to use it: Use when setting up or building in Cursor or via Koen's build agent to enforce hard repo guardrails (blocking .env reads, migration edits, force-pushes, and pushes to main) and deterministic lint/test checks before review.

Coding Agent Guardrails (Cursor & Repo Build Agents)

Apply deterministic guardrails to repositories built in Cursor or by automated dev-process agents so secrets, schema migrations, and protected branches are blocked mechanically—and repeat bugs are caught by tools instead of paying an AI to rediscover them.

1. Cursor repo guardrails (.cursorignore + .cursor/rules/guardrails.mdc)

Add a .cursorignore at the repo root so secrets stay out of model context:

.env
.env.*
**/.env
**/.env.*
*.pem
*.key

Add .cursor/rules/guardrails.mdc (alwaysApply: true) with hard engineering guardrails:

  • Never read or print .env* files, keys, or tokens into context, PRs, or logs.
  • Never edit migrations/** without explicit owner approval.
  • Never run git push --force, git push -f, git reset --hard, or push directly to main/master.
  • Run lint, typecheck, and automated tests before asking a human or QA agent to review.
  • When a bug class happens twice, add a deterministic lint rule, schema check, or test so it fails automatically from then on.

2. Automated build-agent permissions (.claude/settings.json, when used by a build worker)

For repos built by a Claude Code dev-process worker, merge explicit permissions.allow and permissions.deny rules into .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Bash(npm test *)",
      "Bash(npm run lint *)",
      "Bash(npm run typecheck *)",
      "Bash(git status)",
      "Bash(git diff *)",
      "Bash(git log *)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(**/.env)",
      "Read(**/.env.*)",
      "Edit(./migrations/**)",
      "Edit(**/migrations/**)",
      "Bash(git push --force *)",
      "Bash(git push -f *)",
      "Bash(git push origin main *)",
      "Bash(git push origin master *)",
      "Bash(git reset --hard *)"
    ]
  }
}

Adjust test/lint commands to match the repo's package manager (pnpm, yarn, pytest, cargo test, etc.).

3. Deterministic checks before LLM or QA review

Before handing off a PR, build, or preview:

  1. Run the repo's formatter, linter, typechecker, and test suite first.
  2. Trim failing logs to the exact failing test or error line rather than dumping thousands of lines into context.
  3. Convert every repeat bug into a permanent lint rule, CI check, or unit test so it stops costing tokens forever.