进阶 zcode.z.ai 2026-11-25 14:51:22 · 0 阅读
第48章 Command
Core FeaturesCommand
Commands let you save prompts you use often and invoke them by typing / in the input box. Turn repeatable tasks such as code review, commit messages, file walkthroughs, and release checks into commands, and ZCode Agent will follow the same instructions every time.
123
1Switch scope2Import, refresh, and create3Enable or disable
Entry point: open Settings → Commands.
Manage Commands
Use the scope selector at the top of the Commands page to choose what to view: commands in the User scope apply to all projects, and switching to a Workspace shows the commands specific to that project. The list is grouped by source:
Installed: commands you created or imported. Use the switch to enable or disable them. A disabled command no longer appears in the / menu in chat.
Commands provided by plugins: grouped by plugin. These commands are enabled and disabled together with their plugin; manage them in Manage Plugins.
Use the search box to find commands by name, description, or prompt content. Click an installed command to open its editor, where you can change the description, argument hint, and prompt, or delete the command.
Create a Command
On the Commands page, click New, fill in the fields below, and click Save:
FieldDescriptionNameThe command name, invoked as /command-name after saving. Letters, numbers, hyphens, and underscores only, 1–50 charactersScopeSave to User (available in all projects) or to a Workspace (available in that project only)DescriptionOptional. A short description shown in the / menuArgument hintOptional. Indicates the arguments to provide when invoking the command, such as PromptThe content sent to ZCode Agent when the command is invoked
Command Files
Each command is stored as a Markdown file named after the command:
ScopeLocationUser (all projects)~/.zcode/commands/.mdProject (current project only)/.zcode/commands/.md
ZCode also reads the .agents/commands directory. You can write command files directly; after saving, click Refresh on the Commands page:
---
description: Explain a file's structure, key logic, and dependencies
argument-hint:
---
Read $1 and describe its overall structure, key logic, and external dependencies. Point out any implementation details worth noting.
Use the following placeholders in a prompt to reference the arguments passed at invocation:
PlaceholderMeaning$ARGUMENTSAll arguments entered after the command$1, $2 …The first, second, and subsequent arguments by position. Wrap arguments containing spaces in quotes!`command`Runs the command in the workspace before sending and inserts its output into the prompt, for example !`git diff --stat`
If the prompt contains no argument placeholders, any arguments entered at invocation are appended to the end of the prompt.
Take an explain-file command as an example. After you enter /explain-file src/app.ts, ZCode substitutes the arguments, runs the command inside !`…`, and then sends the expanded prompt to ZCode Agent:
You type/explain-filesrc/app.tsCommand file---argument-hint: ---Read $1 and explain its structure and key logic.Recent commits:!`git log -3 --oneline`explain-file.mdWhat ZCode Agent receivesRead src/app.ts and explain its structure and key logic.Recent commits:a1c3f9e Split routes7be2d10 Add error handling52f0a4b Initial commitPlaceholders$ARGUMENTSall arguments$1 $2 …arguments by position!`command`runs in the workspace first; output is inserted
The frontmatter at the top of a command file supports the following fields, all optional:
FieldDescriptiondescriptionShort description shown in the / menu; if omitted, the start of the body is usedargument-hintArgument hint, such as skillsComma-separated skill names. ZCode Agent loads these skills before running the commandmodelModel to use when running this commandallowed-toolsComma-separated list that limits the tools this command can use
Unknown fields do not stop the command from working; the Commands page shows a warning.
Use in Chat
Type / in the input box to open the Commands and capabilities menu. The menu is organized into Commands, Skills, and Agents groups; keep typing to filter.
After you select a command, it appears as a tag in the input box. Add arguments or further instructions after it, then send.
Built-in Commands
Commands from enabled plugins also appear in the Commands group, such as ZCode Sites' /site-deploy, /site-status, and /site-logs. The table below lists the commands that come with ZCode:
CommandPurpose/goalSet, replace, or resume the goal of the current session. See Goal Mode/compactCompact the current conversation context. Useful for continuing long conversations; sent while a task is running, it is queued and runs in order/initCreate or update the workspace's AGENTS.md/workflowDesign and start a dynamic workflow for the task (available when dynamic workflows are enabled); see Dynamic Workflows/planTurn on Plan mode: ZCode Agent presents a plan first and executes it after you confirm/side, /btwCreate and open a side conversation without interrupting the current task; text after the command is sent as the side conversation's first message/reloadReload the current task so changes to MCP servers, plugins, skills, hooks, AGENTS.md, and other configuration take effect immediately, with conversation history kept. See Reload the Current Task
Custom commands cannot use the same name as a built-in command.
Reload the Current Task
After you add, enable, or disable MCP servers, install or toggle plugins, or edit skills, hooks, subagents, or AGENTS.md, tasks that are already open do not pick up the changes automatically. To apply them without starting a new session, send /reload on its own in the task's input box, or choose Restart task from the … menu next to the task title.
Reloaded: MCP servers, plugins, skills, hooks, AGENTS.md and project memory, and subagent definitions.
Kept: conversation history and the task's model, mode, and permission settings, so you can continue from the existing context.
Stopped: any reply in progress, subagents, background commands, and dynamic workflows are stopped, an active goal is paused, and queued messages that have not been sent are discarded. Actions already taken are not rolled back, and the last instruction is not re-run automatically.
/reload runs locally in the client and is never sent to the model; it does not accept arguments, attachments, or references. It is not available in a new task before the first message is sent, or while a remote workspace is disconnected.
Import Commands from External Agents
If you have already built up commands in other AI coding tools, you can import them into ZCode instead of recreating them. On the Commands page, choose Import from the … menu, and ZCode scans the command directories of the tools installed on your computer.
Commands page · Choose Import from the … menuImport window · Select commands and an import mode
Supported sources include Claude Code, Codex CLI, OpenCode, OpenClaw, Augment, Continue, Goose, Qwen Code, Qoder, Windsurf, Trae, Kiro CLI, Roo Code, and CodeBuddy. In the import window you can:
Use Scope to scan global commands or commands in the current project.
Select the commands you need, or use Select all. Existing commands with the same name are not overwritten.
Choose an Import mode: Symlink links to the original command file, so later changes to it take effect automatically; Copy saves an independent copy in ZCode.
Choose Import to Global (available in all projects) or Import to Project (current project only).
Imported commands appear in the Installed group and work the same way as commands you create.
Commands or Skills
Use a command when you only need to save a frequently used prompt. When you need a complete way of working, or need to bundle scripts, templates, or example files, use a Skill.
Next Steps
SkillCapture reusable ways of working as skills.Goal ModeSet a verifiable goal for a session so ZCode Agent keeps working toward it.ZCode AgentLearn how to chat with ZCode Agent in ZCode, choose models, and control execution modes.