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.
In this repository179 other files it gives its agents.
- AGENTS.mdAGENTS.md
- chrono/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- accessible-media-authoringSkill
- agentic-safety-auditSkill
- agent-prompt-engineeringSkill
- audio-event-map-authoringSkill
- auto-scaffoldSkill
- chain-constructSkill
- chain-construct-smart-contractSkill
- claim-verificationSkill
- code-reachability-auditSkill
- code-review-loopSkill
- color-theorySkill
- conversation-designSkill
- copy-refinementSkill
- cosmos-sdk-audit-checklistSkill
- cross-chain-bridge-auditSkill
- cross-file-relationship-synthesisSkill
- data-flow-traceSkill
- dedup-prior-art-checkSkill
- defi-invariant-checkSkill
- dependency-cycle-auditSkill
- dependency-health-triageSkill
- detection-as-codeSkill
- diff-aware-semgrep-scanSkill
- differential-reviewSkill
- dimensional-analysis-checkSkill
- dual-level-retrievalSkill
- durable-nonce-exploitationSkill
- erc1271-revert-data-checkSkill
- error-based-sstiSkill
- evm-audit-flowSkill
- figma-implement-designSkill
- findings-filterSkill
- forensic-timeline-authoringSkill
- game-design-fundamentalsSkill
- game-mechanics-balancingSkill
- head-tailSkill
- incident-response-runbookSkill
- interactive-audio-designSkill
- interface-ambiguity-checkSkill
- keyword-clusteringSkill
- knowledge-base-integrationSkill
- known-advisory-backport-checkSkill
- layered-analysis-loopSkill
- level-design-patternsSkill
- locale-adaptationSkill
- multi-stance-audit-fanoutSkill
- narrative-structureSkill
- osint-platform-auditSkill
- parser-differential-route-confusionSkill
- persuasive-technical-writingSkill
- platform-complianceSkill
- player-engagement-psychologySkill
- program-rubric-lookupSkill
- read-only-reentrancy-checkSkill
- requirements-elicitationSkill
- review-severity-ladderSkill
- rule6-rights-gateSkill
- The first 60 shown.
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
- Very specific: line 31
Run coverage in background (forge coverage, or a project-local hardhat coverage only if the project already has Hardhat installed — never …
- Very specific: line 34
Run a git-security scan: branch shape (linear / merged / squashed-import), fix-commit candidates (commits whose message matches …
- Very specific: line 44
Read every in-scope .sol. Skip interfaces/, vendored copies of OZ/Uniswap libs, tests/mocks.
- Very specific: line 68
Write three files into x-ray/ in a single message (parallel writes):
- Very specific: line 80
Security claims: before writing "check X is missing", grep for every write site of the variable in question and confirm against those write …
- Distinctive: line 86
Never claim "no tests" from a coverage tool failure.
- Distinctive: line 87
Backwards-compatibility code: only classify code as legacy if (a) no active callers exist, (b) no NatSpec documents the behavior as …
- Distinctive: line 93
Do NOT skip the grep gate — subagent contract summaries miss multi-line signatures.
- Distinctive: line 94
Do NOT make a standalone Centralization Risks subsection — distribute into Actors / Trust Boundaries / Attack Surfaces.
- Distinctive: line 96
Do NOT fabricate invariants the code does not state or imply.
- Distinctive: line 98
Do NOT block downstream audit work on coverage tool failure.
≈ “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.
Files
<!-- 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.mdis otherwise the source of truth.
Pipeline (3 steps, sequential)
Step 1 — Enumerate and measure
- Detect source dir: read
foundry.tomlsrc=first, elsehardhat.config.*, else trysrc/thencontracts/. - 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. - Run coverage in background (
forge coverage, or a project-localhardhat coverageonly if the project already has Hardhat installed — nevernpx-fetch a remote tool). If the toolchain is missing, surface the failure reason and continue — coverage is not a gate. - 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/FIXMEdensity), test co-change rate per source file. - 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
- Read every in-scope
.sol. Skipinterfaces/, 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/assertstatements. - 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 - Classify EACH grep hit by reading its body: permissionless (no modifier AND no
internal
msg.sendercheck), role-gated (modifier or internal restriction —acceptOwnershipstyle counts), or admin-only.nonReentrantalone is NOT access control. The grep list is the source of truth — subagent summaries lose. - Centralization analysis per privileged role: enumerate operational actions, distinguish role-transfer delays from action delays, mark which actions can extract user funds.
- 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):
x-ray/architecture.json— contracts, edges, roles, value flows for SVG rendering.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.x-ray/entry-points.md— protocol flow paths first (destination ← writer-of-precondition ← ... ← deploymentarrow 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.
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
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.

