/claude-code-superpowers:skill-and-command-dispatchfrom claude-code-superpowers
Explains Claude Code's Skill and Command system: how slash commands are defined as PromptCommand or LocalCommand, how skills load from .claude/skills/, and the inline vs. fork execution modes. Use when creating new commands or SKILL.md files.
Ships in claude-code-superpowers. 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.
None: SKILL.md is the whole skill.
Any AI agent framework needs a way to let users trigger named behaviors — commands that are text shortcuts for common workflows. The key design decision is execution isolation: does the command run inside the current conversation (sharing history and state), or in a separate fork (isolated context, only the result comes back)? Inline mode is simpler; fork mode is for commands that do extended multi-step research without cluttering the conversation history.
Commands come in two types: prompt injection (a template is added to the conversation for the LLM to act on) and local execution (a function runs directly, bypassing the LLM). Prompt injection suits open-ended tasks; local execution suits deterministic operations (opening a file, showing help text).
Claude Code applies this pattern with PromptCommand (prompt injection) and LocalCommand (local execution). A Command is a user-facing /something that appears in the Claude Code prompt. Skills are SKILL.md files dropped into .claude/skills/ — they become PromptCommands automatically.
The critical split is execution context: context: 'inline' means the skill/command runs inside the current conversation, sharing message history and the current AppState. context: 'fork' means the skill spawns a subagent with an isolated copy of the conversation — the subagent runs, returns a result, and the result is injected back. Fork mode is for skills that do research or generate artifacts without polluting the conversation history.
The skill system is Claude Code's extension mechanism. Users drop a SKILL.md file into .claude/skills/ and it appears as a /skill-name command. No code compilation, no restart. The file's frontmatter (name, description, model, allowedTools) configures the command; the file body becomes the prompt template.
Fork mode exists because some skills (e.g., /commit which drafts a commit message and opens an editor) need to do multi-step work without their intermediate reasoning cluttering the user's conversation history. The subagent's conversation is ephemeral; only its output survives back to the main session.
src/commands/. Export a PromptCommand | LocalCommand | LocalJSXCommand. Register it in src/commands.ts.name, description) and body text as the prompt. Place in .claude/skills/[name]/SKILL.md. It auto-registers as a PromptCommand.context: 'inline' when the skill's output should become part of the ongoing conversation (e.g., answering a code question).context: 'fork' when the skill does extended work and should return a single result (e.g., generating a PR description, running tests and reporting back).allowedTools frontmatter to restrict which tools a skill can invoke — this is a safety mechanism for skills that don't need write access.agent frontmatter to specify which agent type runs a forked skill (e.g., agent: general-purpose).// Source: src/types/command.ts (PromptCommand definition)
export type PromptCommand = {
type: 'prompt'
progressMessage: string // Shown while the command runs
contentLength: number // Estimated prompt size for token budgeting
argNames?: string[] // Named slots in the prompt template: $ARGUMENTS
allowedTools?: string[] // Restrict which tools this command can use
model?: string // Override model for this command
source: SettingSource | 'builtin' | 'mcp' | 'plugin' | 'bundled'
pluginInfo?: {
pluginManifest: PluginManifest
repository: string
}
disableNonInteractive?: boolean
hooks?: HooksSettings
skillRoot?: string // Directory containing the SKILL.md
context?: 'inline' | 'fork' // Execution isolation mode
agent?: string // Which agent type runs this (for fork mode)
effort?: EffortValue // thinking effort: low|medium|high
paths?: string[] // File paths to attach to the prompt
getPromptForCommand(
args: string,
context: ToolUseContext,
): Promise<ContentBlockParam[]> // Returns the prompt content to inject
}
// Source: src/types/command.ts (LocalCommand for non-LLM commands)
export type LocalCommand = {
type: 'local'
description: string
call(
args: string,
context: ToolUseContext,
): Promise<void> // Runs locally, returns nothing to the conversation
}
// Source: src/skills/loadSkillsDir.ts (SKILL.md → PromptCommand conversion)
// SKILL.md frontmatter example:
// ---
// name: commit
// description: Draft a commit message and open an editor
// context: fork
// agent: general-purpose
// allowedTools: [Bash, FileRead, Glob]
// ---
// [prompt body becomes the template]
// The skill loader reads frontmatter and creates a PromptCommand with:
// - type: 'prompt'
// - context: from frontmatter (default 'inline')
// - getPromptForCommand: returns the file body with $ARGUMENTS substituted
// - source: 'plugin' | 'builtin' based on location
The argNames field enables named arguments in the prompt template: a command with argNames: ['filename'] and the user typing /review src/main.tsx substitutes src/main.tsx for $FILENAME in the prompt. Multiple names map positionally to space-separated user arguments.
Before — complex analysis done inline, polluting conversation history:
// User runs /analyze-deps, which makes 20 tool calls and produces intermediate output
// All of this appears in the main conversation history — confusing for the user
export const analyzeDepsCommand: PromptCommand = {
type: 'prompt',
context: 'inline', // Wrong: all analysis steps visible in main conversation
progressMessage: 'Analyzing dependencies...',
contentLength: 500,
async getPromptForCommand(args) {
return [{ type: 'text', text: ANALYZE_DEPS_PROMPT }]
},
}
After — analysis forked into an isolated subagent:
// Fork mode: subagent does the multi-step analysis in isolation
// Only the final report is injected back into the main conversation
export const analyzeDepsCommand: PromptCommand = {
type: 'prompt',
context: 'fork', // Isolated: intermediate steps don't appear in main conversation
agent: 'general-purpose',
progressMessage: 'Analyzing dependencies...',
contentLength: 500,
allowedTools: ['FileRead', 'Glob', 'Bash'], // Read-only — no write access needed
effort: 'medium', // Don't use max thinking for a routine analysis
async getPromptForCommand(args, toolContext) {
const target = args || 'package.json'
return [{
type: 'text',
text: `Analyze the dependencies in ${target}. Check for:
1. Outdated packages (compare to latest versions)
2. Security advisories
3. Unused dependencies
Return a concise markdown report with findings and recommendations.`,
}]
},
}
domain-model — where Commands fit relative to Tools and Tasksasync-concurrency — how fork mode spawns an isolated async contextpermission-system — allowedTools enforcement within skill executionWhat SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (techymt/claude-code-superpowers) — no native marketplace selected
npx claudepluginhub p/techymt-claude-code-superpowers16 skills in this plugin
/async-concurrencyTeaches Claude Code's concurrency model: isConcurrencySafe() for parallel tool execution, AbortController propagation for cancellation, Promise.all() for parallel initialization, and the StreamingToolExecutor for concurrent progress streams. Use this when writing tools that could benefit from parallel execution, need to respect cancellation, or must stream partial results. Read-only tools that don't declare concurrency safety are needlessly serialized.
/build-tool-factoryTeaches how to create a new Claude Code tool using the buildTool() factory from src/Tool.ts.
Use this whenever adding a new capability to Claude Code — buildTool is the only correct entry
point. It fills in safe defaults for isConcurrencySafe, isReadOnly, isDestructive,
checkPermissions, and userFacingName so you only implement what your tool actually needs.
/creating-skillsUse when extracting an engineering pattern from a codebase and packaging it as a skill for an AI assistant. Triggered when: converting a recurring code pattern into a SKILL.md, wanting your AI to apply a specific pattern automatically, or validating whether an existing skill is good enough to ship. Covers structure, the real-code requirement, the two-layer generic/specific design, and six quality tests.
/domain-modelTeaches Claude Code's core domain model: Tool, Message, Task, ToolUseContext, AppState, and Command — the six concepts every part of the system is built around. Use this before writing any new tool, command, or feature that touches the conversation loop. Essential for understanding how Claude's capability system is structured and why the abstractions exist.
/error-handlingTeaches Claude Code's error philosophy: tool call() throws typed errors, the framework catches them and formats them for the LLM as structured tool result content, and custom error types carry structured context at system boundaries. Use this whenever writing a tool, utility function, or service that can fail. The distinction between "errors the LLM should see" and "errors that crash the session" is the core insight.
/hot-pathsTeaches Claude Code's startup and runtime performance patterns: lazySchema() for deferred Zod parsing, feature() flags for build-time dead code elimination, memoize() for expensive repeated computations, parallel initialization with Promise.all(), and profileCheckpoint() for tracking load times. Use this whenever writing code that runs at startup, on every turn, or in a hot loop. Startup latency is Claude Code's most user-visible performance metric.
Other plugins' skills for the same job