Create Custom Agent

dotnet/skills/.agents/skills/create-custom-agent

作者 dotnet0608d8924cd3無授權條款5.5K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Creates VS Code custom agent files (.agent.md) for specialized AI personas with tools, instructions, and handoffs. Use when scaffolding new custom agents, configuring agent workflows, or setting up agent-to-agent handoffs.

僅含說明AI & Agents
AI 產生的概覽

產生 VS Code 自訂代理程式檔案(.agent.md),包含前置資料、工具、指示與交接設定。

功能
此技能會引導建立副檔名為 .agent.md 的 VS Code 自訂代理程式檔案,用來定義開發任務專用的 AI 角色。內容涵蓋撰寫 YAML 前置資料(name、description、tools、handoffs 等欄位)、設定工具權限、設定代理程式之間的交接,以及撰寫 Markdown 指示本文。此外也提供範本、範例代理程式、驗證清單與常見問題對照表。
適用情境
適合從零開始建立新的自訂代理程式、為多步驟工作流程設定代理程式間交接,或為規劃者、審查者等專用角色設定工具限制。不適用於建立指示檔案、可重複使用的提示詞,或修改現有代理程式。
執行需求
不需要指令碼或套件,僅為說明性指示。假定執行環境為支援自訂代理程式的 VS Code,並需要用來存放所產生 .agent.md 檔案的 agents/ 目錄。

Create Custom Agent

This skill helps you create VS Code custom agent files that define specialized AI personas for development tasks. Custom agents configure which tools are available, provide specialized instructions, and can chain together via handoffs.

When to Use

  • Creating a new custom agent from scratch
  • Scaffolding an .agent.md file with proper frontmatter
  • Setting up agent-to-agent handoffs for multi-step workflows
  • Configuring tool restrictions for specialized roles (planner, reviewer, etc.)
  • Creating workspace-shared or user-profile agents

When Not to Use

  • Creating instruction files (use .instructions.md instead)
  • Creating reusable prompts (use .prompt.md instead)
  • Modifying existing agents (edit the file directly)

Inputs

InputRequiredDescription
Agent nameYesDescriptive name for the agent (e.g., planner, code-reviewer)
DescriptionYesBrief description shown as placeholder text in chat
Purpose/PersonaYesWhat role the agent plays and how it should behave
ToolsRecommendedList of tools or tool sets the agent can use
HandoffsOptionalNext-step agents to transition to after completing work

Workflow

Step 1: Create the agent file

Create a file with .agent.md extension in the agents/ directory:

agents/<agent-name>.agent.md

Step 2: Add YAML frontmatter

Add the header with required and optional fields:

yaml
---name: <agent-name>description: <brief description for chat placeholder>tools:  - <tool-name>  - <tool-set-name>---
Available frontmatter fields:
FieldRequiredDescription
nameNoDisplay name (defaults to filename)
descriptionYesPlaceholder text shown in chat input
argument-hintNoHint text guiding user interaction
toolsNoList of available tools/tool sets
agentsNoList of allowed subagents (* for all, [] for none)
modelNoAI model name or prioritized array of models
handoffsNoList of next-step agent transitions
user-invokableNoShow in agents dropdown (default: true)
disable-model-invocationNoPrevent subagent invocation (default: false)
targetNoTarget environment: vscode or github-copilot
mcp-serversNoMCP server configs for GitHub Copilot target

Step 3: Configure tools

Specify which tools the agent can use:

yaml
tools:  - search              # Built-in tool  - fetch               # Built-in tool  - codebase            # Tool set  - myServer/*          # All tools from MCP server

Common tool patterns:

  • Read-only agents: ['search', 'fetch', 'codebase']
  • Full editing agents: ['*'] or specific editing tools
  • Specialized agents: Cherry-pick specific tools

Step 4: Add handoffs (optional)

Configure transitions to other agents:

yaml
handoffs:  - label: Start Implementation    agent: implementation    prompt: Implement the plan outlined above.    send: false    model: GPT-5.2 (copilot)

Handoff fields:

  • label: Button text displayed to user
  • agent: Target agent identifier
  • prompt: Pre-filled prompt for target agent
  • send: Auto-submit prompt (default: false)
  • model: Optional model override for handoff

Step 5: Write agent instructions (body)

Add the agent's behavior instructions in Markdown:

markdown
You are a security-focused code reviewer. Your job is to:
1. Analyze code for security vulnerabilities2. Check for common security anti-patterns3. Suggest secure alternatives
## Guidelines
- Focus on OWASP Top 10 vulnerabilities- Flag hardcoded secrets immediately- Review authentication and authorization logic
## Reference other files
See [security guidelines](../security.md) for standards.

Tips for instructions:

  • Use Markdown links to reference other files
  • Reference tools with #tool:<tool-name> syntax
  • Be specific about agent behavior and constraints

Step 6: Validate the agent

Verify the agent loads correctly:

  1. Open Command Palette (Ctrl+Shift+P)
  2. Run "Chat: New Custom Agent" or check agents dropdown
  3. Use "Diagnostics" view (right-click in Chat view) to check for errors

Template

markdown
---name: <agent-name>description: <brief description for chat placeholder>argument-hint: <optional hint for user input>tools:  - <tool-1>  - <tool-2>handoffs:  - label: <button-text>    agent: <target-agent>    prompt: <pre-filled-prompt>    send: false---
# <Agent Title>
<One paragraph describing the agent's persona and purpose.>
## Role
<Describe the agent's specialized role and expertise.>
## Guidelines
- <Guideline 1>- <Guideline 2>- <Guideline 3>
## Workflow
1. <Step 1>2. <Step 2>3. <Step 3>
## Constraints
- <Constraint 1>- <Constraint 2>

Example Agents

Planning Agent

markdown
---name: plannerdescription: Generate an implementation plantools:  - search  - fetch  - codebasehandoffs:  - label: Start Implementation    agent: implementation    prompt: Implement the plan above.---
# Planning Agent
You are a solution architect. Generate detailed implementation plans.
## Guidelines
- Analyze requirements thoroughly before planning- Break work into discrete, testable steps- Identify dependencies and risks- Do NOT make code changes

Code Review Agent

markdown
---name: code-reviewerdescription: Review code for quality and security issuestools:  - search  - codebase---
# Code Review Agent
You are a senior engineer performing code review.
## Focus Areas
- Security vulnerabilities- Performance concerns- Code maintainability- Test coverage gaps
## Output Format
Provide findings as:1. **Critical**: Must fix before merge2. **Warning**: Should address3. **Suggestion**: Nice to have

Validation Checklist

  • File has .agent.md extension
  • File is in agents/ directory
  • YAML frontmatter is valid (proper indentation, no syntax errors)
  • Description is non-empty and descriptive
  • Tools list contains only available tools
  • Handoff agent names match existing agents
  • Instructions are clear and actionable
  • Agent appears in agents dropdown

Common Pitfalls

PitfallSolution
Agent not appearing in dropdownCheck file is in agents/ directory with .agent.md extension
YAML syntax errorsValidate frontmatter indentation and quoting
Tools not workingVerify tool names exist; unavailable tools are ignored
Handoffs not showingTarget agent must exist; check agent identifier
Instructions too vagueBe specific about role, constraints, and workflow
Agent invoked as subagent unexpectedlySet disable-model-invocation: true
Want agent only as subagentSet user-invokable: false

References

來源與署名

來源:dotnet/skills位於.agents/skills/create-custom-agent提交0608d89

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架