This tool helps AI agents understand the Rocket.Chat codebase. It scans TypeScript files and creates compressed "skeletons" (summaries) of the code. This allows you to analyze large parts of the application without using too many tokens.
- Smart Scanning: Finds relevant files based on your question.
- Skeleton Generation: Removes function bodies to save space, keeping only structure and types.
- Module Scoping: Can focus on specific Rocket.Chat modules to reduce noise.
- Status: ✅ Passing (Core scanner, Scope enforcement, Benchmarks)
Tested on Rocket.Chat (apps/meteor) with real-world queries (Messaging, Auth, E2E):
| Metric | Result |
|---|---|
| Token Reduction (vs Full Scan) | ~96.5% |
| Token Reduction (vs Top-N) | ~78.2% |
| Average Execution Time | ~1.2s |
You can run the tool using npm run cli.
npm run cli -- --question "how are messages sent?"To get better results, tell the tool which part of Rocket.Chat to look at:
npm run cli -- --question "permission checks" --modules authorizationAvailable Modules:
lib-server-functionsauthorizatione2efile-upload
--question: (Required) The question you want to answer.--root: The folder to scan (default: current folder).--limit: How many files to return (default: 10).--modules: Comma-separated list of modules to filter by.--with-mapping: Creates a map of symbols to find definitions later.--skip-cache: Force full analysis without caching.
The tool caches analysis results for faster repeated queries. Cache is stored in .code-analyzer-cache/.
Cache management:
# View cache statistics
npm run cli -- --cache-stats
# Clear cache
npm run cli -- --cache-clear
# Skip cache for current query
npm run cli -- --question "how are messages sent?" --skip-cacheCache Details:
- Strategy: Hybrid (in-memory + persistent disk cache)
- Invalidation: MD5 file hashing (detects changes automatically)
- TTL: 24 hours
- Location:
.code-analyzer-cache/
Use this tool as an MCP (Model Context Protocol) server with Gemini CLI for AI-powered code analysis and benchmarking.
-
Build the extension:
npm run build cd gemini-extension && npm install && npm run build
-
Configure Gemini CLI:
Create or update
~/.gemini/config.json:{ "mcpServers": { "rc-code-analyzer": { "command": "node", "args": ["/path/to/code-analyzer/gemini-extension/dist/server.js"] } } } -
Run Gemini CLI:
cd /path/to/code-analyzer gemini
How are messages sent in Rocket.Chat?
How does user authentication work?
How are permissions checked?
What is the E2E encryption flow?
Gemini CLI will automatically use the scan_codebase tool to analyze relevant files and provide insights with token savings metrics.
- AI-Powered Analysis: Gemini CLI provides context-aware insights and suggestions.
- Token Efficiency: Skeletons reduce token usage by ~96.5% vs full scans.
- Easy Integration: Works seamlessly with Gemini CLI's MCP protocol.
- Benchmarking: Track token stats and performance across queries.
npm install
npm run buildFor Gemini CLI integration:
cd gemini-extension
npm install
npm run buildnpm testTo verify the Gemini CLI extension works correctly:
npm run build && node test-gemini-server.mjsThis tests tool discovery and the scan_codebase tool without requiring Gemini CLI.