Back to .md Directory

Eight Guardrails Framework

Defines eight safety guardrails enforced across three layers (Git hooks, Claude Code, Kubernetes) to prevent mistakes in a Kubernetes platform.

May 2, 2026
0 downloads
0 views
ai prompt eval claude workflow guardrails safety
View source

What this file does

Defines eight safety guardrails enforced across three layers (Git hooks, Claude Code, Kubernetes) to prevent mistakes in a Kubernetes platform.

When to use it

  • Designing safety policies for an AI-assisted Kubernetes workflow
  • Implementing layered security for GitOps pipelines
  • Adding automated rollback and audit trail to cluster deployments
  • Enforcing secrets isolation and supply chain validation in CI/CD

Assumes this stack

KubernetesArgoCDKyvernoFalcoClaude CodeTerraform

Eight Guardrails Framework

Overview

The Eight Guardrails Framework governs how the KubeAuto Day IDP was built and how the platform itself enforces safety. Each guardrail is implemented across three defensive layers, with problems caught at the cheapest possible point.

Cost to fix:  $        $$              $$$
              |         |                |
              v         v                v
         Git Hooks → Claude Code → Kubernetes
         (local)     (pre-exec)    (cluster)

Determinism:  100%      ~80%            100%
Latency:      <1s       1-30s           1-5s
Bypass risk:  None      Low*            None

* Prompt-based hooks are probabilistic. Bash-based hooks are deterministic.

The Eight Guardrails

1. Propose-Approve-Execute

Every change follows a structured workflow: propose (Git commit), approve (test gate), execute (ArgoCD sync).

LayerImplementation
Layer 1: GitPre-push hook blocks push if phase tests fail
Layer 2: Claude CodePreToolUse blocks kubectl apply in production namespaces after Phase 2
Layer 3: KubernetesArgoCD GitOps-only delivery. Backstage templates enforce structured service creation

2. Blast Radius Limits

Contain the impact of any single change to the smallest possible scope.

LayerImplementation
Layer 1: GitNamespace scope check validates manifests target only phase-appropriate namespaces
Layer 2: Claude CodePreToolUse blocks kubectl delete namespace, terraform destroy, operations on kube-system
Layer 3: KubernetesNamespace-scoped RBAC, ResourceQuotas (10 pods, 4 CPU, 8Gi in apps), NetworkPolicies (default-deny), VPC isolation

3. Stop Hooks & Circuit Breakers

Automated mechanisms that halt progress when something is wrong.

LayerImplementation
Layer 1: GitKubeconform schema validation, Kyverno CLI dry-run (pre-commit), full test suite (pre-push)
Layer 2: Claude CodeRalph Wiggum Stop hook blocks exit without phase completion promise. Prompt-based evaluator verifies test criteria actually pass
Layer 3: KubernetesKyverno admission webhooks reject non-compliant pods. Falco runtime rules detect anomalous behavior

4. Assume Misunderstanding

Validate everything. Never trust that output is correct without verification.

LayerImplementation
Layer 1: Gityamllint, kubeconform, terraform validate, helm lint (pre-commit)
Layer 2: Claude CodePostToolUse reminds to verify after kubectl apply and terraform apply
Layer 3: KubernetesSchema validation at admission. Kyverno validate rules enforce structural requirements

5. Immutable Audit Trail

Every action is recorded. Nothing can be silently changed.

LayerImplementation
Layer 1: GitConventional commit format with phase/component tags. Prompt logs in prompts/. Git history as timeline
Layer 2: Claude CodePostToolUse reminders for scorecard updates after deployments. Session logging
Layer 3: KubernetesPrometheus metrics, Grafana dashboards, OTel distributed traces, Falco syscall logging, K8s audit logs

6. Automated Rollback

When something fails, provide a fast path back to the last known-good state.

LayerImplementation
Layer 1: Gitgit revert is the cheapest rollback. Tagged commits at phase completion
Layer 2: Claude CodePostToolUse suggests rollback options after failed terraform/helm/kubectl commands
Layer 3: KubernetesArgoCD self-heal reverts drift. argocd app rollback for instant revision rollback. PDBs protect availability during changes

7. Secrets & Credential Isolation

No secrets in code. No long-lived credentials. No accidental exposure.

LayerImplementation
Layer 1: Gitgitleaks scans every commit. .gitignore excludes *.pem, *.key, terraform.tfstate. .gitleaks.toml allowlist for known test secrets
Layer 2: Claude CodePreToolUse blocks kubectl get secret -o yaml/json and cat of secret files
Layer 3: KubernetesExternal Secrets Operator pulls from AWS Secrets Manager. Pod Identity (no static IAM keys). KMS encryption at rest

8. Supply Chain Validation

Trust but verify. Only allow known-good artifacts.

LayerImplementation
Layer 1: GitTrivy Dockerfile scanning. Image registry allowlist check (pre-commit)
Layer 2: Claude Code(Potential: block Helm installs from unapproved repos)
Layer 3: KubernetesKyverno restrict-image-registries policy enforces ECR + GHCR + docker.io/library + registry.k8s.io

Coverage Summary

PhaseGuardrails Active at Layer 3
After Phase 1 (Foundation)#2 (VPC/SG), #7 (Pod Identity)
After Phase 2 (GitOps)+ #1 (ArgoCD), #6 (self-heal)
After Phase 3 (Security)+ #3 (Kyverno/Falco), #4 (admission), #7 (ESO), #8 (image policy)
After Phase 4 (Observability)+ #5 (Prometheus/OTel/Grafana)
After Phase 7 (Hardening)All 8 guardrails at all 3 layers

Files

LayerFiles
Layer 1.pre-commit-config.yaml, .yamllint.yml, .gitleaks.toml, .current-phase, .claude/hooks/check-image-allowlist.sh, .claude/hooks/check-namespace-scope.sh, .claude/hooks/commit-msg-validate.sh, .claude/hooks/pre-push-tests.sh
Layer 2.claude/settings.json, .claude/hooks/cc-pretool-guard.sh, .claude/hooks/cc-posttool-audit.sh, .claude/hooks/cc-stop-deterministic.sh
Layer 3policies/kyverno/, security/falco/, security/rbac/, security/network-policies/, security/eso/, security/quotas-pdbs/, gitops/, monitoring/, backstage/

Cross-References

  • Three-Layer architecture detail: docs/WALKTHROUGH.md
  • Security posture: docs/SECURITY.md
  • Reconciliation status: docs/EIGHT-GUARDRAILS-RECONCILIATION.md
  • Scorecard: spec/SCORECARD.md
  • Skill file guardrail mappings: .claude/skills/*.md (each has a "Guardrail Integration" section)

What's inside

8 guardrails each with 3-layer implementation table, coverage summary by phase, and file listing per layer

Change this for your project

  • Replace peopleforrester/kubeauto-ai-day with your repository name
  • Replace kubeauto-ai-day with your project name in file paths and docs
  • Replace registry.k8s.io with your allowed image registries in supply chain guardrail
  • Replace aws references (AWS Secrets Manager, Pod Identity) with your cloud provider

Where it goes

Load as policy context for the agent, or keep beside the code enforcing the rules.

Worth borrowing

  • Cost-to-fix diagram showing where each layer catches errors and its latency/determinism trade-offs
  • Phase-based activation table that gradually enables guardrails as infrastructure matures

Related Documents