gitnexus-refactoring
Skill này làm gì
Nó hướng dẫn agent của bạn tái cấu trúc mã, chẳng hạn đổi tên một hàm hoặc chuyển nó sang file mới, mà không làm hỏng các phần phụ thuộc vào nó. Nó dành cho lập trình viên cần tái cấu trúc an toàn và nhất quán.
Khi nào nên dùng
- ✓Khi bạn muốn đổi tên một hàm hoặc lớp trong toàn dự án một cách an toàn.
- ✓Khi bạn muốn tách một phần của file thành module riêng.
- ✓Khi bạn muốn chuyển hoặc chia một service lớn thành các file nhỏ hơn.
Liên kết skill
https://github.com/abhigyanpatwari/GitNexus/blob/main/.claude/skills/gitnexus-refactoring/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
“Bạn có thể đổi tên hàm calculateTotal thành computeTotal ở mọi nơi trong dự án này, và cho tôi xem các thay đổi trước không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent xác nhận kho mã, chạy bản xem trước của thay đổi và rà soát các file bị ảnh hưởng trước khi ghi bất cứ thứ gì. Chỉ sau đó nó mới áp dụng chỉnh sửa.
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.
Refactoring with GitNexus
When to Use
- "Rename this function safely"
- "Extract this into a module"
- "Split this service"
- "Move this to a new file"
- Any task involving renaming, extracting, splitting, or restructuring code
Bind the repository first
Refactoring writes to disk. rename with dry_run: false edits files in
whichever repository was resolved, so binding identity here is a safety gate,
not bookkeeping.
Call list_repos {} before the first tool call. With one indexed repository,
use the examples below as written. With more than one, pass repo on every
call: an omitted repo normally errors, but under an MCP policy with a
configured default it resolves to that default silently. If you cannot tell
which repository is meant, stop and ask. Never run rename with
dry_run: false until the preview in the same bound repository has been
reviewed — its returned file_path values show which checkout is about to be
written, so read them as a confirmation of identity.
list_repos is paginated, so page with offset: pagination.nextOffset until
hasMore is false before concluding a repository is absent.
detect_changes takes worktree when you are editing a linked worktree the
MCP server was not launched from; otherwise git diff runs in the wrong
checkout and reports nothing changed, which reads as a verified refactor.
Workflow
0. list_repos {} → Bind repo (and worktree)
1. impact({target: "X", direction: "upstream"}) → Map all dependents
2. query({search_query: "X"}) → Find execution flows involving X
3. context({name: "X"}) → See all incoming/outgoing refs
4. Plan update order: interfaces → implementations → callers → tests
If "Index is stale" → run
node .gitnexus/run.cjs analyzein terminal. Hot-toolstalenessnames which index answered (branch/lastCommit) and how fresh it is (status). Re-analyze only forbehindordiverged—currentis identity,unknownis unmeasurable.
Checklists
Rename Symbol
- [ ] list_repos {} — bind repo; explicit repo when >1 indexed, ask if ambiguous
- [ ] rename({symbol_name: "oldName", new_name: "newName", dry_run: true}) — preview semantic edits (omitting dry_run also previews)
- [ ] Confirm the previewed file paths are in the bound repository/worktree
- [ ] Review exact graph-backed semantic spans, coverage, and limitations
- [ ] If satisfied: rename({..., dry_run: false, plan_token: "<token from preview>"}) — apply exactly the reviewed edits
- [ ] detect_changes() — verify only expected files changed
- [ ] Run tests for affected processes
Extract Module
- [ ] list_repos {} — bind repo; explicit repo when >1 indexed, ask if ambiguous
- [ ] context({name: target}) — see all incoming/outgoing refs
- [ ] impact({target, direction: "upstream"}) — find all external callers
- [ ] Define new module interface
- [ ] Extract code, update imports
- [ ] detect_changes() — verify affected scope
- [ ] Run tests for affected processes
Split Function/Service
- [ ] list_repos {} — bind repo; explicit repo when >1 indexed, ask if ambiguous
- [ ] context({name: target}) — understand all callees
- [ ] Group callees by responsibility
- [ ] impact({target, direction: "upstream"}) — map callers to update
- [ ] Create new functions/services
- [ ] Update callers
- [ ] detect_changes() — verify affected scope
- [ ] Run tests for affected processes
Tools
rename — semantic rename; preview first, then apply:
rename({symbol_name: "validateUser", new_name: "authenticateUser", repo: "my-app", dry_run: true})
→ 12 edits across 8 files
→ semantic_edits: 12, coverage: {name: "gitnexus-semantic", scope: "indexed-repository", limitations: [...]}
→ changes: [{file_path, edits: [{start, length, line, old_text, new_text, confidence: "semantic"}]}]
dry_run omitted or true previews and never writes; dry_run: false requires
the successful preview's plan_token. Keep the same repository, selected symbol,
and destination name. Tokens are single-use, expire after 15 minutes or a server
restart, and may be evicted when retained previews reach 16 plans or 64 MiB.
Any apply attempt consumes the token; request and review a fresh preview to retry.
An MCP server started with GITNEXUS_MCP_READ_ONLY=1 still lists rename, but
as preview-only: it rejects any dry_run other than omitted or true, so apply
through
Câu hỏi thường gặp
Nó có xem trước thay đổi trước khi ghi không?
Có. Skill nói hãy xem bản xem trước của việc đổi tên trước khi áp dụng thật.
Nếu tôi có nhiều hơn một dự án được lập chỉ mục thì sao?
Skill nói phải nêu tên kho mã trong mỗi lần gọi, và hỏi bạn nếu không biết bạn muốn nói đến kho nào.
Nó có tái cấu trúc mã trong linked worktree không?
Có. Nó có thể nhận đường dẫn worktree khi các thay đổi nằm trong một worktree mà máy chủ không được khởi chạy từ đó.
Chi tiết
Mô tả gốc của tác giả
Use when the user wants to rename, extract, split, move, or restructure code safely. Examples: \"Rename this function\", \"Extract this into a module\", \"Refactor this class\", \"Move this to a separate file\"
repo: abhigyanpatwari/GitNexus
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #3612
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
gitnexus-cli
48kGiúp agent của bạn chạy các lệnh GitNexus để lập chỉ mục một dự án mã nguồn, kiểm tra trạng thái, xóa chỉ mục hoặc tạo wiki.
gitnexus-debugging
48kGiúp agent của bạn lần theo một lỗi qua codebase, tìm nơi lỗi bắt đầu và đoạn mã nào gọi phần bị lỗi.
gitnexus-exploring
48kGiúp agent của bạn khám phá một codebase lạ, giải thích các phần kết nối với nhau thế nào và một tính năng như đăng nhập hoạt động ra sao.
gitnexus-guide
48kCung cấp cho agent của bạn bảng tra cứu nhanh các công cụ, tài nguyên và đồ thị tri thức của GitNexus, rồi chỉ đến hướng dẫn phù hợp.
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á.