Understand — Phân tích codebase

Tạo knowledge graph từ codebase để hiểu architecture, components, và dependencies. Hỗ trợ onboarding, code review, và impact analysis.
Sử dụng GitLab Knowledge Graph (GKG) engine bên dưới. Hỗ trợ go-to-definition, find-usages, impact analysis.

Cú pháp

/understand                      # Scan codebase, tạo knowledge graph
/understand-chat                 # Hỏi đáp về codebase dựa trên graph
/understand-dashboard            # Mở dashboard web để visualize graph
/understand-diff                 # Phân tích git diff/PR — affected components
/understand-explain "file/func"  # Giải thích sâu 1 file hoặc function
/understand-onboard              # Tạo onboarding guide cho thành viên mới

Bảng tham chiếu nhanh

LệnhMô tảUse case
/understandScan + build knowledge graphLần đầu phân tích codebase
/understand-chatHỏi đáp interactive về code”API auth flow hoạt động thế nào?”
/understand-dashboardWeb dashboard visualizeXem architecture diagram
/understand-diffPhân tích changesReview PR, impact analysis
/understand-explainDeep-dive 1 file/functionHiểu logic phức tạp
/understand-onboardGenerate onboarding guideThành viên mới join team

Luồng hoạt động

1

Bước 1: Scan codebase

Đọc toàn bộ source files, parse imports, exports, function calls.
2

Bước 2: Build knowledge graph

Tạo graph với nodes (files, functions, classes) và edges (imports, calls, dependencies).
3

Bước 3: Analyze patterns

Phát hiện architectural patterns, circular dependencies, coupling metrics.
4

Bước 4: Interactive query

Cho phép query graph: “file nào depend vào UserService?”, “component nào bị ảnh hưởng nếu đổi schema?”

Ví dụ thực tế

/understand-explain "src/modules/auth/auth.service.ts"
Output: Giải thích chi tiết từng method, dependencies, security flow.

GKG — GitLab Knowledge Graph

/gkg là engine bên dưới, cung cấp semantic code intelligence:
Tính năngMô tả
Go-to-definitionNhảy đến nơi function/class được define
Find-usagesTìm tất cả nơi sử dụng 1 symbol
Impact analysisĐánh giá ảnh hưởng khi thay đổi code
Dependency graphVisualize module dependencies

Khi nào dùng / không dùng

DùngKhông dùng
Onboarding thành viên mớiTìm 1 file cụ thể (dùng /scout)
Review PR phức tạpDebug lỗi (dùng /debug)
Hiểu legacy codebaseTask đơn giản, đã biết code
Đánh giá refactoring impactGenerate code (dùng /cook)