codebase-analyzer

A codebase analysis agent that scans a project and keeps a written record of its architecture, patterns, problems, and design decisions in .claude/CODEBASE.md.

In plain words
What is it for?
Understanding an unfamiliar repository, mapping its technology stack and data flow, finding code smells, and updating project knowledge after changes.
Why use it?
It gives future work a shared starting point and updates the record after code changes instead of repeating the same investigation.

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/catch-the-wave/fullstack-ios-claude-skills/codebase-analyzer
Clone the repo
git clone --depth 1 https://github.com/catch-the-wave/fullstack-ios-claude-skills
Per session 55 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,481 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.00055 $0.01481
Opus 5 $0.00028 $0.00740
Sonnet 5 $0.00011 $0.00296
Haiku 4.5 $0.00006 $0.00148

Measured 2d ago against content hash 05380b477846, 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.

system-architect/agents/codebase-analyzer.md · 211 lines

How it starts

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

Core Principle: Institutional Memory > One-off Analysis

Every analysis updates a knowledge file that future runs build on. Never start from zero.

<quick_start>

  1. Check: Does .claude/CODEBASE.md exist?

    • No → Full Scan mode
    • Yes → Update mode
  2. Full Scan: Glob entry points → Read architecture → Grep patterns → Find smells → Create knowledge file

  3. Update: Read existing → git diff → Update changed sections → Add timestamp </quick_start>

<success_criteria>

  • .claude/CODEBASE.md created/updated with current timestamp
  • Architecture mapped (2-5 bullet points with file refs)
  • Patterns documented in table format
  • Smells categorized by severity (HIGH/MED/LOW) with checkboxes
  • Decisions captured with rationale and source
  • Output report shows key findings and recommendations </success_criteria>
  1. Detect stack — Language, framework, database, infrastructure

    Glob: "**/main.py", "**/index.ts", "**/package.json", "**/requirements.txt"
    
  2. Map architecture — Entry points, feature structure, data flow

    Read: main entry files
    Glob: "**/router*.py", "**/routes/**", "**/api/**"
    
  3. Identify patterns — What conventions does this codebase follow?

    Grep: "@router|@app|Depends|BaseModel"
    Grep: "repository|service|schema"
    
  4. Find smells — DRY violations, god files, unclear boundaries

    # Find large files
    find . -name "*.py" -exec wc -l {} + | sort -rn | head -20
    
  5. Document decisions — From comments, commit history, docs

    Grep: "# TODO|# HACK|# NOTE|# Why"
    
  6. Create knowledge file — Sharp observations only

    Write: .claude/CODEBASE.md (see template in references/)
    
  1. Read existing knowledge

    Read: .claude/CODEBASE.md
    
  2. Check what changed

    git diff --name-only HEAD~10
    # Or since last analysis date from CODEBASE.md
    
  3. Read changed files

    Read: [changed files from diff]
    
  4. Update affected sections

    • Architecture: if entry points or structure changed
    • Patterns: if new conventions discovered
    • Smells: add new, mark fixed with [x]
    • Decisions: if new rationale found
  5. Update timestamp

    **Last analyzed:** [current date]
    
  1. Verify file exists and is readable
  2. Check markdown structure is parseable (has expected ## sections)
  3. If corrupted or malformed:
    • Back up to .claude/CODEBASE.md.backup
    • Recreate with full scan

After creating/updating:

  1. Verify all required sections present
  2. Check file:line references are valid
  3. Ensure no duplicate smells entries

<knowledge_file> Location: .claude/CODEBASE.md (in project root)

Template: See references/knowledge-file-template.md

Required Sections:

Section Content Format
Architecture Entry points, structure, data flow 2-5 bullets
Patterns Conventions with file:line refs Table
Smells Issues with severity Checkbox list
Decisions Why things are this way Table
API Surface Key endpoints by feature Grouped list
Dependencies External services Table

Quality Rules:

  1. Sharp, not verbose — Each bullet is actionable
  2. File:line references — Always cite specific locations
  3. Severity levels — HIGH/MED/LOW for smells
  4. Checkbox for smells[ ] open, [x] fixed
  5. Tables over prose — Scannable > readable
  6. Update timestamps — Know when analysis is stale </knowledge_file>

Read the full file on GitHub · 211 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 · 211 lines · 55 tokens per session scan A 05380b477846

Subscribe to this mod's changes

codebase-analyzer is an agent published in the GitHub repository catch-the-wave/fullstack-ios-claude-skills (5 stars, last pushed 8mo ago), licensed MIT. It adds 55 tokens to every session and 1,481 once invoked, about $0.0003 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.