data-structure-protocol
install
source · Clone the upstream repo
git clone https://github.com/k-kolomeitsev/data-structure-protocol
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/k-kolomeitsev/data-structure-protocol "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data-structure-protocol" ~/.claude/skills/k-kolomeitsev-data-structure-protocol-data-structure-protocol && rm -rf "$T"
manifest:
skills/data-structure-protocol/SKILL.mdsource content
Data Structure Protocol (DSP)
DSP builds a dependency graph of project entities in a
.dsp/ directory. Each entity (module, function, external dependency) gets a UID, description, import list, and export index. The graph answers: what exists, why it exists, what depends on what, and who uses what.
DSP is NOT documentation for humans or AST dump. It captures meaning (purpose), boundaries (imports/exports), and reasons for connections (why).
Agent Prompt
Embed this context when working on a DSP-tracked project:
This project uses DSP (Data Structure Protocol). The
directory is the entity graph of this project: modules, functions, dependencies, public API. It is your long-term memory of the code structure..dsp/Core rules:
- Before changing code — find affected entities via
,dsp-cli search, orfind-by-source. Read theirread-tocanddescriptionto understand context.imports- When creating a file/module — call
. For each exported function —dsp-cli create-object(withcreate-function). Register exports via--owner.create-shared- When adding an import — call
with a briefdsp-cli add-import. For external dependencies — firstwhyif the entity doesn't exist yet.create-object --kind external- When removing import / export / file — call
,remove-import,remove-sharedrespectively. Cascade cleanup is automatic.remove-entity- When renaming/moving a file — call
. UID does not change.move-entity- Don't touch DSP if only internal implementation changed without affecting purpose or dependencies.
- Bootstrap — if
is empty, traverse the project from root entrypoint via DFS on imports, documenting every file..dsp/Key commands:
dsp-cli init dsp-cli create-object <source> <purpose> [--kind external] [--toc ROOT_UID] dsp-cli create-function <source> <purpose> [--owner UID] [--toc ROOT_UID] dsp-cli create-shared <exporter_uid> <shared_uid> [<shared_uid> ...] dsp-cli add-import <importer_uid> <imported_uid> <why> [--exporter UID] dsp-cli remove-import <importer_uid> <imported_uid> [--exporter UID] dsp-cli remove-shared <exporter_uid> <shared_uid> dsp-cli remove-entity <uid> dsp-cli move-entity <uid> <new_source> dsp-cli update-description <uid> [--source S] [--purpose P] [--kind K] dsp-cli get-entity <uid> dsp-cli get-children <uid> [--depth N] dsp-cli get-parents <uid> [--depth N] dsp-cli search <query> dsp-cli find-by-source <path> dsp-cli read-toc [--toc ROOT_UID] dsp-cli get-stats
Using the CLI
The script is at
scripts/dsp-cli.py relative to this skill directory.
python <skill-path>/scripts/dsp-cli.py [--root <project-root>] <command> [args]
--root defaults to current working directory. All paths in arguments are repo-relative.
Core Concepts
- Code = graph. Nodes are Objects and Functions. Edges are
andimports
.shared/exports - Identity by UID, not file path. Path is an attribute; renames/moves don't change UID.
- "Shared" creates an entity. If something becomes public (exported), it gets its own UID.
- Import tracks both "from where" and "what". One code import may create two DSP links: to the module and to the specific shared entity.
- Full import coverage. Every imported file/asset must be an Object in
— code, images, styles, configs, everything..dsp
lives next to the imported entity in itswhy
directory (reverse index).exports/- Start from roots. Each root entrypoint has its own TOC file.
- External deps — record only.
, no deep dive intokind: external
/node_modules
/etc. Butsite-packages
works — shows who imports it.exports index
UID Format
- Objects:
(e.g.,obj-<8 hex>
)obj-a1b2c3d4 - Functions:
(e.g.,func-<8 hex>
)func-7f3a9c12
UID marker in source code — comment
@dsp <uid> before declaration:
// @dsp func-7f3a9c12 export function calculateTotal(items) { ... }
# @dsp obj-e5f6g7h8 class UserService:
Workflows
Setting Up DSP
- Run
to createdsp-cli init
directory..dsp/ - Identify root entrypoint(s) —
main, framework entry, etc.package.json - Run bootstrap (DFS from root). See bootstrap.md.
Creating Entities (when writing new code)
- Create module:
dsp-cli create-object <path> <purpose> - Create functions:
dsp-cli create-function <path>#<symbol> <purpose> --owner <module-uid> - Register exports:
dsp-cli create-shared <module-uid> <func-uid> [<func-uid> ...] - Register imports:
dsp-cli add-import <this-uid> <imported-uid> <why> [--exporter <module-uid>] - External deps:
dsp-cli create-object <package-name> <purpose> --kind external
Navigating the Graph (when reading/understanding code)
- Find entity by file:
dsp-cli find-by-source <path> - Search by keyword:
dsp-cli search <query> - Read TOC:
→ get all UIDs, thendsp-cli read-toc
for detailsget-entity - Dependency tree down:
dsp-cli get-children <uid> --depth N - Dependency tree up:
dsp-cli get-parents <uid> --depth N - Impact analysis:
— who depends on this entitydsp-cli get-recipients <uid> - Path between entities:
dsp-cli get-path <from> <to>
Updating (when modifying code)
- Purpose changed:
dsp-cli update-description <uid> --purpose <new> - File moved:
dsp-cli move-entity <uid> <new-path> - Import reason changed:
dsp-cli update-import-why <importer> <imported> <new-why>
Deleting (when removing code)
- Import removed:
dsp-cli remove-import <importer> <imported> [--exporter UID] - Export removed:
dsp-cli remove-shared <exporter> <shared> - File/module deleted:
(cascading cleanup)dsp-cli remove-entity <uid>
Diagnostics
— circular dependenciesdsp-cli detect-cycles
— unused entitiesdsp-cli get-orphans
— project graph overviewdsp-cli get-stats
When to Update DSP
| Code Change | DSP Action |
|---|---|
| New file/module | + + + |
| New import added | (+ if new external dep) |
| Import removed | |
| Export added | (+ if new function) |
| Export removed | |
| File renamed/moved | |
| File deleted | |
| Purpose changed | |
| Internal-only change | No DSP update needed |
References
- Storage format —
directory structure, file formats, TOC.dsp/ - Bootstrap procedure — initial project markup (DFS algorithm)
- Operations reference — detailed semantics of all operations with import examples