For Claude Code Agents: This README is your entry point for guiding users through static analysis setup.
This package sets up fast, AI-friendly code navigation tools for large codebases:
- GNU Global - Symbol indexing and cross-referencing (10-100x faster than grep)
- Cscope - Call graph analysis (who calls what)
- LSP - Language Server Protocol for AST-accurate analysis
- Query Scripts - Simple interfaces for Claude to use these tools
Developers who want Claude to efficiently analyze large codebases using pre-indexed databases instead of slow grep/find operations.
When a user points you to this README and asks to set up static analysis, follow this workflow:
- Check OS and package manager
- Detect existing tools:
global --version,cscope --version,clangd --version - Report what's installed and what's missing
For each missing tool, guide user through installation:
- GNU Global: Run
install/install-global.sh - Cscope: Run
install/install-cscope.sh - LSP (clangd): Run
install/install-lsp.sh(optional)
Wait for user confirmation after each installation completes.
Ask user:
- Which repositories to index? (can be multiple)
- Full paths to each repository
- Confirm repositories exist and are readable
For each repository:
- Run
scripts/setup-static-analysis.sh <repo-path> - Report database sizes and generation time
- Verify databases created:
GTAGS,GRTAGS,GPATH,cscope.out
For each repository:
- Read
templates/git-exclude.template - Append patterns to
<repo>/.git/info/exclude - Verify static analysis databases won't be committed
Option A: Repository-Level (Recommended)
- Check if
<repo>/CLAUDE.mdexists - If exists: Append static analysis section from
templates/CLAUDE.md.template - If not exists: Create from template
- Copy
templates/STATIC_ANALYSIS_TOOLS.mdto<repo>/docs/or<repo>/.claude/
Option B: User-Level (Global)
- Check if
~/.claude/CLAUDE.mdexists - Append or create with template
- Place
STATIC_ANALYSIS_TOOLS.mdin~/.claude/
Ask user which approach they prefer.
For each repository:
- Copy
scripts/static-analysis-query.shto<repo>/.static-analysis-query.sh - Make executable:
chmod +x <repo>/.static-analysis-query.sh - Add to git exclude (should already be covered by pattern
.*)
Run verification tests:
- Execute
scripts/verify-setup.sh <repo-path> - Report results for each tool
- Ask user to try a manual query
Show user how to use the tools:
# Quick query (comprehensive)
cd <repo>
./.static-analysis-query.sh function_name
# Individual queries
global -x function_name # Where defined
global -rx function_name # Where called
cscope -d -L -3 function_name # Who calls this
cscope -d -L -2 function_name # What this callsExplain that Claude agents will automatically use these tools when available.
install-tools.sh- Main orchestrator (calls other scripts)install-global.sh- GNU Global installationinstall-cscope.sh- Cscope installationinstall-lsp.sh- clangd installation
setup-static-analysis.sh- Generate databases for a repositorystatic-analysis-query.sh- Unified query interface (template)verify-setup.sh- Test suite for validating setup
CLAUDE.md.template- Claude configuration with static analysisgit-exclude.template- Git exclude patternsSTATIC_ANALYSIS_TOOLS.md- Comprehensive tool documentation
settings.json.snippet- Optional Claude Code settings
- OS: Linux (Ubuntu/Debian tested), macOS (with Homebrew)
- Shell: bash or zsh
- Git: For repository management
- Build tools: gcc, make (for building Global/Cscope if needed)
After major code changes:
cd <repo>
gtags -iv # Incremental update
cscope -b -q -k # Rebuild cscopeOr regenerate completely:
cd <repo>
~/.../setup-static-analysis.sh $(pwd)Version: 1.0
Last Updated: 2026-08-03
License: MIT
Author: AMD Debugger Team