Slash Commands
Slash commands let you control a pw code session without leaving the conversation. Type / in the composer to open the command palette, which filters as you type, or run /help in a session to print the same list. Press Enter to run the highlighted command.
Built-In Commands
| Command | Description |
|---|---|
/allocation [allocation-name] | Show or change the budget allocation (org providers only) |
/auth | Re-authenticate when your token or API key has expired |
/clear | Clear conversation and start fresh |
/compact | Manually compact conversation history |
/cost | Show token usage and estimated cost |
/diff | Show git diff for workspace |
/fork <task> | Fork this conversation into a subagent with its full history |
/help | Show available commands |
/mcp | Show MCP server connection status and tools |
/model [model-name] | Show or change the current model |
/permissions [add|remove <rule>] | View and manage allowed tool rules |
/rename <name> | Rename the current session |
/resume | Resume a previous session from a picker |
/settings | Change pw code settings |
/status | Show session status |
/usage | Show provider usage and reset times |
/version | Show CLI version |
/usage availability
/usage only appears in the palette and in /help when the selected model's provider reports usage information. If your provider does not expose usage windows, the command is hidden.
/fork hands a task to a subagent that starts with a full copy of the conversation so far. See Subagents for details.
The composer has two other prefixes: @ references files and ! runs a shell command yourself. See Interface & Shortcuts.
Custom Slash Commands
You can define your own slash commands as markdown files. A file named <name>.md becomes the command /name, and its body is the prompt sent to the agent when you run it.
pw code looks for command files in these locations, in order of precedence:
<workspace>/.agents/commands/: project commands, shared with your team through version control~/.config/agents/commands/: personal commands, available in every workspace (respectsXDG_CONFIG_HOME)
When the same command name exists in both locations, the project file wins.
Project commands require approval
Command files in the workspace are part of the configuration pw code asks you to approve at launch. See Workspace Trust.
File Format
An optional frontmatter block sets how the command appears in the palette:
description: the one-line description shown next to the commandargument-hint: appended to the command name in the palette to show what arguments it expects
The body is a prompt template. These placeholders are substituted when the command runs:
$ARGUMENTS(or$ARGS): everything typed after the command name$1through$9: individual space-separated arguments; a position with no argument expands to nothing
Example
Save this as .agents/commands/fix-issue.md in your workspace:
---
description: Investigate and fix a GitHub issue
argument-hint: <issue-number>
---
Look up GitHub issue #$1 with `gh issue view $1`.
Reproduce the problem, implement a fix, and run the relevant tests.
Summarize the root cause when you are done.Then run it from the composer:
/fix-issue 123The agent receives the body with $1 replaced by 123 and works through it as a normal turn.
MCP prompts are slash commands too
Connected MCP servers can expose prompt templates, which appear in the palette as /mcp__<server>__<prompt>. See MCP Servers for how arguments are passed.
Related Documentation
- pw code Overview: Feature overview and quick start
- Subagents: Fork conversations and delegate tasks
- MCP Servers: Connect external tools and prompts
- Permissions: Permission modes and allow rules
- Sessions & Resume: Save, rename, and resume sessions
- Usage & Costs: Track token usage and spend
- Settings: Configure
pw code - Interface & Shortcuts: Keyboard shortcuts and the composer