Skip to content
youdede

Infrastructure apply guard

OperationsHookv1.0.0

A deterministic Claude Code PreToolUse gate that distinguishes read-only plan and diff operations from mutating Terraform, OpenTofu, Pulumi, kubectl, and Helm subcommands.

Runs on

Scope
$npx @youdede/toolkit add infrastructure-apply-guard --target claude-code

What it does

Block direct infrastructure and cluster state mutation commands while allowing planning operations.

When it fires

  • release
  • operations

How it behaves

Classify infrastructure CLI subcommands and refuse those that mutate managed state.

It does not apply, destroy, import, or roll back infrastructure.

It does not infer an environment from a prompt, variable, account, or workspace name.

It does not treat a dry-run-like custom flag as proof of safety.

Configuration

targets/claude-code/infrastructure-apply-guard.mjsnode · none

Version
1.0.0
Requires
Shell command guard
Licence
RiskThis automatic gate blocks direct infrastructure and cluster state mutation commands while allowing planning operations; a false denial can interrupt legitimate work, but it does not execute the blocked action.
Medium
ModeHow it works: fixed rules, model instructions, or both.
Deterministic only
Behaviour
Enforces, blocks on violation
On failure
Denies and blocks
LatencyThe entrypoint handles one intercepted event to block direct infrastructure and cluster state mutation commands while allowing planning operations without deferred work.
Immediate
Data retentionWhether data remains after use and who manages its storage.
Not retained

Often used with

All in Operations