agentleFS
HarmonicSecurityHarmonicSecurity/claudit-sec/CLAUDE.md

claudit-sec

CLAUDE.md298 starsChanged 9 months agoApache-2.0View on GitHub

CLAUDIT-SEC is a read-only, single-file security audit tool for macOS that inspects Claude Desktop and Claude Code configuration, scheduled tasks, extensions, plugins, skills, permissions, and runtime state. This project is built and maintained using Claude Code. This file provides architecture context and development guidelines that Claude Code uses when working on the codebase. The script follows this structure:

The file

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

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

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

    Associative array key iteration: Use ${(k)arr[@]} not ${!arr[@]}

    line 104
  2. Very specific:

    Lowercase expansion: Use ${(L)var} not ${var,,}

    line 106
  3. Very specific:

    Read into array: Use read -rA not read -ra

    line 108
  4. Very specific:

    No printf -v: Use var=$(printf ...) instead

    line 110
  5. Distinctive:

    When run as root (uid 0) — which is how MDMs like FleetDM, Jamf, Mosyle, and CrowdStrike RTR execute scripts — the script automatically …

    line 114
  6. Distinctive:

    Read-only invariant: Never write to, modify, or delete any file being audited

    line 157
  7. Distinctive:

    Sensitive data: Always redact tokens, keys, passwords, secrets in all output formats

    line 159
  8. Distinctive:

    New collectors: Add to the script, update the collector table above

    line 160
  9. Very specific:

    Testing: Run zsh claude_audit.sh --json and verify finding counts and section coverage

    line 161

≈ “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

CLAUDIT-SEC — Claude Security Audit Tool

Project Overview

CLAUDIT-SEC is a read-only, single-file security audit tool for macOS that inspects Claude Desktop and Claude Code configuration, scheduled tasks, extensions, plugins, skills, permissions, and runtime state.

  • claude_audit.sh — Zsh (~1900 lines, requires jq) — designed for MDM/CrowdStrike RTR style deployment

This project is built and maintained using Claude Code. This file provides architecture context and development guidelines that Claude Code uses when working on the codebase.

Architecture

The script follows this structure:

  1. Preflight checks — OS validation, dependency checks
  2. User context detection — single user, explicit --user, or all-users scan
  3. Session directory discovery — finds local-agent-mode-sessions/org/user/ paths
  4. 14 data collectors — each reads specific config files and populates findings
  5. Finding aggregation — counts by severity (WARN, INFO, REVIEW)
  6. 3 output renderers — ASCII (ANSI color + Unicode tables), HTML (dark theme), JSON (SIEM-ready)

Data Collectors

CollectorSource FilesKey Findings
Desktop Settingsclaude_desktop_config.json → preferenceskeepAwakeEnabled, allowAllBrowserActions, menuBar, sidebar
Cowork Settingscowork_settings.json, config.jsonscheduledTasks, webSearch, networkMode
MCP Serversclaude_desktop_config.json → mcpServersServer names, commands, env var keys
Pluginsinstalled_plugins.json, remote manifest, marketplace cacheinstalled/remote/cached plugins
Plugin Hookshooks/hooks.json in plugin directoriesShell commands on lifecycle events
Connectorslocal_*.json → remoteMcpServersConfig, .mcp.jsonweb/desktop/not_connected, egressAllowedDomains, disabledMcpTools
SkillsUser skills (6 paths), installed plugin skills (3 paths) — see Key PathsSKILL.md frontmatter parsing
Scheduled Tasksscheduled-tasks.jsonCron expressions with english translation
Extensions (DXT)extensions-installations.jsonSignature status, dangerous tools
Extension SettingsClaude Extensions Settings/*.jsonAllowed directories
Blocklistextensions-blocklist.jsonGovernance control presence
Claude Code Settings~/.claude/settings.jsonPermission grants
Runtimepgrep, pmset, crontab, LaunchAgentsRunning processes, sleep assertions
CookiesCookies, Cookies-journalPresence and permissions

Key Paths

~/Library/Application Support/Claude/          # Claude Desktop dir
  claude_desktop_config.json                   # Desktop prefs + MCP servers
  config.json                                  # App config (network mode, allowlists, device ID)
  extensions-installations.json                # DXT extensions
  extensions-blocklist.json                    # Extension governance
  Claude Extensions Settings/*.json            # Per-extension settings
  local-agent-mode-sessions/<org>/<user>/      # Session directories
    cowork_settings.json                       # Cowork preferences
    scheduled-tasks.json                       # Scheduled tasks
    cowork_plugins/installed_plugins.json       # Installed plugins
    cowork_plugins/marketplaces/               # Marketplace catalog
    cowork_plugins/cache/                      # Downloaded plugin cache
    remote_cowork_plugins/manifest.json        # Org-deployed plugins
    local_*.json                               # Session files with connector state
~/.claude/settings.json                        # Claude Code settings
~/.claude/skills/<skill>/SKILL.md              # Claude Code user skills (manually uploaded)
~/.claude/plugins/marketplaces/<mp>/           # Claude Code marketplace plugin skills
  plugins/<plugin>/skills/<skill>/SKILL.md
  external_plugins/<plugin>/skills/<skill>/SKILL.md
~/Documents/Claude/Scheduled/<skill>/SKILL.md  # Scheduled task skills

Skill scanning paths (collect_skills):
  User skills (source: "user"):
    ~/Documents/Claude/Scheduled/*/SKILL.md                         # Scheduled tasks
    skills-plugin/<uid>/<oid>/skills/*/SKILL.md                     # Cowork-created skills
    ~/.skills/skills/*/SKILL.md                                     # Alt skills dir
    ~/.claude/skills/*/SKILL.md                                     # Claude Code user skills
    <session>/local_*/.claude/skills/*/SKILL.md                     # Session-local skills

  Installed plugin skills (source: "plugin"):
    <session>/remote_cowork_plugins/*/skills/*/SKILL.md             # Org-deployed plugins
    <session>/cowork_plugins/cache/<mp>/<plugin>/<ver>/skills/*/    # Cached (installed) plugins
    ~/.claude/plugins/marketplaces/<mp>/{plugins,external_plugins}/ # Claude Code marketplace

  NOT scanned (marketplace catalog, not installed):
    <session>/cowork_plugins/marketplaces/                          # Full Cowork catalog

