协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
sap-codex-skills【开发与工程】SAP Codex Custom Skills collection (KEIDAI-TechTime/sap-Codex-skills). Custom templates and system instructions for SAP tasks — template catalog (template_repo.py, xls_to_bapi.py), karpathy behavioral wrapper, prompt patterns for correct router dispatch, and authoring new SKILL.md files.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: sap-codex-skills description: SAP Codex Custom Skills collection (KEIDAI-TechTime/sap-Codex-skills). Custom templates and system instructions for SAP tasks — template catalog (template_repo.py, xls_to_bapi.py), karpathy behavioral wrapper, prompt patterns for correct router dispatch, and authoring new SKILL.md files. trigger: keywords: [custom skill, skill template, system instructions, prompt pattern, template catalog, seed templates, write skill, skill frontmatter, instruction stacking] intent: Using or authoring custom Codex skill templates and system instructions so SAP tasks are phrased, dispatched, and executed consistently through the router prerequisites:
Custom skill templates and system instructions for SAP tasks (attribution: KEIDAI-TechTime/sap-Codex-skills). Grounded in this repo's template machinery: ABAP snippet catalog (template_repo.py), BAPI CSV template generation (xls_to_bapi.py), the karpathy behavioral wrapper, and the SKILL.md authoring pattern that makes the router activate the right skill.
| Layer | What it provides |
|---|---|
| Template catalog | Placeholder-based ABAP snippets per module/action (template_repo.py) |
| BAPI CSV templates | Column-mapped CSV skeletons for batch BAPI input (xls_to_bapi.py template) |
| System instructions | karpathy-guidelines wrapper + caveman compression as output default |
| Prompt patterns | Phrasing rules so sap_router.py dispatches to the correct route |
| Skill authoring | Frontmatter pattern (trigger keywords + intent) for new SKILL.md files |
Catalog of ABAP snippets with {{PLACEHOLDER}} slots, keyed by module + action.
# Seed starter templates for all mapped actions (MM/SD/FI/PP/...)
npm run seed # = python scripts/template_repo.py seed
# List catalog: id, module, action, version, line count, placeholder count
python scripts/template_repo.py list
# Add your own template from an ABAP file
python scripts/template_repo.py add --file my_bapi_call.abap \
--module MM --action CREATE_MATERIAL --title "Material create wrapper"
# Resolve placeholders into ready-to-paste ABAP
python scripts/template_repo.py resolve --template MM_CREATE_MATERIAL \
--values '{"HEADER":"ls_head","RETURN_STRUCT":"ls_return"}'
# Export as JSON for abapGit / nugget packaging
python scripts/template_repo.py export --template CREATE_MATERIAL --format abapgit
--template accepts a template ID prefix, ACTION, or MODULE_ACTION. Ambiguous refs list candidates instead of guessing.
Generate a CSV skeleton whose columns map to BAPI fields, fill it, then validate before conversion.
# Generate CSV template for module + action
npm run template -- --output mm_material.csv --module MM --action CREATE_MATERIAL
# = python scripts/xls_to_bapi.py template ...
# Validate a filled CSV against the BAPI field mapping
npm run csv:check -- --input mm_material.csv --module MM --action CREATE_MATERIAL
# Convert validated CSV to BAPI JSON payloads
npm run convert -- --input mm_material.csv --module MM --action CREATE_MATERIAL
karpathy-guidelines is the mandatory behavioral wrapper for every SAP operation. Its 4 principles:
npm run abap:lint, unit tests, transport consistency.Caveman compression is the output default: drop articles/filler/pleasantries, fragments OK, code blocks unchanged, pattern [thing] [action] [reason]. [next step]. Exception: security warnings and irreversible actions use full clarity.
Phrase requests with module + action so the routing tree picks the right lane:
| You say | Router dispatches |
|---|---|
| "MM create material batch from CSV" | BAPI route (ZROUTER RFC / fallback tiers) |
| "SPRO config for pricing" | GUI route immediately (mcp-sap-gui, no ADT attempt) |
| "edit method in ZCL_HANDLER_MM" | ADT route (arc-1 primary, aibap secondary) |
| "where is X defined" / small 1-2 file edit | Caveman crew (investigator/builder/reviewer) |
| "build report from this spec" | 8-stage pipeline |
# Preview the route before executing
python scripts/sap_router.py route --action MM_CREATE_MATERIAL --module MM
python scripts/sap_router.py route --action SPRO_CONFIG
# Or via npm
npm run router -- --action MM_CREATE_MATERIAL
npm run router:gui -- --action SPRO_CONFIG # Force GUI fallback
Vague prompts ("fix SAP thing") skip module/action matching and land in generic fallback — always name the module (MM/SD/FI/...) and a verb-object action.
Skill activation is model-driven: Codex scans YAML frontmatter descriptions in .Codex/skills/*/SKILL.md. New skills MUST follow this pattern:
---
name: my-sap-skill # matches directory name exactly
description: One-line summary with the exact words users will type.
trigger:
keywords: [6-10 lowercase phrases, tcodes, bapi names, module terms]
intent: One sentence stating the user goal this skill serves
prerequisites:
- Access/config the steps assume (auth, .env vars, transactions)
---
Body structure (max 200 lines): # Title, numbered ## sections with copyable commands, ## Pitfalls (Cause/Solution), ## Verification, ## Related.
System-instruction stacking order when a skill runs: karpathy wrapper (behavior) → caveman compression (output format) → your skill's instructions (domain steps). Skills add domain steps only — do not restate wrapper rules inside skill bodies.
After adding a skill, update ALL cross-file consistency targets: SKILL.md (master list), README.md (counts/diagrams), scripts/healthcheck.py (skill count threshold), AGENTS.md, package.json description.
resolve fails with KeyError → Cause: --values JSON missing a {{PLACEHOLDER}} used by the template. Solution: run template_repo.py list to see placeholder count, inspect template via export, supply every key.seed skips (module, action) pairs already in the repo. Solution: expected idempotence; list to confirm, add a new version to override.npm run template, run npm run csv:check before convert.name differs from directory name. Solution: put exact trigger phrases (tcodes, BAPI names) in description + keywords; keep name = folder.sap_router.py route.healthcheck.py skill-count threshold no longer matches disk count. Solution: update threshold and the other cross-file consistency targets listed in section 6.# Catalog seeded and listable
npm run seed
python scripts/template_repo.py list # expect > 0 templates
# Template resolves to clean ABAP (no {{...}} left in output)
python scripts/template_repo.py resolve --template MM_CREATE_MATERIAL \
--values '{"HEADER":"ls_h","DESCRIPTION":"ls_d","RETURN_STRUCT":"ls_r","MATERIAL_NUMBER":"lv_m","DESCRIPTION_TABLE":"lt_d"}'
# CSV template round-trip validates
npm run template -- --output /tmp/mm.csv --module MM --action CREATE_MATERIAL
npm run csv:check -- --input /tmp/mm.csv --module MM --action CREATE_MATERIAL
# New skill counted and healthy
npm run hc