Zero-dependency local security auditor, drop-in AGENTS.md / CLAUDE.md rules, and doc-verified fixes for Claude Code, OpenAI Codex CLI, Cursor, and MCP servers. Every fix is verified word-for-word against official documentation or published studies.
Run directly against any repository (zero installs, exit 0 when clean, 1 when findings exist; supports --json):
curl -fsSL https://raw.githubusercontent.com/seankwon816/ai-coding-agent-tips/main/scripts/audit_agent_configs.py | python3 - .Or run from a local clone:
python3 scripts/audit_agent_configs.py .[FAIL] Audited /path/to/your-project (4 finding(s))
- [HIGH] MCP_AUTO_APPROVE_ALL_PROJECT_SERVERS (.claude/settings.local.json): .claude/settings.local.json sets enableAllProjectMcpServers=true, auto-approving every server in .mcp.json without prompting to inspect tools/list.
Fix: Set enableAllProjectMcpServers to false (or remove it) and list vetted server names explicitly under enabledMcpjsonServers.
- [HIGH] CLAUDE_LOCAL_INLINE_SECRET (.claude/settings.local.json): Found 2 inline credential pattern(s) (OpenAI/API key, Bearer/Authorization header; e.g. sk-p...abcd [REDACTED], Bear...abcd [REDACTED]).
Fix: Run /permissions in Claude Code, remove literal secret allow rules, and pass $ENV_VAR names instead.
- [HIGH] UNIGNORED_CLAUDE_LOCAL_SETTINGS (.gitignore): .claude/ exists without a .gitignore exclusion; future Option 2 rules can be committed by git add .
Fix: Add '.claude/settings.local.json' (or '.claude/') to .gitignore before staging changes.
- [MEDIUM] MCP_UNPINNED_NPX (.mcp.json): .mcp.json server 'docs' launches '@modelcontextprotocol/server-filesystem' via npx -y without a pinned @version.
Fix: Pin exact package versions (pkg@1.2.3) or isolate sessions with managed-mcp.json and --strict-mcp-config.
What the auditor checks (16 built-in rules)
- Secrets & leak hygiene: inline API keys/tokens in
.claude/settings*.jsonand.mcp.json(redacted in output), missing.claude/in.gitignore, DockerfileCOPY/ADD . .without.dockerignoreexclusions. - Sandbox & approval gates:
permissions.defaultMode: "bypassPermissions", blanketpermissions.allowwildcards (*,Bash(*),WebFetch(*),mcp__*),sandbox.filesystem.denyReadnot mirrored inpermissions.deny, missingallowUnsandboxedCommands: false, broadsandbox.excludedCommands. - MCP server safety:
enableAllProjectMcpServers: true,0.0.0.0wildcard bindings, unpinnednpx -ypackages without@version. - Hooks, context & prompt hygiene: blocking hooks using non-blocking
exit 1instead ofexit 2, out-of-rangeautoCompactWindowsettings,CLAUDE.local.mdshadowingAGENTS.mdwithout@AGENTS.md, codebase-ownership phrasing that triggers unrequested refactors.
- rules/AGENTS.minimal-diffs.md: Ready-to-paste
AGENTS.md/CLAUDE.mdrules for surgical diffs, two-phase commits,$ENV_VARcommand safety, and ignore hygiene.
| Area | Fix | What it solves |
|---|---|---|
| Claude Code / Docker | Inline API keys written by "Yes, and don't ask again" | 31,088 GitHub secrets and 613 Docker Hub leaks from .claude/settings.local.json |
| Claude Code | Mirror sandbox denyRead rules in permissions.deny and disable unsandboxed retries | sandbox.filesystem.denyRead blocks bash only, leaving built-in Read and unsandboxed retries open |
| Claude Code | Enforce hard tool and approval gates instead of relying on prompt-injection filters | Prompt-injection detectors look for adversarial instructions inside tool results, not plausible numbers |
| Any agent | Audit AI email connectors against indirect prompt injection | Hidden instructions inside emails, calendar invites, or PDFs hijack connected OAuth tools (OWASP LLM01, CVE-2026-24301) |
| Any agent | Isolate coding-agent containers with --network none, --read-only, and seccomp | Local model weights do not isolate shell commands from host files, cloud metadata (169.254.169.254), or outbound exfiltration |
| Python / Security | Audit site-packages .pth startup hooks in coding-agent Python environments | Compromised Python wheels (agent-framework 1.26.1/1.26.2) harvest keys via .pth hooks even without import |
| Area | Fix | What it solves |
|---|---|---|
| MCP | Bind local HTTP servers to 127.0.0.1 | Local MCP servers open to your whole network |
| MCP | Lock down MCP servers with headersHelper, allowlists, and strict-mcp-config | In MCPTox tests across 45 live MCP servers, hidden rules in tool descriptions reached 72.8% attack success |
| Claude Code / MCP | Audit MCP tools/list for credential exposure and avoid enableAllProjectMcpServers | Prompt-injection scans miss benign-looking MCP tools that request or touch credentials |
| MCP | Route all MCP stdio server logs to stderr so stdout carries JSON-RPC only | Any non-JSON log line printed to stdout breaks newline-delimited MCP stdio framing |
| MCP | Batch browser MCP form fills and return DOM deltas to cut replay tokens | Multi-turn browser MCP form fills replay full ARIA trees each step, reaching 72,614 cumulative tokens |
| MCP | Trim agent tool results to a 5-field allowlist to raise solve rate and cut token spend | Raw REST or MCP list JSON payloads flood context with URLs, avatars, and nested metadata |
| Area | Fix | What it solves |
|---|---|---|
| Claude Code | Run the Explore subagent on Haiku | Codebase searches running on your biggest model |
| Claude Code | Cap 1M auto-compaction earlier when long sessions drive up token spend | On 1M-window models, waiting until ~967K tokens to compact pushes two thirds of spend into the tail |
| Claude Code | Bound headless agent loops with --max-turns and --max-budget-usd | Across 27,280 coding agent runs, step count drove inference cost while starting prompt size barely mattered |
| Any agent | Separate AI project memory with a three-layer setup | Global AI memory loads into every conversation thread |
| Area | Fix | What it solves |
|---|---|---|
| Claude Code | AGENTS.md ignored when CLAUDE.local.md exists | A personal file silently turns off your shared AGENTS.md |
| Claude / AGENTS.md | Prompts claiming codebase ownership cause unrequested refactors | Ownership prompts raise unrequested code consolidation from under 10% to about 75% |
| Any agent | Surgical changes rule | 3-line fixes that come back as 300-line diffs |
| Any agent | Split coding-agent commits into prep and logic phases | Oversized agent diffs that mix renames and formatting into feature logic |
| Claude Code | .worktreeinclude and worktree.baseRef | New worktrees with no .env that start from main |
| Claude Code | Block unfinished agent edits with Stop hook exit code 2 before PR review | AI coding PRs are 154% larger and carry up to 2.74x more security flaws, stalling human code review |
| Any agent | Put a deterministic fail-before-fix proof gate ahead of human PR review | 655-firm and 500k-dev studies show code review stalls and releases lag when vacuous agent PRs pass green CI |
Last checked: 2026-11-22
- One concrete problem, one copy-pasteable fix, and a link to the exact official doc or study lines that prove it.
- Automated verification (contributing guide) checks quote accuracy, table formatting, and auditor tests on every commit.
python3 -m unittest discover -s tests -vQuestions, edge cases, or new tip ideas: open a GitHub Discussion, file an Issue, or join the Discord community.
MIT