mikeaorlando.com Michael Orlando
  • Home
  • Start Here
  • About
  • Work & Ventures
  • Ideas & Writing
  • Collaborate
  • Search

◉Guardrails for AI-Operated Infrastructure

Guardrails for AI-Operated Infrastructure

The permission scoping, deploy paths, and tool hooks I use so AI agents can do real infrastructure and publishing work while people keep the decisions.

Routing Notes

  • Parent Projects for Fun
  • Signal Working Systems

Overview

The goal is to let AI agents do real work on infrastructure and published systems without giving them the ability to make decisions that belong to a person. The rule I build around comes from this site’s colophon: AI proposes, humans decide. That rule only holds if the system enforces it. A written instruction is a request; a credential that cannot reach a resource, a deploy path that requires review, and a hook that blocks a tool call are enforcement.

This page describes the guardrails I use with Claude Code on this site and in my homelab, and with an experimental agent that runs in the homelab.

Context

Agents now edit code, run commands, call cloud APIs, and post to Jira, Confluence, and Slack. The failures I design against are specific: an agent using a broader credential than the task needs, deploying an uncommitted working tree, posting text that readers take as mine, waiting on a process that already failed, and starting work nobody asked for.

The System

If terms like agent, MCP or hook are new to you, How my AI stack fits together explains how the parts relate.

The guardrails sit at four layers: credentials, deploy paths, tool calls, and intake.

Scoped credentials. The AWS profile an agent uses for this website is limited to the two site storage buckets and the two CDN distributions in front of them. The policy is a JSON file kept in the repository next to its setup instructions, so the scope can be reviewed in the same place as the code. The profile signs in with short-term credentials through aws login, so nothing long-lived is written to disk. A committed .envrc.example sets the profile for every command run in the repository, so an agent does not fall back to a developer’s broader default. The CI deploy uses its own identity with its own policy file. In my homelab, risky AWS experiments run in a separate account, and the key used for certificate DNS challenges is limited to the two Route 53 actions that work needs.

One deploy path. Pushing a branch is the deploy. GitHub Actions builds the site, rebuilds the search index, and publishes it; a validation workflow checks the build and internal links on every pull request. The agent instructions say not to run a manual deploy. For the case where CI is broken, ops/deploy.sh runs the correct sequence, refuses to run without an explicit --force-manual flag, and warns when the working tree has uncommitted changes. The break-glass path exists, and it is inconvenient on purpose.

Hooks on tool calls. Claude Code runs hooks before a tool call executes. Two of mine enforce rules that instructions alone did not.

  • A signature hook blocks any post to a shared system (Jira, Confluence, Slack, GitHub comments and pull requests) that does not end with a signature line naming the agent and the model. These posts go out under my account, and the line is how readers and other agents tell the agent’s text from mine. When the hook blocks, the agent adds the line and retries.
  • A sleep hook blocks any single wait longer than a short limit. Long blind waits hid processes that had already failed or never started. The rule that goes with it is to confirm the process started, then poll in short steps that print the observed state, exit on success or failure, and stop at a deadline.

Configuration without secrets. The MCP configuration that connects agents to tools is committed with every credential replaced by an environment variable reference. Secrets live in a user-scoped settings file that is not in the repository, so the shared configuration can be reviewed and copied safely.

Intake and access for agents that run unattended. The homelab agent acts on a Jira issue only when a person asks it directly in chat. Being assigned or mentioned does not start work, and it never assigns itself. A read-only verifier checks that no scheduled job runs Jira work. The same agent gets read-only access to the repository documentation instead of SSH to hosts, and for anything it may not change, it proposes the change in a ticket and names who would make it.

Components and Why I Chose Them

Component What it does here Why I chose it
AWS IAM (tool page) A customer-managed policy limited to the site’s buckets and CDN distributions The scope is enforced by AWS, not by the agent’s instructions, and the policy is a file that can be reviewed in the repository.
AWS CLI aws login (tool page) Signs the limited profile in with short-term credentials Nothing long-lived is written to disk, so there are no access keys to rotate or leak.
direnv Sets the limited profile for every command in the repository An agent’s commands use the narrow profile by default instead of a broader one on the machine. direnv also refuses to load a new or changed file until a person approves it.
GitHub Actions (tool page) The only routine deploy path, plus validation on every pull request The build, search index and deploy run the same way every time, from a commit, with their own credential.
Claude Code hooks (tool page) Check a tool call before it runs and block it with a reason A hook runs on every matching call, so the rule holds even when an instruction is missed.
Model Context Protocol configuration (tool page) Connects agents to tools, committed with variable references only The shared file can be reviewed and copied, and secrets stay in user-scope settings on each machine.
Jira (tool page) Where the homelab agent proposes changes it may not make A ticket keeps the proposal, the decision and the person who made it in one record.

