OpenProgram Docs

Slash commands

Every surface shares one registry, file format and menu. How others do it: reference implementations.

Source layers

Layer, lowest priority firstSourceAuthorReload
L0 builtinSource codeOpenProgramRestart
L1 pluginentrypoints.commands under ~/.openprogram/plugins/<pkg>/...Plugin authorsPlugin reload
L2 mcplist_prompts() of connected serversMCP serversSession reconnect, /api/commands?refresh=mcp
L3 skill~/.openprogram/skills/<name>/SKILL.mdSkill authors, usersWatcher
L4 user~/.openprogram/commands/**/*.mdCurrent userWatcher
L5 project<cwd>/.openprogram/commands/**/*.mdProject maintainersWatcher
  • Same name: the later layer wins. The overridden command stays reachable as /(plugin)name, /(mcp:linear)name, /(skill)name, /(user)name, /(project)name.
  • Within one source, the same realpath loads once.
  • Conflict in the menu: primary entry tagged (+2 more); ⇥ switches source.
  • The source label is always written by the loader; frontmatter cannot claim one.

File format

---
name: review              # default: file name
aliases: [r, rev]
description: Review the current diff per team conventions
when-to-use: |
  Use when the user wants a style and bug review of uncommitted changes.
hidden: false
arguments:
  - name: target
    description: File path or directory; defaults to the current diff
    required: false
argument-hint: "[target]"
type: prompt
context: inline
agent: general-purpose    # only with context: fork
model: inherit
effort: medium
allowed-tools: [Read, Grep]
paths: ["src/**/*.{ts,tsx}", "**/*.py"]
requires:
  any-bins: [git]
  config: [openai_api_key]
hooks:
  PreToolUse: ...
version: 1.0.0
---
Please review this code at {{target}}.

Additional context:
$ARGUMENTS

Recent commits:
!`git log -5 --oneline`

Current diff:
@`git diff --staged`
FieldTypeDefaultMeaningFrom
namestringfile stemCommand namecommon
aliasesstring[][]Also subject to overrideclaude-code
descriptionstring""One line, in the menucommon
when-to-usestring""Detail panelclaude-code
hiddenboolfalseOut of completion, still triggerableclaude-code
argumentslist[]Positional declarations. Numeric names rejected: they collide with $0opencode
argument-hintstringgeneratedGrey hint in the menuclaude-code
typeenumpromptExecution modeclaude-code
contextenuminlineinline or forkclaude-code
agentstringgeneral-purposesubagent_type when forkingclaude-code
modelstringinheritinherit, opus, sonnet, haiku or a full idclaude-code
effortenum, intinheritlow, medium, high, max or a numberclaude-code
allowed-toolsstring[]inheritTool allowlist in fork modeclaude-code
pathsstring[]nullGlob-conditioned activationclaude-code
requiresobject{}Prerequisitesopenclaw
hooksobject{}Temporary hooksclaude-code
versionsemvernullFor upgrade promptsclaude-code
user-invocablebooltrueFalse: only the model can call itclaude-code
shellenuminheritbash or powershell, for ! blocksclaude-code

Undeclared fields go to an extras dict without error.

Body template

