data-structure-protocol
Skill này làm gì
Công cụ này giúp AI hiểu cấu trúc của một dự án mã nguồn, cách các phần kết nối và lý do tồn tại của chúng. Nhờ đó, AI có thể điều hướng và sửa đổi mã hiệu quả hơn mà không phải đọc lại mọi thứ.
Khi nào nên dùng
- ✓Khi AI cần hiểu cách một dự án mã nguồn được tổ chức.
- ✓Trước khi thực hiện thay đổi lớn về mã để biết điều gì có thể bị ảnh hưởng.
- ✓Khi bạn muốn AI giúp lập bản đồ hoặc sắp xếp một dự án.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/data-structure-protocol/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm thế nào để tôi dùng DSP để hiểu các phụ thuộc giữa các module trong dự án của mình?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
DSP biến mã nguồn thành một bản đồ (đồ thị), trong đó mỗi phần là một “nút” và các kết nối là “cạnh”. Nó lưu thông tin về mục đích của mỗi phần và lý do của các kết nối, tất cả trong các file văn bản đơn giản.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Data Structure Protocol (DSP)
LLM coding agents lose context between tasks. On large codebases they spend most of their tokens on "orientation" — figuring out where things live, what depends on what, and what is safe to change. DSP solves this by externalizing the project's structural map into a persistent, queryable graph stored in a .dsp/ directory next to the code.
DSP is NOT documentation for humans and NOT an AST dump. It captures three things: meaning (why an entity exists), boundaries (what it imports and exposes), and reasons (why each connection exists). This is enough for an agent to navigate, refactor, and generate code without loading the entire source tree into the context window.
When to Use
Use this skill when:
- The project has a
.dsp/directory (DSP is already set up) - The user asks to set up DSP, bootstrap, or map a project's structure
- Creating, modifying, or deleting code files in a DSP-tracked project (to keep the graph updated)
- Navigating project structure, understanding dependencies, or finding specific modules
- The user mentions DSP, dsp-cli,
.dsp, or structure mapping - Performing impact analysis before a refactor or dependency replacement
Core Concepts
Code = graph
DSP models the codebase as a directed graph. Nodes are entities, edges are imports and shared/exports.
Two entity kinds exist:
- Object: any "thing" that isn't a function (module/file/class/config/resource/external dependency)
- Function: an exported function/method/handler/pipeline
Identity by UID, not by file path
Every entity gets a stable UID: obj-<8hex> for objects, func-<8hex> for functions. File paths are attributes that can change; UIDs survive renames, moves, and reformatting.
For entities inside a file, the UID is anchored with a comment marker in source code:
// @dsp func-7f3a9c12
export function calculateTotal(items) { ... }
# @dsp obj-e5f6g7h8
class UserService:
Every connection has a "why"
When an import is recorded, DSP stores a short reason explaining why that dependency exists. This lives in the exports/ reverse index of the imported entity. A dependency graph without reasons tells you what imports what; reasons tell you what is safe to change and who will break.
Storage format
Each entity gets a small directory under .dsp/:
.dsp/
├── TOC # ordered list of all entity UIDs from root
├── obj-a1b2c3d4/
│ ├── description # source path, kind, purpose (1-3 sentences)
│ ├── imports # UIDs this entity depends on (one per line)
│ ├── shared # UIDs of public API / exported entities
│ └── exports/ # reverse index: who imports this and why
│ ├── <importer_uid> # file content = "why" text
│ └── <shared_uid>/
│ ├── description # what is exported
│ └── <importer_uid> # why this specific export is imported
└── func-7f3a9c12/
├── description
├── imports
└── exports/
Everything is plain text. Diffable. Reviewable. No database needed.
Full import coverage
Every file or artifact that is imported anywhere must be represented in .dsp as an Object — code, images, styles, configs, JSON, wasm, everything. External dependencies (npm packages, stdlib, etc.) are recorded as kind: external but their internals are never analyzed.
How It Works
Initial Setup
The skill relies on a standalone Python CLI script dsp-cli.py. If it is missing from the project, download it:
curl -O https://raw.githubusercontent.com/k-kolomeitsev/data-structure-protocol/main/skills/data-structure-protocol/scripts/dsp-cli.py
Requires Python 3.10+. All commands use python dsp-cli.py --root <project-root> <command>.
Bootstrap (initial mapping)
If .dsp/ is empty, traverse the project from root entrypoint(s) via DFS on imports:
- Identify root entrypoints (
package.jsonmain, framework entry,main.py, etc.) - Document the root file:
create-object,create-functionfor each export,create-shared,add-importfor all dependencies - Take the first non-external import, document it fully, descend into its imports
- Backtrack when no unvisited local imports remain; continue until all reachable files are documented
- External dependencies:
create-object --kind external, add to TOC, but never descend intonode_modules/site-packages/etc.
…
Câu hỏi thường gặp
“Đồ thị” trong ngữ cảnh này là gì?
Đồ thị giống như một bản đồ kết nối. Hãy nghĩ đến các thành phố (phần mã) và đường đi (kết nối). DSP dùng cách này để thể hiện các phần mã liên kết với nhau thế nào.
Vì sao dùng UID thay vì đường dẫn file?
UID (Unique Universal Identifier) giống như tên cố định. Nếu bạn đổi tên hoặc di chuyển file, UID không thay đổi, nên các kết nối vẫn đúng. Đường dẫn file thì có thể thay đổi.
“Mỗi kết nối đều có lý do” nghĩa là gì?
Ngoài việc biết một phần mã dùng phần khác, DSP còn ghi lại lý do của kết nối đó. Điều này giúp AI hiểu liệu có an toàn để xóa hoặc thay đổi một kết nối mà không làm hỏng các phần khác của dự án hay không.
Chi tiết
Mô tả gốc của tác giả
Give agents persistent structural memory of a codebase — navigate dependencies, track public APIs, and understand why connections exist without re-reading the whole repo.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #4326
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.