template-smart-defaults

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Template Smart Defaults

模板智能默认值

This skill helps an agent fill in cross-parameter defaults when creating a
dotnet new
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.
本Skill可帮助Agent在创建
dotnet new
项目时填补跨参数默认值。以下规则是确保相关参数保持一致的指导启发式规则——它们仅填补未设置的参数,绝不会覆盖用户显式设置的值。

When 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
    template-discovery
    or
    template-comparison
  • User wants to author or validate a custom template — route to
    template-authoring
    or
    template-validation
  • 用户想要实际创建项目——请转至
    template-instantiation
  • 用户想要查找或比较模板——请转至
    template-discovery
    template-comparison
  • 用户想要编写或验证自定义模板——请转至
    template-authoring
    template-validation

Inputs

输入参数

InputRequiredDescription
Template short nameYesThe template the project will be created from (e.g.,
webapi
)
Parameters already chosenYesThe parameter values the user has explicitly set
Available choicesRecommendedParameter names/choices from
dotnet new <template> --help
输入项是否必填描述
模板简称用于创建项目的模板(例如:
webapi
已选参数用户已显式设置的参数值
可用选项推荐来自
dotnet new <template> --help
的参数名称/选项

Workflow

工作流程

  1. Gather the parameters the user has explicitly set.
  2. Apply each rule below only where the corresponding parameter is unset — never override a value the user set explicitly.
  3. Confirm the chosen parameter names and choices against
    dotnet new <template> --help
    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
    --help
    call just to advise on well-known parameters.
  4. Emit the two required outputs (see below) — this is what makes the skill decisive rather than inert.
  1. 收集用户已显式设置的参数。
  2. 仅在对应参数未设置时应用以下每条规则——绝不覆盖用户显式设置的值。
  3. 在创建时,对照
    dotnet new <template> --help
    确认所选参数名称和选项。对于仅咨询的请求(用户尚未创建项目——例如“告诉我参数/命令”),根据以下规则作答,并注明会在创建时确认确切名称;不要仅为咨询知名参数而调用
    --help
  4. 输出两个必填结果(见下文)——这是本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 (
Source = user
) and the gaps you filled by rule (
Source = rule
), so the user can see and override every choice:
ParameterValueSourceWhy
--framework
net10.0
ruleNative AOT (from
--aot
) needs the latest AOT-capable TFM
--auth
Individual
userExplicitly requested — left unchanged
Use
Source = user
for explicit values (never overridden) and
Source = rule
for gap-fills.
B. The exact single
dotnet new
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
--no-https
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.
AOT at create time vs publish time.
--aot
is a
dotnet new
flag only on the templates that expose it — always confirm with
dotnet new <template> --help
rather than assuming a given template does or doesn't offer it. There is no
--publish-aot
template flag — publish-time native AOT is enabled with the MSBuild property
PublishAot=true
(via
dotnet publish
or in the
.csproj
), not through
dotnet new
. Apply the framework rule only when the template actually offers
--aot
.
始终按以下顺序生成两者
A. “已应用默认值”日志——每个参数一行,涵盖所有保留的显式值(
来源 = 用户
)和通过规则填补的未设置参数(
来源 = 规则
),以便用户查看并覆盖所有选择:
参数来源原因
--framework
net10.0
规则Native AOT(来自
--aot
)需要最新的支持AOT的TFM
--auth
Individual
用户显式请求——保持不变
对于显式值使用
来源 = 用户
(绝不会被覆盖),对于填补的未设置参数使用
来源 = 规则
B. 要运行的精确
dotnet new
命令行
——仅包含实际传递的标志。不要列出决定不传递的标志(例如保留HTTPS时不要提及
--no-https
;使用控制器时不要提及minimal-API标志)。省略的标志不显示是正确的、明确的信号。
创建时的AOT与发布时的AOT。仅在模板暴露
--aot
标志时,它才是
dotnet new
的可用标志——请始终通过
dotnet new <template> --help
确认,不要假设某个模板是否提供该标志。不存在
--publish-aot
模板标志——发布时的native AOT是通过MSBuild属性
PublishAot=true
启用的(通过
dotnet publish
或在
.csproj
中设置),而非通过
dotnet new
。仅当模板实际提供
--aot
时才应用框架规则。

Rules

规则

RuleDefault appliedRationale
--aot
is set (on any template whose
--help
exposes it) and
--framework
is unset
Set
--framework
to the latest AOT-compatible framework the template offers
Native AOT requires a recent, AOT-capable target framework; using the latest avoids build failures. (A framework already pinned by the workspace or
global.json
counts as set — keep it unless it's incompatible with AOT.)
--auth
is anything other than
None
Do NOT pass
--no-https
Authentication flows (cookies, tokens, redirects) require HTTPS; disabling it breaks auth.
--use-controllers
is set
Do NOT also pass a minimal-API flagControllers and minimal APIs are mutually exclusive program models; passing both is contradictory.
User set a value explicitlyLeave it unchangedSmart defaults only fill gaps; explicit user intent always wins.
规则应用的默认值原理
设置了
--aot
(在任何
--help
中暴露该标志的模板上)且未设置
--framework
--framework
设置为模板支持的最新兼容AOT的框架
Native AOT需要较新的、支持AOT的目标框架;使用最新版本可避免构建失败。(工作区或
global.json
中已固定的框架视为已设置——除非与AOT不兼容,否则保持不变。)
--auth
设置为
None
以外的任何值
不要传递
--no-https
身份验证流程(Cookie、令牌、重定向)需要HTTPS;禁用HTTPS会破坏身份验证。
设置了
--use-controllers
不要同时传递minimal-API标志控制器和minimal API是互斥的编程模型;同时传递两者会产生矛盾。
用户显式设置了值保持不变智能默认值仅填补未设置的参数;用户的显式意图始终优先。

Validation

验证

  • A "Defaults applied" log was produced with a Source (user/rule) and rationale per row
  • The exact single
    dotnet new
    command line was emitted, listing only flags actually passed
  • No parameter the user set explicitly was overridden
  • Only unset parameters were filled
  • Parameter names/choices were confirmed against
    dotnet new <template> --help
    at creation (for advice-only requests, flagged as to-confirm rather than run eagerly)
  • 生成了“已应用默认值”日志,每行包含来源(用户/规则)和原理
  • 输出了精确的
    dotnet new
    命令行,仅列出实际传递的标志
  • 未覆盖任何用户显式设置的参数
  • 仅填补了未设置的参数
  • 创建时对照
    dotnet new <template> --help
    确认了参数名称/选项(对于仅咨询的请求,标记为待确认而非直接执行)

Common Pitfalls

常见陷阱

PitfallSolution
Treating heuristics as enforcementThese are guidance rules, not validation. Always confirm against
dotnet new <template> --help
choices, since parameter names vary by template.
Overriding an explicit user valueApply a rule only when the target parameter is unset.
Assuming a flag nameThe exact flag differs per template — always verify with
--help
(e.g.
--aot
is present only where
--help
lists it; controllers use
--use-controllers
).
Picking a framework the template doesn't supportUse the latest framework that appears in the template's
--framework
choices, not an arbitrary newest version.
陷阱解决方案
将启发式规则视为强制规则这些是指导规则,而非验证规则。始终对照
dotnet new <template> --help
的选项确认,因为参数名称因模板而异。
覆盖用户显式设置的值仅当目标参数未设置时才应用规则。
假设标志名称确切的标志因模板而异——始终通过
--help
验证(例如
--aot
仅在
--help
列出时存在;控制器使用
--use-controllers
)。
选择模板不支持的框架使用模板
--framework
选项中显示的最新框架,而非任意最新版本。

More Info

更多信息