diff --git a/extensions/EXTENSION-DEVELOPMENT-GUIDE.md b/extensions/EXTENSION-DEVELOPMENT-GUIDE.md index 877cfa0f97..e907c0fef8 100644 --- a/extensions/EXTENSION-DEVELOPMENT-GUIDE.md +++ b/extensions/EXTENSION-DEVELOPMENT-GUIDE.md @@ -252,6 +252,7 @@ Use standard Markdown with special placeholders: - `$ARGUMENTS`: User-provided arguments - `{SCRIPT}`: Replaced with script path during registration +- `__SPECKIT_COMMAND___`: Replaced with the invocation of another command, rendered using the active integration's separator (see [Referencing other commands](#referencing-other-commands)) **Example**: @@ -267,6 +268,30 @@ echo "Running with args: $args" ``` ```` +### Referencing other commands + +A command body is a *template* that Spec Kit renders once per agent. Different agents invoke commands with different surface syntax — for example `/speckit.plan` (dot separator) or `/speckit-plan` (hyphen separator). Some agents also use different prefixes in skills mode (e.g. Kimi `/skill:speckit-plan`, Codex/ZCode `$speckit-plan`). So when you reference a sibling command from a body, **do not hard-code a literal invocation** like `/speckit.my-ext.prepare`. A literal is correct for exactly one agent and breaks on the rest. + +Instead use the agent-neutral token `__SPECKIT_COMMAND___`. Spec Kit resolves it to a `/speckit...` invocation using the active integration's `invoke_separator` (and integrations may post-process that further in skills output). + +Encode the command name in upper case, dropping the `speckit.` prefix and turning each dotted segment separator into an underscore: + +| Command file | Token | +| --- | --- | +| `speckit.plan.md` | `__SPECKIT_COMMAND_PLAN__` | +| `speckit.bug.fix.md` | `__SPECKIT_COMMAND_BUG_FIX__` | +| `speckit.git.commit.md` | `__SPECKIT_COMMAND_GIT_COMMIT__` | + +The resolver maps each underscore back to the active agent's separator, so use tokens to reference commands whose name segments are single words. (Command names are dotted segments like `git.commit`; the token scheme rebuilds those dots and does not carry hyphens within a segment.) + +**Example** — a command body that points the user at the next step: + +```markdown +Once the assessment exists, the next step is `__SPECKIT_COMMAND_BUG_FIX__ slug=`. +``` + +This renders as `/speckit.bug.fix slug=` for a slash-based agent, `/speckit-bug-fix slug=` for a skills-based agent, and so on — the author writes it once and it stays portable. The first-party `bug` and `git` extensions use this token exclusively; see `extensions/bug/commands/` for working examples. + ### Script Path Rewriting Extension commands use relative paths that get rewritten during registration: