| Crates.io | go-brrr |
| lib.rs | go-brrr |
| version | 0.1.0 |
| created_at | 2026-01-17 09:54:32.027349+00 |
| updated_at | 2026-01-17 09:54:32.027349+00 |
| description | Token-efficient code analysis for LLMs - Rust implementation |
| homepage | |
| repository | https://github.com/GrigoryEvko/go-brrr |
| max_upload_size | |
| id | 2050209 |
| size | 6,283,864 |
Token-efficient code analysis for LLMs - High-performance Rust implementation.
____ ____ ____ ____
| __ )| _ \| _ \| _ \
| _ \| |_) | |_) | |_) |
| |_) | _ <| _ <| _ <
|____/|_| \_\_| \_\_| \_\
A blazing-fast CLI tool for extracting structured code information optimized for feeding context to Large Language Models. Achieves up to 95% token savings compared to raw source code by providing structured summaries, call graphs, and semantic search capabilities.
# Clone the repository
git clone https://github.com/GrigoryEvko/go-brrr
cd go-brrr
# Build with release optimizations
cargo build --release
# Install to ~/.cargo/bin
cargo install --path .
portable_simd feature)# Set nightly toolchain (required for SIMD)
rustup override set nightly
# Show file tree
brrr tree ./src --ext .rs
# Extract code structure
brrr structure . --lang rust
# Full file analysis
brrr extract src/main.rs
# Build call graph
brrr calls ./src
# Find dead code
brrr dead ./src
# Control flow graph
brrr cfg src/main.rs main
# Security scan
brrr security scan ./src
# Code metrics report
brrr metrics report ./src
# Semantic search (requires index)
brrr semantic index .
brrr semantic search "authentication handler" .
Display directory structure in JSON format.
brrr tree ./src # Default tree
brrr tree ./src --ext .rs .toml # Filter by extensions
brrr tree ./src --show-hidden # Include dotfiles
brrr tree ./src --max-depth 3 # Limit depth
Extract functions, classes, and methods from source files.
brrr structure . # Current directory
brrr structure ./src --lang python # Specific language
brrr structure ./src --limit 100 # Limit files analyzed
Full AST extraction from a single file.
brrr extract src/main.py
brrr extract src/api.py --class UserController
brrr extract src/api.py --function process_data
brrr extract src/api.py --method UserController.get_user
Regex pattern search with context lines.
brrr search "def process" ./src
brrr search "async fn" ./src --ext .rs
brrr search "TODO" . -C 2 --max 50
Generate control flow graph for a function.
brrr cfg src/main.py process_data
brrr cfg src/main.rs handle_request --format mermaid
brrr cfg src/main.go Process --format dot
Output formats: json (default), mermaid, dot
Generate data flow graph showing variable dependencies.
brrr dfg src/processor.py process_data
brrr dfg src/handler.rs handle --lang rust
Compute program slice - find lines affecting or affected by a target line.
# Backward slice: what affects line 42?
brrr slice src/main.py process 42
# Forward slice: what does line 10 affect?
brrr slice src/main.py process 10 --direction forward
# Track specific variable
brrr slice src/main.py process 42 --var result
# Extended output with metrics
brrr slice src/main.py process 42 --extended
Build cross-file call graph.
brrr calls ./src
brrr calls ./src --lang python
brrr calls ./src --extended # Include call line numbers
Find all callers of a function (reverse call graph).
brrr impact process_data ./src
brrr impact get_user ./src --depth 5
brrr impact critical_func ./src --file api
Find unreachable (dead) code.
brrr dead ./src
brrr dead ./src --entry main cli # Additional entry points
brrr dead ./src --lang python
Detect architectural layers from call patterns.
brrr arch ./src
brrr arch ./src --lang typescript
Parse import statements from a source file.
brrr imports src/main.py
brrr imports src/index.ts --lang typescript
Find all files that import a module.
brrr importers json ./src
brrr importers UserController ./src --lang python
Find tests affected by changed files.
brrr change-impact src/api.py # Specific files
brrr change-impact --git # Use git diff
brrr change-impact --session # Use session-modified files
brrr change-impact --run # Actually run affected tests
Build semantic index for a project.
brrr semantic index .
brrr semantic index ./src --lang python
brrr semantic index . --model all-MiniLM-L6-v2 # Smaller model (80MB)
brrr semantic index . --backend tei # Use TEI server
Search code using natural language queries.
brrr semantic search "authentication logic" .
brrr semantic search "database connection" ./src --k 10
brrr semantic search "error handling" . --expand # Include call graph
brrr semantic search "user validation" . --task code_retrieval
Manage the semantic index cache.
brrr semantic cache stats # Show cache statistics
brrr semantic cache clear # Clear all cached indexes
brrr semantic cache invalidate # Invalidate specific project
Show compute device and backend info.
brrr semantic device
Run all security analyzers.
brrr security scan ./src
brrr security scan ./src --severity high # Only high/critical
brrr security scan ./src --format sarif # SARIF output for CI
brrr security scan ./src --category injection # Only injection issues
brrr security scan ./src --fail-on high # Exit 1 if high+ found
brrr security sql-injection ./src
brrr security command-injection ./src
brrr security xss ./src
brrr security path-traversal ./src
brrr security secrets ./src
brrr security crypto ./src
brrr security deserialization ./src
brrr security redos ./src
Generate comprehensive metrics report.
brrr metrics report ./src
brrr metrics ./src # Shorthand
brrr metrics ./src --format text
brrr metrics ./src --fail-on critical # CI quality gate
brrr metrics ./src --thresholds strict # Stricter thresholds
Calculate cyclomatic complexity.
brrr metrics complexity ./src
brrr metrics complexity ./src --threshold 10 --sort
brrr metrics complexity ./src --violations-only
Calculate cognitive complexity (SonarSource methodology).
brrr metrics cognitive ./src
brrr metrics cognitive ./src --breakdown # Detailed contributions
Calculate Halstead complexity metrics.
brrr metrics halstead ./src
brrr metrics halstead ./src --sort-by-difficulty
brrr metrics halstead ./src --show-tokens
Calculate Maintainability Index.
brrr metrics maintainability ./src
brrr metrics maintainability ./src --threshold 50 --sort
brrr metrics maintainability ./src --include-comments
Calculate lines of code metrics.
brrr metrics loc ./src
brrr metrics loc ./src --by-language
brrr metrics loc ./src --function-threshold 50 --violations-only
Calculate nesting depth metrics.
brrr metrics nesting ./src
brrr metrics nesting ./src --threshold 5 --details
Calculate function size metrics.
brrr metrics functions ./src
brrr metrics functions ./src --sort-by sloc --violations-only
brrr metrics functions ./src --sloc-warn 30 --sloc-critical 60
Calculate coupling metrics for modules.
brrr metrics coupling ./src
brrr metrics coupling ./src --level module
brrr metrics coupling ./src --show-cycles --show-edges
Calculate class cohesion metrics (LCOM variants).
brrr metrics cohesion ./src
brrr metrics cohesion ./src --threshold 2 --show-components
Detect code clones (duplicate code).
brrr quality clones ./src
brrr quality clones ./src --min-lines 10
brrr quality clones ./src --include-tests
Detect structural code clones (Type-2/Type-3).
brrr quality structural-clones ./src
brrr quality structural-clones ./src --similarity 0.8
brrr quality structural-clones ./src --type2-only
Detect God classes violating SRP.
brrr quality god-class ./src
brrr quality god-class ./src --threshold 15
brrr quality god-class ./src --method-threshold 20 --attribute-threshold 15
Detect long methods with extraction suggestions.
brrr quality long-method ./src
brrr quality long-method ./src --max-lines 30 --max-complexity 10
brrr quality long-method ./src --show-suggestions
brrr quality long-method ./src --strict # Stricter thresholds
Detect circular dependencies.
brrr quality circular ./src
brrr quality circular ./src --level function
brrr quality circular ./src --max-suggestions 20
Detect design patterns.
brrr quality patterns ./src
brrr quality patterns ./src --pattern singleton
brrr quality patterns ./src --min-confidence 0.7
Run type checker and linter.
brrr diagnostics src/main.py
brrr diagnostics ./src --project
brrr diagnostics ./src --no-lint # Type checker only
Check and install diagnostic tools.
brrr doctor # Check all tools
brrr doctor --json # JSON output
brrr doctor --install python # Install Python tools
Start background daemon for faster queries.
brrr daemon start
brrr daemon start -p /path/to/project
Stop the daemon gracefully.
brrr daemon stop
Check daemon status.
brrr daemon status
Notify daemon of file changes.
brrr daemon notify src/changed_file.py
Pre-build call graph cache.
brrr warm ./src --lang python
brrr warm ./src --lang all --background
Create a .brrrignore file in your project root to exclude files from analysis. Uses gitignore syntax.
# Dependencies
node_modules/
.venv/
vendor/
target/
# Build outputs
dist/
build/
*.pyc
# IDE files
.idea/
.vscode/
# Security - always exclude
.env
*.pem
*.key
credentials.*
# Custom patterns
large_test_fixtures/
Project-specific configuration (optional).
[general]
default_language = "python"
[metrics]
cyclomatic_threshold = 10
cognitive_threshold = 15
maintainability_threshold = 50
[security]
fail_on_severity = "high"
include_suppressed = false
[semantic]
model = "bge-large-en-v1.5"
backend = "auto"
| Language | Tree-sitter | Call Graph | Metrics | Security |
|---|---|---|---|---|
| Python | Yes | Yes | Yes | Full |
| TypeScript | Yes | Yes | Yes | Full |
| JavaScript | Yes | Yes | Yes | Full |
| Go | Yes | Yes | Yes | Full |
| Rust | Yes | Yes | Yes | Full |
| Java | Yes | Yes | Yes | Full |
| C | Yes | Yes | Yes | Partial |
| C++ | Yes | Yes | Yes | Partial |
Additional languages supported for structure extraction only: Ruby, PHP, Kotlin, Swift, C#, Scala, Lua, Elixir
src/
|-- ast/ # AST extraction, file tree, code structure
|-- callgraph/ # Cross-file call graph, impact analysis, dead code
|-- cfg/ # Control flow graph builder and rendering
|-- dfg/ # Data flow graph and program slicing
|-- pdg/ # Program Dependence Graph (CFG + DFG)
|-- embedding/ # Vector index (usearch) and TEI gRPC client
|-- semantic/ # Semantic search, code chunking, unit extraction
|-- lang/ # Language-specific tree-sitter configurations
|-- metrics/ # All complexity and quality metrics
|-- security/ # Vulnerability scanners and taint analysis
|-- quality/ # Code smells, clones, patterns
|-- simd.rs # SIMD-accelerated operations
|-- util/ # Path validation, ignore patterns, helpers
All parsing is done through tree-sitter for consistent, fast, and accurate AST extraction across languages. Language grammars are included as dependencies:
tree-sitter 0.26tree-sitter-python 0.25tree-sitter-typescript 0.23tree-sitter-go 0.25tree-sitter-rust 0.24tree-sitter-java 0.23tree-sitter-c 0.24tree-sitter-cpp 0.23The src/simd.rs module provides portable SIMD operations:
sum_f32 / dot_product - 8x speedup for embedding similaritycount_byte / find_newlines - 32x speedup for line countingall_equal - Fast duplicate detectioncosine_similarity - Vectorized similarity computationfind_matching_u32 - Fast edge filtering in dataflow analysisTargets: x86_64 (SSE2/AVX2/AVX-512), aarch64 (NEON)
| Optimization | Impact | Use Case |
|---|---|---|
| jemalloc | 10-20% faster allocation | Heavy object creation |
| SIMD dot product | 8x throughput | Embedding similarity |
| SIMD byte search | 32x throughput | Line counting |
| Rayon parallelism | Linear scaling | Multi-file analysis |
| FxHash | 2x faster hashing | Hash maps |
| PHF | O(1) keyword lookup | Language detection |
| Aho-Corasick | Multi-pattern matching | Pattern detection |
| usearch HNSW | Sub-linear search | Semantic search |
| LRU cache | Avoid recomputation | Query embeddings |
Run benchmarks with:
cargo bench
Available benchmarks:
ast_parsing - Tree-sitter parse performanceast_extraction - Full file extractionflow_analysis - CFG/DFG constructionsemantic - Embedding and searchcallgraph - Call graph buildinge2e - End-to-end scenariosMost commands support multiple output formats:
--no-ignore # Ignore .brrrignore patterns
-v, -vv, -vvv # Verbosity levels (info, debug, trace)
--format # Output format (json, text, mermaid, dot, csv)
0 - Success1 - Error or findings above fail threshold2 - Invalid argumentsBRRR_LOG=debug # Set log level
BRRR_TEI_URL=... # TEI server URL for semantic search
RUST_BACKTRACE=1 # Enable backtraces for debugging
Add inline comments to suppress specific findings:
# brrr-ignore: SQLI-001
cursor.execute(query) # Known safe
# Also supports:
# nosec
# noqa
# security-ignore
Apache-2.0
Contributions are welcome. Please ensure:
cargo clippy without warningscargo test