codemap
它能做什么
这个技能为不熟悉的代码仓库构建分层地图,涵盖核心文件和结构。适合开始处理不熟悉代码库的开发者。
适用场景
- ✓你开始处理不熟悉的代码库,需要概览的时候。
- ✓有人要求提供仓库结构的文档或地图的时候。
- ✓你想找到核心代码,并跳过测试、文档和生成文件的时候。
技能链接
https://github.com/alvinunreal/oh-my-opencode-slim/blob/master/src/skills/codemap/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为这个仓库制作一份地图,让我在开始修改前看到主要代码的位置。”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能查看文件夹布局,挑出核心代码和配置文件,并将它们记录在地图文件中。之后的运行只检查有变化的部分。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Codemap Skill
You help users understand and map repositories by creating hierarchical codemaps.
When to Use
- User asks to understand/map a repository
- User wants codebase documentation
- Starting work on an unfamiliar codebase
Workflow
Step 1: Check for Existing State
First, check if .slim/codemap.json exists in the repo root.
If it does not exist, check for legacy state at .slim/cartography.json.
If legacy state exists: move .slim/cartography.json to .slim/codemap.json, then continue with change detection.
If .slim/codemap.json exists: Skip to Step 3 (Detect Changes) - no need to re-initialize.
If neither file exists: Continue to Step 2 (Initialize).
Step 2: Initialize (Only if no state exists)
- Analyze the repository structure - List files, understand directories
- Infer patterns for core code/config files ONLY to include:
- Include:
src/**/*.ts,package.json, etc. - Exclude (MANDATORY): Do NOT include tests, documentation, or translations.
- Tests:
**/*.test.ts,**/*.spec.ts,tests/**,__tests__/** - Docs:
docs/**,*.md(except rootREADME.mdif needed),LICENSE - Build/Deps:
node_modules/**,dist/**,build/**,*.min.js
- Tests:
- Respect
.gitignoreautomatically
- Include:
- Run codemap.mjs init (
scripts/codemap.mjsis relative to this skill's base directory — the host prints it asBase directory for this skill):
node scripts/codemap.mjs init \
--root ./ \
--include "src/**/*.ts" \
--exclude "**/*.test.ts" --exclude "dist/**" --exclude "node_modules/**"
This creates:
.slim/codemap.json- File and folder hashes for change detection- Empty
codemap.mdfiles in all relevant subdirectories
- Delegate codemap writing to Fixer agents - Spawn one fixer per folder to read code and create or update its specific
codemap.mdfile.
Step 3: Detect Changes (If state already exists)
- Run codemap.mjs changes to see what changed:
node scripts/codemap.mjs changes \
--root ./
Review the output - It shows:
- Added files
- Removed files
- Modified files
- Affected folders
Only update affected codemaps - Spawn one fixer per affected folder to update its
codemap.md.Run update to save new state:
node scripts/codemap.mjs update \
--root ./
Step 4: Finalize Repository Atlas (Root Codemap)
Once all specific directories are mapped, the Orchestrator must create or update the root codemap.md. This file serves as the Master Entry Point for any agent or human entering the repository.
- Map Root Assets: Document the root-level files (e.g.,
package.json,index.ts,plugin.json) and the project's overall purpose. - Aggregate Sub-Maps: Create a "Repository Directory Map" section. For every folder that has a
codemap.md, extract its Responsibility summary and include it in a table or list in the root map. - Cross-Reference: Ensure that the root map contains the absolute or relative paths to the sub-maps so agents can jump directly to the relevant details.
Step 5: Register Codemap in AGENTS.md
OpenCode auto-loads AGENTS.md into agent context on every session. To ensure agents automatically discover and use the codemap, update (or create) AGENTS.md at the repo root:
- If
AGENTS.mdalready exists and already contains a## Repository Mapsection, skip this step - the reference is already set up. - If
AGENTS.mdexists but has no## Repository Mapsection, append the section below. - If
AGENTS.mddoesn't exist, create it with the section below.
## Repository Map
A full codemap is available at `codemap.md` in the project root.
Before working on any task, read `codemap.md` to understand:
- Project architecture and entry points
- Directory responsibilities and design patterns
- Data flow and integration points between modules
For deep work on a specific folder, also read that folder's `codemap.md`.
This is idempotent - repeated codemap runs will detect the existing section and skip. No duplication.
Codemap Content
Fixers are responsible for writing codemap.md files during this workflow. Use precise technical terminology to document the implementation:
- Responsibility - Define the specific role of this directory using standard software engineering terms (e.g., "Service Layer", "Data Access Object", "Middleware").
- **Design Pat
常见问题
地图中包括测试和文档吗?
不包括。这个技能设置为将测试、文档和构建输出排除在核心地图之外。
这是一个快速任务吗?
不是。这个技能被描述为开销较大的操作,因此适用于仓库的首次映射。
地图保存在哪里?
保存在项目 .slim 文件夹中的 codemap 文件里。
详情
作者的原始描述
Generate comprehensive hierarchical codemaps for UNFAMILIAR repositories. Expensive operation - only use when explicitly asked for codebase documentation or initial repository mapping
热度
- GitHub 星标
- 10k
- 排名
- #12012
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …