Skip to content

Conversation

@susumutomita
Copy link

@susumutomita susumutomita commented Dec 22, 2025

Summary

Add a new detector that uses Claude (via Claude Code CLI or Anthropic API) to analyze Solidity smart contracts for vulnerabilities.

  • Claude Code CLI integration (free for MAX subscribers)
  • Anthropic API fallback for programmatic access
  • Configurable model selection (opus, sonnet, haiku)
  • Per-contract and all-contracts analysis modes
  • Optional logging of Claude's analysis

Usage

# Using Claude Code CLI (recommended)
slither . --detect claude --claude-use-code

# Using Anthropic API
ANTHROPIC_API_KEY=sk-... slither . --detect claude

Changes

  • slither/detectors/functions/claude.py: Main detector implementation
  • slither/utils/claude.py: Utility functions for Claude integration
  • slither/__main__.py: Added Claude parser initialization
  • slither/slither.py: Added Claude configuration attributes
  • slither/utils/command_line.py: Added Claude default options
  • slither/detectors/all_detectors.py: Added Claude detector import
  • docs/src/detectors/Detector-Documentation.md: Documentation
  • tests/unit/utils/test_claude.py: Unit tests with mocking

Test plan

  • Unit tests pass (10 tests)
  • Lint passes (10.00/10)
  • Manual testing: detector finds reentrancy and access control issues in test contract

Note: E2E tests are not included as this detector requires external API calls which are non-deterministic and need credentials. This is consistent with the existing Codex detector which also lacks e2e tests.

Add a new detector that uses Claude (via Claude Code CLI or Anthropic API)
to analyze Solidity smart contracts for vulnerabilities.

## Features
- Claude Code CLI integration (free for MAX subscribers)
- Anthropic API fallback for programmatic access
- Configurable model selection (opus, sonnet, haiku)
- Per-contract and all-contracts analysis modes
- Optional logging of Claude's analysis

## Usage
```bash
# Using Claude Code CLI (recommended)
slither . --detect claude --claude-use-code

# Using Anthropic API
ANTHROPIC_API_KEY=sk-... slither . --detect claude
```

## Changes
- slither/detectors/functions/claude.py: Main detector implementation
- slither/utils/claude.py: Utility functions for Claude integration
- slither/__main__.py: Added Claude parser initialization
- slither/slither.py: Added Claude configuration attributes
- slither/utils/command_line.py: Added Claude default options
- slither/detectors/all_detectors.py: Added Claude detector import
- docs/src/detectors/Detector-Documentation.md: Documentation
- tests/unit/utils/test_claude.py: Unit tests with mocking

Note: E2E tests are not included as this detector requires external
API calls which are non-deterministic and need credentials. This is
consistent with the existing Codex detector which also lacks e2e tests.
@CLAassistant
Copy link

CLAassistant commented Dec 22, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants