/sc4sap:program-to-specfrom sc4sap
Reverse-engineers an ABAP program into a Functional/Technical Specification artifact (Markdown, HTML, or Excel). Uses Socratic narrowing to scope analysis from broad to user-specific needs.
Ships in sc4sap. 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.
Offline profile (
common/offline-mode.md): blocked — reply with the stop line there and stop.
Reads an existing ABAP program (Report / Module Pool / FM Group / Class / CDS / RAP) via MCP, runs structural + semantic + where-used analysis, then produces a Specification artifact in any combination of Markdown (.md), HTML (.html, one self-contained file) and Excel (.xlsx). Scope is negotiated Socratically — start wide, narrow on each turn, stop when the user's target granularity is confirmed.
<Response_Prefix>Every response triggered by this skill MUST begin with [Model: <main-model> · Dispatched: <sub-summary>] per ../../common/model-routing-rule.md § Response Prefix Convention.</Response_Prefix>
<Target_Object>The target object is looked up on the active profile's system only. Not found → stop and ask per ../../common/multi-profile-artifact-resolution.md § Target object not on the active system — never substitute a similar name, never switch profiles on your own.</Target_Object>
<Phase_Banner>Multi-phase skill. Before each Agent(...) dispatch, emit ▶ phase=<id> (<label>) · agent=<name> · model=<Opus 4.7|Sonnet 4.6|Haiku 4.5> per ../../common/model-routing-rule.md § Phase Banner Convention. Resolve the dispatch mode first per ../../common/model-dispatch-mode.md: auto (default) uses the model below/in the rule; user-defined asks the user Opus / Sonnet / Haiku (recommended one first) before each dispatch group.</Phase_Banner>
<Team_Mode>No teamMode integration. program-to-spec targets a single object (one program / class / FM group / CDS / RAP BO) and performs read-only structural extraction — no cross-module synthesis, no authoring conflict, no incident triage. See ../../docs/team-consultation-architecture.md § 6 gating logic. Future extension: if a target's GetWhereUsed graph spans ≥ 2 modules AND user picks L4 depth, Type A (module consultants annotating cross-module concerns in Step 3) could be added — not in current scope.</Team_Mode>
<Use_When>
<Do_Not_Use_When>
/sc4sap:analyze-code/sc4sap:create-programUpdate* calls or re-run /sc4sap:create-program<Session_Trust_Bootstrap> MANDATORY — runs as Step 0a before any MCP call or user interaction.
Invoke /sc4sap:trust-session with parent_skill=sc4sap:program-to-spec to pre-grant MCP tool + file-op permissions (eliminates per-tool prompts during structural reads + screen rendering pipeline).
.sc4sap/session-trust.log already has a line within the last 24h, skip silently.Full spec: see ../trust-session/SKILL.md.
</Session_Trust_Bootstrap>
<Socratic_Scope_Narrowing> The interview is a funnel: every turn reduces the remaining decision space. Score remaining ambiguity 0–10 after each answer; stop when ≤3.
Default opener — bundled 4-question AskUserQuestion (MANDATORY when the target object is already supplied in ARGUMENTS):
Issue ONE AskUserQuestion call with these four questions in this exact order — Audience / Format / Depth / Language — each with "(Recommended)" as the first option. Format is multi-select (multiSelect: true); the other three are single-select. This replaces Rounds 2+3+5 in one UI turn. Only fall back to per-round questioning when the object itself is missing or ambiguous (Round 1) or when the user picks L3/L4 (Round 4 scope trimming).
| # | Header | Question | Options (Recommended first) |
|---|---|---|---|
| 1 | Audience | Who is the primary audience for the spec? | Both (Recommended) · Functional · Technical |
| 2 | Format | Which output formats? (select one or more) | Markdown (Recommended) · HTML · Excel |
| 3 | Depth | What depth of detail? | L2 Standard (Recommended) · L1 Quick Spec · L3 Deep Technical · L4 Audit-grade |
| 4 | Language | Output language? (an English companion is added automatically unless you pick English) | Korean · English · Japanese (order follows user's current language — promote the matching one to first with "(Recommended)") |
Round 1 — Target object (only if ARGUMENTS did not supply it)
SearchObject. If ambiguous, list candidates.Round 2 — Audience + format (covered by the default opener — do not ask separately)
Round 3 — Depth (pick one) (covered by the default opener)
| Depth | Contains |
|---|---|
| L1 — Quick Spec | Purpose, inputs, outputs, main logic steps (numbered; for Module Pool includes PBO/PAI module flow) |
| L2 — Standard Spec (default) | L1 + inputs & screens, data model, authorizations, outputs, exceptions, every subroutine / method signature |
| L3 — Deep Technical | L2 + SQL inventory, BAdI / exit list, performance notes |
| L4 — Audit-grade | L3 + line-level cross-references, where-used (scope: main object + screens × Z* / Y* callers), risk register, transport history |
Round 4 — Scope trimming (only if L3/L4) Ask ONE narrowing question per turn until ambiguity ≤3:
Where-Used scope (L4 only — fixed default, no interactive prompt)
Z* / Y* only (S2). Standard SAP and add-on namespaces are excluded.Where-Used section MUST repeat this scope in its header so reviewers know what was (and wasn't) searched.Round 5 — Output location
.sc4sap/specs/{object_name}-v{ver}-{lang}.{md|html} (versioned, history in {object_name}-{lang}.history.json — see edit-mode.md) and .sc4sap/specs/{object_name}-{YYYYMMDD}-{lang}.xlsx — one file per selected format, plus the same files with -en (English companion, workflow-steps.md Step 6) when lang ≠ enStop condition: every dimension above has a concrete answer OR user explicitly says "skip remaining, use defaults". </Socratic_Scope_Narrowing>
<Workflow_Steps> The 7-step workflow (Step 0 Socratic → Step 5 Review → Step 6 English companion) lives in a companion file to keep this skill doc short.
MUST read workflow-steps.md (in this skill folder) and execute the steps defined there in order whenever this skill runs.
</Workflow_Steps>
<Spec_Templates> The Markdown L2 skeleton and the Excel sheet-naming convention live in a companion file.
MUST read spec-templates.md (in this skill folder) when rendering the artifact in Step 4.
</Spec_Templates>
<Agent_Composition>
Per-step model allocation. The main thread follows the session model (model: inherit); each Agent(...) carries its own model (frontmatter or explicit override).
sap-analyst × 1, Opus 4.7, frontmatter) — Step 3 primary dispatch: extracts business purpose, inputs, outputs, data sources (including CBO-annotated Z-references when cbo-context.md exists), main-logic narrative, authorization checks, error cases. One dispatch covers all narrative dimensions to keep context continuous.sap-writer × 1) — Step 3 second dispatch (or Step 4 render invocation):
model: "sonnet") — longer narrative + deeper cross-reference + stronger consistency requirement..md; HTML is produced from that same .md by scripts/spec/md-to-html.mjs (no second writer pass).scripts/spec/build-spec.mjs:
English source string → target-language replacement mapping; schema + slot semantics in spec-templates.md § Excel — Template-clone.{selection, alv, processFlow, lang} per-program image data; exact key names + sample values in spec-templates.md § Image Replacement, and selection MUST follow selection-schema.md (blocks / pushbuttons / radio groups transcribed 1:1 from source). Drives the Sheet 3 Selection/ALV mockups + Sheet 4 horizontal Process Flow PNG.
Writer does NOT generate workbook styles, drivers, geometry, or PNGs directly — asset/template_base.xlsx supplies geometry, build-spec.mjs does clone + render + swap in one shot. Depth-driven model override still applies (Sonnet for L3/L4 because the warning-row and processing-step narrative is longer).
Two hard requirements on both JSON files (full rules in spec-templates.md): (1) business-first content — Sheet 4 Step text + processFlow[] describe the business process for a functional reader, with the ABAP event/FORM kept as a secondary annotation (never an event-only list); (2) single-language output — every prose string is in the target lang; only SAP identifiers / ABAP literals stay as-is. build-spec.mjs prints a ⚠ LANGUAGE MIX gate for ko/ja — finalize only when it reports language check OK.sap-writer × 1, model: "sonnet" override) — Step 6, when lang ≠ en: translates the finished files (.md, image-spec.json, tr.json) into their -en twins; the main thread re-runs the same render scripts on them.sap-critic × 1, Opus 4.7, frontmatter, conditional L4 only) — Step 3 gate: verifies every claim in the rendered spec cross-references a concrete line range in source. Skip for L1 / L2 / L3.</Agent_Composition>
<Output_Format>
Spec generated: ZSDR_OPEN_ORDER_ALV v1.0
Depth: L2 Standard · Format: markdown, html · Lang: ko
Sections: 9 · Tables referenced: 6 · Screens: 1 · GUI status: 1
Files: .sc4sap/specs/ZSDR_OPEN_ORDER_ALV-v1.0-ko.md
.sc4sap/specs/ZSDR_OPEN_ORDER_ALV-v1.0-ko.html (editable: Edit → Save → …-edited.html)
.sc4sap/specs/ZSDR_OPEN_ORDER_ALV-ko.history.json
.sc4sap/specs/ZSDR_OPEN_ORDER_ALV-v1.0-en.md (English companion)
.sc4sap/specs/ZSDR_OPEN_ORDER_ALV-v1.0-en.html
.sc4sap/specs/ZSDR_OPEN_ORDER_ALV-en.history.json
Edited copy back from a reader? Hand over the …-edited.html — it is imported as v1.1 (edit-mode.md § Import).
Top-level summary:
Report that lists open sales orders by Sales Organization and date range and displays them via ALV.
Main tables: VBAK, VBAP, VBUK, KNA1 (+ CDS I_SalesOrder).
Authorizations: S_TCODE=ZSDR01, S_TABU_DIS=VBAK.
Next options:
• "Regenerate as Excel" / "Also give me HTML"
• "Extend to L4 with Where-used"
• "Japanese version too"
</Output_Format>
<MCP_Tools_Used>
SearchObject, GetObjectInfoGetProgFullCode, GetIncludesList, GetIncludeReadClass, ReadFunctionModule, ReadInterface, ReadViewRead BehaviorDefinition, Read BehaviorImplementation, Read ServiceDefinition, Read ServiceBindingGetLocalDefinitions, GetLocalMacros, GetLocalTestClass, GetLocalTypesGetScreensList, GetGuiStatusList, GetGuiStatus, GetTextElement (language: "E")GetSqlQuery — T100 message texts only, BASIS ≥ 7.50 (see Data_Extraction_Safety)GetMetadataExtensionGetAbapAST, GetAbapSemanticAnalysisGetWhereUsed, GetEnhancements, GetEnhancementSpot
</MCP_Tools_Used><Related_Skills>
/sc4sap:analyze-code — code quality review (what's wrong)/sc4sap:create-program — spec → new program (forward direction)/sc4sap:deep-interview — requirement clarification for new builds
</Related_Skills><Data_Extraction_Safety>
Spec generation only reads source code + DDIC metadata + where-used — never GetTableContents / GetSqlQuery. No row data is extracted. One exception: GetSqlQuery on T100 (message texts — repository text, not business data) with the explicit fields ARBGB, MSGNR, TEXT, filtered to SPRSL = 'E' and the message classes / numbers the source actually uses, so the spec can print CODE (English text) (workflow-steps.md § Message references). The normal approval prompt still applies. On BASIS < 7.50 GetSqlQuery is unavailable; fall back to the source text as that section describes — never GetTableContents on T100. The blocklist hook is respected if the user asks for sample data (refuse and document the request in the Risk sheet instead).
</Data_Extraction_Safety>
<Inputs_And_Screens_Rendering>
xlsx output — always-on pipeline (clone + program-specific imagery): every xlsx spec runs scripts/spec/build-spec.mjs <tr.json> <image-spec.json> <out.xlsx>. The helper clones asset/template_base.xlsx (geometry / styles / fonts / column widths / row heights / image anchors — all preserved), renders three program-specific PNGs from image-spec.json, then swaps them into the cloned xlsx with dynamic <xdr:ext> extents (no stretching). Three image slots are populated on every spec:
xl/media/image2.png at C4) — driven by image-spec.json.selectionxl/media/image1.png at C19) — driven by image-spec.json.alvxl/media/image3.png at B19, horizontal layout) — driven by image-spec.json.processFlow (each program has a different flow, so drawing4.xml is injected on demand from a blank template container)Graceful degrade: if no headless browser is on PATH, renderScreenImages returns null per slot and build-spec.mjs keeps the template mockups for that slot — never crashes.
No trigger keywords required. Image rendering is part of the default Excel pipeline because each program has unique selection screens, ALV layouts, and flow charts. Drift risk applies only to geometry regression (the old throwaway-driver problem) and image swap only touches drawing extents + PNG bytes, not geometry.
Markdown output — unchanged: continue emitting ASCII wireframes inside fenced code blocks (Step 3.5 in workflow-steps.md). ASCII wireframes never go in xlsx cells.
HTML output: converted from the finished .md by node scripts/spec/md-to-html.mjs <spec.md> --editable --version <ver> — PNGs inlined as data URIs, Mermaid fallbacks drawn by the Mermaid CDN script when opened online (plain source text offline). Same content as the .md, by construction, laid out as a web page: contents sidebar, cover fact card with the version, cross-linked SAP names, sortable / filterable tables, callouts, a Functional view, and a Revision History section. The writer follows html-markup.md so the page can find what it needs.
Edit mode and versions: the page has an Edit button — readers change text, table rows, list items, images and flows in place and Save an …-edited.html carrying their revision (+0.1, author, note). md-to-html.mjs --import turns it back into the next version's .md (only the edited blocks change) and records the revision in history.json. Versioning, review-loop rebuilds (--same-version), import and the English companion: MUST read edit-mode.md before building or importing an HTML spec.
</Inputs_And_Screens_Rendering>
Task: $ARGUMENTS
What SKILL.md sets; muted values are Claude Code's defaults
inheritThree short reads, in order
abap, reverse-engineering, documentation, specification, sap
npx claudepluginhub babamba2/superclaude-for-sap --plugin sc4sap31 skills in this plugin
/adobe-from-pdfBuild an Adobe form (SFP — interface, context and XDP layout) from a PDF of the printed form, the way smartform-from-pdf builds a SmartForm, upload it to the DEV system, print it there and score the print against the source page. Awaiting approval — not runnable yet./adobe-previewDraw the expected print of an Adobe form (SFP, S/4HANA) as HTML pages in mm (plus JPG / PDF with a local browser) — the XFA layout with its master pages, flowed tables with repeated headers, page breaks, captions, pictures (dates, numbers, currency shifts), rich text with embedded fields, rounded boxes and images — filled with invented sample values sized to the interface's DDIC types. On a development system it can print SAP's example forms through ADS and score the preview against SAP's own PDF./analyze-codeABAP code analysis — size-gated review (one Opus sap-code-reviewer, or Haiku sap-checker detectors + Opus judge for large objects), Haiku evidence check on every finding, then a canned report or a richer briefing on the main thread/analyze-symptomRead-only, step-by-step root cause analysis for SAP operational errors. Reads the dump summary and failing source via MCP (known-issue web lookup only when the failure is in standard SAP code), widens to transports and where-used only when the clues call for it, narrows hypotheses with minimal user questions, and provides SAP Note search keywords. Never changes code or data./ask-consultantDirect operational Q&A with a SAP module consultant agent. Auto-routes the question to the matching sap-{module}-consultant and answers against the configured SAP environment (version, industry, country, active modules)./assistBusiness assistant for the connected SAP system — looks up and changes specific documents through the installed business actions (query → preview → user confirm → execute), one confirmed step at a time. Use for requests about concrete SAP data such as open purchase orders, goods receipt, delivery complete, PO release, production order release / confirmation / TECO, sales order create or change, delivery / billing block, post goods issue, billing, FI document display or reversal, payment block, G/L posting, internal order status, cost center actuals, cost repost or activity allocation, document output status or reprint, shipments, picking, packing / handling units, shipment costs, warehouse transfer orders and requirements, bin and warehouse stock (ECC LE / WM), maintenance notifications and orders, equipment, functional locations and maintenance plans (ECC PM), EWM warehouse tasks, warehouse orders, bins, stock locations, handling units and delivery warehouse progress (S/4 EWM, lookups only). Korean requests too — 미결 PO, 입고, 완결, 납기 변경, 승인, 생산오더, 실적 등록, 기술적 완료, 판매오더, 출하 보류, 청구 보류, 출고 전기, 청구 생성, 전표 조회, 역분개, 지급보류, 분개 전기, 내부오더, 코스트센터 실적, 비용 재전기, 활동 배부, 출력 상태, 재출력, 운송/선적 생성, 피킹, 포장, HU, 운송비, 이전오더(TO) 생성/확정/취소, 이전요청(TR), 저장빈, 창고 재고, 재고실사, 보전오더, 보전통지, 고장 통지, 설비, 기능위치, 보전계획, 보전오더 기술적 완료, 미결 창고작업, 창고작업 조회, 창고오더, 빈 저장빈, 재고 위치, 납품 창고 진행, 검사로트, 사용결정, 검사결과 입력, 품질통지. Not for how / why / configuration questions (ask-consultant).Other plugins' skills for the same job