agentleFS
affaan-maffaan-m/agentshield/CLAUDE.md

agentshield

CLAUDE.md1.3k starsChanged 7 months agoMITView on GitHub

Security auditor for AI agent configurations (Claude Code, MCP servers, hooks, agents). Grades: A (>=90), B (>=75), C (>=60), D (>=40), F (<40) Tests in tests/ mirror src/ structure. Use makeFinding(), makeSettings(), etc. helper factories. Run specific suite: npx vitest run tests/rules/mcp.test.ts

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 2 mentionsMay 2026: 0 mentionsJun 2026: 5 mentionsJul 2026: 3 mentionsAug 2026: 0 mentionsSep 2026: 4 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the affaan-m/agentshield repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about affaan-m/agentshield

The biggest 5 of 16 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 16

Talked about on GitHub and Bluesky (16 times).

On GitHub · 15

10 more on GitHub

The file

We split this CLAUDE.md into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Immutability: All arrays typed as ReadonlyArray, all interfaces use readonly fields.

    line 52
  2. Very specific:

    No RegExp .prototype methods: Use String.matchAll() via findAllMatches() helper to avoid security hook conflicts.

    line 53
  3. Very specific:

    Run specific suite: npx vitest run tests/rules/mcp.test.ts

    line 82
  4. Very specific:

    No mutation, no any, no console.log in src

    line 87

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

AgentShield

Security auditor for AI agent configurations (Claude Code, MCP servers, hooks, agents).

Build & Test

npm run build      # tsc + tsup → dist/
npm test           # vitest (912 tests)
npm run dev        # tsx watch mode

Architecture

src/
  index.ts          # CLI entry (commander)
  types.ts          # Core types + Zod schemas
  scanner/
    discovery.ts    # File discovery (CLAUDE.md, settings.json, mcp.json, agents/, etc.)
    index.ts        # Orchestrates discovery → rules → sorted findings
  rules/
    index.ts        # Barrel export of all rule modules
    secrets.ts      # 10 rules — API keys, tokens, passwords, env exposure, webhooks, private keys, base64, internal IPs
    permissions.ts  # 10 rules — allow/deny analysis, dangerous flags, destructive git, mutable tools, sensitive paths, network access
    hooks.ts        # 34 rules — injection, exfiltration, persistence, container escape, clipboard, log tampering, reverse shells
    mcp.ts          # 23 rules — risky servers, env override, npx supply chain, auto-approve, timeout, bind-all, CORS
    agents.ts       # 25 rules — tool restrictions, prompt injection, reflection attacks, output manipulation, social engineering
  reporter/
    score.ts        # Scoring engine (severity deductions, grade A-F, category breakdown)
    terminal.ts     # Colored terminal output
    json.ts         # JSON + Markdown report formats
    index.ts        # Format dispatcher
  opus/
    prompts.ts      # System prompts for Attacker/Defender/Auditor
    pipeline.ts     # Claude Opus three-agent adversarial pipeline
    render.ts       # Opus analysis terminal + markdown rendering
    index.ts        # Pipeline entry point
  miniclaw/
    types.ts        # Core types (immutable, readonly)
    sandbox.ts      # Sandbox lifecycle + path validation
    router.ts       # Prompt sanitization + output filtering
    tools.ts        # Whitelist-based tool authorization
    server.ts       # HTTP server with rate limiting + CORS
    dashboard.tsx   # React dashboard component
    index.ts        # Entry point + startMiniClaw()

Key Patterns

  • Rules: Each rule module exports ReadonlyArray<Rule>. Each Rule has check(file: ConfigFile): ReadonlyArray<Finding>.
  • Immutability: All arrays typed as ReadonlyArray, all interfaces use readonly fields.
  • No RegExp .prototype methods: Use String.matchAll() via findAllMatches() helper to avoid security hook conflicts.
  • False positive prevention: parsePermissionLists() JSON-parses settings to check only the allow array. Negation-aware context checking downgrades prohibitive mentions to info.

Severity Scoring

SeverityDeductionExample
critical-25Hardcoded API key, Bash(*)
high-15Shell MCP server, no deny list
medium-5Unrestricted curl, missing denials
low-2No model specified in agent
info0Missing description, good practice

Grades: A (>=90), B (>=75), C (>=60), D (>=40), F (<40)

CLI

agentshield scan [path]              # Static analysis
agentshield scan --opus              # + Claude Opus adversarial pipeline
agentshield scan --format json|md    # Output format
agentshield scan --fix               # Show auto-fix suggestions
agentshield miniclaw start           # Launch MiniClaw secure agent server
agentshield miniclaw start --port N  # Custom port

Testing

Tests in tests/ mirror src/ structure. Use makeFinding(), makeSettings(), etc. helper factories. Run specific suite: npx vitest run tests/rules/mcp.test.ts

Conventions

  • TypeScript strict mode, ESM modules
  • No mutation, no any, no console.log in src
  • Zod for config validation at boundaries
  • Conventional commits: feat/fix/test/refactor/docs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.