Logotipo de Refactor

Refactor

Comunidad
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.

Descripción general

Editormatt1as
Repositorioclaude-abap-skills
Nombre de la habilidadrefactor
Estrellas
34
Forks
5
Archivos incluidos
Solo instrucciones
LicenciaApache-2.0
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando una petición es realmente relevante.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por matt1as en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Refactor en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/matt1as/claude-abap-skills/tree/main/clean-abap/refactor
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → Desde URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

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
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Refactor en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición es relevante, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Refactor automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Refactor no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición relevante, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

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.

Preguntas frecuentes

¿Qué hace la habilidad de IA 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.

¿Por qué usar Refactor en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Refactor está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Refactor en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/matt1as/claude-abap-skills/tree/main/clean-abap/refactor. TypingMind lee su archivo SKILL.md y la instala como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Refactor?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Refactor?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Refactor con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Refactor?

Sí. matt1as la ha publicado en GitHub bajo la licencia Apache-2.0. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver todos

Crea ya tu propio espacio de trabajo IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