SyntaxMeaningFrom
$ARGUMENTSEverything after the commandclaude-code
$0..$9Nth positional; missing is emptyopencode
{{name}}Named argument declared in arguments:opencode
${OPENPROGRAM_COMMAND_DIR}Directory of the command fileclaude-code
${OPENPROGRAM_SESSION_ID}Current session idclaude-code
${OPENPROGRAM_CWD}Current working directoryOpenProgram
!`cmd` or a ```! blockHost shell; stdout spliced in; 2 s timeoutclaude-code, hermes
@`path`File contents spliced inOpenProgram
<<command-name>>name<</command-name>>Expands another command, at most 3 levelsOpenProgram

Arguments are shell-tokenized, falling back to a whitespace split.

Execution

ModeEffect
type: prompt (default)Rendered template becomes a user message, normal agent loop
type: localCalls the host's handler; for /compact, /clear, /new, /web, /model and other builtins
type: local-jsxInterface reserved for a server-pushed structured event
context: inline (default)Rendered prompt enters the current session
context: forkRuns as one agent(prompt=...) sub-agent: agent sets subagent_type, allowed-tools the tools. Its final message is the command result; the main context stays clean

MCP prompts are prompt and inline, rendered on their server.

Conditions and hooks

An unmet condition hides the command from completion. Typing it runs the check again and gives a clear error.

FieldPasses when
pathsA file recently touched in the session, or named with @file, matches
requires.any-binswhich finds at least one; else "needs git / rg, please install first"
requires.configThe profile has the key
requires.platformMatches, e.g. [darwin, linux]
hooks:
  PreToolUse:
    - matcher: Bash
      command: !`echo "blocked by /review" >&2; exit 2`
  PostToolUse:
    - matcher: Edit
      handler: built-in:auto-stage

Effective only during that command. Event names reuse runtime/events/registry.py. ! block: stdout to the log, exit code allows or denies. built-in:<id>: a registered handler. The schema is fixed ahead of use so enabling it later breaks nothing.

Menu

/review                  Review the current diff per team conventions      [project]
  [target]

/review (project)                                                 ⇥ detail panel
─────────────────────────────────────
Review the current diff per team conventions

Arguments: [target] (optional)
Mode: inline · model: inherit · effort: medium
Source: .openprogram/commands/review.md

Grouped by source (project, user, skill, mcp, plugin, builtin), alphabetical within. Fuzzy search over name, description and when-to-use.

Security

InputRule
Command filesAfter realpath, must fall inside the trusted root being scanned (~/.openprogram/, $cwd/.openprogram/)
YAMLyaml.safe_load
Globsfnmatch; .. and absolute paths disabled
! blocksOff unless commands.allow_shell: true; off in MCP context; 2 s timeout; fork bombs forbidden; stdout capped at 64 KB
@ referencesInside trusted roots, or --allow-file <abs>

Implementation

File in openprogram/runtime/commands/Role
loader.pyScans user and project directories
frontmatter.pyYAML and field parsing
template.pyBody rendering
registry.pyMerged table, conflict index, MCP sync
dispatch.pyResolves and renders; pure, the host carries out the result
_plugin_adapter.py, _skill_adapter.pyProject plugins and skills into the registry
  1. User types/review xxx
  2. dispatch.invoke(text, session_id, cwd)registry.resolve, then template render
  3. Result by kindprompt: the host sends the text. local: the handler runs. mcp_prompt: fetched from the server.
EndpointReturns
GET /api/commandsMerged list; ?source=, ?include_hidden=
GET /api/commands/{name}One entry with body
POST /api/commands/invokeBody {text, session_id, cwd}: resolves and renders, does not send
POST /api/commands/reloadForces a rescan
GET /api/commands/conflictsSame name, several sources
GET /api/plugins/commandsOlder plugin-only list
Front endReads the registry through
Web composer (use-slash-menu.ts)/api/commands, with /api/plugins/commands as a fallback; rendered text lands in the textarea
Rich REPL (repl/handlers.py)_handle_slash and dispatch.invoke. register_repl_builtins registers each local action with a marker string; _LOCAL_ACTIONS maps it back. Existence, aliases and /help read list_all()
Ink TUI (apps/cli/src/commands/registry.ts)Hardcodes only TUI-local actions. GET /api/commands feeds completion, Ctrl+K and /help; POST /api/commands/invoke expands
Dropped on purpose
SourceDesignWhy not
openclawi18n (descriptionLocalizations)English and Simplified Chinese only
openclawProvider routing (Slack, Mattermost)Single host
hermesplatforms filterReplaced by requires.platform
hermes134-pattern prompt-injection detectionBelongs in a standalone scanner
claude-codelocal-jsx React componentsWeb UI uses structured events; the CLI has none
pi-monoPure hardcodingA counterexample
Versioning
  • version is stored in the registry with the source repository's git hash, if any.
  • L0 tracks the OpenProgram version. L1 uses plugin autoupdate. L3 uses skills discovery diff. L4 and L5 are user-written and do not auto-update.
  • New designs from the references become fields here. Frontmatter is a stable contract: if upstream renames a field, an alias in frontmatter.py keeps both spellings parsing.

Implementation status

StatusItems
ImplementedAll six layers, frontmatter parsing, $ARGUMENTS, positional, named and OPENPROGRAM_* substitutions, override and (source)name, conflict table, the API, all three front ends
Parsed, not acted onpaths, requires, hooks, allowed-tools limits, context: fork (returned by invoke, no sub-agent run)
Not built! and @ substitution, <<command-name>> expansion, commands.allow_shell, the watcher, local-jsx, the ⇥ source switcher and detail panel, the field alias table, version and git-hash storage

Skills are registered inline, with agent: general-purpose set so a later switch to fork lands on the right pool.

Last updated · 2026-11-25