Stop Claude Code, Cursor, Windsurf, and autonomous coding agents from leaking .env secrets, SSH keys, or running destructive shell commands.
Zero runtime dependencies. 100% local & air-gapped by default. <20 µs P99 redaction across 10,000-call benchmarks (149k+ ops/sec).
npx @ritualdev-lab/agentshield demo $ npx @ritualdev-lab/agentshield exec "cat .env && printenv" [AgentShield] BLOCKED: Direct credential file read & environment dump (.env / printenv) $ node print-config.js | npx @ritualdev-lab/agentshield stream {"db":"[AGENT_SHIELD:DATABASE_URL:9f3a12]","token":"[AGENT_SHIELD:GITHUB_TOKEN:4c8e19]"}
Recorded with Charm VHS from assets/demo.tape.
Autonomous coding agents have direct access to your shell, filesystem, and git repo. Even well-behaved agents routinely run cat .env, printenv, node -e 'console.log(process.env)', or commit live test keys into PRs—leaking raw credentials into third-party model APIs and git history.
AgentShield intercepts commands and stdout/stderr before credentials leave your machine:
Think you can bypass our .env / /proc/self/environ blocker or split a secret across stream chunks without triggering redaction?
npx @ritualdev-lab/agentshield bounty-verify "your-payload-here" If you find a bypass, open an issue with your repro—every confirmed bypass gets a regression test and credit in the repo. Check THREAT_MODEL.md for exact scope and honest OS isolation limits.
Quick Start · Full Guide · Threat Model · Examples (Claude Code, LangGraph, E2B/Daytona) · GitHub Action
# 1. Diagnose your OS sandbox (Seatbelt / bwrap / Landlock / AppContainer) npx @ritualdev-lab/agentshield doctor # 2. Install a git pre-commit secret leak gate npx @ritualdev-lab/agentshield hook install # 3. Generate Claude Code PreToolUse or Cursor hooks npx @ritualdev-lab/agentshield init-claude npx @ritualdev-lab/agentshield init-cursor # 4. Wrap any agent shell command safely npx @ritualdev-lab/agentshield exec "cat .env" 🚀 Key Defense Layers 🛡️ 1. Autonomous Agent Shell Sandbox & OS Isolation Boundary Intercept and sandbox agent terminal execution. If an agent tries to read .env, dump shell variables (printenv), or send keys to outbound endpoints, AgentShield blocks it on the fly:
npx @ritualdev-lab/agentshield exec "cat .env" # 🚨 [AgentShield Sandbox Block] Blocked attempt to read raw .env or private credential file. # Protected credentials from entering agent LLM context window! OS Isolation Guarantees & Defense-in-Depth Boundary Important
Defense-in-Depth vs OS Security Boundary: Userland command inspection (AST parsing and regex heuristics) is defense-in-depth designed to prevent accidental exfiltration and common script bypasses. It is not an OS kernel security boundary. Arbitrary compiled binaries or direct kernel syscalls require true OS-level containerization.
By default, requesting kernel sandboxing on non-macOS hosts logs an isolation warning and runs under the defense-in-depth AST firewall. To fail-closed and refuse execution whenever OS-level kernel isolation cannot be guaranteed:
# Refuse execution if the host cannot enforce true OS kernel isolation npx @ritualdev-lab/agentshield exec "npm test" --require-isolation # 🛑 [AgentShield Isolation Refusal] Execution refused: requireIsolation is enabled, but OS-level kernel isolation is unavailable on host (win32). Refusing to silently downgrade to process-level firewall. In the TypeScript SDK:
# Install once in your repo (native git hook) npx @ritualdev-lab/agentshield hook git-install # Or manually audit staged files npx @ritualdev-lab/agentshield hook check Or using the standard pre-commit framework (.pre-commit-config.yaml):
repos: - repo: https://github.com/RitualDev-Lab/AgentShield rev: v0.1.1 hooks: - id: agentshield - id: agentshield-audit 🐙 3. CI/CD Security Gate & GitHub Action Block pull requests that introduce exposed credentials into your codebase:
name: AgentShield Security Gate on: [pull_request, push] jobs: secret-audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: RitualDev-Lab/AgentShield@v1 with: fail_on_leak: "true" Or run via CLI in any CI container:
npx @ritualdev-lab/agentshield ci --base origin/main --report security-report.md 📋 4. Scope-Honest Secret-Control Assessment Assess files and workspace streams against technical secret-handling controls in standard frameworks (SOC 2, PCI-DSS, HIPAA, ISO 27001):
npx @ritualdev-lab/agentshield compliance .env 📋 [SECRET-CONTROL ASSESSMENT] Status: NO_FINDINGS_IN_ASSESSED_CONTROLS (Assessed Controls Score: 100%) ℹ️ Scope: Technical secret detection, real-time streaming token redaction, and CLI command firewall. ⚠️ Disclaimer: Notice: This report reflects only the results of automated secret detection across assessed technical controls ('NO_FINDINGS_IN_ASSESSED_CONTROLS'). It does NOT establish overall organizational SOC 2, HIPAA, PCI-DSS, or ISO 27001 compliance. Overall compliance requires an accredited third-party audit firm, administrative governance, physical safeguards, and operational policies. Assessed Controls: ✅ [SOC2] CC6.1: Logical Access Controls & Credential Integrity ✅ [SOC2] CC6.6: Boundary Protection & Unauthorized Egress Controls ✅ [PCI_DSS] Req-3.4: Protection of Authentication & Payment Gateway Secrets ✅ [PCI_DSS] Req-8.3: Strong Authentication Credential Management ✅ [HIPAA] §164.312(a)(1): Technical Safeguards - Access Control & Authentication ✅ [ISO27001] A.8.28: Secure Coding & Secret Management ✅ [ISO27001] A.8.24: Use of Cryptography & Key Protection Broader Controls (Not Assessed by Secret Scanning): ⏸️ [SOC2] CC1.1: Integrity & Ethical Values (Governance) (NOT ASSESSED) ⏸️ [SOC2] CC5.2: Risk Assessment & Vendor Management (NOT ASSESSED) ⏸️ [PCI_DSS] Req-9.1: Physical Access Restrictions (NOT ASSESSED) ⏸️ [HIPAA] §164.308(a)(1): Administrative Safeguards (NOT ASSESSED) ⏸️ [ISO27001] A.5.1: Policies for Information Security (NOT ASSESSED) 🔐 5. Zero-Trust In-Memory Surrogate Injection Instead of cleartext .env keys, AgentShield provides deterministic, collision-resistant surrogate tokens ([AGENT_SHIELD:ID:hexHash]). Agents can safely manipulate configurations and inspect outputs without ever seeing the plaintext secret in prompt history, rehydrating values locally when required.
AgentShield provides 1-command generators for leading AI coding agent environments:
Automatically intercept agent terminal executions before commands touch your environment:
npx @ritualdev-lab/agentshield init-claude Generates .claude/settings.json configured with:
{ "hooks": { "PreToolUse": [ { "matcher": "Bash|Terminal", "command": "npx @ritualdev-lab/agentshield exec --claude-hook" } ] } } Note: Claude Code delivers tool call payloads via stdin JSON. AgentShield inspects the payload in real-time and cleanly returns exit code 2 to halt unauthorized commands before execution.
Plug SKILL.md into workspace agent instructions to enforce zero-leak guarantees natively.
Traditional scanners (gitleaks, trufflehog) were designed for post-facto static git repository scanning (scanning files and commit histories at rest).
AgentShield is designed specifically for Autonomous Agent Runtime Protection — intercepting shell commands, scrubbing streaming stdio chunk-by-chunk in sub-milliseconds, and sanitizing LLM prompt inputs before transmission.
AgentShield combines high-performance regular expressions with Shannon Entropy to catch both structured keys and arbitrary high-entropy passwords:
AgentShield provides first-class, idiomatic SDKs across multiple languages:
Works in pure-Python without requiring Node.js, with built-in LangChain/LangGraph callbacks:
npx @ritualdev-lab/agentshield sidecar {"jsonrpc": "2.0", "id": 1, "method": "shield.scanAndRedact", "params": {"text": "My API key is sk-proj-placeholder"}} Response:
{"jsonrpc":"2.0","id":1,"result":{"hasSecrets":true,"sanitizedText":"My API key is [AGENT_SHIELD:AI:...]","findings":[...]}} 🧩 Programmatic TypeScript SDK Integrate AgentShield directly into your AI workflows, proxy servers, or custom agent frameworks:
AgentShield is 100% open-source and Apache-2.0 licensed. Your sponsorship directly funds multi-platform OS sandbox testing rigs (Linux Landlock, macOS Seatbelt, Windows AppContainer), automated security regression suites, and cloud runner hours.
⚡ 1-Click Dodo Payments Checkout • 🎁 Interactive Donation Form (USD & INR UPI) • ❤️ GitHub Sponsors
🔒 Zero physical shipping required. Powered by Dodo Payments (Merchant of Record) with instant tax invoice and global payment methods (Cards, UPI, Apple Pay).
Huge thanks to all our open-source Contributors!




