/sap-gen-code:sap-docs-convert <work-folder> [rules-file-path]from sap-gen-code
Normalizes extracted SAP spec files with customer-specific field rename, type rename, and flag mapping rules. Optional schema migration from legacy YAML/TSV to Customer Brief format. Runs between extraction and validation.
Ships in sap-gen-code. 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 normalise an extracted spec by applying customer-specific rules. Runs
between /sap-docs-extract and the validation / generation skills:
spec.xlsx ──[sap-docs-extract]──▶ raw _*.txt
│
▼
──[sap-docs-convert]── (optional, rules-driven)
│
┌────────────────────┴─────────────────────┐
▼ ▼
/sap-docs-check (ddic + process dimensions) /sap-gen-abap
Task: $ARGUMENTS
| File | Purpose |
|---|---|
<SAP_DEV_CORE_SHARED_DIR>/rules/skill_operating_rules.md | Mandatory operating rules |
<SAP_DEV_CORE_SHARED_DIR>/rules/language_independence_rules.md | GUI-scripting language independence — offline normaliser, but rule applies to downstream deploy skills the converted spec feeds |
<SAP_DEV_CORE_SHARED_DIR>/rules/abap_code_quality_rules.md | ABAP code-quality rules — type-rename and flag-mapping rules that convert legacy spec fields into Customer Brief layout must preserve ABAP-quality affordances (DTEL vs. primitive, currency reference) so the generated code stays clean |
Resolve work_dir via the env-aware helper — do NOT take work_dir from a direct settings.json read (that ignores the SAPDEV_AI_WORK_DIR env var and userconfig.json). Use the WORK_DIR= value printed by:
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))"
The settings note below still applies to the OTHER keys.
Settings reads/writes follow <SAP_DEV_CORE_SHARED_DIR>/rules/settings_lookup.md — merge per-key on the .value field (env var → settings.local.json → userconfig.json → settings.json); non-per-connection writes go to userconfig.json. Resolve cross-plugin paths: 3 levels up from <SKILL_DIR>, then into sap-dev-core\settings.json and (if present) sap-dev-core\settings.local.json. Read custom_url.
| Setting | Default if blank |
|---|---|
work_dir | C:\sap_dev_work |
custom_url | {work_dir}\custom |
Locate the rules file (priority order — first hit wins):
{custom_url}\spec_conversion_rules.tsv — customer override.<SAP_DEV_CORE_SHARED_DIR>\tables\spec_conversion_rules.tsv — built-in default.If no rules file is found, abort with:
"No spec_conversion_rules.tsv found. Either pass the path as the 2nd argument, drop one in {custom_url}, or use the default at sap-dev-core/shared/tables/."
Also set {WORK_TEMP} = {work_dir}\temp (base dir only) and {RUN_TEMP} =
the RUN_TEMP= value printed above (Get-SapRunTemp mints + creates a fresh
per-run dir {work_dir}\temp\run_<id>) — the per-run scratch dir holding the
Step 0.5 / Step 6 log state file. Mint it once here and reuse the same value
below — do not call Get-SapRunTemp again in a later step.
Start a structured log run. Best-effort: silently no-ops if disabled or the
lib can't load. <SAP_DEV_CORE_SHARED_DIR> resolves to
plugins/sap-dev-core/shared/. State file: {RUN_TEMP}\sap_docs_convert_run.json.
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_docs_convert_run.json" -Skill sap-docs-convert -ParamsJson "{\"work_folder\":\"<WORK_FOLDER>\",\"rules_file\":\"<RULES_PATH>\"}"
Extract the work-folder argument. If missing, ask:
"Please provide the work folder path containing the extracted
_*.txtfiles."
Verify the folder exists and contains at least one *_raw.txt file. Locate
the single *_raw.txt to derive {doc_name} (strip _raw.txt suffix). If
zero or multiple raw files exist, abort with a clear error.
Before any rewriting, copy the current _*.txt files to a snapshot folder so
the operation is reversible:
$snap = Join-Path "{work_folder}" ".pre-convert"
if (-not (Test-Path $snap)) { New-Item -ItemType Directory -Path $snap | Out-Null }
Get-ChildItem -Path "{work_folder}" -Filter "*.txt" -File |
ForEach-Object { Copy-Item $_.FullName -Destination $snap -Force }
If .pre-convert already exists from a prior run, leave it alone — keep the
oldest snapshot so the user can always roll back to the original extract
output.
The rules file is TSV with a header line. Required columns:
| Column | Meaning |
|---|---|
CATEGORY | One of field_rename, type_rename, flag_mapping, schema_migration |
FROM | Source token (legacy value) |
TO | Target token (canonical value); for flag_mapping use KEY1=VAL1;KEY2=VAL2 |
SCOPE | (optional) Comma-separated list of files to limit the rule to. Empty = apply everywhere. Examples: _tables.txt, _domains.txt,_dataElements.txt |
NOTES | (optional) Free-text comment, ignored by the engine |
Example rows:
CATEGORY FROM TO SCOPE NOTES
field_rename FELDNAME FIELDNAME legacy German naming
field_rename KEY_FLAG KEY _tables.txt
type_rename CHAR(N) CHAR strip parentheses
type_rename STRING255 CHAR 255 _domains.txt flatten to fixed-length
flag_mapping PK KEY=X;INITIAL=X _tables.txt primary-key shorthand
schema_migration LEGACY_HK_V1 CUSTOMER_BRIEF see notes
Skip blank lines and lines starting with #.
Iterate the target files in {work_folder} — the table covers every
/sap-docs-extract output; files listed "no rules apply" are excluded
deliberately, not by omission:
| File | Rules to apply |
|---|---|
{doc_name}_PGM_summary.txt | field_rename |
{doc_name}_domains.txt | field_rename, type_rename |
{doc_name}_dataElements.txt | field_rename, type_rename |
{doc_name}_tables.txt | field_rename, type_rename, flag_mapping |
{doc_name}_errorMsgs.txt | field_rename |
{doc_name}_textElements.txt | field_rename |
{doc_name}_process.txt | field_rename, type_rename |
{doc_name}_selection_definition.txt | field_rename (field-name columns), type_rename (type columns) |
{doc_name}_interface.txt | field_rename (field-name columns), type_rename (type columns) |
{doc_name}_file_mapping_in.txt / {doc_name}_file_mapping_out.txt | field_rename (file-field and SAP-field name columns), type_rename (type columns) |
{doc_name}_golden.txt | field_rename (header / field-reference columns ONLY — never rewrite test data values) |
{doc_name}_supplement.txt | field_rename, type_rename (free-form notes; keep tokens consistent with the converted spec) |
{doc_name}_deps.txt | no rules apply — rows are FM / BAPI / class / include object names, not spec field or DDIC type tokens |
{doc_name}_selection_screen_layout.png | no rules apply — binary image |
table_data_*.txt | field_rename (header row only) |
For each rule:
FROM=PK, TO=KEY=X;INITIAL=X means: when a row
contains a column with value PK, set the KEY column to X and the
INITIAL column to X. Implemented per file format — driven by header row.LEGACY_HK_V1) is looked up as a transformation spec at this skill's
references/migrations/<name>.md. No migration docs ship with the
plugin (see references/migrations/README.md for the mechanism) — when
no doc exists for the named migration, log a WARNING and skip the rule.Honour SCOPE: if non-empty, only apply the rule to files whose name appears
in the comma-separated list.
For each file rewritten, write the new content with the Write tool (UTF-8, overwriting the original).
Maintain a per-run log at {work_folder}/_convert_log.txt (overwrite each
run) recording:
sap-docs-convert run @ <timestamp>
Rules file: <path>
Rules loaded: <n>
File: {doc_name}_tables.txt
field_rename: FELDNAME -> FIELDNAME (3 hits)
type_rename : CHAR(N) -> CHAR (5 hits)
flag_mapping: PK -> KEY=X;INITIAL=X (1 hit)
File: {doc_name}_domains.txt
type_rename : STRING255 -> CHAR 255 (2 hits)
TOTAL CHANGES: 11
Rolled-back snapshot: {work_folder}/.pre-convert/
If a rule has zero hits across all files, list it as (0 hits) so the user
can spot stale rules.
Report to the user:
<path> (was it the override or the default?)/sap-docs-check {work_folder} (validates both the process and DDIC dimensions)/sap-gen-abap {work_folder}/{doc_name}_process.txtIf the user wants to roll back, they restore from {work_folder}/.pre-convert/:
Get-ChildItem "{work_folder}\.pre-convert" -File |
ForEach-Object { Copy-Item $_.FullName "{work_folder}\" -Force }
End the log run. Use SUCCESS when at least one rule changed at least one
file; use EXISTED when no rule matched (no-op convert); use FAILED with
ErrorClass=CONVERT_FAILED if a rule could not be applied:
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{RUN_TEMP}\sap_docs_convert_run.json" -Status SUCCESS -ExitCode 0
_raw.txt file is not modified — it always represents the original
document dump from /sap-docs-extract.schema_migration rules are intentionally pluggable, and none ship with
the plugin today — references/migrations/ contains only a README
describing the mechanism. To add a migration, drop a
references/migrations/<NAME>.md file with a clear step-by-step
transformation spec; the skill loads it on demand and WARNs+skips any
schema_migration rule whose doc is missing.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
12 skills in this plugin
/sap-docs-checkValidates an extracted design spec before ABAP code generation, across two
dimensions: `ddic` checks DDIC objects (domains / data elements / tables) —
naming, data-type validity, domain/DTEL/table cross-references, currency-ref
completeness, the primitive-as-data-element trap; `process` checks the
process-logic text for unclear/ambiguous steps, missing info, and logic /
type / cross-reference inconsistencies. Both optionally verify references
against the live system over RFC when a SAP logon is given. Runs BOTH by default
(whichever inputs exist); --dimension ddic|process forces one. Writes a
TAB-separated result file per dimension for Excel review. Replaces the former
/sap-docs-check-ddic and /sap-docs-check-process.
Input: work folder path; optional SAP Logon description enables the RFC checks.
/sap-docs-estimateTurn the spec pipeline's structural signals into a transparent, falsifiable effort estimate
— no gut feel. `score` reads a spec work folder's `_*.txt` DDIC/process/interface counts and
`/sap-docs-check` ambiguity rows, applies published weights, and maps the complexity class to
a WIDE effort band with named drivers and an assumptions register. `--batch` rolls up a
portfolio of specs; `--ledger` bands a `/sap-cc-triage` migration wave by (tier x object
type). `record-actuals` appends real hours to an append-only ledger so every estimate becomes
measurable; `calibrate` (v1.5) tightens the multipliers once enough pairs accrue. Pure-local,
read-only, no SAP access in v1 (a `--live-delta` brownfield-credit RFC mode is v2). Every
report is labelled UNCALIBRATED so a wide band can never masquerade as a commitment.
/sap-docs-extractReads a SAP design document (Excel .xlsx, Word .docx, PDF) — or an existing work
folder / a _raw.txt file — and extracts structured information into separate text
files by type: program summary, domains, data elements, tables, error messages,
text elements, and process logic. From a document it creates a fresh work folder,
dumps {doc_name}_raw.txt, then structures; existing {doc_name}_*.txt files are
silently overwritten. Optionally chain /sap-docs-convert afterwards for
customer-specific normalisation, then /sap-docs-check and /sap-gen-abap. Legacy
binary .doc is not supported (save as .docx first); an unsupported format aborts
with "ERROR: Unsupported file format."
/sap-docs-layoutEdits the structural layout of a SAP design spec template (.xlsx) by writing
to the workbook's `(Meta) Layout` sheet. Lets customers customize sheet
names, column orders, and output mappings without editing Markdown rules or
skill code. The meta sheet becomes the per-workbook source of truth that
`/sap-docs-extract` reads on its next run.
Operations:
inspect Print the current layout in human-readable form.
bootstrap Copy a `(Meta) Layout` sheet from the canonical
`spec_template.xlsx` into a workbook that doesn't have one.
add-column Add a column to a section. Updates xlsx + meta in one step.
rename-sheet Rename a sheet and update meta so the parser still finds it.
validate Reconcile the meta sheet against actual workbook structure.
Input: workbook path + operation + op-specific args.
Output: in-place modifications to the .xlsx file. A timestamped backup is
written next to the original before any write operation.
/sap-gen-abapGenerates ABAP source code from a process text file ({doc_name}_process.txt)
produced by sap-docs-extract. Supports generating:
- Dialog/Module Pool programs
- ABAP Reports (帳票/バッチ)
- Function Modules / RFC
Uses variable naming conventions from sap-dev-core/shared/tables/abap_naming_rules.tsv (or custom override from {custom_url}).
Prerequisites: Run /sap-docs-convert and /sap-docs-extract first.
/sap-gen-abap-unitGenerates ABAP Unit tests for an EXISTING object (global class / function module
/ report) and closes the loop on a live system: pre-check the generated test,
deploy, activate, run with coverage, read failures, fix, repeat until green
(bounded). Reads the active source, builds a call/data map, and runs a SEAM
ANALYSIS that classifies every DB read and external call into a doubling strategy
(OSQL test double for SELECTs, ABAP test double for injected dependencies, or
flags untestable-without-refactor), then emits a test class honest about what it
could and could not cover. Pairs with /sap-run-abap-unit (which runs the tests).
Deploy is GUI (/sap-se24 --test-source CCAU for a class, /sap-se38 for a report
test) and gated — asks before writing anything (Rule 2).
Prerequisites: pinned /sap-login connection; active GUI session for class download
+ deploy + run; SAP NCo 3.1 for RFC source read.
npx claudepluginhub sapdev-ai/sap-dev --plugin sap-gen-code