Outcomes

Agents do routine work on this site and in the homelab: editing, building, filing tickets, and posting updates. The parts that need a decision stay with me: what reaches production, what credentials exist, and what work starts. Posts that Claude Code makes with my account carry its signature line, so readers can tell them from mine.

Artifacts

This site’s colophon states the operating rule and the review path the guardrails enforce. The real credential scopes, hooks, and agent configuration are internal and are not published, because they describe access to live systems. The simplified excerpts below show their shape.

Example Configuration

These are simplified excerpts with placeholder values.

A scoped IAM policy. List the two buckets, manage objects in them, and invalidate two CDN distributions. Nothing else.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListSiteBuckets",
      "Effect": "Allow",
      "Action": ["s3:GetBucketLocation", "s3:ListBucket", "s3:ListBucketMultipartUploads"],
      "Resource": [
        "arn:aws:s3:::example-site-bucket",
        "arn:aws:s3:::example-staging-site-bucket"
      ]
    },
    {
      "Sid": "ManageSiteObjects",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject", "s3:PutObject", "s3:DeleteObject",
        "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts"
      ],
      "Resource": [
        "arn:aws:s3:::example-site-bucket/*",
        "arn:aws:s3:::example-staging-site-bucket/*"
      ]
    },
    {
      "Sid": "InvalidateSiteDistributions",
      "Effect": "Allow",
      "Action": [
        "cloudfront:CreateInvalidation", "cloudfront:GetInvalidation",
        "cloudfront:ListInvalidations", "cloudfront:GetDistribution"
      ],
      "Resource": [
        "arn:aws:cloudfront::<account-id>:distribution/<production-distribution-id>",
        "arn:aws:cloudfront::<account-id>:distribution/<staging-distribution-id>"
      ]
    }
  ]
}

A named profile that signs in with aws login. The profile holds no keys. The IAM user also needs the AWS-managed policy that allows aws login.

[profile example-site-limitedaccess]
region = us-east-1
output = json
login_session = arn:aws:iam::<account-id>:user/<limited-user>

The signature hook, simplified. It runs before a tool call and receives the call as JSON. If the call publishes text to a shared system and the text lacks the signature line, it denies the call and says how to fix it.

#!/bin/bash
# ~/.claude/hooks/require-agent-marker.sh (simplified)
# Required signature, using a made-up agent name for this example:
#   — Agent 007 (Claude Code, <model>), posted with <owner>'s account
MARKER='Agent 007 (Claude'
input=$(cat)
tool=$(jq -r '.tool_name' <<<"$input")

case "$tool" in
  *createJiraIssue|*addCommentToJiraIssue|*createConfluencePage|*slack_send_message)
    text=$(jq -c '.tool_input' <<<"$input") ;;
  Bash)
    cmd=$(jq -r '.tool_input.command' <<<"$input")
    # Only gh commands that publish text: pr/issue create, comment, review, edit
    grep -Eq 'gh (pr|issue) (create|comment|review|edit)' <<<"$cmd" || exit 0
    text="$cmd" ;;
  *)
    exit 0 ;;   # every other tool call passes
esac

grep -qF -- "$MARKER" <<<"$text" && exit 0
jq -n '{hookSpecificOutput: {hookEventName: "PreToolUse",
  permissionDecision: "deny",
  permissionDecisionReason: "End the text with the signature line naming the agent and the model, then retry."}}'

Patterns Worth Reusing

Enforce in the system, not only in the prompt. Put the rule where the agent cannot skip it: in the credential’s scope, in the deploy path, or in a hook that runs before the tool call.

Make the safe path the easy path. When pushing a branch is the deploy, nobody needs a manual deploy. Keep the break-glass route, and make it ask for an explicit flag.

Mark agent output. If an agent posts with a person’s account, readers need a way to tell the two apart. A required signature line is simple and checkable.

Block messages should say what to do next. A guardrail that only refuses leaves the agent guessing. One that explains the correct procedure gets the correct procedure.

Explore

  • ✎Posts
  • ○Categories
  • ◉Projects for Fun
  • ▶Projects for Work
  • ◎Systems Across Domains
  • ▪Technical Tools
  • ◆Transferable Skills
  • ✕Value Multipliers
  • ◇Ventures

Michael Orlando

Systems, ventures, writing, and public proof arranged so the right people can find the right next step.

© 2026 Michael Orlando

Privacy & Data Handling

about.me Substack Credly Polywork