agentleFS
mtarcuremtarcure/claude-vibe-squad/.agents/skills/pre-audit-threat-model/SKILL.md

pre-audit-threat-model

Skill220 starsChanged 20 days agoMITView on GitHub

Use as the first pass on a new Solidity engagement, before any scanner runs, building an audit-readiness x-ray that enumerates permissionless entry points, maps every actor and privileged role, and extracts the protocol's stated invariants so downstream passes have a target list. Reach for it when asked to x-ray, prep, or find where to start on a protocol.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    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:

    Run coverage in background (forge coverage, or a project-local hardhat coverage only if the project already has Hardhat installed — never …

    line 31
  2. Very specific:

    Run a git-security scan: branch shape (linear / merged / squashed-import), fix-commit candidates (commits whose message matches …

    line 34
  3. Very specific:

    Read every in-scope .sol. Skip interfaces/, vendored copies of OZ/Uniswap libs, tests/mocks.

    line 44
  4. Very specific:

    Write three files into x-ray/ in a single message (parallel writes):

    line 68
  5. Very specific:

    Security claims: before writing "check X is missing", grep for every write site of the variable in question and confirm against those write …

    line 80
  6. Distinctive:

    Never claim "no tests" from a coverage tool failure.

    line 86
  7. Distinctive:

    Backwards-compatibility code: only classify code as legacy if (a) no active callers exist, (b) no NatSpec documents the behavior as …

    line 87
  8. Distinctive:

    Do NOT skip the grep gate — subagent contract summaries miss multi-line signatures.

    line 93
  9. Distinctive:

    Do NOT make a standalone Centralization Risks subsection — distribute into Actors / Trust Boundaries / Attack Surfaces.

    line 94
  10. Distinctive:

    Do NOT fabricate invariants the code does not state or imply.

    line 96
  11. Distinctive:

    Do NOT block downstream audit work on coverage tool failure.

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill 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
SKILL.md
<!-- inspired by pashov/skills:x-ray (MIT); concept-rebuilt for Chrono -->

pre-audit-threat-model

Audit-readiness x-ray. Build the threat model BEFORE running any tooling so every later pass has an entry-point list, an actor map, and a stated invariant set to evaluate against.

When to use

  • First skill on any new Solidity engagement. Always.
  • Operator says "x-ray", "audit readiness", "prep this protocol", "summarize this protocol", or "where do I start".
  • Re-run when the codebase changes meaningfully (new contract, new role, new external integration); the cached x-ray.md is otherwise the source of truth.

Pipeline (3 steps, sequential)

Step 1 — Enumerate and measure

  1. Detect source dir: read foundry.toml src= first, else hardhat.config.*, else try src/ then contracts/.
  2. Count: source files, nSLOC (no ~ prefix in the report), test files, test functions, stateful-fuzz files, foundry-invariant files, echidna/medusa/halmos/certora configs, fork tests. These signal test presence — never infer "no tests" from coverage tool failure.
  3. Run coverage in background (forge coverage, or a project-local hardhat coverage only if the project already has Hardhat installed — never npx-fetch a remote tool). If the toolchain is missing, surface the failure reason and continue — coverage is not a gate.
  4. Run a git-security scan: branch shape (linear / merged / squashed-import), fix-commit candidates (commits whose message matches fix|patch|vuln|exploit|audit), late changes (commits in the final 10% of history), forked deps, tech-debt markers (TODO/FIXME density), test co-change rate per source file.
  5. Glob for spec/whitepaper docs and extract only stated invariants, actor definitions, trust assumptions, economic properties. Tag spec-derived claims (per spec) so auditors can tell code-verified from spec-stated.

Step 2 — Read source and classify entry points

  1. Read every in-scope .sol. Skip interfaces/, vendored copies of OZ/Uniswap libs, tests/mocks. For each contract record: type & inheritance, roles & access control, value-holding state vars, external calls, fund flows, invariant comments, require/assert statements.
  2. Entry-point grep gate (PCRE — Bash, not the Grep tool):
    # single-line signatures
    grep -rnP 'function\s+\w+\s*\([^)]*\)\s+(external|public)(?!.*\b(view|pure)\b)' src/ --include='*.sol'
    # multi-line signatures (visibility on closing-paren line)
    grep -rnP '^\s*\)\s+(external|public)(?!.*\b(view|pure)\b)' src/ --include='*.sol' -B5
  3. Classify EACH grep hit by reading its body: permissionless (no modifier AND no internal msg.sender check), role-gated (modifier or internal restriction — acceptOwnership style counts), or admin-only. nonReentrant alone is NOT access control. The grep list is the source of truth — subagent summaries lose.
  4. Centralization analysis per privileged role: enumerate operational actions, distinguish role-transfer delays from action delays, mark which actions can extract user funds.
  5. Pause-coverage analysis: which critical functions are whenNotPaused, which aren't. Integrate gaps into the relevant role's attack surface — do NOT make a standalone "Centralization Risks" section (that duplicates Actors / Trust Boundaries / Attack Surfaces).

Step 3 — Write outputs

Write three files into x-ray/ in a single message (parallel writes):

  1. x-ray/architecture.json — contracts, edges, roles, value flows for SVG rendering.
  2. x-ray/x-ray.md — under 500 lines. Sections: Overview, Threat & Trust Model, Invariants, Actors, Permissionless Entry Points (grep-verified list only), Trust Boundaries, Key Attack Surfaces, Integrations & Composability, Tests & Coverage, Git History, Verdict.
  3. x-ray/entry-points.md — protocol flow paths first (destination ← writer-of-precondition ← ... ← deployment arrow chains), then per-access-level detail blocks.

Verification rules

  • Permissionless list: grep-verified only. If a subagent summary disagrees, grep wins.
  • Security claims: before writing "check X is missing", grep for every write site of the variable in question and confirm against those write sites. Qualify anything you cannot verify with could not confirm.
  • Branch scoping: state the analyzed branch in the header (Analyzed branch: <name> at <commit>). Never describe code state from other branches.
  • Test presence vs coverage: enumeration counts test files even if coverage failed. Never claim "no tests" from a coverage tool failure.
  • Backwards-compatibility code: only classify code as legacy if (a) no active callers exist, (b) no NatSpec documents the behavior as intentional, (c) git history shows the mechanism was removed. Otherwise it is current design.

Anti-patterns

  • Do NOT skip the grep gate — subagent contract summaries miss multi-line signatures.
  • Do NOT make a standalone Centralization Risks subsection — distribute into Actors / Trust Boundaries / Attack Surfaces.
  • Do NOT fabricate invariants the code does not state or imply; mark unstated ones as "auditor-derived" so downstream skills know which are protocol-claimed.
  • Do NOT block downstream audit work on coverage tool failure.

Recording (chrono-vault)

The task packet's injected memory contract owns the exact call shape, sequence, and fields - see wirework-reflect. Do not copy a record(...) example or add fields (including source_task) from memory; the server binds them, and a baked example violates the run's authenticated schema. Memory is best-effort telemetry and never gates the work. What is worth recording here is the task-specific outcome: nSLOC, entry points, permissionless count, roles, invariants, integrations, branch@commit.

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.