program-to-spec
Skill69 starsChanged 7 months agoMITView on GitHub
Reverse-engineer an ABAP program into a Functional/Technical Specification artifact (Markdown, HTML, and/or Excel — any combination). Socratic scope narrowing from "everything" to "only what the user needs".
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
If .sc4sap/session-trust.log already has a line within the last 24h, skip silently.
- Very specific: line 63
Verify via SearchObject. If ambiguous, list candidates.
- Distinctive: line 68
Default if user says "up to you" / "you choose" → Audience Both + Format Markdown.
- Distinctive: line 79
Ask ONE narrowing question per turn until ambiguity ≤3:
- Very specific: line 90
Default: .sc4sap/specs/{object_name}-v{ver}-{lang}.{md|html} (versioned, history in {object_name}-{lang}.history.json — see edit-mode.md) …
- Distinctive: line 93
Stop condition: every dimension above has a concrete answer OR user explicitly says "skip remaining, use defaults".
- Very specific: line 181
Graceful degrade: if no headless browser is on PATH, renderScreenImages returns null per slot and build-spec.mjs keeps the template mockups …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SC4SAP Program → Specification
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.
<Purpose>
Turn legacy or unfamiliar ABAP objects into a reviewable Functional/Technical Spec for handover, documentation audit, AMS transition, refactoring preparation, or compliance artifacts. Unlike `analyze-code` (quality-focused), this skill is **documentation-focused**: it describes what the program DOES, not what's wrong with it.
</Purpose><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>
- User says "program to spec", "reverse engineer", "make a spec", "document this program", "functional specification", "technical specification", "generate a specification"
- Knowledge transfer / handover of legacy ABAP to another team
- Preparing a refactoring or rewrite (need to capture as-is behavior)
- Compliance / audit requires a written spec for custom code
- Building a WRICEF inventory with detailed per-object specs </Use_When>
<Do_Not_Use_When>
- User wants a code quality review →
/sc4sap:analyze-code - User wants to create a new program from a spec →
/sc4sap:create-program - User wants to fix the program → direct MCP
Update*calls or re-run/sc4sap:create-program - Object does not exist yet </Do_Not_Use_When>
<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).
- If
.sc4sap/session-trust.logalready has a line within the last 24h, skip silently. - Otherwise run it and surface the one-line confirmation.
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)
- "Which object? (program / FM group / class / CDS / RAP BO name)"
- Verify via
SearchObject. If ambiguous, list candidates.
Round 2 — Audience + format (covered by the default opener — do not ask separately)
- Audience: Functional (business readers — SD/FI/MM users) vs Technical (developers) vs Both
- Format (any combination): Markdown (review-friendly, git-friendly) · HTML (one self-contained file with images inlined — share, mail, print) · Excel (project-PMO-friendly, reviewable cell-by-cell)
- Default if user says "up to you" / "you choose" → Audience Both + Format Markdown.
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:
- "Include unit tests inventory?"
- "Include generated artifacts (Screens / GUI Status / Text Elements)?"
- "Cover all includes or just main?"
Where-Used scope (L4 only — fixed default, no interactive prompt)
- Target = main program / class / FM-group / CDS / RAP-BO object + each of its screens (T1+Screen).
- Caller filter = customer namespace
Z*/Y*only (S2). Standard SAP and add-on namespaces are excluded. - The rendered
Where-Usedsection MUST repeat this scope in its header so reviewers know what was (and wasn't) searched.
Round 5 — Output location
- Default:
.sc4sap/specs/{object_name}-v{ver}-{lang}.{md|html}(versioned, history in{object_name}-{lang}.history.json— seeedit-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.mdStep 6) whenlang≠en - Language: ko / en / ja (infer from user's current language; confirm once).
Stop 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).
- Main orchestrator (Sonnet 4.6) — Steps 0, 1, 1.5, 2, 5: Socratic interview orchestration, object classification routing, CBO context preload, Step 5 review loop. State tracking across depth / format / language dimensions needs Sonnet headroom.
- Analysis (
sap-analyst× 1, Opus 4.7, frontmatter) — Step 3 primary dispatch: extracts business purpose, inputs, outputs, data sources (including CBO-annotated Z-references whencbo-context.mdexists), main-logic narrative, authorization checks, error cases. One dispatch covers all narrative dimensions to keep context continuous. - Rendering (
sap-writer× 1) — Step 3 second dispatch (or Step 4 render invocation):- L1 / L2 depth → Haiku 4.5 base (frontmatter). Pure templating from structured analyst output.
- L3 / L4 depth → Sonnet 4.6 override (
model: "sonnet") — longer narrative + deeper cross-reference + stronger consistency requirement. - Markdown / HTML output — writer renders the
.md; HTML is produced from that same.mdbyscripts/spec/md-to-html.mjs(no second writer pass). - Excel output — writer's deliverable is TWO JSON files consumed by
scripts/spec/build-spec.mjs:- TR (translation) map —
English source string → target-language replacementmapping; schema + slot semantics inspec-templates.md§ Excel — Template-clone. - image-spec.json —
{selection, alv, processFlow, lang}per-program image data; exact key names + sample values inspec-templates.md§ Image Replacement, andselectionMUST followselection-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.xlsxsupplies geometry,build-spec.mjsdoes 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 inspec-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 targetlang; only SAP identifiers / ABAP literals stay as-is.build-spec.mjsprints a⚠ LANGUAGE MIXgate for ko/ja — finalize only when it reportslanguage check OK.
- TR (translation) map —
- English companion (
sap-writer× 1,model: "sonnet"override) — Step 6, whenlang≠en: translates the finished files (.md,image-spec.json,tr.json) into their-entwins; the main thread re-runs the same render scripts on them. - Audit verification (
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:
- Sheet 3 Selection (
xl/media/image2.pngat C4) — driven byimage-spec.json.selection - Sheet 3 ALV (
xl/media/image1.pngat C19) — driven byimage-spec.json.alv - Sheet 4 Process Flow (
xl/media/image3.pngat B19, horizontal layout) — driven byimage-spec.json.processFlow(each program has a different flow, sodrawing4.xmlis 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
In this repository23 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analyze-cbo-objSkill
- analyze-codeSkill
- analyze-symptomSkill
- ask-consultantSkill
- compare-programsSkill
- config-to-documentSkill
- create-objectSkill
- create-programSkill
- ecoSkill
- interface-mapping-specSkill
- mcp-setupSkill
- module-to-processSkill
- package-to-processSkill
- program-to-manualSkill
- project-dashboardSkill
- role-matrixSkill
- sap-doctorSkill
- sap-optionSkill
- setupSkill
- smartform-from-pdfSkill
- smartform-previewSkill
- trust-sessionSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

