Codemap 技能验证
- 作者仓库星标 22
- 许可证 MIT
- 作者仓库 archflow
CodeMap - Codebase Structural Index
Navigate codebases efficiently using pre-built structural indexes stored in .codemap/ directories.
When to Use This Skill
USE CodeMap when:
- Finding where a class, function, method, or type is defined
- Understanding a file's structure before reading it
- Searching for symbols by name
- Reducing token usage during codebase exploration
READ full files when:
- Understanding implementation details
- Making edits to code
- The symbol isn't in the index (new/untracked file)
Quick Reference
# Find a symbol by name (case-insensitive)
codemap find "SymbolName"
# Filter by type
codemap find "handle" --type method
codemap find "User" --type class
codemap find "Config" --type interface
# Show file structure with all symbols
codemap show path/to/file.ts
# Check if index is up-to-date
codemap validate
# View index statistics
codemap stats
Workflow: Finding Code
Step 1: Find Symbol Location
codemap find "UserService"
Output:
src/services/user.ts:15-189 [class] UserService
(config: Config)
Step 2: Read Only Relevant Lines
Instead of reading the entire file, read just lines 15-189:
Read src/services/user.ts lines 15-189
Step 3: Explore Nested Symbols
codemap show src/services/user.ts
Output:
File: src/services/user.ts (hash: a3f2b8c1)
Lines: 542
Language: typescript
Symbols:
- UserService [class] L15-189
- constructor [method] L20-35
- getUser [method] L37-98
(userId: string) : Promise<User>
- createUser [async_method] L100-145
(data: CreateUserDto) : Promise<User>
Symbol Types
| Type | Description |
|---|---|
class |
Class declaration |
function |
Function declaration |
method |
Class method |
async_function |
Async function |
async_method |
Async class method |
interface |
TypeScript interface |
type |
TypeScript type alias |
enum |
Enum declaration |
Index Structure
The .codemap/ directory mirrors the project structure:
.codemap/
├── .codemap.json # Root manifest
├── _root.codemap.json # Files in project root
├── src/
│ ├── .codemap.json # Files in src/
│ └── services/
│ └── .codemap.json # Files in src/services/
Direct JSON Access
For programmatic access, read the JSON files directly:
cat .codemap/src/services/.codemap.json
Validation
Before trusting cached line numbers (especially after context compaction):
codemap validate path/to/file.ts
- "up to date": Line ranges are valid
- "stale": File changed, re-read or run
codemap update
Setup (If Not Initialized)
If a project doesn't have a .codemap/ directory:
Prerequisites
- Python 3.10+ and pip must be installed
- Verify with:
python3 --version && pip --version
Installation
# Install codemap from GitHub (NOT from PyPI - there's a different package there)
pip install git+https://github.com/AZidan/codemap.git
# Initialize index
codemap init .
IMPORTANT: Do NOT use pip install codemap - that installs a different package from PyPI. Always use the GitHub URL above.
Start Watch Mode (Recommended)
Start watch mode in the background to keep the index automatically updated:
codemap watch . &
This runs in the background and updates the index whenever files change. No need to manually run codemap update.
To stop watch mode later:
pkill -f "codemap watch"
Best Practices
- Search before scanning: Always try
codemap findbefore grep/glob - Use line ranges: Read specific line ranges instead of full files
- Check freshness: Use
codemap validatebefore trusting cached line numbers - Explore structure first: Use
codemap showto understand file layout before diving in
Example Session
Task: "Fix the authentication bug in the login handler"
# 1. Find relevant symbols
codemap find "login"
# → src/auth/handlers.ts:45-92 [function] handleLogin
# 2. Check file structure
codemap show src/auth/handlers.ts
# Shows handleLogin and related functions with line ranges
# 3. Read only the relevant function (lines 45-92)
# ... make your fix ...
# 4. If you need related code, find it
codemap find "validateToken"
# → src/auth/utils.ts:12-38 [function] validateToken- 流狐分类
- 通用
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @AZidan · MIT
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 即装即用
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- Python >=3.10
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Workflow: Finding Code
Output:
Instead of reading the entire file, read just lines 15-189:
Output:
# CodeMap - Codebase Structural Index
Navigate codebases efficiently using pre-built structural indexes stored in `.codemap/` directories.
## When to Use This Skill
**USE CodeMap when:**
- Finding where a class, function, method, or type is defined
- Understanding a file's structure before reading it
- Searching for symbols by name
- Reducing token usage during codebase exploration
**READ full files when:**
- Understanding implementation details
- Making edits to code
- The symbol isn't in the index (new/untracked file)
## Quick Reference
```bash
# Find a symbol by name (case-insensitive)
codemap find "SymbolName"
# Filter by type
codemap find "handle" --type method
codemap find "User" --type class
codemap find "Config" --type interface
# Show file structure with all symbols
codemap show path/to/file.ts
# Check if index is up-to-date
codemap validate
# View index statistics
codemap stats
```
## Workflow: Finding Code
### Step 1: Find Symbol Location
```bash
codemap find "UserService"
```
Output:
```
src/services/user.ts:15-189 [class] UserService
(config: Config)
```
### Step 2: Read Only Relevant Lines
Instead of reading the entire file, read just lines 15-189:
```
Read src/services/user.ts lines 15-189
```
### Step 3: Explore Nested Symbols
```bash
codemap show src/services/user.ts
```
Output:
```
File: src/services/user.ts (hash: a3f2b8c1)
Lines: 542
Language: typescript
Symbols:
- UserService [class] L15-189
- constructor [method] L20-35
- getUser [method] L37-98
(userId: string) : Promise<User>
- createUser [async_method] L100-145
(data: CreateUserDto) : Promise<User>
```
## Symbol Types
| Type | Description |
|------|-------------|
| `class` | Class declaration |
| `function` | Function declaration |
| `method` | Class method |
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> When to Use This Skill → Quick Reference → Workflow: Finding Code → Step 1: Find Symbol Location → Step 2: Read Only Relevant Lines → Step 3: Explore Nested Symbols
要点 -> USE CodeMap when · READ full files when · IMPORTANT · Search before scanning · Use line ranges · Check freshness · Explore structure first
文件/命令 -> .codemap/ · class · function · method · asyncfunction · asyncmethod · interface · type
内容 SHA-256 -> 0bbf92fb95e6
方法与流程
适用与边界
原文中的明确线索
.codemap/、class、function、method、asyncfunction、asyncmethod、interface、type