codemap
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodemap
Codemap
Codemap gives you instant architectural context about any codebase. Use it proactively before exploring or modifying code.
Codemap 可为你提供任意代码库的即时架构上下文信息。建议你在浏览或修改代码前主动使用它。
Commands
命令
bash
codemap . # Project structure and top files
codemap --deps # Dependency flow (imports/functions)
codemap --diff # Changes vs main branch
codemap --diff --ref <branch> # Changes vs specific branch
codemap handoff . # Build + save handoff artifact
codemap handoff --latest . # Read latest saved handoff
codemap handoff --json . # Machine-readable handoff payload
codemap handoff --since 2h . # Limit timeline lookback when building
codemap handoff --prefix . # Stable prefix snapshot only
codemap handoff --delta . # Recent delta snapshot only
codemap handoff --detail a.go . # Lazy-load full detail for one changed filebash
codemap . # 项目结构与核心文件
codemap --deps # 依赖流向(导入/函数)
codemap --diff # 与main分支的差异对比
codemap --diff --ref <branch> # 与指定分支的差异对比
codemap handoff . # 生成并保存交接工件
codemap handoff --latest . # 读取最近保存的交接信息
codemap handoff --json . # 机器可读格式的交接数据
codemap handoff --since 2h . # 生成时限制时间回溯范围(最近2小时)
codemap handoff --prefix . # 仅生成稳定前缀快照
codemap handoff --delta . # 仅生成近期增量快照
codemap handoff --detail a.go . # 懒加载某一变更文件的完整详情When to Use
使用场景
ALWAYS run codemap .
when:
codemap .以下场景请务必运行 codemap .
:
codemap .- Starting any new task or feature
- User asks "where is X?" or "what files handle Y?"
- User asks about project structure or organization
- You need to understand the codebase before making changes
- Exploring unfamiliar code
- 开始任何新任务或新功能开发时
- 用户询问“X在哪里?”或“哪些文件处理Y?”时
- 用户询问项目结构或组织方式时
- 你需要在修改代码前先理解代码库时
- 浏览不熟悉的代码时
ALWAYS run codemap --deps
when:
codemap --deps以下场景请务必运行 codemap --deps
:
codemap --deps- User asks "how does X work?" or "what uses Y?"
- Refactoring or moving code
- Need to trace imports or dependencies
- Evaluating impact of changes
- Finding hub files (most-imported)
- 用户询问“X如何工作?”或“哪些模块使用Y?”时
- 重构或迁移代码时
- 需要追踪导入关系或依赖链时
- 评估变更影响范围时
- 查找核心枢纽文件(被导入次数最多的文件)时
ALWAYS run codemap --diff
when:
codemap --diff以下场景请务必运行 codemap --diff
:
codemap --diff- User asks "what changed?" or "what did I modify?"
- Reviewing changes before commit
- Summarizing work done on a branch
- Assessing what might break
- Use when comparing against something other than main
--ref <branch>
- 用户询问“有哪些变更?”或“我修改了什么?”时
- 提交前审查变更内容时
- 总结分支上已完成的工作时
- 评估可能出现的问题时
- 若需与main以外的分支对比,使用 参数
--ref <branch>
ALWAYS run codemap handoff
when:
codemap handoff以下场景请务必运行 codemap handoff
:
codemap handoff- Handing work from one agent to another (Claude, Codex, MCP client)
- Resuming work after a break and you want a compact recap
- User asks "what should the next agent know?"
- You want a durable summary in
.codemap/handoff.latest.json
- 在不同Agent之间交接工作时(如Claude、Codex、MCP客户端)
- 中断后恢复工作,需要简洁的工作回顾时
- 用户询问“下一个Agent需要了解哪些信息?”时
- 你需要在 中保存持久化的工作摘要时
.codemap/handoff.latest.json
Output Interpretation
输出解读
Tree View (codemap .
)
codemap .树状视图(codemap .
)
codemap .- Shows file structure with language detection
- Stars (★) indicate top 5 largest source files
- Directories are flattened when empty (e.g., )
src/main/java
- 显示文件结构并自动检测语言类型
- 星号(★)标记前5个最大的源文件
- 空目录会被扁平化展示(例如 )
src/main/java
Dependency Flow (codemap --deps
)
codemap --deps依赖流向(codemap --deps
)
codemap --deps- External dependencies grouped by language
- Internal import chains showing how files connect
- HUBS section shows most-imported files
- Function counts per file
- 外部依赖按语言分组展示
- 内部导入链展示文件间的关联关系
- HUBS 部分展示被导入次数最多的文件
- 显示每个文件的函数数量
Diff Mode (codemap --diff
)
codemap --diff差异模式(codemap --diff
)
codemap --diff- = untracked file
(new) - = modified file
✎ - = lines added/removed
(+N -M) - Warning icons show files imported by others (impact analysis)
- = 未被追踪的新文件
(new) - = 已修改的文件
✎ - = 新增/删除的代码行数
(+N -M) - 警告图标表示被其他文件导入的文件(影响范围分析)
Handoff (codemap handoff
)
codemap handoff交接信息(codemap handoff
)
codemap handoff- layered output: (stable hubs/context) +
prefix(recent changed-file stubs + timeline)delta - changed file transport uses stubs (,
path,hash,status) for lower context costsize - highlights high-impact changed files when dependency context is available
risk_files - includes deterministic hashes (,
prefix_hash,delta_hash) and cache metricscombined_hash - reads saved artifact without rebuilding
--latest
- 分层输出:(稳定的枢纽文件/上下文) +
prefix(近期变更文件的存根信息 + 时间线)delta - 变更文件传输使用存根信息(、
path、hash、status)以降低上下文成本size - 当依赖上下文可用时,会高亮显示高影响的变更文件
risk_files - 包含确定性哈希值(、
prefix_hash、delta_hash)和缓存指标combined_hash - 参数可直接读取已保存的工件,无需重新生成
--latest
Daemon and Hooks
守护进程与钩子
- With daemon state: handoff includes richer timeline and better risk context.
- Without daemon state: handoff still works using git-based changed files.
- Hook behavior:
- writes
session-stop.codemap/handoff.latest.json - may show recent handoff summary (24h freshness window)
session-start - session-start structure output is capped/adaptive for large repos
- 开启守护进程状态时:交接信息包含更丰富的时间线和更精准的风险上下文
- 未开启守护进程状态时:交接信息仍可基于Git追踪的变更文件生成
- 钩子行为:
- 会写入
session-stop文件.codemap/handoff.latest.json - 可能会显示最近24小时内的交接摘要
session-start - 对于大型代码库,session-start输出的结构会自适应限制内容规模
Examples
示例
User asks: "Where is the authentication handled?"
Action: Run then to find auth-related files and trace their connections.
codemap .codemap --depsUser asks: "What have I changed on this branch?"
Action: Run to see all modifications with impact analysis.
codemap --diffUser asks: "How does the API connect to the database?"
Action: Run to trace the import chain from API to database files.
codemap --depsUser asks: "I want to refactor the utils module"
Action: Run first to see what depends on utils before making changes.
codemap --depsUser asks: "I'm switching to another agent, what should I pass along?"
Action: Run and share the summary (or for tools).
codemap handoff .--jsonUser asks: "I just came back, what was in progress?"
Action: Run and continue from that state.
codemap handoff --latest .用户提问: “认证功能在哪里实现?”
操作: 先运行 ,再运行 ,查找与认证相关的文件并追踪它们的关联关系。
codemap .codemap --deps用户提问: “我在这个分支上做了哪些修改?”
操作: 运行 查看所有修改内容及影响范围分析。
codemap --diff用户提问: “API是如何与数据库建立连接的?”
操作: 运行 追踪从API到数据库文件的导入链。
codemap --deps用户提问: “我想重构utils模块”
操作: 先运行 ,查看哪些模块依赖utils,再进行修改。
codemap --deps用户提问: “我要切换到另一个Agent,需要传递哪些信息?”
操作: 运行 并分享生成的摘要(或使用 参数生成工具可读格式)。
codemap handoff .--json用户提问: “我刚回来,之前在做什么?”
操作: 运行 ,基于该状态继续工作。
codemap handoff --latest .