template-smart-defaults
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTemplate Smart Defaults
模板智能默认值
This skill helps an agent fill in cross-parameter defaults when creating a
project. The rules below are guidance heuristics that keep related parameters consistent —
they only fill gaps and never override a value the user set explicitly.
dotnet new本Skill可帮助Agent在创建项目时填补跨参数默认值。以下规则是确保相关参数保持一致的指导启发式规则——它们仅填补未设置的参数,绝不会覆盖用户显式设置的值。
dotnet newWhen to Use
使用场景
- The user asks to create a project but leaves related parameters unspecified
- A parameter the user chose implies a sensible value for another parameter
- You need to explain why a particular default was selected
- 用户要求创建项目,但未指定相关参数
- 用户选择的某个参数暗示了另一个参数的合理值
- 需要解释为何选择特定默认值
When Not to Use
不适用场景
- User wants to actually create the project — route to
template-instantiation - User wants to find or compare templates — route to or
template-discoverytemplate-comparison - User wants to author or validate a custom template — route to or
template-authoringtemplate-validation
- 用户想要实际创建项目——请转至
template-instantiation - 用户想要查找或比较模板——请转至或
template-discoverytemplate-comparison - 用户想要编写或验证自定义模板——请转至或
template-authoringtemplate-validation
Inputs
输入参数
| Input | Required | Description |
|---|---|---|
| Template short name | Yes | The template the project will be created from (e.g., |
| Parameters already chosen | Yes | The parameter values the user has explicitly set |
| Available choices | Recommended | Parameter names/choices from |
| 输入项 | 是否必填 | 描述 |
|---|---|---|
| 模板简称 | 是 | 用于创建项目的模板(例如: |
| 已选参数 | 是 | 用户已显式设置的参数值 |
| 可用选项 | 推荐 | 来自 |
Workflow
工作流程
- Gather the parameters the user has explicitly set.
- Apply each rule below only where the corresponding parameter is unset — never override a value the user set explicitly.
- Confirm the chosen parameter names and choices against at creation time. For an advice-only request (the user isn't creating yet — e.g. "tell me the parameters/command"), answer from the rules below and note you'd confirm the exact names at creation; don't spend a
dotnet new <template> --helpcall just to advise on well-known parameters.--help - Emit the two required outputs (see below) — this is what makes the skill decisive rather than inert.
- 收集用户已显式设置的参数。
- 仅在对应参数未设置时应用以下每条规则——绝不覆盖用户显式设置的值。
- 在创建时,对照确认所选参数名称和选项。对于仅咨询的请求(用户尚未创建项目——例如“告诉我参数/命令”),根据以下规则作答,并注明会在创建时确认确切名称;不要仅为咨询知名参数而调用
dotnet new <template> --help。--help - 输出两个必填结果(见下文)——这是本Skill具有决策性而非仅提供建议的关键。
Required output
必填输出
Always produce both, in this order:
A. A "Defaults applied" log — one row per parameter, covering both the explicit values you preserved () and the gaps you filled by rule (), so the user can see and override every choice:
Source = userSource = rule| Parameter | Value | Source | Why |
|---|---|---|---|
| | rule | Native AOT (from |
| | user | Explicitly requested — left unchanged |
Use for explicit values (never overridden) and for gap-fills.
Source = userSource = ruleB. The exact single command line you would run — include only the flags you are actually passing. Do not list flags you decided not to pass (e.g. don't mention when you are keeping HTTPS; don't mention a minimal-API flag when using controllers). Silence on an omitted flag is the correct, decisive signal.
dotnet new--no-httpsAOT at create time vs publish time.is a--aotflag only on the templates that expose it — always confirm withdotnet newrather than assuming a given template does or doesn't offer it. There is nodotnet new <template> --helptemplate flag — publish-time native AOT is enabled with the MSBuild property--publish-aot(viaPublishAot=trueor in thedotnet publish), not through.csproj. Apply the framework rule only when the template actually offersdotnet new.--aot
始终按以下顺序生成两者:
A. “已应用默认值”日志——每个参数一行,涵盖所有保留的显式值()和通过规则填补的未设置参数(),以便用户查看并覆盖所有选择:
来源 = 用户来源 = 规则| 参数 | 值 | 来源 | 原因 |
|---|---|---|---|
| | 规则 | Native AOT(来自 |
| | 用户 | 显式请求——保持不变 |
对于显式值使用(绝不会被覆盖),对于填补的未设置参数使用。
来源 = 用户来源 = 规则B. 要运行的精确命令行——仅包含实际传递的标志。不要列出决定不传递的标志(例如保留HTTPS时不要提及;使用控制器时不要提及minimal-API标志)。省略的标志不显示是正确的、明确的信号。
dotnet new--no-https创建时的AOT与发布时的AOT。仅在模板暴露标志时,它才是--aot的可用标志——请始终通过dotnet new确认,不要假设某个模板是否提供该标志。不存在dotnet new <template> --help模板标志——发布时的native AOT是通过MSBuild属性--publish-aot启用的(通过PublishAot=true或在dotnet publish中设置),而非通过.csproj。仅当模板实际提供dotnet new时才应用框架规则。--aot
Rules
规则
| Rule | Default applied | Rationale |
|---|---|---|
| Set | Native AOT requires a recent, AOT-capable target framework; using the latest avoids build failures. (A framework already pinned by the workspace or |
| Do NOT pass | Authentication flows (cookies, tokens, redirects) require HTTPS; disabling it breaks auth. |
| Do NOT also pass a minimal-API flag | Controllers and minimal APIs are mutually exclusive program models; passing both is contradictory. |
| User set a value explicitly | Leave it unchanged | Smart defaults only fill gaps; explicit user intent always wins. |
| 规则 | 应用的默认值 | 原理 |
|---|---|---|
设置了 | 将 | Native AOT需要较新的、支持AOT的目标框架;使用最新版本可避免构建失败。(工作区或 |
| 不要传递 | 身份验证流程(Cookie、令牌、重定向)需要HTTPS;禁用HTTPS会破坏身份验证。 |
设置了 | 不要同时传递minimal-API标志 | 控制器和minimal API是互斥的编程模型;同时传递两者会产生矛盾。 |
| 用户显式设置了值 | 保持不变 | 智能默认值仅填补未设置的参数;用户的显式意图始终优先。 |
Validation
验证
- A "Defaults applied" log was produced with a Source (user/rule) and rationale per row
- The exact single command line was emitted, listing only flags actually passed
dotnet new - No parameter the user set explicitly was overridden
- Only unset parameters were filled
- Parameter names/choices were confirmed against at creation (for advice-only requests, flagged as to-confirm rather than run eagerly)
dotnet new <template> --help
- 生成了“已应用默认值”日志,每行包含来源(用户/规则)和原理
- 输出了精确的命令行,仅列出实际传递的标志
dotnet new - 未覆盖任何用户显式设置的参数
- 仅填补了未设置的参数
- 创建时对照确认了参数名称/选项(对于仅咨询的请求,标记为待确认而非直接执行)
dotnet new <template> --help
Common Pitfalls
常见陷阱
| Pitfall | Solution |
|---|---|
| Treating heuristics as enforcement | These are guidance rules, not validation. Always confirm against |
| Overriding an explicit user value | Apply a rule only when the target parameter is unset. |
| Assuming a flag name | The exact flag differs per template — always verify with |
| Picking a framework the template doesn't support | Use the latest framework that appears in the template's |
| 陷阱 | 解决方案 |
|---|---|
| 将启发式规则视为强制规则 | 这些是指导规则,而非验证规则。始终对照 |
| 覆盖用户显式设置的值 | 仅当目标参数未设置时才应用规则。 |
| 假设标志名称 | 确切的标志因模板而异——始终通过 |
| 选择模板不支持的框架 | 使用模板 |
More Info
更多信息
- dotnet new — CLI reference
- Native AOT deployment — AOT framework requirements
- dotnet new — CLI参考文档
- Native AOT部署 — AOT框架要求