CodeSearch
Fast, intelligent code search and analysis for 48+ languages.
Find what you need in seconds: functions, classes, duplicates, dead code, complexity issues.
What Can You Search & Detect?
🔍 Search Capabilities
| What | Example | Use Case |
|---|---|---|
| Functions | codesearch "fn authenticate" -e rs |
Find where authentication logic lives |
| Classes | codesearch "class User" -e py |
Locate data models |
| TODO/FIXME | codesearch "TODO|FIXME" . |
Track technical debt |
| Imports | codesearch "^import" -e js |
Understand dependencies |
| Patterns | codesearch "async.*await" --fuzzy |
Find async code (handles typos) |
| Exact Text | codesearch "deprecated_function" |
Find all usages before refactoring |
Supports: Regex, fuzzy matching, case-insensitive, multi-language (48+ languages)
🔎 Code Quality Detection
| What | Command | Value |
|---|---|---|
| Dead Code | codesearch deadcode |
Find unused functions, variables, imports, empty functions |
| Duplicates | codesearch duplicates |
Identify copy-paste code (Type-1/2/3 clones) |
| Complexity | codesearch complexity |
Spot overly complex functions (cyclomatic/cognitive) |
| Circular Deps | codesearch circular |
Detect circular dependencies |
💡 Real-World Use Cases
Before Refactoring:
# Find all usages of old function
# Result: Found in 12 files, 23 occurrences
Code Review:
# Check for technical debt
# Result: 5 unused functions, 12 TODO comments
Understanding Codebase:
# Find all authentication-related code
# Result: Ranked by relevance, with line numbers
Quality Check:
# Find duplicated code
# Result: 8 duplicate blocks (90%+ similar)
🚀 Quick Start
# Simple search: codesearch <query> [path]
# Fuzzy search (handles typos)
# Interactive mode
# Analysis commands
# Advanced features
# Graph analysis (6 types)
# Other advanced features
Why CodeSearch?
Fast & Precise
- Parallel processing using Rust and rayon
- Exact line numbers with precise matching
- Smart caching for repeated searches
Language-Aware
- 48+ languages supported
- Understands functions, classes, imports
- Syntax-specific patterns
Quality Focused
- Detect dead code before it ships
- Find duplicates to improve DRY
- Measure complexity to guide refactoring
- Analyze design quality (coupling, cohesion, instability)
Developer Friendly
- Interactive REPL mode
- Export to CSV/Markdown
- MCP server for AI agents
Advanced Capabilities
- Incremental indexing for large codebases
- Real-time file watching
- Git history search
- Remote repository search (GitHub/GitLab)
Graph Analysis (6 Types)
- Abstract Syntax Tree (AST) - code structure
- Control Flow Graph (CFG) - execution paths
- Data Flow Graph (DFG) - variable dependencies
- Call Graph - function relationships
- Dependency Graph - module dependencies
- Program Dependency Graph (PDG) - combined analysis
Installation
# Optional: MCP server for AI agents
Common Options
# Filter by file type
# Exclude directories
# Case-insensitive
# Fuzzy matching (handles typos)
# Rank by relevance
# Export results
📖 Usage Examples
Search Patterns
# codesearch <query> [path] [options]
# Regex patterns
# Fuzzy search (handles typos)
Code Analysis
# Codebase overview
# Output: Files, lines, languages, function count, class count
# Complexity analysis
# Output: Files ranked by cyclomatic/cognitive complexity
# Dead code detection (enhanced with 6+ detection types)
# Output: Unused variables, unreachable code, empty functions,
# TODO/FIXME markers, commented code, unused imports
# Duplicate detection
# Output: Similar code blocks that violate DRY
Interactive Mode
Commands:
- Type any pattern to search
/f- Toggle fuzzy mode/i- Toggle case insensitivityanalyze- Codebase metricscomplexity- Complexity analysisdeadcode- Dead code detectionduplicates- Find duplicateshelp- All commands
MCP Server (AI Integration)
# Start MCP server
# Agents can call:
# - search_code(query, path, extensions, fuzzy, regex)
# - list_files(path, extensions, exclude)
# - analyze_codebase(path, extensions)
📊 Output Examples
Search Results
🔍 Search Results for "fn main"
──────────────────────────────
📁 ./src/main.rs (1 match)
358: fn main() -> Result<(), Box<dyn std::error::Error>> {
📊 Statistics:
Files searched: 12
Matches found: 1
Time: 0.003s
Dead Code Detection
🔍 Dead Code Detection
──────────────────────────────
⚠️ Found 12 potential dead code items:
📄 src/example.rs
[var] L 10: variable 'unused_var' - Variable declared but never used
[!] L 25: unreachable - Code after return statement is unreachable
[∅] L 42: empty_helper - Empty function with no implementation
[?] L 58: // TODO: implement this - TODO marker - incomplete implementation
[imp] L 72: import 'HashMap' - Imported but never used
📊 Summary:
• variable: 3
• unreachable: 2
• empty: 2
• todo: 3
• import: 2
Complexity Analysis
📊 Code Complexity Analysis
──────────────────────────────
📁 Files by Complexity (highest first):
src/search.rs
Cyclomatic: 45 Cognitive: 38 Lines: 645
src/analysis.rs
Cyclomatic: 28 Cognitive: 22 Lines: 378
Supported Languages
48+ languages including: Rust, Python, JavaScript, TypeScript, Go, Java, C/C++, Ruby, PHP, Swift, Kotlin, and more.
See ARCHITECTURE.md for technical details.
License
Apache-2.0 License
Built with Rust • Fast • Precise • 48+ Languages