template-discovery

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Template Discovery

模板发现

This skill helps an agent find, inspect, and select the right
dotnet new
template for a given task using
dotnet new
CLI commands for search, listing, and parameter inspection.
该技能可帮助Agent使用用于搜索、列表和参数检查的
dotnet new
CLI命令,查找、检查并为给定任务选择合适的
dotnet new
模板。

When to Use

适用场景

  • User asks "What templates are available for X?"
  • User describes a project in natural language ("I need a web API with authentication")
  • User wants to compare templates or understand parameters before creating a project
  • User needs to know what a template produces (files, structure) before committing
  • 用户询问“有哪些可用于X的模板?”
  • 用户用自然语言描述项目(“我需要一个带身份验证的web API”)
  • 用户想要在创建项目前比较模板或了解参数
  • 用户需要在确认创建前了解模板会生成什么内容(文件、结构)

When Not to Use

不适用场景

  • User wants to create a project — route to
    template-instantiation
    skill
  • User wants to author or validate a custom template — route to
    template-authoring
    skill
  • User is troubleshooting build issues — route to
    dotnet-msbuild
    plugin
  • 用户想要创建项目——请跳转至
    template-instantiation
    技能
  • 用户想要编写或验证自定义模板——请跳转至
    template-authoring
    技能
  • 用户正在排查构建问题——请跳转至
    dotnet-msbuild
    插件

Inputs

输入项

InputRequiredDescription
User intent or keywordsYesNatural-language description or keywords (e.g., "web API", "console app", "MAUI")
Language preferenceNoC#, F#, or VB — defaults to C#
Framework preferenceNoTarget framework (e.g., net10.0, net9.0)
输入必填描述
用户意图或关键词自然语言描述或关键词(例如“web API”、“控制台应用”、“MAUI”)
语言偏好C#、F#或VB —— 默认为C#
框架偏好目标框架(例如net10.0、net9.0)

Workflow

工作流程

Step 1: Resolve intent to template candidates

步骤1:将意图解析为候选模板

Map the user's natural-language description to template short names using these common keyword mappings:
User IntentTemplateSuggested Parameters
web API, REST API
webapi
--auth Individual --use-controllers
if auth requested
web app, website
webapp
Blazor, interactive web
blazor
console app, CLI tool
console
class library, shared code
classlib
worker service, background job
worker
gRPC service
grpc
MAUI app, mobile app
maui
test project, unit tests
xunit
,
mstest
, or
nunit
使用以下常见关键词映射,将用户的自然语言描述映射为模板短名称:
用户意图模板建议参数
web API、REST API
webapi
如果请求身份验证则添加
--auth Individual --use-controllers
web应用、网站
webapp
Blazor、交互式网页
blazor
控制台应用、CLI工具
console
类库、共享代码
classlib
工作器服务、后台任务
worker
gRPC服务
grpc
MAUI应用、移动应用
maui
测试项目、单元测试
xunit
mstest
nunit

Step 2: Search for templates

步骤2:搜索模板

Use
dotnet new search
to find templates by keyword across both locally installed templates and NuGet.org:
bash
dotnet new search blazor
Use
dotnet new list
to show only installed templates, with optional filters:
bash
dotnet new list --language C# --type project
dotnet new list web
使用
dotnet new search
在本地已安装模板和NuGet.org中按关键词查找模板:
bash
dotnet new search blazor
使用
dotnet new list
仅展示已安装的模板,可添加可选过滤器:
bash
dotnet new list --language C# --type project
dotnet new list web

Step 3: Inspect template details

步骤3:检查模板详情

Use
dotnet new <template> --help
to get full parameter details for a specific template — parameter names, types, defaults, and allowed values:
bash
dotnet new webapi --help
使用
dotnet new <模板名称> --help
获取指定模板的完整参数详情——参数名、类型、默认值和允许的取值:
bash
dotnet new webapi --help

Step 4: Preview output

步骤4:预览输出

Use
dotnet new <template> --dry-run
to show what files and directories a template would create without writing anything to disk:
bash
dotnet new webapi --name MyApi --auth Individual --dry-run
使用
dotnet new <模板名称> --dry-run
展示模板将会创建的文件和目录,不会向磁盘写入任何内容:
bash
dotnet new webapi --name MyApi --auth Individual --dry-run

Step 5: Present findings

步骤5:展示查找结果

Summarize the best template match with:
  • Template name and short description
  • Key parameters and recommended values
  • What the user should expect (files created, project structure)
  • Any constraints or prerequisites
总结最匹配的模板,包含以下内容:
  • 模板名称和简短描述
  • 关键参数和推荐取值
  • 用户可预期的结果(创建的文件、项目结构)
  • 所有约束或前置要求

Validation

验证项

  • At least one template match was found for the user's intent
  • Template parameters are explained with types and defaults
  • User understands what the template produces before proceeding to creation
  • 至少为用户意图找到一个匹配的模板
  • 模板参数已说明类型和默认值
  • 用户在继续创建前已了解模板的生成内容

Common Pitfalls

常见陷阱

PitfallSolution
Not searching NuGet for templatesIf
dotnet new list
shows no matches, use
dotnet new search <keyword>
to find installable templates on NuGet.org.
Not checking template constraintsSome templates require specific SDKs or workloads. Use
dotnet new <template> --help
to surface constraints before recommending.
Recommending a template without previewing outputAlways use
dotnet new <template> --dry-run
to confirm the template produces what the user expects.
陷阱解决方案
未在NuGet中搜索模板如果
dotnet new list
没有找到匹配项,使用
dotnet new search <关键词>
查找NuGet.org上可安装的模板。
未检查模板约束部分模板需要特定的SDK或工作负载。在推荐前使用
dotnet new <模板名称> --help
查看约束。
未预览输出就推荐模板始终使用
dotnet new <模板名称> --dry-run
确认模板生成的内容符合用户预期。

More Info

更多信息