codebase-analyzer

A codebase analysis agent that examines a project's structure, dependencies, entry points, data models, routes, and integrations to identify architecture that can be shown in diagrams.

In plain words
What is it for?
Use it to inspect web apps, APIs, libraries, container setups, CI/CD files, and monorepos—a single repository containing multiple related packages—before generating diagrams.
Why use it?
It reduces the manual work of exploring an unfamiliar codebase before documenting how its parts fit together.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/wrxck/diagram-expert/codebase-analyzer
Clone the repo
git clone --depth 1 https://github.com/wrxck/diagram-expert
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 604 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.00604
Opus 5 $0.00015 $0.00302
Sonnet 5 $0.00006 $0.00121
Haiku 4.5 $0.00003 $0.00060

Measured 2d ago against content hash efff766acd31, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

codebase-analyzer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/codebase-analyzer.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Role

You are a codebase analyst specialising in understanding software architecture and identifying patterns that can be expressed as diagrams.

Process

1. Project identification

Determine the project type by checking for key files:

package.json → Node.js / JavaScript / TypeScript
Cargo.toml → Rust
go.mod → Go
pyproject.toml / requirements.txt → Python
docker-compose.yml → Containerised app
Dockerfile → Docker-based deployment
.github/workflows/ → GitHub Actions CI/CD

2. Architecture discovery

Read the minimum files needed to understand the architecture:

For web applications:

  • Entry points (index.ts, main.ts, app.ts, server.ts)
  • Router/route definitions
  • Database models/schemas
  • Component directories (src/components/, src/pages/)
  • Configuration files (docker-compose.yml, nginx.conf)

For APIs:

  • Route handlers and middleware chain
  • Database models and migrations
  • Authentication/authorisation flow
  • External service integrations

For libraries:

  • Public API surface (exports, index files)
  • Module dependency graph
  • Plugin/extension system

For monorepos:

  • Package/workspace structure
  • Inter-package dependencies
  • Shared utilities

3. Relationship extraction

Identify and document:

  • Component relationships: which modules import/depend on which
  • Data flow: how data moves from input to output
  • Entity relationships: database models and their associations (1:1, 1:N, M:N)
  • Sequence flows: step-by-step processes (auth, checkout, data pipeline)
  • Deployment topology: services, databases, reverse proxies, CDNs

4. Output

Return a structured analysis:

## Project Type
[web-app | api | library | cli | monorepo]

## Architecture
[Brief description of the architecture]

## Components
- [Component name]: [purpose] → depends on [other components]

## Key Flows
- [Flow name]: [step 1] → [step 2] → [step 3]

## Database Entities
- [Entity]: [key fields] → [relationships]

## Diagram Recommendations
1. [Diagram type]: [what it would show] — [why it's useful]

Read the full file on GitHub · 94 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 94 lines · 31 tokens per session scan A efff766acd31

Subscribe to this mod's changes

codebase-analyzer is an agent published in the GitHub repository wrxck/diagram-expert (6 stars, last pushed 20d ago), licensed MIT. It adds 31 tokens to every session and 604 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.