Skip to main content

Overview

AgentShield is a security auditor for Claude Code configurations. Built at the Claude Code Hackathon (Cerebral Valley x Anthropic, Feb 2026), it scans for vulnerabilities, misconfigurations, and injection risks. Stats: 1,282 tests | 98% coverage | 102 static analysis rules

Quick Start

What It Scans

AgentShield analyzes your Claude Code setup across 5 categories:

1. Secrets Detection (14 patterns)

  • API keys (OpenAI, Anthropic, AWS, etc.)
  • GitHub tokens (ghp_, gho_, ghs_, etc.)
  • Database credentials
  • Private keys and certificates
  • OAuth tokens

2. Permission Auditing

  • Tool access boundaries
  • File system permissions
  • Command execution limits
  • Network access restrictions

3. Hook Injection Analysis

  • Command injection vulnerabilities
  • Path traversal risks
  • Shell escape issues
  • Unsafe eval/exec patterns

4. MCP Server Risk Profiling

  • Excessive permissions
  • Unvalidated MCP configurations
  • Deprecated or insecure MCP servers
  • Missing authentication

5. Agent Config Review

  • Overly permissive agent definitions
  • Missing security constraints
  • Unsafe tool combinations
  • Model selection vulnerabilities

Files Scanned

  • CLAUDE.md — Project-level configuration
  • ~/.claude/settings.json — User settings
  • ~/.claude.json — MCP server configurations
  • hooks/hooks.json — Hook definitions
  • agents/*.md — Agent definitions
  • skills/*.md — Skill files

The --opus Flag

Runs three Claude Opus 4.6 agents in a red-team/blue-team/auditor pipeline:
  1. Attacker Agent — Finds exploit chains and injection vectors
  2. Defender Agent — Evaluates existing protections and mitigations
  3. Auditor Agent — Synthesizes both into a prioritized risk assessment
Adversarial reasoning, not just pattern matching.
This provides:
  • Attack surface analysis
  • Exploit chain mapping
  • Defense effectiveness scoring
  • Prioritized remediation steps

Output Formats

Terminal (Default)

Color-graded report with severity scores:

JSON (CI Pipelines)

Machine-readable output for automated processing.

Markdown (Reports)

HTML (Web Dashboard)

Exit Codes

  • 0 — No issues found
  • 1 — Low/medium issues found
  • 2 — Critical/high issues found (fails CI builds)
Use in CI/CD:

Using in Claude Code

Run directly from Claude Code via the /security-scan command:
This:
  1. Runs AgentShield on current project
  2. Reports findings in chat
  3. Offers auto-fix for safe issues

Configuration

Create .agentshield.json to customize scans:

Auto-Fix

AgentShield can automatically fix safe issues:
Safe fixes:
  • Add .gitignore entries for config files with secrets
  • Remove debug hooks in production configs
  • Update deprecated MCP server URLs
  • Fix path traversal vulnerabilities in hooks
Manual fixes required:
  • Hardcoded secrets (requires you to choose secret manager)
  • Overly permissive agents (requires context about intent)
  • Complex injection chains

GitHub Action

Run AgentShield in CI:
See github.com/affaan-m/agentshield for the official GitHub Action.

Common Issues Found

Hardcoded Secrets

Fix: Use environment variables

Unsafe Hook Commands

Fix: Validate and sanitize inputs

Overly Permissive MCPs

Fix: Restrict to project directory