# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Build and Test Commands

```bash
# Build the project
cargo build --release

# Run tests
cargo test

# Check code compilation
cargo check

# Run clippy linter
cargo clippy
```

## Architecture Overview

This is a Rust workspace with two crates:

1. **scan_crate** (root): Binary crate providing CLI and MCP server functionality
2. **scan_crate_lib** (crates/scan_crate_lib): Library crate containing core inspection logic

The tool fetches Rust crates from multiple sources and performs regex searches using ripgrep. It can run as:
- CLI tool for direct command-line usage
- MCP (Model Context Protocol) server for integration with AI assistants

### Fetcher Architecture

The tool uses a modular fetcher system to support different crate sources:
- **CratesIoFetcher**: Downloads from crates.io registry
- **GitFetcher**: Clones from GitHub/git repositories
- **LocalPathFetcher**: Uses local directories
- **WorkspaceFetcher**: Finds dependencies in current workspace
- **CompositeFetcher**: Orchestrates all fetchers, automatically detecting source type

Key components:
- **fetchers/** module: Contains all fetcher implementations
- **scanner.rs**: Executes ripgrep searches on fetched crate source code
- **lib.rs**: MCP server implementation with `scan_crate` tool endpoint
- **main.rs**: Entry point handling CLI args and MCP/CLI mode switching

The tool requires ripgrep (`rg`) to be installed and available in PATH.