DevSafe / Docs
Docs AI Safety devsafe shield

devsafe shield

One command to protect your secrets from AI coding tools. Scans for exposures, installs git hooks, writes deny rules for Cursor, Copilot, and Windsurf, and hardens MCP configs. Free, no account needed.

Usage

terminal
$ devsafe shield [on|off|scan] [--mcp]

Shield has three modes. Run scan to see what is exposed. Run on to fix everything. Run off to reverse the changes.

shield scan

Scans your project for secret exposures without changing anything. This is a read-only operation. It checks for .env files that are not gitignored, AI tool configs that could read your secrets, and git history that already contains leaked keys.

terminal
$ devsafe shield scan

Scanning ~/projects/api-server...

! .env is NOT in .gitignore
! .env.local is NOT in .gitignore
! No AGENTS.md deny rules found
! No .cursor/rules deny rules found
! No pre-commit hook blocking secrets
 .github/copilot-instructions.md has deny rules
 No secrets found in git history

Result: 4 exposures found
Run devsafe shield on to fix all of them.

The scan checks five things:

shield on

Enables secret interception across your project. This is the "fix everything" button. After running devsafe diagnose to see what is wrong, run shield on to fix it.

terminal
$ devsafe shield on

Protecting ~/projects/api-server...

 Added .env, .env.local, .env.production to .gitignore
 Created AGENTS.md with deny rules
 Created .cursor/rules/no-secrets.mdc
 Created .github/copilot-instructions.md with deny rules
 Installed pre-commit hook (.git/hooks/pre-commit)
 Wrote Windsurf deny rules to .windsurfrules

Shield is ON. 6 protections applied.
Your secrets are now blocked from AI tools and git commits.

What shield on does

Each protection targets a specific attack vector. Here is exactly what gets written:

MCP hardening

Add the --mcp flag to also harden MCP (Model Context Protocol) server configurations. MCP configs often contain plaintext API keys passed as environment variables or command arguments.

terminal
$ devsafe shield on --mcp

Protecting ~/projects/api-server...

 Added .env, .env.local, .env.production to .gitignore
 Created AGENTS.md with deny rules
 Created .cursor/rules/no-secrets.mdc
 Created .github/copilot-instructions.md with deny rules
 Installed pre-commit hook (.git/hooks/pre-commit)
 Wrote Windsurf deny rules to .windsurfrules
 Hardened 3 MCP configs (moved secrets to env refs)

Shield is ON. 7 protections applied.

With --mcp, shield finds MCP config files (like claude_desktop_config.json or .cursor/mcp.json), identifies plaintext secrets in them, and replaces the values with environment variable references. The original secrets are not deleted. They are moved to your .env file so the MCP servers still work, but the config files no longer contain raw keys.

shield off

Disables secret interception. Removes the pre-commit hook and the deny rule files that shield created. Your .gitignore entries are left in place (removing those would re-expose your secrets).

terminal
$ devsafe shield off

Removing protections from ~/projects/api-server...

 Removed pre-commit hook
 Removed AGENTS.md deny rules
 Removed .cursor/rules/no-secrets.mdc
 Removed .github/copilot-instructions.md deny rules
 Removed .windsurfrules

Shield is OFF. .gitignore entries preserved.
Turning shield off re-exposes your project.

With shield off, AI tools can read your .env files again, and the pre-commit hook no longer blocks secret commits. Only turn shield off if you have a specific reason, and turn it back on when you are done.

Flags

Typical workflow

Shield is designed to run right after devsafe diagnose. The typical flow looks like this:

terminal
# Step 1: See what's exposed
$ devsafe diagnose

# Step 2: Fix everything
$ devsafe shield on --mcp

# Step 3: Verify the fix
$ devsafe shield scan
 0 exposures found. Your project is protected.
Free tool, no account required.

devsafe shield works without signing up or logging in. Install the CLI, run the command, and your project is protected. No data leaves your machine.

Files created

For reference, here is every file that shield on may create or modify: