Refactorのロゴ

Refactor

コミュニティ
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.

概要

公開者matt1as
リポジトリclaude-abap-skills
スキル名refactor
スター
34
フォーク
5
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    matt1asがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルRefactorをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/matt1as/claude-abap-skills/tree/main/clean-abap/refactor
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをその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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでRefactorを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にRefactorを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Refactorは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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.

よくある質問

AIスキル「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.

TypingMindでRefactorを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Refactorはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにRefactorをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/matt1as/claude-abap-skills/tree/main/clean-abap/refactorを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Refactorを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Refactorは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもRefactorを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Refactor」は無料ですか?

はい。matt1asがGitHubでApache-2.0ライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