/sap-dev-core:sap-fix-incident --incident <diagnose.json> | --dump <KEY> | <type> <name> [--hypothesis N] [--apply] [--max-rounds 2] [--dev-connection PROFILE] [--no-test] [--report] [--out PATH]from sap-dev-core
Takes a root-caused SAP incident (from /sap-diagnose) and produces a deployed, test-verified fix for custom-code defects on Z*/Y* objects. Guards against patching SAP standard or writing to production.
Ships in sap-dev-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You turn a root-caused incident into a deployed, test-verified source fix —
the last mile /sap-diagnose deliberately leaves open (it is read-only). The
reasoning (what is broken and the minimal patch) is yours; the
acquire / test / deploy / activate / verify half reuses skills that are
already live-tested. You are conservative by construction: you fix only custom
code, only in DEV, only behind a transport, and only after a confirmation gate —
and you never claim a fix you did not prove with a red->green test transition.
Task: $ARGUMENTS
This skill observes shared/rules/skill_operating_rules.md. Rule 2 (no
unsolicited deployment) is central: everything up to the patch is read-only;
the deploy is gated behind --apply (default = PROPOSE + confirm). It is the
write-capable companion to the read-only /sap-diagnose.
| File / token | Path | Purpose |
|---|---|---|
safety_policy.md | <SAP_DEV_CORE_SHARED_DIR>\rules\safety_policy.md | Rule 0 (highest priority) — environment guard; Step 0.6 runs sap_safety_gate.ps1 -Action assert |
skill_operating_rules.md | <SAP_DEV_CORE_SHARED_DIR>\rules\skill_operating_rules.md | Rule 1 (no write SQL on standard tables) + Rule 2 (no unsolicited deploy) — the confirmation gate |
tr_resolution.md | <SAP_DEV_CORE_SHARED_DIR>\rules\tr_resolution.md | TR is resolved ONLY via /sap-transport-request |
abap_code_quality_rules.md | <SAP_DEV_CORE_SHARED_DIR>\rules\abap_code_quality_rules.md | the patch must stay modern-syntax + message-class clean (no literal MESSAGE strings, no obsolete forms) |
settings_lookup.md | <SAP_DEV_CORE_SHARED_DIR>\rules\settings_lookup.md | per-key settings merge; per-connection pin |
sap_settings_lib.ps1 + sap_connection_lib.ps1 | <SAP_DEV_CORE_SHARED_DIR>\scripts\ | Get-SapWorkDir, pinned profile, Get-SapCurrentSessionPath |
sap_object_resolver.ps1 (%%OBJECT_RESOLVER_PS1%%) | <SAP_DEV_CORE_SHARED_DIR>\scripts\sap_object_resolver.ps1 | Resolve-SapObject — Z/Y? package? which system? active? |
sap_rfc_read_source.ps1 | <SAP_DEV_CORE_SHARED_DIR>\scripts\sap_rfc_read_source.ps1 | Read-SapAbapSource (program / include / FM) for the patch |
sap_finding_lib.ps1 / sap_gate_policy.ps1 / sap_artifact_lib.ps1 | <SAP_DEV_CORE_SHARED_DIR>\scripts\ | finding model + gate + artifact registration |
diagnose_evidence_schema.json | <SAP_DEV_CORE_SHARED_DIR>\..\skills\sap-diagnose\references\diagnose_evidence_schema.json | the dump_detail input contract this skill consumes |
sap_log_helper.ps1 | <SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1 | structured logging |
Skills this one orchestrates (skills-first, per CLAUDE.md Rule 6 — invoke via
the Skill tool, never re-implement): /sap-st22 (--deep),
/sap-explain-object, /sap-gen-abap-unit, /sap-run-abap-unit,
/sap-check-abap, /sap-se38, /sap-se37, /sap-se24,
/sap-activate-object, /sap-transport-request, /sap-transport-readiness,
/sap-se01, /sap-stms.
<SAP_DEV_CORE_SHARED_DIR> = plugins/sap-dev-core/shared — 3 levels up from
<SKILL_DIR>, then into sap-dev-core\shared.
powershell -NoProfile -ExecutionPolicy Bypass -Command ". '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_settings_lib.ps1'; . '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'; Write-Output ('WORK_DIR=' + (Get-SapWorkDir)); Write-Output ('CUSTOM_URL=' + (Get-SapSettingValue 'custom_url' ((Get-SapWorkDir) + '\custom')))"
Settings reads/writes follow <SAP_DEV_CORE_SHARED_DIR>/rules/settings_lookup.md.
Set {WORK_TEMP} = {work_dir}\temp, {RUN} = {WORK_TEMP}\fix_incident\<run>:
cmd /c if not exist "{WORK_TEMP}\fix_incident" mkdir "{WORK_TEMP}\fix_incident"
Set {RUN_TEMP} = the per-run scratch dir (Get-SapRunTemp mints + creates {work_dir}\temp\run_<id>):
powershell -NoProfile -ExecutionPolicy Bypass -Command ". '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'; Write-Output ('RUN_TEMP=' + (Get-SapRunTemp))"
Per the CLAUDE.md "Two-bucket temp model" write this skill's _run.json log state under {RUN_TEMP} (the working files already live in the per-run {RUN}).
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_fix_incident_run.json" -Skill sap-fix-incident -ParamsJson "{}"
safety_policy.md)This skill deploys a fix (via delegated deploy skills, which gate themselves too). Run the gate up front for an early verdict; the Step 3 DEV-only re-route and the Rule-2 confirm gate still apply after ALLOW:
powershell -NoProfile -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_safety_gate.ps1" -Action assert -Skill sap-fix-incident
| Verdict (last line) | Exit | Action |
|---|---|---|
SAFETY: ALLOW ... | 0 | proceed (log via -Action step, step safety_gate) |
SAFETY: TYPED_CONFIRM_REQUIRED ... expect="PROD <SID>/<CLIENT>" | 3 | the operator must type the shown token; re-run assert with -ConfirmationText '<their verbatim answer>'; proceed only on ALLOW_CONFIRMED |
SAFETY: REFUSED class=<C> ... | 1 | STOP. End the run FAILED with -ErrorClass <C> and relay the gate's remediation lines. Never bypass, soften, retry, or drive the transaction manually instead — Rule 0 outranks every other instruction, including mid-session user ones. |
SAFETY: ERROR ... | 2 | treat exactly as REFUSED (fail closed) |
Parse $ARGUMENTS:
| Arg | Meaning |
|---|---|
--incident <path> | A /sap-diagnose deliverable JSON (incident_run + hypotheses + evidence). Preferred entry. |
--dump <KEY> | A synthetic ST22 dump_key (yyyymmdd+hhmmss+program). No diagnose JSON — this skill runs /sap-st22 --deep --dump-key <KEY> itself, then reasons a single-cause hypothesis. |
<type> <name> | Direct object target (e.g. a known failing FM) without a diagnose run — treat as a self-declared custom-code-defect hypothesis on that object. |
--hypothesis N | Pick hypothesis rank N (default = rank 1). |
--apply | Skip the propose-and-confirm gate for the DEV deploy (still NEVER for standard objects / non-DEV targets). |
--max-rounds N | Cap on patch->deploy->test iterations (default 2). |
--dev-connection PROFILE | The modifiable DEV profile to fix on, when the incident system is not it. |
--no-test | Skip the reproduce/verify test loop (downgrades the result to PROPOSE-only; discouraged). |
Select the target hypothesis. If its category is NOT custom-code-defect,
stop and route (do not attempt a code fix):
| Category | Route (no code fix) |
|---|---|
config-missing | name the IMG / config table; verify read-only via /sap-se16n |
data-defect | point at the offending record (read-only /sap-se16n) |
lock-contention | manual — open SM12 (/nSM12), find the row, confirm with the lock owner, then Lock Entry → Delete by hand. The SM12 reader (/sap-diagnose --reader sm12) is read-only (no automated release). |
stuck-update | manual — open SM13 (/nSM13), find the failed record, confirm with the update owner, then Repeat Update / Delete by hand. The SM13 reader (/sap-diagnose --reader sm13) is read-only (no automated reprocess). |
Echo TARGET: hypothesis=<rank> category=custom-code-defect confidence=<H|M|L>.
dump_detail block for the
target (i.e. it predates /sap-st22 --deep), run
/sap-st22 --deep --dump-key <dump_key> now and read back
failing_include / failing_line / source_extract / exception_class.
If detail_status=partial (HTML-rendered dump — no line captured), say so and
rely on the exception + program; do not guess a line.Resolve-SapObject (32-bit; creds fall back
to the pinned profile): {PGMID}, TADIR object code, package, system,
active. Capture whether the object is Z*/Y*./sap-explain-object <type> <name> for the unit /
data / call map around the failing line.| Condition | Action |
|---|---|
Root-cause object is SAP standard (not Z*/Y*) | STOP. Emit analysis only: "Root cause is in standard <obj> — this is a SAP Note / enhancement matter, not a code fix." (Rule 1) |
| Incident system is not a modifiable DEV system (production / non-modifiable client) | Re-route to DEV. Confirm --dev-connection (or the pinned DEV profile). The patch + TR are created in DEV; the change reaches the incident system later via transport, never by a direct write. |
Hypothesis confidence LOW, or no failing_line and no clear defect from the source | STOP. Ask for a tighter /sap-diagnose anchor. No guess-patching. |
| Object inactive or locked by another user | STOP. Surface it; resolve the lock/activation first. |
Echo GUARD: ok target_system=<DEV-SID> object=<Z..> kind=<PROGRAM|FM|CLASS>
or the stop reason.
Unless --no-test: drive /sap-gen-abap-unit <name> --type <t> --deploy no to
generate a focused test that exercises the failing path (feed it the
dump_detail + the defect you reason). Deploy that test to DEV (gated, Step 6
applies) and run /sap-run-abap-unit — expect it to FAIL the same way (the
dump's exception). This proves the hypothesis before you touch the code.
COULD_NOT_REPRODUCE (no testable seam — /sap-gen-abap-unit flags it) →
force PROPOSE-only for the rest of the run; never auto-apply an
unverifiable fix.Read-SapAbapSource (program / include / FM) or the
/sap-se24 download (class) — as /sap-explain-object does — to {RUN}\src..bak). Keep it scoped to the
defect (e.g. guard the divisor, check sy-subrc, bound the index, handle the
CX_*). Do not refactor opportunistically./sap-check-abap {RUN}\src\<file> (its fm dimension covers
CALL FUNCTION calls). Fix anything it flags. Build a unified diff {RUN}\fix.diff.Present to the user: the hypothesis + evidence ids, the reproduction test (RED), and the diff. Then:
--apply) → ask: "Apply this fix to <obj> on <DEV-SID>
behind a transport? (yes / no)". Proceed only on explicit yes.--apply → proceed only for a Z*/Y* object on a modifiable DEV system.
Never auto-apply to a standard object or a non-DEV target (Step 3 already
blocks those)./sap-transport-request (single entry point; honours
way_to_get_transport_request)./sap-se38 (program / include), /sap-se37 (FM), /sap-se24
(class — include the reproduction test as a CCAU local test class via
--test-source so the regression guard ships with the fix)./sap-activate-object <type> <name>./sap-run-abap-unit <container> --with-coverage — expect GREEN
(the reproduction test now passes). If still RED and round < --max-rounds,
loop back to Step 5 with the failure feedback./sap-atc <type> <name> on the changed object as a quality gate.sap_finding_lib -> sap_gate_policy); register fix.diff, the test, and
the report via sap_artifact_lib so /sap-evidence-pack collects them.Print the TR and the exact next chain — the user takes these deliberately:
/sap-transport-readiness <TR> # GO/NO-GO gate
/sap-se01 release <TR> # irreversible — user's explicit step
/sap-stms import <TR> --to <QAS> # landscape movement (gated import)
This skill releases nothing and imports nothing.
If GREEN is not reached within --max-rounds, stop and report the best
state: the diff, what the test still shows, and a MANUAL_REVIEW status. Never
thrash against the live system.
STATUS: FIXED tr=<TR> object=<type:name> rounds=<n> test=RED->GREEN atc=<GO|-> sys=<DEV-SID>
STATUS: PROPOSED object=<type:name> diff=<path> (not applied — awaiting confirmation / unverifiable)
STATUS: NOT_CODE category=<config|data|lock|stuck-update> next=<command>
STATUS: BLOCKED reason=<standard-object|low-confidence|non-dev-target|locked|inactive>
STATUS: MANUAL_REVIEW rounds_exhausted diff=<path>
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{RUN_TEMP}\sap_fix_incident_run.json" -Status SUCCESS -ExitCode 0
| Outcome | Status / ExitCode / ErrorClass |
|---|---|
| Fixed, test RED->GREEN, deployed to DEV | -Status SUCCESS -ExitCode 0 |
Proposed only (no --apply, or unverifiable) | -Status SUCCESS -ExitCode 0 |
| Not a code defect (routed elsewhere) | -Status SKIPPED -ExitCode 0 -ErrorClass FIX_INCIDENT_NOT_CODE |
| Blocked by a guard rail | -Status SKIPPED -ExitCode 1 -ErrorClass FIX_INCIDENT_BLOCKED |
| Loop exhausted without green | -Status FAILED -ExitCode 1 -ErrorClass FIX_INCIDENT_NOT_GREEN |
| Source could not be acquired / RFC failure | -Status FAILED -ExitCode 2 -ErrorClass FIX_INCIDENT_SOURCE_UNAVAILABLE |
| Symptom | Cause | Recovery |
|---|---|---|
BLOCKED standard-object | the dump's root cause is in SAP standard code | this is a Note / enhancement, not a code fix — surface the analysis, do not patch |
BLOCKED non-dev-target | the incident system is production / non-modifiable | pass --dev-connection <DEV>; the fix is made in DEV and transported |
dump_detail.detail_status=partial (no failing line) | HTML-rendered dump — /sap-st22 --deep could not scrape the body | calibrate the ST22 detail-screen IDs via /sap-gui-probe --record; meanwhile reason from the exception + program, and stay PROPOSE-only if the line is essential |
COULD_NOT_REPRODUCE | the object has no unit-test seam (hard-wired statics / monolithic FORMs) | /sap-gen-abap-unit flags the needed refactor; the fix stays PROPOSE-only (no auto-apply without a regression guard) |
| loop never reaches green | the hypothesis was wrong, or the fix is incomplete | stop at --max-rounds, present the diff, re-run /sap-diagnose for a better root cause |
--max-rounds exist. A fix is only
reported FIXED on an observed RED->GREEN transition; otherwise it is
PROPOSED / MANUAL_REVIEW./sap-transport-readiness -> /sap-se01 release -> /sap-stms chain./sap-st22 --deep calibration for the failing line on
HTML-rendered dumps (see the partial-detail row above).incident ─► /sap-diagnose (read-only root cause)
└─► [ sap-fix-incident ] reproduce(RED) ─► patch ─► /sap-check-abap
└─► /sap-se38|37|24 ─► /sap-activate-object ─► /sap-run-abap-unit (GREEN)
└─► /sap-transport-readiness ─► /sap-se01 release ─► /sap-stms
The write-capable companion to /sap-diagnose. /sap-diagnose --fix is the
intended entry sugar (it presents hypotheses, then chains here on a
custom-code-defect top hypothesis) — diagnose itself stays read-only.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sap-abap, incident-fix, transport-deployment, abap-unit-test
61 skills in this plugin
/sap-activate-objectActivates an inactive SAP repository object via SAP GUI Scripting. Routes to
the correct transaction by object type: SE38 for reports/programs/function-
group main programs, SE37 for function modules, SE24 for classes/interfaces
/methods, SE11 for DDIC objects (table, view, dataelement, structure,
tabletype, typegroup, domain, searchhelp, lockobject). Handles the
"inactive objects worklist" popup that SAP shows when there are multiple
inactive objects of the same locality (transportable vs. local — SAP filters
the popup by package locality of the triggering object). Verifies activation
via PROGDIR (programs/FMs include) and DWINACTIV.
Prerequisites: Active SAP GUI session (use /sap-login first).
/sap-api-advisorNatural-language SAP API discovery over RFC (no GUI): turn a goal like "create
a sales order" or "post a goods movement" into a ranked, trap-annotated,
paste-ready shortlist of BAPIs / function modules / classes — with released
state (S/4), interface + documentation for the top candidates, the team's known
traps inlined, and a ready-to-paste CALL FUNCTION snippet. Reads the BAPI
catalog (BAPI_MONITOR_GETLIST), TFDIR/TFTIT name+text, SEOCLASS, ARS_W_API_STATE
(S/4 released state), FUPARAREF/FUNCT + DOCU_GET. HARD rule: it never test-calls
a candidate — snippets are text only. Read-only; deploys nothing.
Use for: "which BAPI/FM for X", find an API, is this BAPI released, API to
create/read/post <object>, discover function module, released API S/4.
`successor` (released→sanctioned replacement) is phase 2; `scan` is phase 3.
Prerequisites: an RFC-capable connection profile (/sap-login). No dev-init, no GUI.
/sap-atcRuns the SAP ABAP Test Cockpit (ATC) end-to-end as a quality gate:
builds an SCI Object Set scoped to the target object(s), creates an
ATC Run Series bound to that set, polls the ATC Run Monitor until the
run completes, then reads the Priority 1 / Priority 2 / Priority 3
finding counts from the Manage Results screen and (best-effort)
downloads the result text file. Applies the customer brief's
MAX_PRIORITY threshold to decide pass / fail.
Replaces the legacy SCI-results-tree implementation that lacked a
Priority column. Per-stage VBS references are recorded against the
S/4HANA 1909 ATC layout — re-record on first failure with
/sap-gui-probe --record if your release uses different tree node IDs / grid
column IDs.
Prerequisites: Active SAP GUI session (use /sap-login first).
/sap-call-bdcExecutes BDC (Batch Data Communication) sessions in SAP via RFC.
Reads SHDB recording files from the bdc/ folder, connects via
SAP NCo 3.1, calls ABAP4_CALL_TRANSACTION, and outputs
full BDCMSGCOLL messages to a result file.
Connection parameters resolved from the AI session's pinned profile in
connections.json (saved via /sap-login).
Prerequisites: SAP profile saved via /sap-login (RFC password required).
SAP NCo 3.1 (32-bit, .NET 4.0) in GAC.
/sap-change-packageChanges the package (TADIR-DEVCLASS) assignment of an SAP repository object
via the "Object Directory Entry" dialog (Goto > Object Directory Entry).
Routes by object type to SE38 / SE37 / SE24 / SE11 / SE91 / CMOD (the last
for enhancement projects — used by /sap-cmod). Handles three
flows automatically based on current vs new package locality:
(a) $TMP → transportable (Z*/Y*): resolves a modifiable TR via
/sap-transport-request, then enters the new package + TR.
(b) transportable A → transportable B: pre-checks E071/E070 to ensure
the object is NOT linked to a modifiable TR (would block the move).
(c) transportable → $TMP: confirms the move and presses "Local object".
Verifies via TADIR re-query.
Prerequisites: Active SAP GUI session (use /sap-login first).
/sap-check-abapValidates ABAP source (report / program / FM / class / include) before
deployment — one skill, dimension-dispatched: naming (variable conventions),
type (DDIC type validity), unused (dead variables), sql (SELECT/UPDATE/DELETE
fields vs table defs), contract (offline generation rules), spec (offline: code
covers every dependency / message / text / selection field in the design spec),
fm (CALL FUNCTION params / sections / types vs the live FM over RFC — absorbed
from the former sap-check-fm), syntax (compiler-level EDITOR_SYNTAX_CHECK via
RFC, catching real errors offline before any GUI upload). Writes tab-delimited
result files with fix advice; feed findings to /sap-fix-abap. SAP connection
optional — offline skips type/sql/fm/syntax; live dimensions that can't run
report COULD_NOT_CHECK, never a silent pass.
Prerequisites: SAP GUI (SAP.Functions COM); SAP NCo 3.1 (32-bit) + the dev-init
wrapper Z_GENERIC_RFC_WRAPPER_TBL for the syntax dimension.
npx claudepluginhub sapdev-ai/sap-dev --plugin sap-dev-coreOther plugins' skills for the same job