Logo Refactor

Refactor

Cộng đồng
matt1as
refactor

Refactor existing ABAP code to Clean ABAP style without changing behavior. Use when the user asks to refactor, clean up, modernize, or tidy ABAP code. Applies the rule set in ../CLAUDE.md in deterministic passes (naming, declaration, expression, method shape, error, class) and asks before writing back via MCP. Targets modern ABAP only — BTP ABAP Environment or S/4HANA on-prem in the ABAP Cloud development model.

Tổng quan

Nhà phát hànhmatt1as
Kho mãclaude-abap-skills
Tên kỹ năngrefactor
Sao
34
Bản fork
5
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
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 là Markdown thuần túy, không phải 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ộ.

  • Đầy đủ trong hướng dẫn

    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 matt1as công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Refactor 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 thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/matt1as/claude-abap-skills/tree/main/clean-abap/refactor
  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/matt1as/claude-abap-skills.git /tmp/claude-abap-skills
mkdir -p .claude/skills
cp -r /tmp/claude-abap-skills/clean-abap/refactor .claude/skills/refactor
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 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ự tải Refactor 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 Refactor không bị giới hạn ở mô hình mà kỹ năng này được viết cho. 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 kỹ năng chưa dùng không tốn chi phí.

  • Đổ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.

clean-abap:refactor

