# Slash Commands

> Source: https://parallelworks.com/docs/ai/code/slash-commands

# 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 <kbd>Enter</kbd> to run the highlighted command.

## Built-In Commands

| Command | Description |
| --- | --- |
| [`/allocation [allocation-name]`](/docs/ai/code/models#allocations) | Show or change the budget allocation (org providers only) |
| [`/auth`](/docs/ai/code/troubleshooting#authentication-expired-mid-session) | Re-authenticate when your token or API key has expired |
| `/clear` | Clear conversation and start fresh |
| [`/compact`](/docs/ai/code/usage-and-costs#context-compaction) | Manually compact conversation history |
| [`/cost`](/docs/ai/code/usage-and-costs) | Show token usage and estimated cost |
| `/diff` | Show git diff for workspace |
| [`/fork <task>`](/docs/ai/code/subagents#forking-the-conversation) | Fork this conversation into a subagent with its full history |
| `/help` | Show available commands |
| [`/mcp`](/docs/ai/code/mcp) | Show MCP server connection status and tools |
| [`/model [model-name]`](/docs/ai/code/models) | Show or change the current model |
| [`/permissions [add\|remove <rule>]`](/docs/ai/code/permissions#allow-rules) | View and manage allowed tool rules |
| [`/rename <name>`](/docs/ai/code/sessions) | Rename the current session |
| [`/resume`](/docs/ai/code/sessions) | Resume a previous session from a picker |
| [`/settings`](/docs/ai/code/settings#the-settings-menu) | Change pw code settings |
| `/status` | Show session status |
| [`/usage`](/docs/ai/code/usage-and-costs#provider-quotas-usage) | Show provider usage and reset times |
| `/version` | Show CLI version |

:::note /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](/docs/ai/code/subagents) for details.

The composer has two other prefixes: `@` references files and `!` runs a shell command yourself. See [Interface & Shortcuts](/docs/ai/code/interface).

## 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:

1. `<workspace>/.agents/commands/`: project commands, shared with your team through version control
2. `~/.config/agents/commands/`: personal commands, available in every workspace (respects `XDG_CONFIG_HOME`)

When the same command name exists in both locations, the project file wins.

:::note 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](/docs/ai/code/settings#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 command
- `argument-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
- `$1` through `$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:

```markdown
---
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:

```text
/fix-issue 123
```

The agent receives the body with `$1` replaced by `123` and works through it as a normal turn.

:::info 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](/docs/ai/code/mcp) for how arguments are passed.
:::

## Related Documentation

- [pw code Overview](/docs/ai/code): Feature overview and quick start
- [Subagents](/docs/ai/code/subagents): Fork conversations and delegate tasks
- [MCP Servers](/docs/ai/code/mcp): Connect external tools and prompts
- [Permissions](/docs/ai/code/permissions): Permission modes and allow rules
- [Sessions & Resume](/docs/ai/code/sessions): Save, rename, and resume sessions
- [Usage & Costs](/docs/ai/code/usage-and-costs): Track token usage and spend
- [Settings](/docs/ai/code/settings): Configure `pw code`
- [Interface & Shortcuts](/docs/ai/code/interface): Keyboard shortcuts and the composer
