map-codebase

A codebase discovery workflow that explores a project and creates or updates an ARCHITECTURE.md file describing its structure, technologies, data flow, and entry points.

In plain words
What is it for?
Use it when starting work in an unfamiliar project, onboarding a teammate, or refreshing architecture documentation after major changes.
Why use it?
It gives developers a shared written map of an unfamiliar codebase, reducing the time spent guessing where things are and how they connect.

Command for Claude Code

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 commands/luutuankiet/gsd-lite/map-codebase
Clone the repo
git clone --depth 1 https://github.com/luutuankiet/gsd-lite

Made for: Claude Code.

Per session 23 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 783 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.00023 $0.00783
Opus 5 $0.00012 $0.00392
Sonnet 5 $0.00005 $0.00157
Haiku 4.5 $0.00002 $0.00078

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

Security

Grade A, and why

map-codebase 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 yesterday.

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.

template/.claude/commands/gsd/map-codebase.md · 105 lines

How it starts

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

Map Codebase Workflow

[SYSTEM: MAP-CODEBASE MODE - Codebase Discovery]

Initialization Check

Check if ARCHITECTURE.md exists in gsd-lite/:

  • If exists: Read it and propose to update/refresh
  • If missing: Create fresh from mapping

Coaching Philosophy

You are a thinking partner. Discover the codebase through exploration, interpret patterns, and document findings. Ask user to clarify purpose when code is ambiguous.


First Turn Protocol

First turn sequence:

  1. Check if ARCHITECTURE.md exists (silently)
  2. TALK to user: "I'm going to map your codebase structure. What should I know before I start exploring?"
  3. Only begin mapping AFTER user provides context

Mapping Process

Step 1: Discover Project Structure

Use Bash and Glob to understand directory layout:

  • Top-level structure
  • Second level key subdirectories
  • Build semantic understanding: entry points, core logic, infrastructure, support

Ask user if unclear: "I see directories [A], [B], [C]. Is [A] the main application code?"

Step 2: Identify Tech Stack

Read package manifests (package.json, pyproject.toml, go.mod, Cargo.toml, etc.). Extract:

  • Runtime and version
  • Language
  • 2-5 key dependencies that define architecture (NOT utilities)

Ask user: "Which 3-5 dependencies are critical to how this system works?"

Step 3: Trace Data Flow

Read entry points. Follow the flow:

  1. Where does request/input arrive?
  2. What components process it?
  3. Where does data persist or transform?
  4. How does response/output return?

Use Mermaid diagrams for complex flows, text for simple ones.

Step 4: Document Entry Points

Identify the 3-5 files that give fastest path to understanding. Format as bulleted list with paths and descriptions.

Step 5: Write ARCHITECTURE.md

Write to gsd-lite/ARCHITECTURE.md, preserving the two-zone skeleton:

Architecture

Mapped: [today's date]

How To Read This File - bounded-read contract, agents start here

[keep the template's block verbatim - it is the read contract every future agent depends on]

Read the full file on GitHub · 105 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. yesterday First seen · 105 lines · 23 tokens per session scan A bb79be7e7b64

Subscribe to this mod's changes

map-codebase is a command published in the GitHub repository luutuankiet/gsd-lite (2 stars, last pushed 24d ago), licensed MIT. It adds 23 tokens to every session and 783 once invoked, about $0.0001 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.