awesome-docs
Generate, convert, and maintain animated GitHub-safe Markdown documents with animated SVG…
Generate and enforce policy gates for AI coding agents (Copilot, Claude Code) — real-time session hooks that deny protected-path edits and dangerous commands, plus a merge-time backstop for anything that bypasses them. Use when asked to "govern AI agents", "block AI from
$ npx -y skills add nitinjain999/platform-skills --skill ai-governance --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/ai-governanceContext preview
The summary Claude sees to decide when to auto-load this skill.
Generate and enforce policy gates for AI coding agents (Copilot, Claude Code) — real-time session hooks that deny protected-path edits and dangerous commands, plus a merge-time backstop for anything that bypasses them. Use when asked to "govern AI agents", "block AI from
name: ai-governance description: Generate and enforce policy gates for AI coding agents (Copilot, Claude Code) — real-time session hooks that deny protected-path edits and dangerous commands, plus a merge-time backstop for anything that bypasses them. Use when asked to "govern AI agents", "block AI from touching secrets", "add an AI policy gate", or "why did the AI agent hook not fire". argument-hint: "[generate|check|audit|explain] [path]" title: "AI Governance Command" sidebar_label: "ai-governance" custom_edit_url: null
Generate and enforce a policy gate for AI coding agents operating on this repo: real-time session hooks for Copilot and Claude Code, plus a merge-time GitHub Actions check that catches anything the hooks miss.
Read `references/ai-governance.md` before responding.
---
When invoked with no arguments, ask before proceeding:
**Q1 — Mode?**
What do you need? 1. generate — scaffold policy, evaluator, hooks, and merge-time check 2. check — dry-run the evaluator against a path, command, or diff 3. audit — scan repos in an org for policy presence, tier, and drift 4. explain — plain-English translation of an existing .ai-governance.yaml Enter 1-4 or mode name:
**Q2 — Context** (after mode selected, one at a time):
Then proceed into the relevant mode below.
---
Scaffold the policy file, evaluator, session hooks, and merge-time check for this repo.
Steps:
1. Detect which AI tools are configured (`.github/copilot/`, `.claude/`, `.cursor/`, `.codex/` if present) and which CI system is in use — reuse the scan approach `setup-agents.md` already implements; do not reimplement it.
2. Write `.ai-governance.yaml` with the chosen default pack. All packs share this shape; only `protected_paths` differs:
**generic:**
version: 1
source: local
enforcement: audit
protected_paths:
- ".github/workflows/**"
- ".github/hooks/**"
- ".claude/settings.json"
- ".ai-governance.yaml"
- ".ai-governance/**"
- "**/secrets/**"
denied_commands:
- "rm -rf"
- "git push --force"
max_diff_files: 25
require_disclosure: true**terraform** (adds): `"**/*.tfstate"`, `"iam/**"` to `protected_paths`; adds `"terraform apply"` to `denied_commands`.
**kubernetes** (adds): `"**/rbac/**"`, `"**/*secret*.yaml"` to `protected_paths`; adds `"kubectl delete"` to `denied_commands`.
**blank**: same shape, empty `protected_paths`/`denied_commands` — for a team that wants to author its own list from the CODEOWNERS-mandatory paths onward.
3. Copy `examples/ai-governance/evaluate.sh` into `.ai-governance/evaluate.sh` in the target repo, executable bit set (`chmod +x`).
4. Check for `yq` (`command -v yq`); if absent, install it using the OS-detected path (same pattern `checkov.md` uses for its own bootstrap). Pin the version and verify the checksum — `releases/latest` is a moving target, and this binary parses the file that decides what the agent may touch:
YQ_VERSION=v4.53.6
YQ_SHA256=c5f056448f973ae7d39b5401949648a78f2dc1947d6a8eb65be60d5c504b9385 # yq_linux_amd64
case "$(uname -s)" in
Darwin) brew install yq ;; # Homebrew verifies its own bottle checksum
Linux)
curl -fsSL -o /tmp/yq \
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
echo "${YQ_SHA256} /tmp/yq" | sha256sum -c -
sudo install -m 0755 /tmp/yq /usr/local/bin/yq
;;
esac5. Write `.github/hooks/preToolUse.json`:
{
"version": 1,
"hooks": {
"preToolUse": [
{"type": "command", "bash": ".ai-governance/evaluate.sh --mode=hook --platform=copilot --event=preToolUse", "timeoutSec": 10}
]
}
}And `.github/hooks/postToolUse.json` (same shape, `--event=postToolUse`). This one is not a second gate. `--event=postToolUse` short-circuits before the policy is even loaded: it appends one `completed` line to the audit log, emits no decision, and exits 0. It never re-evaluates `protected_paths` or `denied_commands` — the call has already run by then, and re-deciding would duplicate the audit line `preToolUse` already wrote for the same call under `audit` or `warn`:
{
"version": 1,
"hooks": {
"postToolUse": [
{"type": "command", "bash": ".ai-governance/evaluate.sh --mode=hook --platform=copilot --event=postToolUse", "timeoutSec": 10}
]
}
}**On Claude Code, prefer the plugin:** with `platform-guardrails@platform-skills` enabled, the `PreToolUse`/`PostToolUse` gate already ships from the plugin and switches on in any project that commits `.ai-governance.yaml`. Skip the settings merge below in that case (a second wiring would evaluate every call twice), and keep only the policy file and `.ai-governance/` assets in the repository.
6. **Merge, never overwrite** `.claude/settings.json`.
Claude Code's `settings.json` hook registration is **three levels deep**, not two: each event key holds an array of *matcher-group* objects, and each matcher group holds its own inner `hooks` array of handler objects. `matcher` is optional — omitting it means "match every tool call", which is what this policy wants (every call gets evaluated, not just one tool):
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{"type": "command", "command": ".ai-governance/evaluate.sh --mode=hook --platform=claude --event=PreToolUse"}
]
}
]
}
}A production-grade field handbook for platform, DevOps, SRE, and cloud engineers covering Kubernetes, Flux CD, Terraform, GitHub Actions, AWS, OPA/Rego, KEDA, Karpenter, supply chain security, Falco, observability, and more.
Repo: nitinjain999/platform-skills
Generate, convert, and maintain animated GitHub-safe Markdown documents with animated SVG…
AWS profile management for MCP servers — discover profiles across SSO, Granted, and…
Structured guidance for AWS CloudFront distributions, WAF web ACLs, Lambda@Edge, CloudFront…
Azure identity (Workload Identity, OIDC, Entra ID), resource tagging, AKS platform patterns,…
Back up and restore Kubernetes workloads with Velero, and prove recovery works. Covers Velero…
Design, run, and debug Chaos Engineering experiments on Kubernetes using Litmus Chaos v3 and…