Logo Refactor Simple

Refactor Simple

Tổ chức
greenfield-inc
refactor-simple

Phân tích chất lượng mã, chỉ đọc nhánh so với nhánh mặc định trên remote cho các thay đổi nhỏ đến vừa: phân loại diff, tìm hiểu quy ước của repo đích và viết kế hoạch tái cấu trúc vào ./tmp/. Thường do refactor orchestrator chạy; dùng trực tiếp để kiểm tra nhanh trước PR khi có 2–10 tệp thay đổi.

Add to TypingMind

Tổng quan

Nhà phát hànhgreenfield-inc
Kho mãPane
Tên kỹ năngrefactor-simple
Sao
529
Bản fork
227
Tệp đi kèm
Chỉ có hướng dẫn
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được greenfield-inc công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Refactor Simple trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/greenfield-inc/Pane/tree/main/main/src/services/paneChatBundle/skills/refactor-simple
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/greenfield-inc/Pane.git /tmp/Pane
mkdir -p .claude/skills
cp -r /tmp/Pane/main/src/services/paneChatBundle/skills/refactor-simple .claude/skills/refactor-simple
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Refactor Simple trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Refactor Simple ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Refactor Simple với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Simple Refactor

Read-only code quality analysis for small to medium changes.

Safe to run anytime. Analyzes the branch against the target repository's own conventions and writes a refactor plan without modifying files.

What This Does

Fast, focused code quality analysis that:

  1. Classifies your changes (size, type, complexity)
  2. Learns the conventions of the repository you are in
  3. Identifies code smells and convention violations in the lines you changed
  4. Generates a refactor plan with auto-fixable and manual issues
  5. Writes the plan to ./tmp/ for review

When to Use

  • Small changes (2-5 files, 50-200 lines)
  • Medium changes (5-10 files, 200-500 lines)
  • Bug fixes and enhancements
  • Quick pre-PR quality check

For large features (>10 files, >500 lines), use refactor-deep instead. Simple and deep are the whole set: simple is the cheap pass with the cleanest signal-to-noise, deep is the one that finds real defects in big diffs. Run both on a large PR when you want coverage; their findings overlap by about half and the rest is complementary.

Process

1. Classify Changes

Diff against the merge-base with the remote default branch, never a bare local main - a stale local main pulls unrelated commits into the review and every finding in them becomes a false positive.

Resolve the PR/current branch's relevant remote and that remote's default branch before running these commands. If either is ambiguous or unavailable, report the blocked comparison; do not guess a remote or silently review an empty diff. Record the resolved remote, base ref, and merge-base for helpers.

bash
# Resolve the relevant remote from the PR/current branch configuration first.
# Set REFACTOR_REMOTE to that verified name; do not assume origin.
git remote show "$REFACTOR_REMOTE"
# Resolve its actual default branch and set BASE to the verified remote ref.
# Fetch that branch explicitly if the ref is missing/stale, then verify it.
git rev-parse --verify "$BASE^{commit}"
MB=$(git merge-base "$BASE" HEAD)
git diff "$MB" --name-status
git diff "$MB" --numstat
git diff "$MB" --stat

Also enumerate non-ignored untracked files with git ls-files --others --exclude-standard -z. Treat these as added files: include their full contents and handwritten line counts in sizing and analysis, applying the same generated/vendor/lockfile exclusions. Pass this file inventory to every analyzer; plain git diff omits it. Do not stage files to inspect them.

$BASE is the remote's real default branch (main, master, develop), never an assumed name. Diffing from the merge-base to the working tree - one revision, not two - includes committed, staged, and unstaged work, so a pre-PR run sees the edits that are not committed yet.

If the branch is behind $BASE, note it once as "rebase before merge"; it is not a finding and does not lower the score.

Determine:

  • Size: Tiny (<50) | Small (50-200) | Medium (200-500)
  • Type: Bug Fix | Enhancement | Refactor
  • Complexity: Trivial | Simple | Moderate
  • Layers: Backend | Frontend | Both

Size counts changed source lines. A lockfile, generated file, or vendored directory can add thousands of lines and no complexity - say so and classify on the hand-written change.

2. Learn the Repository's Conventions

Conventions come from the repository you are in, never from a rule remembered from another repo. In order:

  1. Read CLAUDE.md / AGENTS.md at the root and in every directory the diff touches. These state the conventions the maintainers actually enforce.
  2. Read two or three exemplar files that neighbour the changed code - files the maintainers clearly consider done - and note how they import, structure, handle errors, and document.
  3. Before flagging any convention violation, confirm the convention exists here. grep how many existing files already do the thing. If the codebase does it everywhere, it is the convention, not a violation.

