From structured-english
Upgrade an existing specification to LLM-optimized HSF v6 format
npx claudepluginhub reggiechan74/cc-plugins --plugin structured-english<path to spec file># Upgrade a Specification to LLM-Facing HSF v6 Detect the format version of an existing specification and migrate it to HSF v6, optimized for LLM execution. Preserves all domain logic while upgrading notation and structure for maximum LLM compliance and token efficiency. ## Audience Context The upgraded spec will be consumed by an LLM agent. Optimize the migration for: - **Compliance** — clear, unambiguous instructions with RFC 2119 keywords - **Token efficiency** — remove boilerplate sections, strip rationale that doesn't prevent misapplication - **XML envelope** — use XML section tags...
Detect the format version of an existing specification and migrate it to HSF v6, optimized for LLM execution. Preserves all domain logic while upgrading notation and structure for maximum LLM compliance and token efficiency.
The upgraded spec will be consumed by an LLM agent. Optimize the migration for:
Use the hsf skill — it contains all the rules, formats, and validation requirements for HSF v6. Read it fully before proceeding. Also read the reference at ${CLAUDE_PLUGIN_ROOT}/skills/hsf/assets/reference.md.
If the user provided a file path in the arguments, read it. Otherwise, ask the user:
Read the full file content, then detect the format version:
| Signal | Inferred Format |
|---|---|
Has **BEHAVIOR**, **PROCEDURE**, **RULE**, **STEP** keywords | SESF v4 / v4.1 |
Has @route or @config or ## Instructions prose, no BEHAVIOR/PROCEDURE and no XML section tags | HSF v5 (needs v6 upgrade) |
Has XML section tags (<purpose>, <instructions>, <config>, <errors>) | Already HSF v6 |
No BEHAVIOR, PROCEDURE, ## Instructions, or XML section tags found | Not a spec |
If already HSF v6: Report that the specification is already at the latest LLM-facing format and stop.
If HSF v5: Proceed with migration to HSF v6. The main changes are: replace ## section headers with XML tags, convert @config to <config> with JSON body, convert @route to <route> with <case> elements, change $config.key references to config.key.
If not a spec: Suggest using /write-LLM-spec to create a new specification or /assess-LLM-doc to evaluate suitability, then stop.
Also detect the tier from context.
Detect whether the file is a self-contained executable (Claude Code command or skill) or a standalone specification.
Use AskUserQuestion to ask:
"How should this specification be structured after the upgrade?"
Options:
allowed-tools or argument-hint frontmatter)Store the user's choice as $output_mode.
Compare the specification against HSF v6 requirements. Build two lists:
Format migrations (auto-apply):
When upgrading from SESF v4/v4.1 → HSF v6:
**BEHAVIOR** block:
<rules> or inline in the relevant instruction phase@route tables to <route name="..." mode="..."> with <case> elements**PROCEDURE** block:
<instructions> with ### phase headers**STEP** keywords; convert to numbered lists or phase headers→ $variable syntax unless data flow is genuinely complex<errors>@config blocks to <config> with JSON body (reference as config.key, not $config.key)<purpose>, <scope>, <instructions>, <rules>, <errors>, <examples>)When upgrading from HSF v5 → HSF v6:
## Section headers with XML tags (<purpose>, <scope>, <instructions>, <rules>, <errors>, <examples>)@config blocks to <config> with JSON body@route name [mode] with → rows to <route name="..." mode="..."> with <case when="..."> and <default> elements$config.key references to config.key (drop $ prefix)<errors> tags<output-schema> blocks for phases producing structured outputLLM-specific optimizations (apply automatically):
v6 opportunity suggestions (require user approval):
<config> candidates: Repeated literal values (3+)<route> candidates: Conditional logic with 3+ branches<output-schema> candidates: Phases producing structured outputShow:
Use AskUserQuestion:
${CLAUDE_PLUGIN_ROOT}/skills/hsf/assets/template.md${CLAUDE_PLUGIN_ROOT}/skills/hsf/references/examples.mdApply output mode based on $output_mode:
CRITICAL: Preserve ALL domain logic exactly. Only change format and notation.
python3 ${CLAUDE_PLUGIN_ROOT}/skills/hsf/scripts/validate_sesf.py <output-file>
Fix failures and re-validate. Overwrite the original file.
Report: original format, changes applied, validation result.