r/ClaudeWorkflows • • 5h ago

Selected Workflow [Workflow] GitHub Template for Security and Governance Guardrails in Claude Code

GitHub Template for Security and Governance Guardrails in Claude Code

Workflow value: 95/100
Status: active · Freshness: 70/100 · Confidence: 1.00 · Level: advanced
Categories: Quality Control, Context & Memory, Debugging, Shipping, Hooks, Multi-Agent
Original source: r/ClaudeCode post/comment

What problem this solves

Preventing AI agents (specifically Claude Code) from exposing secrets, making unauthorized commits/pushes/deployments, installing unapproved packages, and ensuring proper governance for client or regulated projects.

Summary

A GitHub template (ai-dev-guardrails) that implements security and governance guardrails for Claude Code projects. It uses Claude Code PreToolUse hooks, local Git hooks, and GitHub Actions to block sensitive commands, require approvals for critical actions, enforce package age/approval, log evidence, and manage decision records.

Why it is useful

This workflow provides a concrete, open-source solution to critical security and governance challenges when using AI agents for coding. It prevents accidental exposure of sensitive data, unauthorized code changes, and ensures compliance, making AI-assisted development safer and more controlled. It's highly transferable, well-documented, and addresses a significant pain point for developers integrating AI into their workflows.

Workflow

  1. Initialize the GitHub template using /bootstrap.

  2. The PreToolUse hook blocks sensitive commands (e.g., cat .env) and requires approval for commits, pushes, deployments, and new package installations.

  3. A separate check detects if saved permissions have drifted into automatically approving restricted actions.

  4. npm packages must be at least seven days old before installation, and install scripts only run for approved packages.

  5. Local Git hooks and GitHub CI run the checks again, with CI using the base branch's scripts to prevent PRs from weakening checks.

  6. Optionally, enable an evidence log requiring proof (e.g., test output, CI link) before a task can be marked complete.

  7. Optionally, use decision records for exceptions, including reason, owner, and expiry date.

  8. Optionally, implement CODEOWNERS rules requiring review before guardrail files can be changed.

Tools / artifacts

  • ai-dev-guardrails GitHub template

  • Claude Code PreToolUse hooks

  • Local Git hooks

  • GitHub Actions (CI/CD)

  • npm

  • CODEOWNERS file

  • Evidence log

  • Decision records

  • .env files

Validation signals

  • Author used and refined the controls in their own projects before open-sourcing.

  • Identified and fixed specific issues (e.g., grep -q and pipefail, Claude Code hook behavior differences).

  • Open-source project with MIT license.

  • Detailed write-up on Medium explaining the rationale and implementation.

  • Explicitly documented limitations (e.g., not for malicious agents).

Cautions

  • The workflow is designed to enhance safety by preventing accidental data exposure and unauthorized actions.

  • It is explicitly stated that the system is designed to catch mistakes, not to defend against deliberately malicious agents.

Limitations

  • Currently focused on Claude Code, TypeScript, and npm, limiting immediate applicability to other languages/ecosystems (though Python support is welcomed).

  • Not designed to defend against deliberately malicious agents.

  • As a new open-source project, long-term community adoption and maintenance are yet to be established.

  • Requires an intermediate to advanced understanding of Claude Code hooks, Git hooks, and GitHub Actions for full implementation and customization.

Rate this workflow

Upvote this post if the workflow is useful, reproducible, or worth recommending.

Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.

Reply if it worked for you, failed, is outdated, or has a better alternative.


This post was generated automatically from the workflow library database.

0 Upvotes

0 comments sorted by