/sap-gen-code:sap-docs-layout <operation> [<workbook-path>] [op-specific-flags]from sap-gen-code
Edits the structural layout of a SAP design spec template (.xlsx) by writing to the workbook's (Meta) Layout sheet. Supports inspect, bootstrap, add-column, rename-sheet, validate operations.
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 edit the structural layout of a customer's design-spec template. Customers
fill specs into spec_template.xlsx; this skill is what they use to customize
that template's structure without touching Markdown rules or Python.
The skill writes to a hidden (Meta) Layout sheet inside the workbook. That
sheet is the only authoritative description of the workbook's layout.
/sap-docs-extract reads it directly. The canonical spec_template.xlsx
ships with a populated Meta sheet; bootstrap copies it into other
workbooks when needed.
Task: $ARGUMENTS
| File | Purpose |
|---|---|
<SAP_DEV_CORE_SHARED_DIR>/rules/skill_operating_rules.md | Mandatory operating rules |
<SAP_DEV_CORE_SHARED_DIR>/rules/ddic_excel_layout_rules.md | DDIC Excel-spec authoring rules — naming-suffix consistency, primitive-type-as-DTEL trap, currency reference, column order, no merged data cells. Constrain meta-layout edits to remain compatible with the rule set. |
<SAP_DEV_CORE_SHARED_DIR>/rules/language_independence_rules.md | GUI-scripting language independence — offline layout editor, but rule applies to downstream deploy skills the spec feeds |
<SKILL_DIR>/templates/spec_layout_schema.md | Canonical schema for the (Meta) Layout sheet. Read this before generating or editing meta rows. |
<SAP_DEV_CORE_SHARED_DIR>/templates/spec_template.xlsx | Canonical reference template. Default target when no workbook path is provided. bootstrap copies its (Meta) Layout sheet into other workbooks. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_log_helper.ps1 | Structured logging. |
<SKILL_DIR>/references/edit_meta_layout.py | openpyxl helper — read/write meta sheet, perform structural edits, copy Meta sheet between workbooks. |
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 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 |
Set {WORK_TEMP} = {work_dir}\temp. Ensure it exists. Set {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
log state file. Mint it once here and reuse the same value in Step 0.5 and
Final — do not call Get-SapRunTemp again later.
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_docs_layout_run.json" -Skill sap-docs-layout -ParamsJson "{\"args\":\"<RAW_ARGUMENTS>\"}"
Tokenise $ARGUMENTS. The first positional argument MUST be one of:
inspect | bootstrap | add-column | rename-sheet | validate
If the first token is none of those, the user spoke conversationally ("add an AuthGroup column to my Field Definitions sheet") — translate into the explicit form yourself, confirm with the user, and proceed.
The second positional argument is the workbook path. If omitted:
{custom_url}\spec_template.xlsx exists → use it.<SAP_DEV_CORE_SHARED_DIR>\templates\spec_template.xlsx.Report the chosen path:
INFO: Workbook: <resolved-path>
INFO: Operation: <op>
If the resolved workbook does not exist, abort with:
ERROR: Workbook not found at <path>. Pass the path explicitly:
/sap-docs-layout <op> C:\path\to\template.xlsx ...
Op-specific flags follow the workbook path. They are documented per operation in Steps 3a–3e below.
inspect and validate)Read-only operations (inspect, validate) never modify the file — skip this
step for them.
For all other operations, before any write:
from datetime import datetime
import shutil
from pathlib import Path
src = Path(workbook_path)
ts = datetime.now().strftime("%Y%m%d%H%M%S")
backup = src.with_suffix(f".bak.{ts}.xlsx")
shutil.copy2(src, backup)
print(f"INFO: Backup written to {backup}")
The backup lives next to the workbook and is never auto-cleaned. Customers
can delete old .bak.*.xlsx files themselves.
inspectArgs: none beyond workbook path.
Read the (Meta) Layout sheet via references/edit_meta_layout.py
(function read_meta). If the sheet is absent:
WARN: This workbook has no (Meta) Layout sheet. Run:
/sap-docs-layout bootstrap <workbook>
to create one from the built-in defaults.
Otherwise print, in this order:
key, sheet_name, output_file,
format, required.section_key, one block per section, each as
a markdown table: output_position, output_column, source_column_header,
source_column_letter, transform, required.N sections, M columns, K required sections.bootstrapCopy a (Meta) Layout sheet into a workbook that doesn't have one. Useful
when a customer has localized or customized a template in Excel before
running the skill, and the meta sheet got lost or never existed.
Args:
| Flag | Default |
|---|---|
--from <path> | <SAP_DEV_CORE_SHARED_DIR>\templates\spec_template.xlsx (the canonical reference) |
--force | not set (refuse if (Meta) Layout already exists in the target) |
Behaviour:
(Meta) Layout sheet AND
--force is not set, abort with:
ERROR: (Meta) Layout already exists. Use --force to overwrite or run
/sap-docs-layout inspect <workbook>
to review the current layout first.
--from) with openpyxl. Read its
(Meta) Layout sheet contents (header rows + SECTIONS table +
COLUMNS table).--force) a
(Meta) Layout sheet, copy in the source content row-by-row,
preserving formatting (font, fill, borders, named ranges scoped to
the sheet).language row to match the target workbook's localization
if obvious from sheet names; otherwise leave as-is and warn.sheet_state = 'hidden').inspect and report the result to the user.add-columnArgs (all required unless noted):
| Flag | Meaning |
|---|---|
--section <key> | Section key from the meta Sections table (e.g. ddic_dataelements). |
--name <COL> | Output column name (e.g. AUTHGROUP). Becomes the TSV header. |
--after <existing> | Output column to insert after. Use START to insert at position 1. |
--source-header <text> | Header text on the actual sheet. Optional — defaults to --name. |
--required | Optional — marks the column required. Default optional. |
--transform <fn> | Optional — one of trim, upper, int, bool_X. Default trim. |
Behaviour:
--section not found, abort with the list of known keys.meta.sections[--section].sheet_name.--after.--source-header into the header cell. Copy header style from the
neighbouring column.output_position shifted to match the inserted column. Renumber any rows
below it.OK: Added column <NAME> to sheet "<sheet>" at position <N>.
Meta updated: section=<key>, output_position=<N>.
Run /sap-docs-layout validate <workbook> to confirm.
rename-sheetArgs:
| Flag | Meaning |
|---|---|
--section <key> | Section key whose sheet to rename. |
--to <new-name> | New sheet name (any Excel-valid string up to 31 chars). |
Behaviour:
sheet_name.--to:
:\\/?*[].ws.title = new_name).meta.sections[*].sheet_name for every section mapped to the
renamed sheet — sections can share one sheet (interface_* on
Interface Contract, ddic_tables_* on Tables), and updating only the
named section would break its siblings.wb.defined_names and rewrite the sheet portion of each affected range.validateArgs:
| Flag | Default |
|---|---|
--dry-parse | not set (skip the dry-parse phase) |
Behaviour — read-only, never modifies the workbook. Phase A runs through
references/edit_meta_layout.py validate <workbook>; Phase B is orchestrated
by the skill itself (the helper does not shell other skills).
Phase A — structural reconciliation:
For every section in the meta Sections table, dispatch on format:
format = kv or format = tsv:
anchor_named_range is defined and resolves on that sheet, OR the
anchor_keyword is found on that sheet, scanned across ALL columns
(top-to-bottom, then left-to-right within each row) — the same scan
/sap-docs-extract performs, NOT just column A (e.g. ddic_tables_fields
anchors on FIELDNAME in column C). (Else WARN.)source_column_letter is in range, OR source_column_header text is
found on the anchor row. (Else WARN.)tsv only — kv
sections have no on-sheet header row; their source_column_header
values are meta-comments like (col A labels)). (Else FAIL.)format = image:
worksheet._images in openpyxl). (Else WARN with the message
"section : sheet '' has no embedded image yet — paste a
whole-screen image into the sheet before extraction".)anchor_named_range, if set, resolves on the sheet. The anchor is
not used for parsing image-format sections, but a defined anchor is
still part of the schema regularity invariant.anchor_keyword should be empty for image-format sections. If
populated, WARN — keyword scanning is meaningless for images.format = text:
anchor_named_range, if set, resolves on the sheet (schema
regularity invariant). Anchor is not used for parsing.anchor_keyword should be empty for text-format sections. If
populated, WARN.format = <unknown>: FAIL with "section <key>: unknown format '<value>'. Allowed: kv, tsv, image, text."
For every worksheet in the workbook NOT named (Meta) Layout, README, or
(Auto) *:
Phase B — dry-parse (only if --dry-parse):
Run /sap-docs-extract against this workbook with output redirected to a
scratch folder under {WORK_TEMP}\layout_validate\<timestamp>\. Report which
expected output files were produced and which were empty / missing. Delete
the scratch folder after reporting unless any check failed.
Output:
=== Phase A: Structural reconciliation ===
OK <N> sections checked
OK <M> columns checked
WARN <K> warnings
FAIL <X> errors
=== Phase B: Dry-parse === (only if --dry-parse)
OK <K> output files produced as expected
WARN <Y> output files empty
FAIL <Z> expected output files missing
=== Punch list ===
- [WARN] section "ddic_tables": anchor_keyword "Table name" not found on sheet "DDIC Definitions"
- [FAIL] section "interface_inputs": column "TYPE" required but header cell is blank
- ...
Exit 0 if no FAIL, 1 otherwise (so this is callable from CI).
Use SUCCESS for completed write operations, EXISTED for inspect/validate
that found no issues, FAILED with an ErrorClass if any step blocked
progress (META_NOT_FOUND, META_ALREADY_EXISTS, SECTION_UNKNOWN,
SHEET_NOT_FOUND, INVALID_ARGUMENT, XLSX_WRITE_FAILED).
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{RUN_TEMP}\sap_docs_layout_run.json" -Status SUCCESS -ExitCode 0
references/edit_meta_layout.py. Refactor there, not in SKILL.md.bootstrap copies the (Meta) Layout sheet from a reference workbook
(default: the canonical spec_template.xlsx). It does NOT parse Markdown —
the Markdown-bootstrap path was removed in favour of a single source of
truth (the canonical workbook's Meta sheet).(Meta) Layout sheet is documented in
<SKILL_DIR>/templates/spec_layout_schema.md. Bump the
schema's version row when changing it; the skill should refuse to
operate on workbooks with a schema version it doesn't understand.(Meta) Layout sheet
itself are within scope.format values in the SECTIONS tableformat | Meaning | Required Meta state | Output produced by /sap-docs-extract |
|---|---|---|---|
kv | Two-column key/value layout (Cover sheet pattern). | At least 2 COLUMN rows (FIELD, VALUE or equivalent). Anchor named range or keyword required. | One _<name>.txt file with KEY\tVALUE lines |
tsv | Standard tabular layout — one TSV row per data row. | One COLUMN row per output column. Anchor required. Required columns must have non-empty header cells. | One _<name>.txt TSV with header + data rows |
image | Sheet contains an embedded image (e.g. selection-screen layout). No tabular data. | ZERO COLUMN rows. Anchor named range optional, anchor_keyword should be empty. Sheet should contain ≥1 embedded image. | One _<name>.png (the first embedded image, saved via openpyxl worksheet._images) |
text | Free-form notes (Supplement sheet pattern). No header, no columns, no schema. | ZERO COLUMN rows. Anchor named range optional, anchor_keyword should be empty. | One _<name>.txt plain-text dump (every non-empty cell, row-by-row, tab-joined) |
Adding a new format is a schema change — bump schema_version in the
meta header, document semantics here, and update both validate (Phase A
dispatch) and /sap-docs-extract (image-extraction-equivalent step) to
handle it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sap-docs, design-spec, excel-layout, meta-sheet, workbook-customization
npx claudepluginhub sapdev-ai/sap-dev --plugin sap-gen-code12 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-convertApplies customer-specific normalisation rules to the extracted spec files
in a work folder. Reads `spec_conversion_rules.tsv` (default at
sap-dev-core/shared/tables/, override at {custom_url}/spec_conversion_rules.tsv)
and rewrites the affected `_*.txt` files in place.
Three rule categories:
* field_rename — legacy field name → canonical name
* type_rename — legacy DDIC type token → canonical token
* flag_mapping — legacy flag value → one or more KEY=VALUE pairs
Plus optional schema migration (legacy customer YAML/TSV layout → Customer
Brief layout).
Input: work folder containing the extracted `_*.txt` files (output of /sap-docs-extract).
Output: same files rewritten in place; a `.pre-convert/` snapshot is taken first.
This skill is OPTIONAL — projects already authoring specs in Customer Brief
format can skip it entirely.
/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-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.