Refactor existing ABAP code to conform to the Clean ABAP rule set in ../CLAUDE.md (relative to this skill's directory).

What this command does

You are refactoring ABAP source code to bring it into compliance with the Clean ABAP rule set. Style and structure only — business logic stays identical. If a change would alter what the code does, you do not make it; you flag it instead.

Inputs

Accept any of the following. If nothing is provided, ask which target the user wants.

  • An ABAP object name — read it with arc-1 SAPRead
  • A package name — enumerate with arc-1 SAPRead type=DEVC, then refactor object by object, never as a single bulk change
  • A code block pasted into the conversation — always works, and is the only path when no read-capable server is connected

Tool routing. Read the ## Tooling section in ../CLAUDE.md before the first tool call. The two halves of this skill land on different servers:

StepPrimaryFallback
Read the sourcearc-1 SAPReadask the user to paste it
Find callers before touching a signaturearc-1 SAPNavigate action="references"ask the user; if unknown, skip the change
Dry-run the refactored sourcearc-1 SAPDiagnose action="syntax" with source — validates without writingskip, and rely on activation
Write back and activateabap-adt abap_creation-create_object, abap_activate_objectsarc-1 SAPWrite + SAPActivate when write scope is enabled; otherwise hand the diff to the user to paste in ADT
Prove behaviour is preservedabap-adt abap_run_unit_testsarc-1 SAPDiagnose action="unittest"

If only arc-1 is connected, check whether its write actions are actually enabled before promising a write-back — when write scope is off, the mutating actions are absent from the tool's action enum. If they are absent, the refactor is read-only: produce the diff and hand it to the user. If they are present, write through arc-1, then read the object back with SAPRead and confirm it matches the diff you showed, and run SAPActivate. A successful SAPWrite means abaplint passed, not that the object compiles — activation is the real gate.

Procedure

  1. Load the rule set. Read every ## RULE: block in ../CLAUDE.md. Those are the only refactoring targets.
  2. Get the source. If pasted inline, use it. If an object name was given, read it with arc-1 SAPRead. If no read-capable server is connected, ask the user to paste it from ADT.
  3. Run the review first. Internally, perform the same analysis as /clean-abap:review. Use the prioritised list as your refactor plan.
  4. Refactor in passes, in this order. Do not skip ahead:
    1. Naming pass — apply use-problem-domain-names, no-magic-numbers-or-literals
    2. Declaration pass — apply prefer-inline-declarations, no-default-key-on-internal-tables
    3. Expression pass — apply use-string-templates-not-concatenate, prefer-is-not-initial-over-negation, prefer-case-over-long-if-elseif, use-table-expressions-not-read-table-plus-sy-subrc
    4. Method shape pass — apply methods-do-one-thing-and-stay-small, at-most-three-importing-parameters, prefer-returning-over-exporting
    5. Error pass — apply class-based-exceptions-not-sy-subrc, catch-specific-exceptions-not-cx-root
    6. Class shape pass — apply final-classes-and-private-members-by-default, prefer-new-over-create-object
  5. Preserve behaviour. After every pass, mentally diff the program logic. If you cannot prove a change is behaviour-preserving (e.g. a refactor would change exception types caught upstream, would change SELECT result order, would alter authority checks), stop and ask instead of guessing.
  6. Show the diff before writing back. Produce a per-method or per-section before/after diff. Annotate every change with the rule name that motivated it. Syntax-check the result first with arc-1 SAPDiagnose action="syntax" (passing source) — it validates the new source without writing anything, so a broken refactor never reaches the system.
  7. Ask for confirmation before writing back. Explicit confirmation per object — not a blanket yes for a package. Write via the official abap-adt server (or arc-1 SAPWrite if that is the only one enabled), then activate and confirm the object activated cleanly. When writing through arc-1, read the object back afterwards and confirm it matches the diff you showed.
  8. Re-run the object's ABAP Unit tests after activation (abap-adt abap_run_unit_tests, fallback arc-1 SAPDiagnose action="unittest"). A behaviour-preserving refactor with no test evidence is a claim, not a proof — if the object has no tests, say so in the report.

Behaviour preservation — non-negotiable

These changes are out of scope for this command — they alter behaviour:

  • Changing exception classes raised by a public method (callers catch them)
  • Changing the order or set of database rows returned by a SELECT
  • Removing authority checks, even if they look redundant
  • Inlining or extracting code that crosses a COMMIT WORK / ROLLBACK WORK
  • Changing the public signature of a method except EXPORTING → RETURNING for a single output where no caller relies on IS SUPPLIED

If a Clean ABAP rule appears to require one of the above, flag it in the report and skip the change. Behaviour change belongs in a separate task, not in a style refactor.

Output format

# Clean ABAP Refactor — <OBJECT NAME>

## Plan
1. <rule-name> — <count> occurrences
2. <rule-name> — <count> occurrences
...

## Changes

### <method or section name>

**Rule:** <rule-name>
**Before:**
` ` `abap
<original>
` ` `
**After:**
` ` `abap
<refactored>
` ` `
**Rationale:** <one sentence, no longer>

(repeat per change)

## Behaviour-preserving check
- [ ] No public method signature changed (except EXPORTING→RETURNING for single output)
- [ ] No exception classes added or removed from public methods
- [ ] No SELECTs reordered or filtered differently
- [ ] No authority checks removed
- [ ] No statements moved across COMMIT/ROLLBACK boundaries

## Skipped
<rule-name> at <location> — <one-line reason it would have changed behaviour>

## Verification
- Syntax check (arc-1 SAPDiagnose): pass / fail / not run
- ABAP Unit after activation: N passed, N failed / object has no tests / not run

## Confirmation
Write these changes back to <OBJECT NAME> via <abap-adt | arc-1>? (yes / no / per-method)

Hard rules for this command

  • Style and structure only. Never change what the code does.
  • One object at a time. No silent batching across a package.
  • Confirm before write-back. Always. Even if the user said yes for a previous object.
  • Activate after writing. If activation fails, report the error and revert the write. Do not patch through activation errors.
  • No rule-by-rule chatter. Group changes by method or section; one diff per change.
  • If a Clean ABAP rule conflicts with the ABAP Cloud / RAP overlay, the overlay wins. Apply the overlay version of the rule. Note the conflict in the report.

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

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

Refactor existing ABAP code to Clean ABAP style without changing behavior. Use when the user asks to refactor, clean up, modernize, or tidy ABAP code. Applies the rule set in ../CLAUDE.md in deterministic passes (naming, declaration, expression, method shape, error, class) and asks before writing back via MCP. Targets modern ABAP only — BTP ABAP Environment or S/4HANA on-prem in the ABAP Cloud development model.

Vì sao nên dùng Refactor 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 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 trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/matt1as/claude-abap-skills/tree/main/clean-abap/refactor. TypingMind đọc tệp SKILL.md và cài đặt thành một kỹ năng mà 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?

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.

Bạn có thể dùng Refactor 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 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 có miễn phí không?

Có. Kỹ năng này được matt1as phát hành trên GitHub theo giấy phép Apache-2.0. 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 cho mô hình các công cụ mới để gọi — mã đượ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à tiêu chí của đầu ra tốt. 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 👇