An import style is a finding only when the target repository's guidance and existing code establish that convention. Explain the actual impact rather than assigning severity from a preference remembered from another project.

Pattern Matrix:

  • Tiny/Bug Fix → Universal smells only
  • Small/Enhancement → Universal + the repo's basic architecture rules
  • Medium → Universal + architecture + documentation for new files

Universal Smells (any repository):

  • Long functions (>100 lines), deep nesting (>3 levels)
  • Magic numbers/strings
  • Missing or swallowed error handling on new paths
  • Unused imports/variables, commented-out code, TODOs without context
  • Duplicate logic: two similar functions, hooks, or types where one with options would do
  • New public surface without a file-level or symbol-level comment when the neighbouring code has them

Repo-Derived Rules (Small+): import style, layering (where logic is allowed to live), state-management and hook patterns, error types, test conventions - whatever steps 1-3 above surfaced, cited to the file that states them.

3. Analyze Files

Read the changed files and the non-ignored untracked file inventory gathered above:

bash
git diff "$MB" --name-only

Pre-existing vs introduced: only issues in lines this branch adds or changes count against the PR. Pre-existing debt in touched files may be listed under Info as "pre-existing, not against this PR" and never lowers the score. Read enough surrounding code to tell the difference - a git blame on the line settles it.

4. Generate Report

Write the plan to ./tmp/simple-refactor-plan-[timestamp].md:

markdown
# Simple Refactor Plan

## Classification
- Size: [X] ([N] hand-written lines; [M] generated/lockfile lines excluded)
- Type: [X]
- Complexity: [X]
- Diff base: merge-base with $BASE at [sha], to working tree
- Conventions sourced from: [files read in step 2]

## Quality Score: X/10

## Issues Found

### Critical (Must Fix)
- [file:line] Description
  → Convention: [file that states it, or "universal"]
  → Fix: How to fix
  → Auto-fixable: Yes/No

### Warnings (Should Fix)
- [file:line] Description
  → Suggestion: Improvement
  → Auto-fixable: Yes/No

### Info (Nice to Have)
- [file:line] Suggestion
- [file:line] Pre-existing, not against this PR: description

## Auto-Fixable Issues: X
## Manual Fixes Required: Y

## Convention Compliance
✓/✗ [each repo-derived rule checked, with its source file]

## Recommendations
1. Hand this plan to `refactor-apply` (auto-fixable first)
2. Manually fix [specific issues]
3. Re-run `refactor-simple` to verify

## References
- Exemplar files studied: [paths]
- Convention sources: [paths]

An empty Critical section is a valid, common result. Do not manufacture findings to fill the template; "no PR-introduced defects" is the honest baseline for a clean change and should score accordingly.

5. Show Next Steps

📊 Analysis complete!
Plan written to: ./tmp/simple-refactor-plan-[timestamp].md
Quality Score: X/10
Auto-fixable: X issues · Manual fixes: Y issues
Issues found: [one line each for criticals and warnings]

Return the plan path to the caller. When run standalone, ask before running `refactor-apply`.

IMPORTANT: This skill never applies fixes. Standalone, ask the user before proceeding to refactor-apply; under refactor, the orchestrator owns that gate.

Command Arguments

  • --strict: Treat Medium as Large (stricter enforcement)
  • --classify-as=<type>: Override type classification
  • --size=<size>: Override size classification

Success Checklist

  • Diffed from the merge-base with the remote default branch to the working tree
  • Changes classified, generated lines excluded from size
  • Conventions read from THIS repo's guidance files and exemplars
  • Every convention finding confirmed by grep before it was written
  • Pre-existing debt separated from PR-introduced issues
  • Auto-fixable vs manual separated
  • Plan written to ./tmp/
  • No files modified (read-only)

This command is read-only and safe. It analyzes code against the conventions of the repository you are in and writes a refactor plan for you to review. Run refactor-apply after reviewing the plan to apply fixes.

Câu hỏi thường gặp

Kỹ năng AI Refactor Simple làm được gì?

Phân tích chất lượng mã, chỉ đọc nhánh so với nhánh mặc định trên remote cho các thay đổi nhỏ đến vừa: phân loại diff, tìm hiểu quy ước của repo đích và viết kế hoạch tái cấu trúc vào ./tmp/. Thường do refactor orchestrator chạy; dùng trực tiếp để kiểm tra nhanh trước PR khi có 2–10 tệp thay đổi.

Vì sao nên dùng Refactor Simple trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Refactor Simple là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Refactor Simple trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/greenfield-inc/Pane/tree/main/main/src/services/paneChatBundle/skills/refactor-simple. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Refactor Simple?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Refactor Simple với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Refactor Simple với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Refactor Simple có miễn phí không?

Kỹ năng này được greenfield-inc phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