Checkable Guardrail Rules for a Coding Agent: Blocked Commands, Approvals, Secrets and Hooks

Produces a set of testable guardrail rules for your coding agent, covering blocked commands, approval gates, secret handling and hook checks.

You get: Blocked commands table, approval-required actions table and secret handling rules with the hook that checks each one

More like this

Ready to use: no blanks to fill in.

The prompt

checkable-guardrail-rules-for-a-coding-agent-blocked-commands-approvals-secrets-and-hooks.md
Act as a security-minded platform engineer writing guardrails for a coding agent. First ask me two short questions: which repo or environment the agent runs in (languages, CI, hosting, secrets manager), and what the agent is allowed to do today. Wait for my answers. Then write guardrails as rules that a script, hook or reviewer can check.

Rules:
- Give every rule an ID, a one-sentence pass/fail test and an enforcement point (pre-tool hook, pre-commit, CI or human review).
- Prefer allowlists over denylists where possible, and say why when you use a denylist.
- The agent must never print, log, commit or paste secrets. State how it may access them instead.
- List anything you assumed separately from what I told you.

Output format:
1. Assumptions and missing information.
2. Blocked commands table: ID, pattern, reason, check.
3. Approval-required actions table: ID, action, approver, evidence needed.
4. Secret handling rules with the hook that checks each one.
5. Eight sample agent actions marked allow, approve or block, so I can test the rules.
6. Top five residual risks and next actions.

Example output

AI-written example

1. Assumptions and missing information

Told: Python and TypeScript monorepo; GitHub Actions CI; AWS hosting; AWS Secrets Manager. The agent edits files, runs tests and opens PRs from a dev container.

Assumed: The agent has no prod credentials. main is branch-protected. Hooks run outside the agent's control. Egress is unrestricted today.

Missing: Whether the dev container can reach AWS APIs, and who owns the hook config.

2. Blocked commands (allowlist first: only pytest, npm test, ruff, eslint, git add/commit/switch, gh pr create run unprompted. The denylist below catches risky forms of otherwise-allowed tools.)

IDPatternReasonCheck
B1git push --force*, git push * mainHistory loss, bypasses reviewPre-tool hook rejects match
B2rm -rf with a path outside $WORKSPACEData lossHook resolves path, fails if outside
B3curl*|*sh, wget*|*shUnreviewed code executionHook regex
B4printenv, env, cat .env*Secret exposureHook regex
B5aws secretsmanager get-secret-valueDirect secret readHook regex
B6terraform apply, kubectl * --context prod*Infra changeHook rejects; CI-only

3. Approval-required actions

IDActionApproverEvidence
A1Add or upgrade a dependencyCode ownerLockfile diff, license and advisory scan
A2Edit .github/workflows/* or hook configPlatform teamPR diff, reviewer sign-off
A3Create a DB migrationService ownerMigration plan, rollback step
A4Contact a new external domainSecurityDomain, purpose, request sample

4. Secret handling

  • S1: The agent never reads secrets. The test harness injects them as env vars at runtime from Secrets Manager. Hook: pre-tool hook blocks reads of .env* and ~/.aws.
  • S2: No secret-shaped strings in diffs. Hook: pre-commit gitleaks, repeated in CI.
  • S3: Tool output is redacted before it reaches the model or logs. Hook: output filter fails if a canary token appears in logs.
  • S4: Missing secrets are reported by name only (e.g. "STRIPE_TEST_KEY unset"). Check: human review of transcript samples.

5. Sample actions

  1. pytest -q tests/billing → allow
  2. git push --force origin feature/x → block (B1)
  3. npm install lodash@latest → approve (A1)
  4. cat .env.local → block (B4)
  5. Edit .github/workflows/ci.yml
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Use before giving a coding agent access to a repo, CI or shell. Answer the two opening questions, then paste the resulting rules into your hook config or agent policy file and run the sample actions as a test.

Questions about this prompt

More in Agentic AI

20-Case Agent Eval Set with Pass/Fail Rubric for Normal, Edge and Unsafe Requests

Builds 20 test cases for your agent's task, with expected behavior, failure signals and a pass/fail rubric covering normal, edge and unsafe requests.

Agent Tool Names, Descriptions and JSON Schemas from API Docs

Turns pasted API docs or a function list into agent-ready tool names, descriptions, JSON input schemas and when-to-use and when-not-to-use notes.

Agent Workflow Decomposition with Autonomy Levels and Stop Rules

Turns a manual process into a step-by-step agent plan with tools, approval gates, retry limits, and a build/pilot/skip recommendation.

Research Agent Brief: Source Discovery, Evidence Review, and Citation Table

Directs an AI agent to plan source discovery, grade evidence, build a citation table, and support a decision without claiming live browsing occurred.

Tool Permission Matrix and Function Spec for a Tool-Using Agent

Produces a least-privilege tool inventory, function definitions, and approval rules for an agent that calls APIs or internal systems.

Rewrite a Vague Issue into a Copilot Coding Agent-Ready Issue

Turns a vague GitHub issue into a self-contained task with context, testable acceptance criteria, files to touch, and tests to add, so the Copilot coding agent can finish it.

Agent Run Pre-Mortem and Self-Correction Loop Designer

Designs verification checks, error handling, and a self-correction loop for an agent task before it runs, based on likely failure modes.

Short-Form Hook Test Plan for Reels, TikTok, and Shorts

Generates a set of testable hook variants and a measurement plan for a vertical video so a creator can decide which version to publish first and what to learn from results.

Characterization Tests Before a Refactor

Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.

Codebase Tour for a Specific Task

Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.

Coding Agent Task Brief with Guardrails, Test Plan, and Rollback Steps

Creates a scoped brief for an AI coding agent that limits file changes, defines tests, and includes a rollback plan and review checklist.

Conventional Commit and PR Description from a Diff and Ticket

Produces a Conventional Commits message and a reviewer-ready PR description covering what changed, why, how to test it, and the risks, based on your diff and ticket.