← 返回命令列表

Linux command

gh-agent 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start interactive Copilot CLI session with a custom agent

gh copilot --agent [agent_name]

Run a custom agent with a prompt non-interactively

gh copilot --agent [security-auditor] --prompt "[Check /src/app/validator.go]"

Invoke an agent interactively using the slash command

/agent [agent_name]

Delegate a task to Copilot coding agent

/delegate [task description]

说明

gh agent functionality is provided through GitHub Copilot CLI's custom agent system, accessible via `gh copilot --agent` or the `/agent` slash command in an interactive session. Agents are defined by Markdown files with an `.agent.md` extension that specify the agent's name, description, prompt instructions, and available tools. Custom agents can be defined at user level (~/.copilot/agents/), repository level (.github/agents/), or organization level ({org}/.github/agents/). In case of naming conflicts, user-level agents override repository-level, which override organization-level. The `/delegate` slash command commits unstaged changes to a new branch and delegates the task to the Copilot coding agent, which opens a draft pull request and works in the background.

参数

--agent _name_
Specify the custom agent to use (matches the .agent.md filename).
--prompt _text_
Provide a prompt for programmatic (non-interactive) usage.
--allow-tool _tool_
Specify tools the agent can use (shell, write, url, MCP server tools).

FAQ

What is the gh-agent command used for?

gh agent functionality is provided through GitHub Copilot CLI's custom agent system, accessible via `gh copilot --agent` or the `/agent` slash command in an interactive session. Agents are defined by Markdown files with an `.agent.md` extension that specify the agent's name, description, prompt instructions, and available tools. Custom agents can be defined at user level (~/.copilot/agents/), repository level (.github/agents/), or organization level ({org}/.github/agents/). In case of naming conflicts, user-level agents override repository-level, which override organization-level. The `/delegate` slash command commits unstaged changes to a new branch and delegates the task to the Copilot coding agent, which opens a draft pull request and works in the background.

How do I run a basic gh-agent example?

Run `gh copilot --agent [agent_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --agent _name_ do in gh-agent?

Specify the custom agent to use (matches the .agent.md filename).