piagent_
← ~/guides

Slash Commands

Last updated: Aug 11, 2026

$ pi –commands

TL;DR. Slash commands in pi are typed at the prompt after / to drive interactive-only operations — authentication (/login, /logout), model and session control (/model, /scoped-models, /new, /resume, /name, /tree, /fork, /clone), context management (/compact), and output (/copy, /export, /share, /import). 22 entries are documented on the canonical Usage page; they are interactive-only and do not run if pasted into a prompt or sent via RPC. Extensions register their own commands alongside the built-ins, skills appear as /skill:name, and prompt templates as /templatename.

Slash commands are the interactive surface of pi. They are not part of the prompt grammar — typing /login mid-message does not call a tool — and they are handled by the TUI, not the LLM. If you want the same operations in headless mode, use the corresponding CLI flags (pi -r, pi --fork <id>, pi --no-session, pi --export ...) or the JSON / RPC modes.

Built-in commands

The canonical list lives on the Usage page in pi’s docs. Below is the set as of v0.84.x, grouped by intent. Exact descriptions are in the Usage table; this guide gives you the orientation and the things that are easy to get wrong.

Authentication and credentials

  • /login — open the OAuth or API-key sign-in flow for a chosen provider.
  • /logout — clear stored credentials.

Model and routing

  • /model — switch the current session’s model.
  • /scoped-models — toggle which models are reachable from the Ctrl+P quick-cycle picker.
  • /settings — open the interactive settings panel (thinking level, theme, message delivery, transport).

Local model management

  • /llama — download, load, and unload models through a llama.cpp router.

Session control

  • /resume — pick from a list of previous sessions in the interactive picker; same picker as pi -r.
  • /new — start a fresh session.
  • /name <name> — set the current session’s display name.
  • /session — show the session file, ID, message count, tokens, and accumulated cost.
  • /tree — jump to any entry in the session’s tree and continue from there.
  • /fork — create a new session file from a previous user message.
  • /clone — duplicate the current active branch into a new session file.
  • /trust — persist the project trust decision for future sessions.

/tree, /fork, and /clone look similar but mean different things — /tree stays inside the same session file for in-place exploration, /fork opens a new file at an earlier user message, /clone opens a new file containing a copy of the current active branch.

Context management

  • /compact [prompt] — summarize older context, optionally steered with a custom prompt. The session guide links the details.

Output and sharing

  • /copy — copy the last assistant message to the clipboard.
  • /export [file] — export the session to HTML or JSONL.
  • /import <file> — import and resume from a JSONL file.
  • /share — upload the session as a private GitHub gist and copy a shareable HTML link.

Meta

  • /reload — reload keybindings, extensions, skills, prompts, themes, and context files.
  • /hotkeys — show every keyboard shortcut.
  • /changelog — display the in-app version history.
  • /quit — quit pi.

/reload is the fastest way to pick up changes without leaving the session — it is hot, so you do not need to restart. Pair it with /settings for runtime configuration tweaks and /tree for navigating back through branches the LLM tried.

Built-ins are interactive-only

The built-in commands are wired into the TUI, not the agent. From the Extensions documentation:

“Built-in interactive commands (like /model and /settings) are not included here [pi.getCommands()]. They are handled only in interactive mode and would not execute if sent via prompt.”

So when you launch pi with --mode rpc or --mode json, slash commands typed into a prompt are ignored — there is no parser fallback. The same is true for --print mode. Use CLI flags in those modes:

Slash command Headless equivalent
/resume pi -r
/fork pi --fork <id-or-path>
/clone clone is session-time, no CLI flag
/session read the file at ~/.pi/agent/sessions/<workdir>/<id>.jsonl directly
/compact not exposed; trigger via the agent loop or write a small session script
/new pi --no-session for ephemeral; otherwise just start the binary
/name pi --name "..."
/export pi --export <file>

When you embed pi through the SDK, pi.getCommands() returns only the extension-registered commands. Built-ins like /model are not part of that list — the SDK does not route them.

Custom commands: extensions, skills, prompt templates

Three registration paths can add a slash command alongside the built-ins. They share the same / prefix but show up in completion under different sources.

Extension commands

Extensions call pi.registerCommand(name, options). The handler receives the typed arguments and a context object. If two extensions register the same name, pi keeps both and appends numeric suffixes in load order: /review:1, /review:2. This is documented in the Extensions page.

If you want the command to be invokable from RPC sendUserMessage, set expandPromptTemplates: true on the RPC options; the default is false, meaning extension / skill / prompt-template commands are NOT expanded in RPC. Plan accordingly for any host that drives pi non-interactively.

Skill commands

Skills register as /skill:name. The skill body is invoked with any text after the command appended as User: <args>. Skill-command availability is controlled by enableSkillCommands in settings — leave it off and /skill:name will not appear in completion. Skills with disable-model-invocation: true in their frontmatter must be triggered explicitly by the user.

Prompt template commands

Prompt templates (under ~/.pi/agent/prompts/ or a project-level equivalent) are invoked as /templatename. They substitute the template’s body into the prompt, which makes them cheap ways to standardize recurring requests like “review this PR” or “write a commit message for these changes”.

Finding and listing commands

Within the TUI, type / to open command completion. The list is filtered by what is actually registered — built-ins you do not have access to (none currently) are hidden, extensions you have not loaded are hidden, skills are only listed if enableSkillCommands is on, and prompt templates are only listed if at least one template is reachable.

For programmatic discovery, use the SDK’s pi.getCommands(). The result includes each command’s name, source ("extension" | "prompt" | "skill"), and whether it accepts arguments. Remember that this does NOT include built-ins — the result is the extension / skill / template layer only.

A short worked example

Suppose you want a command called /security-review that runs a structured prompt. Three paths, in order of how invasive they are:

  1. Prompt template. Drop a security-review.md into ~/.pi/agent/prompts/. Type /security-review src/auth/. The template body replaces the prompt and the LLM gets a focused task. No code, no install step.

  2. Skill. Add a SKILL.md for security-review under ~/.pi/agent/skills/. Now /security-review src/auth/ works the same way but the body lives in the skills directory and can carry structured instructions, examples, and tool hints.

  3. Extension. Write a TypeScript extension that calls pi.registerCommand('security-review', { description, handler }). The handler runs JavaScript, can show progress, and returns a final message — useful when the command needs to read files or call APIs before producing output.

For anything that fits in a single prompt, prompt templates are the cheapest path. For commands that need state or want to render UI, extensions are the right tool. Skills sit in between: more structure than a template, less code than an extension.

Note on staleness. This guide’s command table is current as of the source-of-truth Markdown file linked at the bottom of this section; the live pi.dev docs roll forward and may add commands between releases. If you need an authoritative answer for a specific pi version, cross-check the table against packages/coding-agent/docs/usage.md at that release tag.

Further reading

  • Usage — canonical aggregate of built-in slash commands
  • Sessions/resume, /tree, /fork, /clone, /compact, /share, and the JSONL tree format
  • Compaction/compact [prompt] internals and retry policy
  • Extensionspi.registerCommand, pi.getCommands(), RPC dispatch
  • Skills/skill:name invocation and enableSkillCommands
  • Prompt templates/templatename invocation
  • RPCexpandPromptTemplates and command dispatch from RPC
  • Settings — thinking level, theme, message delivery, transport
  • Keybindings — keyboard shortcuts surfaced by /hotkeys
  • packages/coding-agent/docs/usage.md — source-of-truth for the command table