template-discovery
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTemplate Discovery
模板发现
This skill helps an agent find, inspect, and select the right template for a given task using CLI commands for search, listing, and parameter inspection.
dotnet newdotnet new该技能可帮助Agent使用用于搜索、列表和参数检查的 CLI命令,查找、检查并为给定任务选择合适的模板。
dotnet newdotnet newWhen 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 skill
template-instantiation - User wants to author or validate a custom template — route to skill
template-authoring - User is troubleshooting build issues — route to plugin
dotnet-msbuild
- 用户想要创建项目——请跳转至技能
template-instantiation - 用户想要编写或验证自定义模板——请跳转至技能
template-authoring - 用户正在排查构建问题——请跳转至插件
dotnet-msbuild
Inputs
输入项
| Input | Required | Description |
|---|---|---|
| User intent or keywords | Yes | Natural-language description or keywords (e.g., "web API", "console app", "MAUI") |
| Language preference | No | C#, F#, or VB — defaults to C# |
| Framework preference | No | Target 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 Intent | Template | Suggested Parameters |
|---|---|---|
| web API, REST API | | |
| web app, website | | |
| Blazor, interactive web | | |
| console app, CLI tool | | |
| class library, shared code | | |
| worker service, background job | | |
| gRPC service | | |
| MAUI app, mobile app | | |
| test project, unit tests | |
使用以下常见关键词映射,将用户的自然语言描述映射为模板短名称:
| 用户意图 | 模板 | 建议参数 |
|---|---|---|
| web API、REST API | | 如果请求身份验证则添加 |
| web应用、网站 | | |
| Blazor、交互式网页 | | |
| 控制台应用、CLI工具 | | |
| 类库、共享代码 | | |
| 工作器服务、后台任务 | | |
| gRPC服务 | | |
| MAUI应用、移动应用 | | |
| 测试项目、单元测试 | |
Step 2: Search for templates
步骤2:搜索模板
Use to find templates by keyword across both locally installed templates and NuGet.org:
dotnet new searchbash
dotnet new search blazorUse to show only installed templates, with optional filters:
dotnet new listbash
dotnet new list --language C# --type project
dotnet new list web使用在本地已安装模板和NuGet.org中按关键词查找模板:
dotnet new searchbash
dotnet new search blazor使用仅展示已安装的模板,可添加可选过滤器:
dotnet new listbash
dotnet new list --language C# --type project
dotnet new list webStep 3: Inspect template details
步骤3:检查模板详情
Use to get full parameter details for a specific template — parameter names, types, defaults, and allowed values:
dotnet new <template> --helpbash
dotnet new webapi --help使用获取指定模板的完整参数详情——参数名、类型、默认值和允许的取值:
dotnet new <模板名称> --helpbash
dotnet new webapi --helpStep 4: Preview output
步骤4:预览输出
Use to show what files and directories a template would create without writing anything to disk:
dotnet new <template> --dry-runbash
dotnet new webapi --name MyApi --auth Individual --dry-run使用展示模板将会创建的文件和目录,不会向磁盘写入任何内容:
dotnet new <模板名称> --dry-runbash
dotnet new webapi --name MyApi --auth Individual --dry-runStep 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
常见陷阱
| Pitfall | Solution |
|---|---|
| Not searching NuGet for templates | If |
| Not checking template constraints | Some templates require specific SDKs or workloads. Use |
| Recommending a template without previewing output | Always use |
| 陷阱 | 解决方案 |
|---|---|
| 未在NuGet中搜索模板 | 如果 |
| 未检查模板约束 | 部分模板需要特定的SDK或工作负载。在推荐前使用 |
| 未预览输出就推荐模板 | 始终使用 |
More Info
更多信息
- dotnet new templates — built-in template reference
- Template Engine Wiki — template engine internals
- dotnet new templates —— 内置模板参考
- Template Engine Wiki —— 模板引擎内部原理