Shell Script (claude_audit.sh)

Zsh Compatibility

The shell script uses #!/bin/zsh for stock macOS compatibility (Apple ships bash 3.2 which lacks associative arrays). Key setopt flags:

OptionPurpose
KSH_ARRAYS0-based array indexing (bash-compatible)
BASH_REMATCH=~ populates BASH_REMATCH array
TYPESET_SILENTPrevents local re-declaration from printing values in loops
NULL_GLOBUnmatched globs expand to nothing (prevents NOMATCH errors)
PIPE_FAILPipeline returns rightmost non-zero exit code

Zsh-Specific Gotchas

Do NOT use these variable names as locals — they are zsh special variables:

  • path (tied to PATH) — use _path instead
  • status (tied to $?) — use perm_status or similar
  • fpath (function autoload path) — avoid entirely
  • match, MATCH, MBEGIN, MEND — regex related

Associative array key iteration: Use ${(k)arr[@]} not ${!arr[@]}

Lowercase expansion: Use ${(L)var} not ${var,,}

Read into array: Use read -rA not read -ra

No printf -v: Use var=$(printf ...) instead

MDM Deployment

When run as root (uid 0) — which is how MDMs like FleetDM, Jamf, Mosyle, and CrowdStrike RTR execute scripts — the script automatically scans all users with Claude data. No flags needed.

  • As root (MDM): Auto-discovers users via dscl, scans all with Claude directories
  • As user: Scans current user only
  • --user USERNAME: Scans specific user
  • --all-users: Explicit all-users scan (requires sufficient permissions)

Output Formats

  • Default (ASCII): ANSI-colored terminal output with Unicode box-drawing tables
  • --json: Single JSON object (or array for multi-user) for SIEM ingestion. Sensitive fields auto-redacted.
  • --html [FILE]: Standalone dark-themed HTML report. Created with mode 0600. Auto-named per user if scanning multiple users.
  • -q/--quiet: Suppresses INFO-only sections, shows only WARN/CRITICAL findings

Security Properties

  • Read-only — never modifies any audited files
  • No eval — no dynamic code execution
  • All variables quoted — no word-splitting or injection vectors
  • Sensitive values redacted — [REDACTED] in all output formats
  • MCP env vars — only key names emitted, never values
  • MCP args — patterns matching sk-, key=, token=, secret=, password= are redacted
  • HTML output — created with umask 077 (mode 0600)
  • Username validation — ^[a-zA-Z0-9._-]+$ with explicit ./.. rejection

CLI Reference

Usage: claude_audit.sh [OPTIONS]

Options:
  --html [FILE]    HTML report (auto-named if no FILE given)
  --json           JSON output for SIEM ingestion
  --user USER      Scan specific user
  --all-users      Scan all users with Claude data
  -q, --quiet      Only show WARN/CRITICAL findings
  --version        Print version and exit
  -h, --help       Show usage

Development Guidelines

  • Single-file constraint: The script must remain a self-contained single file with no external dependencies (except jq)
  • Read-only invariant: Never write to, modify, or delete any file being audited
  • Findings format: severity (WARN/INFO/REVIEW), section, message, detail
  • Sensitive data: Always redact tokens, keys, passwords, secrets in all output formats
  • New collectors: Add to the script, update the collector table above
  • Testing: Run zsh claude_audit.sh --json and verify finding counts and section coverage

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.