codegraph
Skill này làm gì
Skill này xây dựng chỉ mục cho một codebase và dùng nó để trả lời các câu hỏi về cấu trúc, như ai gọi một hàm hoặc đoạn mã rủi ro nhất nằm ở đâu. Skill dành cho lập trình viên muốn hiểu các dự án lớn.
Khi nào nên dùng
- ✓Khi bạn cần biết ai gọi một hàm hoặc nó phụ thuộc vào cái gì.
- ✓Khi bạn muốn tìm mã chết, điểm nóng hoặc sự gắn kết giữa các module trong một dự án.
- ✓Khi bạn muốn biết một thay đổi sẽ ảnh hưởng đến những gì trước khi thực hiện nó.
Liên kết skill
https://github.com/QwenLM/qwen-code/blob/main/.qwen/skills/codegraph/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
“Hãy lập chỉ mục dự án này và cho tôi thấy các hàm mà không có gì gọi đến, cùng các điểm nóng lớn nhất.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent lập chỉ mục mã nguồn thành một đồ thị gồm hàm, lệnh gọi, import và lịch sử, cùng các embedding để tìm kiếm theo ý nghĩa. Sau đó nó chạy các truy vấn đồ thị và báo cáo, như chuỗi gọi, phụ thuộc và phân tích tác động.
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.
CodeScope Q&A
CodeScope indexes source code into a two-layer knowledge graph — structure (functions, calls, imports, classes, modules) and evolution (commits, file changes, function modifications) — plus semantic embeddings for every function. Supports Python, JavaScript/TypeScript, C, and Java (including Hadoop-scale repositories with 8K+ files). This combination enables analyses that grep, LSP, or pure vector search cannot do alone. It can also fetch GitHub issues and trace bugs to code, and review open PRs — scoring per-PR risk, detecting cross-PR conflicts, identifying auto-merge candidates, and applying GitHub labels.
When to Use This Skill
- User asks about call chains, callers, callees, or dependencies
- User wants to find dead code, hotspots, or architectural layers
- User asks about code history, who changed what, or why something was modified
- User wants to find semantically similar functions across a codebase
- User wants a full architecture analysis or report
- User asks about module coupling, circular dependencies, or bridge functions
- User wants to index or analyze a Java project (Maven, Gradle, plain Java)
- User wants to analyze GitHub issues or bug reports to find root causes
- User asks "why does this project have so many bugs" or "what code is most buggy"
- User wants to trace a bug report to the most relevant code locations
- User asks about class relationships, ownership, composition, or wants a class diagram / UML
- User wants to understand which classes own or depend on other classes
- User wants to review PRs, assess PR risk, or prioritize PR reviews
- User asks about cross-PR conflicts or which PRs can be merged independently
- User wants to find auto-merge candidates or generate a PR review report
- User asks about the blast radius or impact scope of a PR
- User wants to apply labels to PRs from analysis results
- User wants to explore PR-specific follow-up questions for a given PR
- A
.codegraphdirectory (or similar index) exists in the workspace
Getting Started
Installation
pip install codegraph-ai
Environment Variables (optional)
# Create Python virtural environment
python -m venv .venv
source .venv/bin/activate
# Point to a pre-built database (skip indexing)
export CODESCOPE_DB_DIR="/path/to/.linux_db"
# Offline mode for HuggingFace models
export HF_HUB_OFFLINE="1"
# Fallback when HuggingFace is unreachable (e.g., network issues in China)
# Use HF mirror or ModelScope for sentence-transformers models:
export HF_ENDPOINT="https://hf-mirror.com"
# https://www.modelscope.cn/models/sentence-transformers/all-MiniLM-L6-v2
Check Index Status
codegraph status --db $CODESCOPE_DB_DIR
If no index exists, create one:
codegraph init --repo . --lang auto --commits 500
Supported languages: python, c, javascript, typescript, java, or auto (auto-detects from file extensions).
The --commits flag ingests git history (for evolution queries). Without it, only structural analysis is available. Add --backfill-limit 200 to also compute function-level MODIFIES edges (slower but enables change_attribution and co_change).
To add git history to an existing index (without re-indexing structure):
codegraph ingest --repo . --db $CODESCOPE_DB_DIR --commits 500
codegraph ingest --repo . --db $CODESCOPE_DB_DIR --backfill-limit 200 # add MODIFIES edges only
Two Interfaces: CLI vs Python
Use the CLI for status and reports:
codegraph status --db $CODESCOPE_DB_DIR
codegraph analyze --db $CODESCOPE_DB_DIR --output report.md
Use the Python API for queries and custom analyses:
import os
os.environ['HF_HUB_OFFLINE'] = '1' # required
from codegraph.core import CodeScope
cs = CodeScope(os.environ['CODESCOPE_DB_DIR'])
# Cypher query
rows = list(cs.conn.execute('''
MATCH (caller:Function)-[:CALLS]->(f:Function {name: "free_irq"})
RETURN caller.name, caller.file_path LIMIT 10
'''))
for r in rows:
print(r)
cs.close() # always close when done
The Python API is more powerful — it gives you raw Cypher access and lets you chain queries.
Core Python API
Raw Queries
These are the building blocks for any custom analysis:
| Method | What it does |
|---|
Câu hỏi thường gặp
Skill hỗ trợ những ngôn ngữ nào?
Skill hỗ trợ Python, JavaScript, TypeScript, C và Java.
Phân tích tác động là gì?
Đó là cho thấy những đoạn mã khác có thể bị ảnh hưởng bởi một thay đổi, dựa trên đồ thị gọi.
Có tìm được mã theo ý nghĩa không?
Có. Skill dùng chỉ mục vector để tìm các hàm có ngữ nghĩa tương tự.
Chi tiết
Mô tả gốc của tác giả
Analyze indexed codebases via graph database (neug) and vector index (zvec). Covers call graphs, dependencies, dead code, hotspots, module coupling, architecture reports, semantic search, impact analysis, bug root cause from GitHub issues, class diagrams (UML), and PR review (risk scoring, conflict detection, auto-merge candidates, labeling). Also covers creating, inspecting, and repairing a CodeScope index. Use for: code structure, who calls what, why something changed, similar functions, module boundaries, bug tracing, class relationships, PR risk/conflicts, or any question benefiting from a
repo: QwenLM/qwen-code
Độ phổ biến
- Sao GitHub
- 29k
- Vị trí xếp hạng
- #9768
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
qwen-code-claw
29kGiúp agent của bạn giao các tác vụ lập trình cho Qwen Code, như tìm hiểu codebase, sửa lỗi, tái cấu trúc mã hoặc tạo một dự án mới.
structured-debugging
29kDạy agent của bạn cách gỡ lỗi khó theo từng bước: đặt giả thuyết, thêm kiểm tra có mục tiêu, kiểm thử và tìm nguyên nhân thật trước khi sửa.
tmux-real-user-testing
29kGiúp agent của bạn kiểm thử một ứng dụng terminal như người dùng thật trong tmux, lưu nhật ký từng bước dễ đọc kèm ảnh chụp màn hình của mỗi hành động.
generated-ui
29kCho phép agent của bạn hiển thị một máy tính, mô phỏng hoặc so sánh tương tác ngay trong cuộc trò chuyện, để bạn có thể thay đổi đầu vào và xem kết quả.
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á.