cartography
Original:🇺🇸 English
Not Translated
2 scripts
Repository understanding and hierarchical codemap generation
1installs
Added on
NPX Install
npx skill4agent add ctrl-alt-del-1/oh-my-opencode-slim cartographySKILL.md Content
Cartography 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 exists in the repo root.
.slim/cartography.jsonIf it exists: Skip to Step 3 (Detect Changes) - no need to re-initialize.
If it doesn't exist: 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, etc.package.json - Exclude (MANDATORY): Do NOT include tests, documentation, or translations.
- Tests: ,
**/*.test.ts,**/*.spec.ts,tests/**__tests__/** - Docs: ,
docs/**(except root*.mdif needed),README.mdLICENSE - Build/Deps: ,
node_modules/**,dist/**,build/***.min.js
- Tests:
- Respect automatically
.gitignore
- Include:
- Run cartographer.py init:
bash
python3 ~/.config/opencode/skills/cartography/scripts/cartographer.py init \
--root ./ \
--include "src/**/*.ts" \
--exclude "**/*.test.ts" --exclude "dist/**" --exclude "node_modules/**"This creates:
- - File and folder hashes for change detection
.slim/cartography.json - Empty files in all relevant subdirectories
codemap.md
- Delegate to Explorer agents - Spawn one explorer per folder to read code and fill in its specific file.
codemap.md
Step 3: Detect Changes (If state already exists)
- Run cartographer.py changes to see what changed:
bash
python3 ~/.config/opencode/skills/cartography/scripts/cartographer.py changes \
--root ./-
Review the output - It shows:
- Added files
- Removed files
- Modified files
- Affected folders
-
Only update affected codemaps - Spawn one explorer per affected folder to update its.
codemap.md -
Run update to save new state:
bash
python3 ~/.config/opencode/skills/cartography/scripts/cartographer.py update \
--root ./Step 4: Finalize Repository Atlas (Root Codemap)
Once all specific directories are mapped, the Orchestrator must create or update the root . This file serves as the Master Entry Point for any agent or human entering the repository.
codemap.md- Map Root Assets: Document the root-level files (e.g., ,
package.json,index.ts) and the project's overall purpose.plugin.json - Aggregate Sub-Maps: Create a "Repository Directory Map" section. For every folder that has a , extract its Responsibility summary and include it in a table or list in the root map.
codemap.md - 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.
Codemap Content
Explorers are granted write permissions for files during this workflow. Use precise technical terminology to document the implementation:
codemap.md- Responsibility - Define the specific role of this directory using standard software engineering terms (e.g., "Service Layer", "Data Access Object", "Middleware").
- Design Patterns - Identify and name specific patterns used (e.g., "Observer", "Singleton", "Factory", "Strategy"). Detail the abstractions and interfaces.
- Data & Control Flow - Explicitly trace how data enters and leaves the module. Mention specific function call sequences and state transitions.
- Integration Points - List dependencies and consumer modules. Use technical names for hooks, events, or API endpoints.
Example codemap:
markdown
# src/agents/
## Responsibility
Defines agent personalities and manages their configuration lifecycle.
## Design
Each agent is a prompt + permission set. Config system uses:
- Default prompts (orchestrator.ts, explorer.ts, etc.)
- User overrides from ~/.config/opencode/oh-my-opencode-slim.json
- Permission wildcards for skill/MCP access control
## Flow
1. Plugin loads → calls getAgentConfigs()
2. Reads user config preset
3. Merges defaults with overrides
4. Applies permission rules (wildcard expansion)
5. Returns agent configs to OpenCode
## Integration
- Consumed by: Main plugin (src/index.ts)
- Depends on: Config loader, skills registryExample Root Codemap (Atlas):
markdown
# Repository Atlas: oh-my-opencode-slim
## Project Responsibility
A high-performance, low-latency agent orchestration plugin for OpenCode, focusing on specialized sub-agent delegation and background task management.
## System Entry Points
- `src/index.ts`: Plugin initialization and OpenCode integration.
- `package.json`: Dependency manifest and build scripts.
- `oh-my-opencode-slim.json`: User configuration schema.
## Directory Map (Aggregated)
| Directory | Responsibility Summary | Detailed Map |
|-----------|------------------------|--------------|
| `src/agents/` | Defines agent personalities (Orchestrator, Explorer) and manages model routing. | [View Map](src/agents/codemap.md) |
| `src/features/` | Core logic for tmux integration, background task spawning, and session state. | [View Map](src/features/codemap.md) |
| `src/config/` | Implements the configuration loading pipeline and environment variable injection. | [View Map](src/config/codemap.md) |