codemap

A command that scans a software project and generates compact architecture documents. The documents summarize the technology stack, folders, APIs, important files, and relationships between modules.

In plain words
What is it for?
Use it to document a whole project or a selected backend or frontend area, including routes, module structure, dependencies, file responsibilities, and change metadata.
Why use it?
It turns a large or unfamiliar codebase into a quick map for developers and coding agents. An update mode can compare file changes and refresh only the affected documentation when the change is small.

Command

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/xiaobei930/cc-best/codemap
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best
Per session 19 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 963 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.00019 $0.00963
Opus 5 $0.00010 $0.00481
Sonnet 5 $0.00004 $0.00193
Haiku 4.5 $0.00002 $0.00096

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

Security

Grade A, and why

codemap 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.

commands/codemap.md · 103 lines

How it starts

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

/codemap - 代码架构文档

自动扫描项目结构,生成 token 优化的架构文档。

用法

/cc-best:codemap                 # 生成完整 codemap
/cc-best:codemap --update        # 仅更新变化部分
/cc-best:codemap --scope backend # 仅后端

工作流程

Step 1: 项目扫描

  • 扫描项目目录结构(排除 node_modules、.git、dist 等)
  • 识别框架和技术栈(package.json、go.mod、requirements.txt、pom.xml 等)
  • 按区域分类:frontend / backend / database / integrations / workers

Step 2: 架构提取

对每个区域提取关键信息:

提取项 说明 示例
路由/API 端点 URL → Handler 映射 GET /api/users → UserController
组件/模块层级 目录结构 → 职责划分 src/auth/ → 认证模块
关键文件 文件名 + 职责 + 行数 auth.ts (认证中间件, 120L)
依赖关系 模块间导入/调用关系 auth → database → cache

Step 3: 文档生成

输出到 docs/CODEMAPS/ 目录:

docs/CODEMAPS/
├── overview.md        # 项目总览(技术栈、目录结构、模块划分)
├── frontend.md        # 前端架构(如有)
├── backend.md         # 后端架构(如有)
└── _meta.json         # 生成元数据(时间、范围、文件数、hash)

文档格式要求

  • Token 优化:避免冗余注释,使用紧凑表格
  • 元数据头:生成时间、扫描范围、文件数
  • 每个文件说明限 1 行(文件名 + 职责 + 行数)

Step 4: 变化检测(--update 模式)

读取上次 _meta.json → 对比当前文件 hash
    │
    ├─ 变化 ≤ 30% → 自动增量更新
    └─ 变化 > 30% → 提示用户确认全量重建

输出格式示例

# Project Codemap

Generated: 2026-02-24 | Files: 127 | Scope: all

## Tech Stack

- Runtime: Node.js 20 + TypeScript 5.3
- Framework: Express + React 18
- Database: PostgreSQL + Redis

## Module Map

| Module     | Path        | Files | Purpose       |
| ---------- | ----------- | ----- | ------------- |
| auth       | src/auth/   | 8     | 认证与授权    |
| api        | src/api/    | 15    | REST API 端点 |
| models     | src/models/ | 12    | 数据模型      |
| components | src/ui/     | 34    | React 组件    |

## Key Files

| File              | Lines | Purpose      |
| ----------------- | ----- | ------------ |
| src/auth/jwt.ts   | 120   | JWT 令牌管理 |
| src/api/routes.ts | 85    | 路由注册     |
| src/db/migrate.ts | 200   | 数据库迁移   |

Read the full file on GitHub · 103 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 · 103 lines · 19 tokens per session scan A 58e276dda817

Subscribe to this mod's changes

codemap is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 19 tokens to every session and 963 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-30.