The bulletproof safety harness for autonomous AI coding agents.
Never let your AI coding agent leak API keys, stage .env files, or execute destructive commands.
When running autonomous AI agents (like Claude Code, Cursor Composer in YOLO mode, Cline, or Aider), you give models permission to execute bash commands and git workflows.
Every developer has faced (or fears) an agent that:
- ❌ Runs
git add .and accidentally commits your.envor.pemkeys. - ❌ Commits raw conversation transcripts (
.claude/,.cursor/) containing sensitive tokens. - ❌ Executes destructive terminal commands (
rm -rf,DROP TABLE,git push --force). - ❌ Exposes private developer emails in git author commits.
Traditional static linters run too late. AgentShield acts as a real-time command proxy and pre-commit gate tailored specifically for autonomous agent lifecycles.
pip install -e .Run inside any project directory:
agentshield initThis automatically installs the Git Pre-Commit and Pre-Push security hooks and creates a customizable shield.config.json.
agentshield doctor| Feature | Gitleaks / TruffleHog | GitHub Push Protection | AgentShield 🛡️ |
|---|---|---|---|
| Agent Tool Call Interception | ❌ No | ❌ No | ✅ Yes (Blocks destructive bash) |
Agent Artifacts Protection (.claude, .cursor) |
❌ No | ❌ No | ✅ Yes (Auto-intercepted) |
| 2-Step Confirmation Gate | ❌ No | ❌ No | ✅ Yes (Interactive verify) |
| Git Author Anonymization | ❌ No | ❌ No | ✅ Yes (Noreply enforcement) |
| Zero-Dependency Core | ❌ Cloud-only | ✅ Pure Python / Zero-bloat |
AgentShield inspects git diff --cached and blocks:
- Private Keys (
RSA,EC,OPENSSH) - Cloud API Credentials (AWS
AKIA..., Google Cloud, GitHub PATsghp_..., Slack, JWTs) - Unintended Personal Identifiers (customizable via
shield.config.json) - Automatically exempts verified GitHub noreply addresses (
*@users.noreply.github.com).
Intercepts agent bash calls before they touch your terminal:
# Example agent command evaluated before execution
agentshield check-cmd "rm -rf /"
# 🚫 [BLOCKED] AgentShield intercepted high-risk command:
# Rule: recursive_root_deletion | Risk: CRITICALWhen potential security items or forced overrides are requested, AgentShield enforces a deterministic two-phase gate:
- Inspection Step: Displays masked samples and requires file confirmation.
- Authorization Step: Requires affirmative confirmation phrase before any push.
{
"version": "1.0.0",
"security": {
"block_on_secrets": true,
"block_on_pii": true,
"confirmation_steps": 2,
"exempt_noreply_emails": true
},
"protected_patterns": {
"files": [".env*", "*.pem", "*.key", "id_rsa*", "secrets.*"],
"agent_artifacts": [".claude/*", ".cursor/*", ".gemini/*"],
"destructive_commands": ["rm\\s+-rf\\s+[/~]", "git\\s+push\\s+.*--force"]
},
"custom_pii_patterns": [],
"user_settings": {
"user_alias": "Developer"
}
}Run comprehensive unit tests:
python -m unittest discover -s testsContributions, rules, and ecosystem adapters are welcome! Licensed under the MIT License.