/sap-dev-core:sap-diagnose [<natural-language incident>] [--user U] [--tcode T] [--program P] [--job J] [--dump KEY] [--object TYPE:KEY] [--date today|YYYYMMDD] [--time HH:MM] [--window MIN] [--sources a,b] [--reader sm13|sm12|slg1|sm37|smq|gateway|st22] [--depth quick|standard|deep] [--remediate] [--fix] [--connection PROFILE] [--report] [--out PATH]from sap-dev-core
Orchestrates read-only SAP incident triage across SM13, SM12, SLG1, SM37, SMQ, Gateway, and ST22 readers, correlating evidence into ranked root-cause hypotheses with fix paths.
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 triage a SAP incident the way a senior support consultant does — but in
parallel, with full cross-source correlation. Take one anchor, fan out across
the read-only readers, merge their evidence into incident clusters, and report
ranked root-cause hypotheses plus the next concrete command. You NEVER modify
the SAP system; custom-code fixes are handed to /sap-fix-incident (gated), lock release to
/sap-sm12 release (its own liveness gate + typed confirm), and stuck-update
remediation to manual SM13 steps (the diagnose readers are read-only).
Task: $ARGUMENTS
| File | Token / role | Purpose |
|---|---|---|
<SAP_DEV_CORE_SHARED_DIR>/rules/skill_operating_rules.md | (rule) | Read-only by construction; remediate handoff respects "ask before mutating". |
<SAP_DEV_CORE_SHARED_DIR>/rules/language_independence_rules.md | (rule) | Applies to the GUI ST22 leg + any downstream fix skill. |
<SAP_DEV_CORE_SHARED_DIR>/rules/settings_lookup.md | (rule) | Per-key settings merge; per-connection pin resolution. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_rfc_lib.ps1 | %%RFC_LIB_PS1%% | NCo helpers for the anchor server-time read. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_settings_lib.ps1 + sap_connection_lib.ps1 | (lib) | Get-SapWorkDir, pinned profile. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_log_helper.ps1 | (lib) | start/step/end logging. |
<SKILL_DIR>/references/sap_diagnose_anchor_resolve.ps1 | (helper) | flags → absolute SERVER-time anchor. |
<SKILL_DIR>/references/sap_diagnose_correlate.ps1 | (helper) | deterministic graph + clustering. |
<SKILL_DIR>/references/diagnose_evidence_schema.json | (schema) | evidence contract every reader emits. |
<SKILL_DIR>/references/diagnose_source_matrix.tsv | (table) | anchor-signal → reader set. |
<SKILL_DIR>/references/sap_diagnose_reader_lib.ps1 | %%DIAG_READER_LIB_PS1%% | Reader helpers (anchor, read-table, evidence emit) — dot-sourced by the six RFC reader scripts below. |
<SKILL_DIR>/references/sap_sm37_read.ps1 | (reader) | Background-job reader (TBTCO). |
<SKILL_DIR>/references/sap_sm13_read.ps1 | (reader) | Update-task failure reader (VBHDR + VBERROR). |
<SKILL_DIR>/references/sap_sm12_read.ps1 | (reader) | Lock-entry reader (ENQUEUE_READ). |
<SKILL_DIR>/references/sap_slg1_read.ps1 | (reader) | Application-log reader (BALHDR). |
<SKILL_DIR>/references/sap_smq_read.ps1 | (reader) | tRFC + qRFC reader (ARFCSSTATE narrow; TRFCQOUT/TRFCQIN aggregated per queue). |
<SKILL_DIR>/references/sap_gateway_read.ps1 | (reader) | Gateway/OData error-log preflight (NOT_APPLICABLE vs COULD_NOT_CHECK; full read owned by /sap-gateway-service). |
Evidence readers. The six RFC readers (SM13 / SM12 / SLG1 / SM37 / SMQ / GATEWAY) are
internal to this skill — the references/sap_*_read.ps1 scripts above, run
directly in Step 4 (they were formerly the standalone /sap-sm13 … /sap-sm37
skills, folded in here to shrink the catalogue). The GUI dump reader stays a
separate skill, /sap-st22 (called via the Skill tool), because it drives
ST22 through GUI scripting. /sap-trace (performance) is likewise separate and
is not auto-chained.
Fix hand-off (Step 8.5, only with --fix): /sap-fix-incident — the
write-capable companion. Diagnose stays read-only; it only invokes the fix skill
(which owns its own confirmation gate + guard rails) after a confirmation.
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 ('RUN_TEMP=' + (Get-SapRunTemp))"
Resolve the active connection: --connection if given, else the AI-session pin
in {work_dir}\runtime\session_registry.json. Read log_redact_keys and the
SAP RFC connection keys for that system. Set {RUN_TEMP} = the RUN_TEMP=
value (per-run scratch dir, minted + created by Get-SapRunTemp — home of the
_run.json logging state), {WORK_TEMP} = {work_dir}\temp,
{RUN_DIR} = {WORK_TEMP}\diagnose\<run>:
cmd /c if not exist "{WORK_TEMP}\diagnose" mkdir "{WORK_TEMP}\diagnose"
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_diagnose_run.json" -Skill sap-diagnose -ParamsJson "{}"
Interpret the leading natural-language text + flags into a flags object
{ date, time, window, from_ts, to_ts, user, tcode, program, job, jobcount, dump, object, client }. Explicit flags win. If the anchor is too thin (e.g.
date only), default to "most recent error-class events in window" and say so.
Write the flags to {RUN_DIR}\flags.json.
Fill sap_diagnose_anchor_resolve.ps1 with %%RFC_LIB_PS1%% + the SAP
connection tokens (same substitution pattern as /sap-dev-status), then run it
under 32-bit PowerShell:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "{RUN_DIR}\anchor_resolve_run.ps1" -InputJson "{RUN_DIR}\flags.json" -OutFile "{RUN_DIR}\anchor.json"
Server-time discipline. The window is resolved against the SAP server clock (RFC
RFC_SYSTEM_INFO→RFCTZONE), never the workstation. Echo theRESOLVED_WINDOW=line. A skew here silently returns "no evidence" — the same failure class as the SE01-create timezone bug.
Standalone single-reader mode (
--reader <name>). When--readernames one reader (sm13|sm12|slg1|sm37|smq|gateway|st22), skip source selection (Step 3): resolve the anchor (Steps 1–2), run just that one reader with the Step 4 mechanics, print its evidence summary, and STOP — no correlation, clustering, or hypotheses (Steps 5–8 are not run). This replaces the former standalone/sap-sm13…/sap-sm37skills one-for-one; e.g./sap-diagnose --reader sm37 --job ZFOO --date today== the old/sap-sm37.
Read references/diagnose_source_matrix.tsv, pick the reader set by the
strongest anchor signal, honor --sources and --depth (quick = top-3; deep =
all). Echo SOURCES_SELECTED: ....
Not-yet-available readers. The matrix lists one source that still has no reader —
sm21(system log), marked(manual)in the TSV. Do not try to invoke it via the Skill tool; name it in the report'snext_actions(e.g. "run SM21 for the window") so the operator collects that evidence by hand. The internal RFC readers (sm13,sm12,slg1,sm37,smq,gateway) and thest22GUI reader skill (plustrace, a separate skill) are available today. Thesmqreader covers qRFC/tRFC (SMQ1/SMQ2/SM58); thegatewayreader is a present/absent preflight for the OData error log — it returns NOT_APPLICABLE off a Gateway hub and COULD_NOT_CHECK where the full read needs/sap-gateway-service.
Each reader is read-only, time-boxed, top-N capped, and writes an evidence file
matching diagnose_evidence_schema.json. A reader that errors or lacks
authorization writes a skipped stub — record it and continue; never drop a
source silently.
For each selected RFC source, materialize its reader script and run it under
32-bit PowerShell. Substitute only the two library paths; leave the
%%SAP_*%% credential tokens literal so Connect-SapRfc fills them from the
pinned connection profile. The four readers share one signature
(-AnchorJson <path> -OutFile <path> [-TopN <n>]), so the block below is
identical per source — swap <src> ∈ { sm13, sm12, slg1, sm37, smq, gateway }:
$ps = [IO.File]::ReadAllText('<SKILL_DIR>\references\sap_<src>_read.ps1', [Text.Encoding]::UTF8)
$ps = $ps.Replace('%%RFC_LIB_PS1%%', '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_rfc_lib.ps1')
$ps = $ps.Replace('%%DIAG_READER_LIB_PS1%%', '<SKILL_DIR>\references\sap_diagnose_reader_lib.ps1')
[IO.File]::WriteAllText('{RUN_DIR}\<src>_run.ps1', $ps, (New-Object Text.UTF8Encoding($false)))
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "{RUN_DIR}\<src>_run.ps1" -AnchorJson "{RUN_DIR}\anchor.json" -OutFile "{RUN_DIR}\evidence_<src>.json"
The RFC readers are independent — materialize and run the whole selected set
before correlating. Honor --top-n by appending -TopN <n>. Each reader prints
an EVIDENCE: source=<SRC> … summary line and writes evidence_<src>.json,
which sap_diagnose_correlate.ps1 consumes in Step 5.
If st22 is in the selected set, invoke /sap-st22 via the Skill tool,
passing --anchor {RUN_DIR}\anchor.json --out {RUN_DIR}\evidence_st22.json. It
uses the pinned GUI session, so run it on its own (do not interleave it with a
second GUI skill).
--fix(or--depth deep) → run ST22 deep. When--fixis set, invoke/sap-st22with--deepso the deliverable carries adump_detail(failinginclude/line+ source snippet) — that is the input/sap-fix-incidentneeds in Step 8.5. Without it the fix skill would have to re-open the dump itself. This stays read-only.
powershell -ExecutionPolicy Bypass -File "<SKILL_DIR>\references\sap_diagnose_correlate.ps1" -RunDir "{RUN_DIR}" -TightSeconds 5
Writes {RUN_DIR}\correlation.json (incident clusters + weighted edges:
explicit / business-key = HIGH, identity+temporal / context = MED, temporal =
LOW; clusters use MED+). Each cluster carries a timeline, an anchor_event_id,
and an earliest_event_id (nearer the root cause).
Read correlation.json + the raw evidence and reason per cluster. For each, emit
{ rank, confidence, category, statement, symptom_vs_root, evidence_ids, confirm_by, refute_by, recommended_action }. Hard rules:
confirm_by / refute_by before presenting a hypothesis as likely.| Root cause | Next command |
|---|---|
| custom-code defect | (closed loop) /sap-fix-incident --incident <out> — auto-chained by --fix (Step 8.5); or manually /sap-explain-object <type> <name> → /sap-se38|37|24 fix |
| config-missing | name the IMG/config table; verify read-only via /sap-se16n |
| data-defect | point at the record (read-only /sap-se16n) |
| lock-contention | delegate to /sap-sm12 release --user=<owner> [--table=<T>] — it re-reads the lock, proves the owner has no session on any application server (liveness gate), requires typed confirmation, deletes via ENQUE_DELETE, and verifies by re-read; it refuses if the owner is live or liveness is unprovable. (The diagnose SM12 reader leg itself stays read-only.) |
| stuck update | (manual — operator-performed) open SM13 (/nSM13), find the failed record, confirm with the update owner, then Repeat Update / Delete by hand. The SM13 reader leg is read-only — there is no automated --reprocess. |
The orchestrator performs no write itself. With --fix it delegates the
custom-code path to /sap-fix-incident, which owns its own confirmation gate
(Rule 2) and guard rails. For lock contention --remediate points at
/sap-sm12 release (which owns the liveness gate + typed confirmation and does
the delete); for stuck updates there is still no automated remediation — the
sm13 reader is read-only, so --remediate surfaces the manual SM13 steps
above. Diagnose itself never mutates SAP directly under any flag.
Derive incident_id from the resolved server timestamp + a short hash of the
anchor. Write the JSON deliverable to --out
(default {work_dir}\diagnose\<incident_id>.json) with incident_run,
evidence, correlation, hypotheses, truncation (LOUD), next_actions.
With --report, also write <out>.md. Print a final status line:
STATUS: DIAGNOSED clusters=<n> top_confidence=<HIGH|MED|LOW> report=<path>
STATUS: NO_EVIDENCE window=<from>..<to> (possible time-zone skew — see Failure Modes)
STATUS: ERROR <reason>
--fix)Only when --fix was passed. /sap-diagnose itself still writes nothing
here — it hands the deliverable to the gated /sap-fix-incident.
Chain only if both hold:
--out path, andcategory == custom-code-defect.Otherwise do NOT chain — print the Step-7 next command and stop (config-missing / data-defect / lock-contention have their own paths; a low-confidence or non-code top hypothesis is never auto-fixed).
When both hold:
--fix will hand it to /sap-fix-incident.yes./sap-fix-incident --incident <out> (the
Step-8 deliverable path). The fix skill re-applies its own guard rails
(Z/Y-only, DEV-only, never standard / production) and its own deploy gate —
this chain bypasses none of them.STATUS: line back to the user.Echo FIX_CHAIN: invoked target=<type:name> or
FIX_CHAIN: skipped reason=<not-code|low-confidence|no-deliverable|declined>.
Keep the deliverable under {work_dir}\diagnose; remove {RUN_DIR} unless
--depth deep (then retain raw evidence for audit and say so). If --fix
chained a fix (Step 8.5), retain the deliverable regardless — it is the
--incident input the fix skill consumed.
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{RUN_TEMP}\sap_diagnose_run.json" -Status SUCCESS -ExitCode 0
NO_EVIDENCE → -Status SKIPPED -ExitCode 1 -ErrorClass DIAGNOSE_NO_EVIDENCE.
RFC_READ_TABLE them (the
sap_rfc_lib.ps1 guard would block it).VBHDR has no sub-second time, so SM13 events
correlate via the engine's context edge (same day + user + program/tcode)
and business keys, not the tight temporal window.skipped with a record hint
(/sap-gui-probe --record) if it cannot locate the list.| Symptom | Cause | Recovery |
|---|---|---|
NO_EVIDENCE for a real incident | server/workstation time-zone skew | re-check RESOLVED_WINDOW; widen --window; confirm server tz |
a reader returns skipped | no auth for that tcode/FM | re-run that reader alone with a privileged user (--reader <name>); triage continues |
| hundreds of events | anchor too broad | narrow --user/--tcode; read truncation[] |
| one giant cluster | TightSeconds too loose on a busy system | lower -TightSeconds |
/sap-trace, a separate skill —
invoke it directly for trace analysis; /sap-diagnose does not chain it).confirm_by/refute_by rule.README.md (opens in a new tab)references/diagnose_evidence_schema.json (opens in a new tab)references/diagnose_source_matrix.tsv (opens in a new tab)references/sap_diagnose_anchor_resolve.ps1 (opens in a new tab)references/sap_diagnose_correlate.ps1 (opens in a new tab)references/sap_diagnose_reader_lib.ps1 (opens in a new tab)references/sap_gateway_read.ps1 (opens in a new tab)references/sap_slg1_read.ps1 (opens in a new tab)references/sap_sm12_read.ps1 (opens in a new tab)references/sap_sm13_read.ps1 (opens in a new tab)references/sap_sm37_read.ps1 (opens in a new tab)references/sap_smq_read.ps1 (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sapdev-ai/sap-dev --plugin sap-dev-core61 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.
Other plugins' skills for the same job