>-
Add this skill
npx mdskills install k-kolomeitsev/data-structure-protocolComprehensive graph-based structural memory system with clear agent instructions and full CLI
Graph-based long-term structural memory for LLM coding agents.
DSP externalizes your codebase “map” into a small, versionable graph stored in .dsp/: entities (modules/functions/external deps), dependencies (imports), public API (shared/exports), and reasons for every connection (why).
This repository ships:
ARCHITECTURE.mdarticle.mdskills/data-structure-protocol
SKILL.md (agent instructions)scripts/dsp-cli.py (reference CLI)references/ (storage format, operations, bootstrap procedure)Anyone who works with agents recognizes the pattern: the first 5–15 minutes are spent not on the task, but on “getting oriented.”
On small projects this is annoying. On large ones it becomes a constant tax on tokens and attention.
DSP reduces that tax by letting agents:
Honest trade-off: bootstrapping DSP for a large project is expensive (time, attention, often tokens).
It typically pays off over the lifetime of the project through lower token usage, faster dependency discovery, and more reliable agent execution.
DSP is NOT human-facing documentation and NOT an AST dump.
It captures:
purpose)imports, shared)exports/ reverse index)DSP works with any codebase and artifact system (TS/JS, Python, Go, infra, SQL, assets, configs, etc.).
┌──────────────────────┐
│ Codebase │
│ (files + assets) │
└──────────┬───────────┘
│ create/update graph as you work
▼
┌──────────────────────┐
│ DSP Builder / CLI │
│ (dsp-cli.py) │
└──────────┬───────────┘
│ writes
▼
┌──────────────────────┐
│ .dsp/ │
│ entity graph + whys │
└──────────┬───────────┘
│ reads/searches/traverses
▼
┌──────────────────────┐
│ LLM Orchestrator │
│ (your agent + skill) │
└──────────────────────┘
obj-, func-). File paths are attributes, not identity.imports: outgoing edges — what this entity uses.shared: public API of an object — what it exposes.exports/ reverse index: incoming edges — who imports this entity and why..dsp/TOC or .dsp/TOC-).For entities inside a file (exported functions/classes/etc.), DSP anchors identity with a comment marker:
// @dsp func-7f3a9c12
export function calculateTotal(items: Item[]): number { /* ... */ }
# @dsp func-3c19ab8e
def process_payment(order):
...
This stays stable across formatting, line shifts, and refactors.
.dsp/)DSP is intentionally simple: plain text files in a deterministic directory layout.
.dsp/
├── TOC # Table of contents (single root)
├── TOC- # One TOC per root (multi-root projects)
├── obj-a1b2c3d4/ # Object entity
│ ├── description # source, kind, purpose (+ optional freeform sections)
│ ├── imports # imported UIDs (one per line)
│ ├── shared # exported/shared UIDs (one per line)
│ └── exports/ # reverse index: who imports this entity and why
│ ├── # why the whole object is imported
│ └── / # per shared entity
│ ├── description # what is exported (auto-filled from shared's purpose)
│ └── # why this shared is imported
└── func-7f3a9c12/ # Function entity
├── description
├── imports
└── exports/
└── # ownership link (function belongs to object)
The full specification is in ARCHITECTURE.md and summarized in:
Bootstrap is a DFS traversal from root entrypoint(s). For each root:
kind: external, but do not descend into dependency internals (node_modules, site-packages, etc.).See:
Bootstrapping a large repo can be its own mini-project:
purposewhy for edges (this is where a lot of value lives)It typically pays back via:
data-structure-protocol skillThe skill is a compact package that teaches agents how to:
.dsp before touching code (search/find-by-source/read-toc)Skill location in this repo (universal layout):
skills/data-structure-protocol/SKILL.mdskills/data-structure-protocol/scripts/dsp-cli.pyskills/data-structure-protocol/references/*This repository keeps skills in skills/ so you can install them into whichever assistant you use.
Copy the skill into your project’s .cursor/skills/:
New-Item -ItemType Directory -Force .\.cursor\skills | Out-Null
Copy-Item -Recurse -Force .\skills\data-structure-protocol .\.cursor\skills\data-structure-protocol
skills/ is the universal, repo-friendly location. .cursor/skills/ is just Cursor’s installation target so the skill can be discovered/activated by Cursor.
If your assistant supports “skills” via a folder convention, copy skills/data-structure-protocol into the appropriate directory for that tool (for example: .claude/skills/, .continue/skills/, etc.).
The skill is plain Markdown + supporting files, so installation is typically just “copy the folder”.
str | None)The CLI is shipped with the skill. Pick the path you want to use:
# If your repo keeps skills in the universal root location:
$DSP_CLI = ".\skills\data-structure-protocol\scripts\dsp-cli.py"
# If you prefer running the copy installed into Cursor’s skill folder:
# $DSP_CLI = ".\.cursor\skills\data-structure-protocol\scripts\dsp-cli.py"
.dsp/python $DSP_CLI --root . init
# Create a module/file entity
python $DSP_CLI --root . create-object "src/app.ts" "Main application entrypoint"
# Create an exported function entity (owner = module UID)
python $DSP_CLI --root . create-function "src/app.ts#start" "Starts the HTTP server" --owner obj-a1b2c3d4
# Mark exports (public API)
python $DSP_CLI --root . create-shared obj-a1b2c3d4 func-7f3a9c12
# Record imports with a reason (why)
python $DSP_CLI --root . add-import obj-a1b2c3d4 obj-deadbeef "HTTP routing"
# Search by meaning/keywords
python $DSP_CLI --root . search "authentication"
# Find entities by source file path
python $DSP_CLI --root . find-by-source "src/auth/index.ts"
# Inspect one entity
python $DSP_CLI --root . get-entity obj-a1b2c3d4
# Downward dependency tree
python $DSP_CLI --root . get-children obj-a1b2c3d4 --depth 2
# Upward dependency tree / impact analysis
python $DSP_CLI --root . get-parents obj-a1b2c3d4 --depth inf
python $DSP_CLI --root . get-recipients obj-a1b2c3d4
Use this snippet as a “system/user” preface when you want an agent to respect DSP:
This project uses DSP (Data Structure Protocol).
The.dsp/directory is the entity graph of this project: modules, functions, dependencies, public API. It is your long-term memory of the code structure.Rules:
- Before changing code: locate affected entities via
search,find-by-source, orread-toc, then readdescription/imports.- When creating modules/functions/exports/imports: register them with DSP immediately (
create-object,create-function,create-shared,add-importwithwhy).- When moving/deleting: use
move-entity/remove-*to keep the graph consistent.- Do not update DSP for internal-only changes that don’t affect purpose/dependencies.
The CLI operations are intentionally aligned with the architecture specification.
ARCHITECTURE.md §5skills/data-structure-protocol/references/operations.mdKey commands (non-exhaustive):
init, create-object, create-function, create-shared, add-importupdate-description, update-import-why, move-entityremove-import, remove-shared, remove-entityget-entity, get-children, get-parents, get-path, read-tocdetect-cycles, get-orphans, get-statsDSP stays valuable only if it stays:
Rules of thumb:
why..dsp/ as a first-class artifact: review diffs, keep it consistent.Contributions that improve:
ARCHITECTURE.md)skills/data-structure-protocol/SKILL.md)…are welcome. Please keep changes minimal, explicit, and consistent with the “minimal sufficient context” philosophy.
This project is licensed under the Apache License 2.0. See LICENSE.
Install via CLI
npx mdskills install k-kolomeitsev/data-structure-protocolData Structure Protocol is a free, open-source AI agent skill. >-
Install Data Structure Protocol with a single command:
npx mdskills install k-kolomeitsev/data-structure-protocolThis downloads the skill files into your project and your AI agent picks them up automatically.
Data Structure Protocol works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.