audit-prep-assistant
Audit-Prep-Assistant systematically prepares codebases for security reviews using Trail of Bits' methodology across multiple languages including Solidity, Rust, Go, and C++. Use this skill 1-2 weeks before a scheduled audit to set review goals, run static analysis tools, increase test coverage, remove dead code, ensure accessibility through documentation, and generate flowcharts, user stories, and inline comments that help auditors understand the codebase architecture and critical workflows.
git clone --depth 1 https://github.com/trailofbits/skills /tmp/audit-prep-assistant && cp -r /tmp/audit-prep-assistant/plugins/building-secure-contracts/skills/audit-prep-assistant ~/.claude/skills/audit-prep-assistantSKILL.md
# Audit Prep Assistant ## Purpose Helps prepare for a security review using Trail of Bits' checklist. A well-prepared codebase makes the review process smoother and more effective. **Use this**: 1-2 weeks before your security audit --- ## The Preparation Process ### Step 1: Set Review Goals Helps define what you want from the review: **Key Questions**: - What's the overall security level you're aiming for? - What areas concern you most? - Previous audit issues? - Complex components? - Fragile parts? - What's the worst-case scenario for your project? Documents goals to share with the assessment team. --- ### Step 2: Resolve Easy Issues Runs static analysis and helps fix low-hanging fruit: **Run Static Analysis**: For Solidity: ```bash slither . --exclude-dependencies ``` For Rust: ```bash dylint --all ``` For Go: ```bash golangci-lint run ``` For Go/Rust/C++: ```bash # CodeQL and Semgrep checks ``` Then I'll: - Triage all findings - Help fix easy issues - Document accepted risks **Increase Test Coverage**: - Analyze current coverage - Identify untested code - Suggest new tests - Run full test suite **Remove Dead Code**: - Find unused functions/variables - Identify unused libraries - Locate stale features - Suggest cleanup **Goal**: Clean static analysis report, high test coverage, minimal dead code --- ### Step 3: Ensure Code Accessibility Helps make code clear and accessible: **Provide Detailed File List**: - List all files in scope - Mark out-of-scope files - Explain folder structure - Document dependencies **Create Build Instructions**: - Write step-by-step setup guide - Test on fresh environment - Document dependencies and versions - Verify build succeeds **Freeze Stable Version**: - Identify commit hash for review - Create dedicated branch - Tag release version - Lock dependencies **Identify Boilerplate**: - Mark copied/forked code - Highlight your modifications - Document third-party code - Focus review on your code --- ### Step 4: Generate Documentation Helps create documentation: **Flowcharts and Sequence Diagrams**: - Map primary workflows - Show component relationships - Visualize data flow - Identify critical paths **User Stories**: - Define user roles - Document use cases - Explain interactions - Clarify expectations **On-chain/Off-chain Assumptions**: - Data validation procedures - Oracle information - Bridge assumptions - Trust boundaries **Actors and Privileges**: - List all actors - Document roles - Define privileges - Map access controls **External Developer Docs**: - Link docs to code - Keep synchronized - Explain architecture - Document APIs **Function Documentation**: - System and function invariants - Parameter ranges (min/max values) - Arithmetic formulas and precision loss - Complex logic explanations - NatSpec for Solidity **Glossary**: - Define domain terms - Explain acronyms - Consistent terminology - Business logic concepts **Video Walkthroughs** (optional): - Complex workflows - Areas of concern - Architecture overview --- ## How I Work When invoked, I will: 1. **Help set review goals** - Ask about concerns and document them 2. **Run static analysis** - Execute appropriate tools for your platform 3. **Analyze test coverage** - Identify gaps and suggest improvements 4. **Find dead code** - Search for unused code and libraries 5. **Review accessibility** - Check build instructions and scope clarity 6. **Generate documentation** - Create flowcharts, user stories, glossaries 7. **Create prep checklist** - Track what's done and what's remaining Adapts based on: - Your platform (Solidity, Rust, Go, etc.) - Available tools - Existing documentation - Review timeline --- ## Rationalizations (Do Not Skip) | Rationalization | Why It's Wrong | Required Action | |-----------------|----------------|-----------------| | "README covers setup, no need for detailed build instructions" | READMEs assume context auditors don't have | Test build on fresh environment, document every dependency version | | "Static analysis already ran, no need to run again" | Codebase changed since last run | Execute static analysis tools, generate fresh report | | "Test coverage looks decent" | "Looks decent" isn't measured coverage | Run coverage tools, identify specific untested code paths | | "Not much dead code to worry about" | Dead code hides during manual review | Use automated detection tools to find unused functions/variables | | "Architecture is straightforward, no diagrams needed" | Text descriptions miss visual patterns | Generate actual flowcharts and sequence diagrams | | "Can freeze version right before audit" | Last-minute freezing creates rushed handoff | Identify and document commit hash now, create dedicated branch | | "Terms are self-explanatory" | Domain knowledge isn't universal | Create comprehensive glossary with all domain-specific terms | | "I'll do this step later" | Steps build on each other - skipping creates gaps | Complete all 4 steps sequentially, track progress with checklist | --- ## Example Output When I finish helping you prepare, you'll have concrete deliverables like: ``` === AUDIT PREP PACKAGE === Project: DeFi DEX Protocol Audit Date: March 15, 2024 Preparation Status: Complete --- ## REVIEW GOALS DOCUMENT Security Objectives: - Verify economic security of liquidity pool swaps - Validate oracle manipulation resistance - Assess flash loan attack vectors Areas of Concern: 1. Complex AMM pricing calculation (src/SwapRouter.sol:89-156) 2. Multi-hop swap routing logic (src/Router.sol) 3. Oracle price aggregation (src/PriceOracle.sol:45-78) Worst-Case Scenario: - Flash loan attack drains liquidity pools via oracle manipulation Questions for Auditors: - Can the AMM pricing model produce negative slippage under edge cases? - Is the slippage protection sufficient to prevent sandwich attacks? - How resilient is the system to temporary oracle failures? --- ## STATIC ANALYSIS REPORT Slither Scan Results: ✓
Audits GitHub Actions workflows for security vulnerabilities in AI agent integrations including Claude Code Action, Gemini CLI, OpenAI Codex, and GitHub AI Inference. Detects attack vectors where attacker-controlled input reaches AI agents running in CI/CD pipelines, including env var intermediary patterns, direct expression injection, dangerous sandbox configurations, and wildcard user allowlists. Use when reviewing workflow files that invoke AI coding agents, auditing CI/CD pipeline security for prompt injection risks, or evaluating agentic action configurations.
Clarify requirements before implementing. Use when serious doubts arise.
Enables ultra-granular, line-by-line code analysis to build deep architectural context before vulnerability or bug finding.
Scans Algorand smart contracts for 11 common vulnerabilities including rekeying attacks, unchecked transaction fees, missing field validations, and access control issues. Use when auditing Algorand projects (TEAL/PyTeal).
Scans Cairo/StarkNet smart contracts for 6 critical vulnerabilities including felt252 arithmetic overflow, L1-L2 messaging issues, address conversion problems, and signature replay. Use when auditing StarkNet projects.
Systematic code maturity assessment using Trail of Bits' 9-category framework. Analyzes codebase for arithmetic safety, auditing practices, access controls, complexity, decentralization, documentation, MEV risks, low-level code, and testing. Produces professional scorecard with evidence-based ratings and actionable recommendations.
Scans Cosmos SDK blockchain modules and CosmWasm contracts for consensus-critical vulnerabilities — chain halts, fund loss, state divergence. 25 core + 16 IBC + 10 EVM + 3 CosmWasm patterns. Use when auditing custom x/ modules, reviewing IBC integrations, or assessing pre-launch chain security. Updated for SDK v0.53.x.
Smart contract development advisor based on Trail of Bits' best practices. Analyzes codebase to generate documentation/specifications, review architecture, check upgradeability patterns, assess implementation quality, identify pitfalls, review dependencies, and evaluate testing. Provides actionable recommendations.