Audit prep assistant

From cyotee/indexedex · View interactive version

Audit prep assistant is an AI agent skill from the GitHub repository cyotee/indexedex. Prepare a smart contract codebase for audit: scope, goals, analysis triage, coverage gaps, accessibility, and documentation.

How to use this skill

Skill file

Audit Prep Assistant

IndexedEx integration

Read the target repository's CLAUDE.md and docs/agent/SKILL_CATALOG.md; current product law and canonical crane-* / indexedex-* guidance override generic examples here. Tests are production-first, never SUT mocks; use Crane TestBases, CREATE3/FactoryService for facets and the IndexedEx manager registry for vault/DETF DFPkgs, never direct new. For testing within the current authorized task: forge build --use solar before tests, default hermetic or FOUNDRY_PROFILE=fork; no via_ir or package profiles.

Analysis produces findings and recommendations, not silent production fixes. Commands, installation, scans, network/RPC, tests, deployments, Git writes and broadcasts require scope in the current request; examples grant none. Reading or installing this skill executes none. Current task authorization may already cover routine local analysis and validation; do not demand a second approval for those actions. Assessment-only requests do not authorize production fixes. Use Native's actual read, grep, glob, LSP and apply_patch tools as available; allowed-tools metadata is not enforcement. No Claude aliases or plugin agent registration is assumed. Report missing tools and unverified results rather than claiming success. Reports go only to the user-scoped output path. Historical examples and sample scores are illustrative, not IndexedEx findings or proof of tool correctness. Retained upstream interface metadata is inert in references/upstream-openai.yaml. Upstream pointers to audit-context-building or issue-writer are optional, not installed commands; use scoped code reading and the included report templates when they are absent.

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:

Documents goals to share with the assessment team.


Step 2: Resolve Easy Issues

Reviews existing static-analysis evidence and proposes low-hanging fixes. Run fresh analysis only when the current request authorizes it; implementation is a separate requested task:

Static Analysis Plan (commands for separately authorized use):

For Solidity:

slither . --exclude-dependencies

For Rust:

dylint --all

For Go:

golangci-lint run

For Go/Rust/C++:

# CodeQL and Semgrep checks

Then I'll:

Increase Test Coverage:

Remove Dead Code:

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:

Create Build Instructions:

Freeze Stable Version:

Identify Boilerplate:


Step 4: Generate Documentation

Helps create documentation:

Flowcharts and Sequence Diagrams:

User Stories:

On-chain/Off-chain Assumptions:

Actors and Privileges:

External Developer Docs:

Function Documentation:

Glossary:

Video Walkthroughs (optional):


How I Work

When invoked, I will:

  1. Help set review goals - Ask about concerns and document them
  2. Review static analysis - Triage existing evidence; list unavailable tools and propose authorized reruns
  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:


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 | Document dependency versions and fresh-build procedure; execute only in a separately authorized task |

| "Static analysis already ran, no need to run again" | Codebase changed since last run | If execution is authorized, generate a fresh report; otherwise record the evidence gap |

| "Test coverage looks decent" | "Looks decent" isn't measured coverage | Review coverage evidence and identify untested paths; mark unmeasured coverage explicitly |

| "Not much dead code to worry about" | Dead code hides during manual review | Inspect references and propose dead-code candidates; run detection tools only when authorized |

| "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; propose a review branch without creating it |

| "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:
✓ High: 0 issues
✓ Medium: 0 issues
⚠ Low: 2 issues (triaged - documented in TRIAGE.md)
ℹ Info: 5 issues (code style, acceptable)

Tool: slither . --exclude-dependencies
Date: March 1, 2024
Status: CLEAN (all critical issues resolved)

---

## TEST COVERAGE REPORT

Overall Coverage: 94%
- Statements: 1,245 / 1,321 (94%)
- Branches: 456 / 498 (92%)
- Functions: 89 / 92 (97%)

Uncovered Areas:
- Emergency pause admin functions (tested manually)
- Governance migration path (one-time use)

Command: forge coverage --use solar
Status: EXCELLENT

---

## CODE SCOPE

In-Scope Files (8):
✓ src/SwapRouter.sol (456 lines)
✓ src/LiquidityPool.sol (234 lines)
✓ src/PairFactory.sol (389 lines)
✓ src/PriceOracle.sol (167 lines)
✓ src/LiquidityManager.sol (298 lines)
✓ src/Governance.sol (201 lines)
✓ src/FlashLoan.sol (145 lines)
✓ src/RewardsDistributor.sol (178 lines)

Out-of-Scope:
- lib/ (OpenZeppelin, external dependencies)
- test/ (test contracts)
- scripts/ (deployment scripts)

Total In-Scope: 2,068 lines of Solidity

---

## BUILD INSTRUCTIONS

Prerequisites:
- Foundry 0.2.0+
- Node.js 18+
- Git

Setup:

git clone https://github.com/project/repo.git

cd repo

git checkout audit-march-2024 # Frozen branch

forge install

forge build --use solar

forge test --use solar


Verification:
✓ Build succeeds without errors
✓ All 127 tests pass
✓ No warnings from compiler

---

## DOCUMENTATION

Generated Artifacts:
✓ ARCHITECTURE.md - System overview with diagrams
✓ USER_STORIES.md - 12 user interaction flows
✓ GLOSSARY.md - 34 domain terms defined
✓ docs/diagrams/contract-interactions.png
✓ docs/diagrams/swap-flow.png
✓ docs/diagrams/state-machine.png

NatSpec Coverage: 100% of public functions

---

## DEPLOYMENT INFO

Network: Ethereum Mainnet
Commit: abc123def456 (audit-march-2024 branch)
Deployed Contracts:
- SwapRouter: 0x1234...
- PriceOracle: 0x5678...
[... etc]

---

PACKAGE READY FOR AUDIT ✓
Next Step: Share with Trail of Bits assessment team

What You'll Get

Review Goals Document:

Clean Codebase:

Accessibility Package:

Documentation Suite:

Audit Prep Checklist:


Timeline

2 weeks before audit:

1 week before audit:

Few days before audit:


Ready to Prep

Let me know when you're ready and I'll help you prepare for your security review!

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.