The Complete Production SOP: How to Deploy and Run Slither Solidity Smart Contract Static Analyzer in Autonomous AI Agents
Step-by-step SOP to install and run Slither Solidity Static Analyzer in Codex, Claude Code, and Cursor. Audit smart contracts and detect reentrancy bugs safely.
Technical Overview & Architectural Context
Autonomous coding agents frequently misinterpret AST representations and control flow vulnerabilities in Solidity smart contracts when operating without structured constraints. When analyzing decentralized finance (DeFi) protocols, agents often hallucinate false positives, overlook cross-function reentrancy vectors, or propose gas-optimizing refactors that introduce dangerous state update re-ordering. Without deterministic static analysis guardrails, agents cannot reliably parse complex inheritance trees, storage layout packing, or compiler-specific quirks. The Slither Solidity Smart Contract Static Analyzer skill embeds deterministic boundaries directly into the agent runtime. By bridging Trail of Bits Crytic Slither with Codex, Claude Code, Cursor, and Windsurf, this skill enforces a strict verification pipeline. It compels autonomous agents to compile the AST via solc or Foundry artifacts, parse control flow graphs (CFGs), classify vulnerabilities across established security taxonomies (e.g., arbitrary-send-erc20, unchecked-transfer, reentrancy-eth), and validate contract invariants before suggesting any smart contract edits or deploying pull requests.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into the agent runtime.
Agent runtimes such as Claude Code, Cursor, and Codex discover custom capabilities by scanning localized skill repositories. We mount the SKILL.md file into the global `.agents/skills` registry or workspace root `.cursor/rules` / `.claude/skills` directory so the agent's intent matching engine can map user triggers like 'run slither contract audit' directly to Crytic Slither's AST engine.
mkdir -p ~/.agents/skills/slither-solidity-static-analyzer && curl -fsSL https://askills.dev/api/skills/slither-solidity-static-analyzer/raw -o ~/.agents/skills/slither-solidity-static-analyzer/SKILL.md---
name: "slither-solidity-static-analyzer"
description: "Detect vulnerabilities, reentrancy hazards, and gas optimizations in Solidity code."
metadata:
author: "Trail of Bits"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "run slither contract audit"
- "detect reentrancy slither"
- "check erc20 compliance slither"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: true
net_access: false
---
# Slither Solidity Smart Contract Static Analyzer SOP
1. Ensure dependencies are compiled using `forge build --build-info` or `npx hardhat compile`.
2. Execute static analysis via `slither . --json slither-report.json`.
3. Filter output for high and medium severity vulnerabilities.
4. Propose code modifications that follow the Checks-Effects-Interactions (CEI) pattern.
5. Verify post-patch resolution by rerunning Slither with zero non-whitelisted findings.Instruct the agent to generate a JSON report using `--json -` or write to a temporary file instead of streaming raw ASCII text to reduce context window consumption by up to 65%.
Ensure that the agent sandbox has read access to root configuration files like `foundry.toml` or `hardhat.config.js`; missing compiler configuration causes Slither to exit with compile errors.
Compiler Toolchain & Dependency Validation
Inject solc-select and verify underlying framework binaries without leaking sensitive RPC keys or private keys.
Slither relies on underlying Solidity compiler binaries (`solc`) to extract AST structures. If the contract pragma specifies `^0.8.20` but the host environment defaults to `0.8.19`, the audit command will fail. We configure `solc-select` and setup the `slither.config.json` configuration file to suppress known external dependency false positives (such as OpenZeppelin internal checks).
pipx install slither-analyzer && pipx install solc-select && solc-select install 0.8.24 && solc-select use 0.8.24{
"filter_paths": "node_modules|lib|test",
"exclude_dependencies": true,
"detectors_to_exclude": "naming-convention,solc-version",
"confidence": "medium,high",
"severity": "low,medium,high"
}Setting `"exclude_dependencies": true` prevents the agent from wasting time auditing audited OpenZeppelin contracts inside `lib/` or `node_modules/`.
Never place deployer private keys or infura/alchemy RPC tokens in your `slither.config.json` or committed agent manifests; enforce workspace `.env` exclusion.
Intent Matching & Trigger Invocation
Verify deterministic activation using tested natural language prompts that map directly to the skill frontmatter.
Autonomous agents leverage semantic vector matching against frontmatter `triggers`. To invoke this skill deterministically, phrase instructions using the precise procedural verbs declared in the skill manifest, instructing the agent to isolate high-risk security flaws like reentrancy and unchecked low-level calls.
# Execute via Claude Code CLI or Codex Desktop Prompt
claude "run slither contract audit on src/Vault.sol and detect reentrancy slither hazards"Include the explicit target contract path in your prompt (e.g., `src/Vault.sol`) so the agent limits AST traversal scope to active changes.
Avoid vague prompts like 'check my smart contract'; generic prompts often trigger raw LLM guessing rather than running the deterministic Slither CLI tool.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks and diff validation before accepting agent deliverables.
Once the agent proposes a fix (e.g., moving state assignments prior to external calls or wrapping calls in `SafeERC20`), it must execute the verification quality gate. The agent reruns the static analyzer and executes local Foundry/Hardhat test suites to ensure zero behavioral regression.
slither . --config-file slither.config.json --checklist && forge test// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract Vault is ReentrancyGuard {
mapping(address => uint256) public balances;
function withdraw() external nonReentrant {
uint256 amount = balances[msg.sender];
require(amount > 0, "Zero balance");
// CEI Pattern: Update balance before external transfer
balances[msg.sender] = 0;
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Transfer failed");
}
}Instruct the agent to review the `git diff` output to verify it did not modify interface definitions, imports, or gas limits unnecessarily.
Beware of agents suppressing findings using `// slither-disable-next-line` rather than fixing the underlying vulnerability. Disallow automated suppression in prompt boundaries.
Real-World Scenario: Audit and Remediate Cross-Function Reentrancy in an Escrow Smart Contract
“Run slither contract audit on src/Escrow.sol, detect reentrancy slither bugs, and patch any high-severity findings following the Checks-Effects-Interactions pattern.”
Runtime Troubleshooting & Failure Modes
Root Cause: The local solc compiler version selected by solc-select does not match the pragma declared in the smart contract files or foundry.toml.
solc-select install $(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' foundry.toml | head -1) && solc-select use $(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' foundry.toml | head -1)Root Cause: Foundry remappings or git submodules are uninitialized, preventing the Solidity AST builder from resolving import paths.
forge install && forge remappings > remappings.txtFrequently Asked Questions (Slither Solidity Smart Contract Static Analyzer SOP)
Q:Can I use Slither Solidity Smart Contract Static Analyzer across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification supported across all modern agent runtimes. Simply place the manifest in your local agent registry path (~/.agents/skills/) or workspace configuration directory (.cursor/rules/ or .claude/skills/).
Q:How does Slither Solidity Smart Contract Static Analyzer prevent context window overflow during long agent sessions?
The skill enforces structured output flags (`--json` or `--checklist`) and filters out informational/optimization detectors. By limiting analysis results to high and medium severity vulnerabilities, agent context windows remain focused on critical security vectors.
Q:Does this skill require escalated root or container permissions?
No. It is audited with a security score of 98/100 and runs safely within workspace-scoped sandboxes. It requires local file system read access for smart contract source files and standard CLI shell execution permissions to run the Slither binary.
Ready to equip your autonomous agent with Slither Solidity Smart Contract Static Analyzer?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.