Codebase Analysis
Full-codebase static analysis. Powers the architecture-expert subagent and the get_architecture_knowledge tool. Ask about your project’s structure and get answers grounded in real analysis instead of the LLM guessing.
Quick start
Section titled “Quick start”CodeBuddy: Analyze Codebase & Answer Questions (Cmd/Ctrl + Shift + 6)Progress notification during the scan. Once done, ask things like:
- “What architectural patterns does this project use?”
- “Show me all API endpoints”
- “What are the most-imported modules?”
- “Are there any circular dependencies?”
Languages
Section titled “Languages”Tree-sitter analysis for 7 languages:
| Language | Extensions |
|---|---|
| JavaScript | .js, .jsx, .mjs, .cjs |
| TypeScript | .ts, .tsx, .mts, .cts |
| Python | .py |
| Java | .java |
| Go | .go |
| Rust | .rs |
| PHP | .php, .phtml |
Plus config files (package.json, tsconfig.json, requirements.txt, pyproject.toml, go.mod, Cargo.toml, pom.xml, build.gradle, composer.json) and schema files (*.sql, schema.prisma) for dependency + model info.
What gets extracted
Section titled “What gets extracted”For each supported language, Tree-sitter pulls out classes / interfaces / structs / traits / enums (with methods, properties, decorators), functions (parameters, return types, export/async flags), imports + exports, React components (in JSX/TSX), and API endpoints via framework detection.
Framework endpoint detection:
| Language | Frameworks |
|---|---|
| JavaScript / TypeScript | Express, NestJS, Fastify, Hono |
| Python | FastAPI, Flask, Django |
| Java | Spring (@GetMapping etc.), JAX-RS |
| Go | Gin, Chi, Echo, net/http |
| Rust | Actix, Axum, Rocket |
| PHP | Laravel, Symfony |
NestJS decorators are parsed via the TypeScript compiler API for accurate parameter + return type extraction.
Architecture detection
Section titled “Architecture detection”ArchitectureDetector examines file-path patterns to identify layers and match patterns.
Layers detected: controllers, services, repositories, models, middleware, views, config, utils, tests.
Patterns matched with confidence scores:
| Pattern | Criteria |
|---|---|
| Layered architecture | Controllers + services + repositories |
| MVC | Controllers + models + views |
| Microservices | Multiple service directories |
| Frontend SPA | Components + views directories |
| Full-stack web app | Pages + components + API routes |
| CLI tool | cmd/ or commands/ directories |
| Library / SDK | src/ with no framework indicators |
| REST API | API endpoints + no frontend components |
Each detection includes confidence: “Layered Architecture (85% confidence)”.
Call graph
Section titled “Call graph”Import/dependency graph → extract:
- Node + edge counts (total modules + import relationships)
- Dependency hubs — most-imported modules (up to 8)
- Entry points — modules not imported by anything (up to 8)
- Circular dependencies — detected cycles (up to 5)
Middleware + auth
Section titled “Middleware + auth”For web apps:
- Auth strategies (JWT, OAuth, session-based, API key)
- Middleware chain — ordered pipeline (up to 10)
- Auth flows — login, register, token refresh (up to 5)
- Error handlers — count + source files
Caching
Section titled “Caching”Results cached in SQLite:
- Git state tracking — branch name + commit hash + diff hash stored with each analysis.
- Change detection — subsequent runs check git state; only re-analyze if significantly changed.
- Worker thread — analysis runs in a
worker_threadsWorker; UI stays responsive. - File limit — up to 1000 files per run.
- Cancellation — long analyses can be cancelled via the progress notification.
Excluded dirs: node_modules, dist, build, .git, .codebuddy, coverage, .next, .nuxt.
Cache management
Section titled “Cache management”| Command | Behavior |
|---|---|
| Show Cache Status | Panel with cache status, last analysis date, branch, file count, snapshot count, DB size |
| Clear Cache | Delete all snapshots (with confirmation) |
| Refresh Analysis | Force a fresh analysis regardless of cache state |
Architecture-expert access
Section titled “Architecture-expert access”The get_architecture_knowledge tool accepts a section:
| Section | Returns |
|---|---|
overview | Project type, entry points, frameworks, file count |
patterns | Architectural patterns with confidence scores |
call-graph | Import graph stats, hubs, circular deps |
middleware | Auth strategies, middleware chain, error handlers |
endpoints | API routes with method + source file |
models | Data models with property names |
all | Everything (capped at 12 000 chars) |
No data yet? The tool suggests running the analyze command first.
Branch-switch watcher
Section titled “Branch-switch watcher”CodeBuddy watches .git/HEAD. When you switch branches:
Branch changed to
feature/auth. Analyze now? [Analyze Now] · [Later]
Related
Section titled “Related”- Subagents —
architecture-expertrole - Code indexing — orthogonal indexer (chunks + embeddings)