The complete guide to Claude Code setup (Opus 4.6, Sonnet 4.6, Haiku 4.5). 1M token context window. 100+ hours saved. 25 hook events. Agent teams and task management. Production-tested patterns for skills, hooks, and MCP integration.
How to detect secrets, permission gaps, and injection risks in your ~/.claude/ setup
Your Claude Code configuration is an attack surface. Skills can contain prompt injection, hooks can exfiltrate data, MCP servers can inherit secrets, and overly broad permissions let Claude run arbitrary commands. This chapter covers automated scanning to catch these issues before they become incidents.
A March 2026 scan of a mature setup (47 rules, 42 skills, 16 hooks) scored 56/100 with 14 high-severity findings — despite the maintainer being security-conscious. The most common issues:
Bash(docker *), Bash(node *), Bash(curl *) allow arbitrary executionchmod 777, ssh, or device file writesrm -f, git config --global, output suppression via >/dev/null@package/name@latest auto-updates could introduce supply chain attacksAgentShield is a free, MIT-licensed scanner with 102 rules across 5 categories. It runs via npx with zero installation.
# Scan your config (zero install)
npx ecc-agentshield scan ~/.claude/
# Save results to a log
npx ecc-agentshield scan ~/.claude/ | tee ~/.claude/logs/agentshield-$(date +%Y-%m-%d).log
# Auto-fix findings (review first!)
npx ecc-agentshield scan ~/.claude/ --fix
| Category | Rules | What It Checks |
|---|---|---|
| Secrets | 10 | API keys, tokens, hardcoded passwords, connection strings in CLAUDE.md, settings, skills |
| Permissions | 10 | Wildcard Bash(*), missing deny lists, dangerous flags like --no-verify |
| Hooks | 34 | Command injection, data exfiltration patterns, reverse shells, credential harvesting, container escape |
| MCP Servers | 23 | Supply chain risks (@latest), remote transport, auto-approve, env inheritance |
| Agent Config | 25 | Prompt injection surfaces, hidden directives, URL execution, time bombs, jailbreak patterns |
AgentShield produces an overall score (0-100) and per-category scores:
Overall Grade: D (56/100)
Secrets: 100/100 ← No hardcoded credentials found
Permissions: 13/100 ← Broad allow rules, no deny list
Hooks: 0/100 ← rm -f, git config --global, output suppression
MCP Servers: 85/100 ← One unversioned package, env inheritance
Agents: 81/100 ← Minor: missing observation hooks in commands
Priority triage:
// BEFORE (flagged as HIGH)
"Bash(docker *)"
"Bash(node *)"
"Bash(curl *)"
// AFTER (scoped)
"Bash(docker ps *)"
"Bash(docker logs *)"
"Bash(docker restart *)"
"Bash(node scripts/*)"
"Bash(curl -sf localhost:*)"
// Add to settings.json under "deny"
"deny": [
"Bash(chmod 777 *)",
"Bash(rm -rf /)",
"Bash(> /dev/*)",
"Bash(ssh *)"
]
// BEFORE (inherits ALL env vars including secrets)
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "@package/server"]
}
}
// AFTER (explicit env whitelist)
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "@package/server@1.2.3"],
"env": {
"NODE_ENV": "development"
}
}
}
// BEFORE (supply chain risk)
"args": ["-y", "@remotion/mcp@latest"]
// AFTER (pinned version)
"args": ["-y", "@remotion/mcp@4.0.293"]
| When | Action |
|---|---|
| Monthly | Full scan, triage new findings |
| After adding skills/hooks | Quick scan to catch injection patterns |
| After installing community plugins | Scan for malicious skill patterns |
| After upgrading Claude Code | Check if new features affect security posture |
The claude-code-ultimate-guide catalogues 655 known malicious skill patterns and 24 CVE-mapped vulnerabilities. Key patterns:
| Pattern | Risk | Detection |
|---|---|---|
Skills that curl to external URLs |
Data exfiltration | Grep for curl, wget, fetch in SKILL.md |
| Hidden directives in long skill text | Prompt injection | AgentShield agent-config rules detect these |
Skills requesting Bash(*) permission |
Arbitrary code execution | Check allowed-tools in all SKILL.md files |
| Hooks that pipe to external services | Credential theft | Review all hook scripts for network calls |
Add security scanning as a fifth area in your monthly stack audit:
### 5. Security Scan
- [ ] Run `npx ecc-agentshield scan ~/.claude/`
- [ ] All critical/high findings resolved
- [ ] No new MCP servers using `@latest`
- [ ] Deny list covers dangerous operations
- [ ] Hook scripts reviewed for output suppression