code-refactor-review
Skill này làm gì
Skill hướng dẫn AI kiểm tra xem mã mới có tái sử dụng các hàm tiện ích hiện có và khớp với mẫu thiết kế, cách đặt tên của dự án hay không. Dành cho lập trình viên review pull request hoặc diff mã.
Khi nào nên dùng
- ✓Khi bạn muốn review một pull request hoặc diff mã về khả năng tái sử dụng và tính nhất quán.
- ✓Khi bạn muốn kiểm tra xem mã mới có trùng lặp với thứ mã nguồn đã có không.
- ✓Khi bạn muốn biết một thay đổi có khớp với cách tổ chức file và đặt tên của dự án không.
Liên kết skill
https://github.com/trycompai/crm/blob/release/.agents/skills/code-refactor-review/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ể xem lại diff của tôi và cho biết đoạn mã này có trùng với các hàm tiện ích hiện có hoặc không khớp với mẫu của chúng tôi không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI đọc toàn bộ thay đổi, theo dõi cách tính năng được kết nối và tìm trong mã nguồn trước khi đánh giá các hàm hoặc thành phần mới.
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.
Code Refactor Review
Review code changes deeply for reuse, composition, codebase consistency, and anything that reads like slop.
First Pass
- Inspect the full diff:
- Use
git difffor unstaged changes. - Use
git diff HEADif there are staged changes. - For a PR URL, inspect the changed files and understand the feature flow before reviewing details.
- Use
- Build the call stack / data flow when useful. Do not review isolated lines without understanding how the feature is wired.
- Search the codebase before judging new helpers, components, hooks, or patterns. Prefer nearby and sibling patterns over invented abstractions.
Review Lenses
1. Reuse Existing Code
- Look for existing utilities, components, hooks, server actions, route patterns, copy patterns, and styling primitives before accepting newly written code.
- Flag duplicated logic, copied helpers, or custom implementations of things the codebase already has.
- Prefer reusing the existing flow even if it needs a small extension.
- If the new code creates a shared helper, verify it has real reuse and is not just extracted private logic with a vague name.
2. Codebase Consistency
- File placement should match the domain and neighboring features. Be suspicious of random top-level
libdumps. - Naming should match what the code actually does and follow sibling file/function names.
- Avoid implementation details in names unless they are the actual product/API distinction.
- Use existing result/error/loading patterns. Do not invent bespoke success/failure types when the codebase has a standard one.
- Match existing copy and tone for user-facing text.
3. Composition and Boundaries
- Functions should do one thing at the right level of abstraction.
- Avoid grab-bag modules that mix unrelated concerns like flags, API calls, transformation, UI state, logging, and scheduling.
- Avoid parameter sprawl. If a function needs many knobs, check whether the boundary is wrong.
- Prefer simple composition over chains of callbacks, wrappers, memoized helpers, and prop plumbing.
- When two backing entities are presented as one product concept, package them into one transport/view model across intermediate components. Black-box components should receive one unified prop/callback and should not care about distinctions like remote vs prebuilt; split back into core entities only at roots/adapters where persistence or payload formats require it.
- Keep domain-specific logic close to its domain unless there is proven cross-domain reuse.
4. Slop Detection
Flag and, when asked, remove:
- Comment slop: obvious comments, comments defending awkward code, long comments that should become clearer code, stale context in PR descriptions.
- Helper slop: tiny wrappers that add no meaning, helper files created only to make one function look shorter, unnecessary indirection.
- Type slop: exported one-off types, custom result shapes, annotations where inference is clearer, types that only paper over awkward code.
- Memo/callback slop:
useMemo/useCallbackadded without a measured or structural reason. - Effect slop: effects that mirror props/state, reset derived state, or handle events after the fact.
- Compatibility cruft: bolted-on behavior that preserves accidental architecture instead of building the coherent end state.
- Diff churn: unrelated renames, formatting, comments, or wrappers that make the PR larger without improving the design.
5. React / Next.js Quality
- Apply “You Might Not Need an Effect”: derive values during render, move event-caused work into event handlers, and reset state with keys when appropriate.
- Avoid redundant state and synchronization effects.
- Do not add memoization just to quiet performance anxiety. Memoization should solve a real render identity or expensive computation issue.
- Prefer straightforward component boundaries over prop/callback gymnastics.
- For server/data code, avoid unnecessary waterfalls and run independent work concurrently when the codebase has a pattern for it.
6. Minimality
- Prefer deleting code over adding new structure.
- Prefer one clear function over several helper-y fragments unless extraction improves reuse or readability.
- Keep the fix proportional to the problem.
- Do not add architecture, docs, or comments unless they remove ambiguity for future readers.
Output Format
Start with a verdict:
clean— no meaningful concerns.mostly clean— m
Câu hỏi thường gặp
Skill tập trung vào điều gì?
Nó tập trung vào khả năng tái sử dụng, cách kết hợp, tính nhất quán và sự gọn gàng của mã.
Có cần link pull request không?
Không. Nó có thể xem diff hiện tại, hoặc pull request nếu bạn cung cấp đường liên kết.
Skill có đánh giá mã một cách riêng lẻ không?
Không. Nó yêu cầu hiểu luồng tính năng trước khi xem xét các chi tiết.
Chi tiết
Mô tả gốc của tác giả
Reviews code changes for reuse, composition, codebase consistency, and slop. Use when asked to review PRs/diffs, check code reuse, composition, cleanliness, or whether code fits the codebase.
repo: trycompai/crm
Độ phổ biến
- Sao GitHub
- 12k
- Vị trí xếp hạng
- #11516
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
ai-elements
12kGiúp agent của bạn xây dựng giao diện chat AI với các thành phần có sẵn cho hội thoại, tin nhắn, hiển thị công cụ và ô nhập prompt.
ai-sdk
12kGiúp agent của bạn xây dựng tính năng AI với Vercel AI SDK, gồm tạo văn bản, truyền phát, gọi công cụ và agent.
better-accessibility
12kGiúp agent của bạn làm giao diện dùng được bằng bàn phím và trình đọc màn hình, bao gồm focus, nhãn, ARIA và biểu mẫu.
better-auth-best-practices
12kGiúp agent của bạn thiết lập Better Auth cho đăng nhập, phiên làm việc, OAuth và plugin trong ứng dụng TypeScript, theo các bước tài liệu.
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á.