@@ -11,22 +11,104 @@ Built at the [Claude Code Hackathon](https://cerebralvalley.ai/e/claude-code-hac
1111## Quick Start
1212
1313``` bash
14- # Install
15- npm install -g agentshield
14+ # Scan your Claude Code config (no install required)
15+ npx agentshield scan
1616
17- # Scan your Claude Code config
17+ # Or install globally
18+ npm install -g agentshield
1819agentshield scan
1920
2021# Scan a specific directory
2122agentshield scan --path /path/to/.claude
2223
23- # Output as JSON
24- agentshield scan --format json
25-
2624# Auto-fix safe issues
2725agentshield scan --fix
26+
27+ # Generate an HTML security report
28+ agentshield scan --format html > report.html
29+
30+ # Run Opus 4.6 adversarial analysis with real-time streaming
31+ agentshield scan --opus --stream
32+
33+ # Generate a secure baseline config
34+ agentshield init
35+ ```
36+
37+ ## Features
38+
39+ ### Static Analysis (` agentshield scan ` )
40+
41+ Rule-based scanning with 16 rules across 5 categories, graded A-F with a 0-100 numeric score.
42+
43+ ### Auto-Fix Engine (` --fix ` )
44+
45+ Automatically applies safe fixes for detected issues:
46+ - Replaces hardcoded secrets with ` ${ENV_VAR} ` references
47+ - Tightens wildcard permissions (` Bash(*) ` β scoped ` Bash(git *) ` , ` Bash(npm *) ` )
48+ - Generic string-replacement transforms for other fixable patterns
49+
50+ Only ` auto: true ` fixes are applied. Files are never overwritten without a matching pattern.
51+
52+ ### Secure Init (` agentshield init ` )
53+
54+ Generates a hardened ` .claude/ ` directory with:
55+ - ** settings.json** β scoped permissions (no ` Bash(*) ` ) and safety hooks
56+ - ** CLAUDE.md** β security best practices for the AI agent
57+ - ** mcp.json** β empty MCP config placeholder
58+
59+ Existing files are never overwritten.
60+
61+ ### Opus 4.6 Deep Analysis (` --opus ` )
62+
63+ Three-agent adversarial pipeline powered by Claude Opus 4.6:
64+
65+ 1 . ** Red Team (Attacker)** β finds exploitable attack vectors
66+ 2 . ** Blue Team (Defender)** β recommends concrete hardening measures
67+ 3 . ** Auditor** β synthesizes both perspectives into a final risk assessment
68+
69+ ``` bash
70+ # Run with Opus analysis
71+ agentshield scan --opus
72+
73+ # Stream Opus analysis in real-time
74+ agentshield scan --opus --stream
2875```
2976
77+ Requires ` ANTHROPIC_API_KEY ` environment variable.
78+
79+ ### GitHub Action
80+
81+ Add AgentShield to your CI pipeline:
82+
83+ ``` yaml
84+ - name : AgentShield Security Scan
85+ uses : affaan-m/agentshield@main
86+ with :
87+ path : " ."
88+ min-severity : " medium"
89+ fail-on-findings : " true"
90+ ` ` `
91+
92+ **Inputs:**
93+
94+ | Input | Default | Description |
95+ |-------|---------|-------------|
96+ | ` path` | `.` | Path to scan |
97+ | `min-severity` | `medium` | Minimum severity : critical, high, medium, low, info |
98+ | `fail-on-findings` | `true` | Fail the action if findings are detected |
99+ | `format` | `terminal` | Output format |
100+
101+ **Outputs:**
102+
103+ | Output | Description |
104+ |--------|-------------|
105+ | `score` | Numeric security score (0-100) |
106+ | `grade` | Letter grade (A-F) |
107+ | `total-findings` | Total number of findings |
108+ | `critical-count` | Number of critical findings |
109+
110+ The action writes a markdown job summary and emits GitHub annotations (warnings/errors) inline on affected files.
111+
30112# # What It Catches
31113
32114# ## Secrets Detection
@@ -85,37 +167,54 @@ agentshield scan --fix
85167| Terminal | `--format terminal` (default) | Interactive use, demos |
86168| JSON | `--format json` | CI pipelines, programmatic use |
87169| Markdown | `--format markdown` | Documentation, PRs |
170+ | HTML | `--format html` | Self-contained dark-themed report |
88171
89- ## CI Integration
172+ ## CLI Reference
90173
91- AgentShield exits with code 2 when critical findings are detected, making it easy to integrate into CI pipelines:
92-
93- ``` yaml
94- - name : Security audit
95- run : npx agentshield scan --min-severity high
174+ ```
175+ agentshield scan [ options] Scan a configuration directory
176+ -p, --path <path > Path to scan (default: ~ /.claude or cwd)
177+ -f, --format <format > Output: terminal, json, markdown, html
178+ --fix Auto-apply safe fixes
179+ --opus Enable Opus 4.6 multi-agent analysis
180+ --stream Stream Opus analysis in real-time
181+ --min-severity <severity > Filter: critical, high, medium, low, info
182+ -v, --verbose Show detailed output
183+
184+ agentshield init [ options] Generate secure baseline config
96185```
97186
98187## Architecture
99188
100189```
101190src/
102191βββ index.ts CLI entry point (commander)
103- βββ types.ts Type system (Finding, Rule, Report, Score)
192+ βββ action.ts GitHub Action entry point
193+ βββ types.ts Type system + Zod schemas
104194βββ scanner/
105195β βββ discovery.ts Config file discovery
106- β βββ index.ts Main scan orchestrator
196+ β βββ index.ts Scan orchestrator
107197βββ rules/
108198β βββ index.ts Rule registry
109199β βββ secrets.ts Secret detection (11 patterns)
110- β βββ mcp.ts MCP server security (4 rules)
111200β βββ permissions.ts Permission audit (3 rules)
112- β βββ agents.ts Agent config review
113- β βββ hooks.ts Hook security analysis
114- βββ reporter/
115- βββ index.ts Report orchestrator
116- βββ terminal.ts Color terminal output
117- βββ json.ts JSON + Markdown output
118- βββ score.ts Security scoring (A-F grades)
201+ β βββ mcp.ts MCP server security (4 rules)
202+ β βββ hooks.ts Hook security analysis
203+ β βββ agents.ts Agent config review
204+ βββ reporter/
205+ β βββ score.ts Scoring engine (A-F grades)
206+ β βββ terminal.ts Color terminal output
207+ β βββ json.ts JSON + Markdown output
208+ β βββ html.ts Self-contained HTML report
209+ βββ fixer/
210+ β βββ transforms.ts Fix transforms (secret, permission, generic)
211+ β βββ index.ts Fix engine orchestrator
212+ βββ init/
213+ β βββ index.ts Secure config generator
214+ βββ opus/
215+ βββ prompts.ts Attacker/Defender/Auditor system prompts
216+ βββ pipeline.ts Three-agent Opus 4.6 pipeline
217+ βββ render.ts Opus analysis rendering
119218```
120219
121220## Security Rules
@@ -137,15 +236,18 @@ npm install
137236# Development mode
138237npm run dev scan --path examples/vulnerable
139238
239+ # Run tests (202 tests)
240+ npm test
241+
242+ # Run tests with coverage
243+ npm run test:coverage
244+
140245# Type check
141246npm run typecheck
142247
143248# Build
144249npm run build
145250
146- # Run tests
147- npm test
148-
149251# Demo scan (vulnerable examples)
150252npm run scan:demo
151253```
0 commit comments