Claude Code Guardrails is a protective system for Claude Code that prevents accidental code loss. It uses branch protection, automatic checkpointing, and safe commit squashing. Benefits developers and operations teams by ensuring code integrity during development.
git clone https://github.com/wangbooth/Claude-Code-Guardrails.gitClaude Code Guardrails is a smart guardrail system that prevents accidental code loss during Claude Code development. It uses three core mechanisms: protected branch interception (blocks writes to main branch), file-level snapshot commits (captures only changed files), and smart commit merging (organizes multiple checkpoints into clean task commits). The system also detects uncommitted manual changes and backs up critical files like .gitignore before modifications. Developers and operations teams benefit from automatic version tracking, clean Git history, and rollback capabilities without manual intervention.
Install via one-click bash script: `curl -fsSL https://raw.githubusercontent.com/wangbooth/claude-code-guardrails/main/install.sh | bash` for project-level or add `--global` flag for global installation. Alternatively, manually copy the `.claude/` directory to your project. Git must be initialized with configured user.name/email, and jq must be installed.
Prevent direct modifications to main branch during AI-assisted coding
Protect uncommitted manual changes from being overwritten by Claude Code
Maintain precise version history with file-level snapshot commits
Automatically backup configuration files before Claude Code modifications
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/wangbooth/Claude-Code-GuardrailsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Act as Claude Code Guardrails. I'm working on a project for [COMPANY] in the [INDUSTRY] sector. I need to implement the following code changes: [CODE_CHANGES]. Ensure these changes are protected with branch protection, automatic checkpointing, and safe commit squashing. Provide a step-by-step guide to implement these changes safely.
# Code Guardrails Implementation Guide ## Branch Protection - Create a new branch named `feature/[FEATURE_NAME]` - Set branch protection rules to require at least 2 approvals before merging - Enable 'Require branches to be up to date before merging' ## Automatic Checkpointing - Implement checkpointing every 30 minutes using the following script: ```bash #!/bin/bash # Checkpoint script git add . git commit -m "Automatic checkpoint: $(date)" git push origin HEAD ``` ## Safe Commit Squashing - Use the following command to squash commits before final merge: ```bash git rebase -i --autosquash origin/main ``` - Ensure all tests pass before squashing commits ## Final Merge - Create a Pull Request (PR) from `feature/[FEATURE_NAME]` to `main` - Wait for at least 2 approvals - Merge the PR once all checks pass
Automate your browser workflows effortlessly
AI assistant built for thoughtful, nuanced conversation
Agents that listen, think and act for you.
Get more done every day with Microsoft Teams – powered by AI
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan