csharp-scripts
Run file-based C# apps with the .NET CLI when the user explicitly wants C#/.NET code without creating a project. Use for C# language/API experiments, one-file…
Applies cross-parameter default rules when creating .NET projects with dotnet new, filling gaps consistently without overriding values the user set explicitly. USE FOR: choosing which target framework to pair with native AOT, deciding whether to keep HTTPS when authentication is
$ npx -y skills add dotnet/skills --skill template-smart-defaults --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/template-smart-defaultsContext preview
The summary Claude sees to decide when to auto-load this skill.
Applies cross-parameter default rules when creating .NET projects with dotnet new, filling gaps consistently without overriding values the user set explicitly. USE FOR: choosing which target framework to pair with native AOT, deciding whether to keep HTTPS when authentication is
name: template-smart-defaults description: > Applies cross-parameter default rules when creating .NET projects with dotnet new, filling gaps consistently without overriding values the user set explicitly. USE FOR: choosing which target framework to pair with native AOT, deciding whether to keep HTTPS when authentication is enabled, recognizing that controllers and minimal-API flags are mutually exclusive, filling unset related parameters during project creation, explaining why a default was applied and ensuring an explicit user value is never overridden. DO NOT USE FOR: creating the project itself (use template-instantiation), finding or comparing templates (use template-discovery and template-comparison), authoring or validating custom templates (use template-authoring and template-validation). license: MIT
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.
| Input | Required | Description | |-------|----------|-------------| | Template short name | Yes | The template the project will be created from (e.g., `webapi`) | | Parameters already chosen | Yes | The parameter values the user has explicitly set | | Available choices | Recommended | Parameter names/choices from `dotnet new <template> --help` |
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` whenever the user asks for an exact command. This inspection does not create files and is worthwhile even for advice-only requests. Skip it only for a conceptual explanation that does not claim exact option names. 4. **Emit the two required outputs** (see below) — this is what makes the skill decisive rather than inert.
For advice-only prompts that say "don't create files", make the displayed command safe to run by appending `--dry-run`. If a scenario needs a named example and the user omitted the name, choose a short descriptive sample name and mark it `Source = rule`. Do not add a name when the user asked for a command containing only explicitly requested choices or when the template can demonstrate those choices safely without one.
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:
| Parameter | Value | Source | Why | |-----------|-------|--------|-----| | `--framework` | `net10.0` | rule | Native AOT (from `--aot`) needs the latest AOT-capable TFM | | `--auth` | `Individual` | user | Explicitly requested — left unchanged | | `--name` | `AotWorker` | rule | Added a descriptive sample name for this named example |
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.
Always emit a flag the user explicitly requested when the observed template help exposes it, even when its value matches the template default; this keeps intent visible and reproducible (for example, `--auth None`). Omit only **inferred** defaults that you are not actually passing. Boolean switches such as `--no-https` are passed without `true`.
> **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`.
| Rule | Default applied | Rationale | |------|-----------------|-----------| | `--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 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. | | Advice-only command must not create files | Add `--dry-run` | The command itself must
This repository contains the .NET team's curated set of portable skills and host-specific custom agents for coding agents. For information about the Agent Skills standard, see agentskills.io.
Repo: dotnet/skills
Run file-based C# apps with the .NET CLI when the user explicitly wants C#/.NET code without creating a project. Use for C# language/API experiments, one-file…
Correctly call native (C/C++) libraries from .NET using P/Invoke and LibraryImport. Covers function signatures, string marshalling, memory lifetime,…
Set up NuGet trusted publishing (OIDC) on a GitHub Actions repo — replaces long-lived API keys with short-lived tokens. USE FOR: trusted publishing, NuGet…
Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64/128/256/512, or platform hardware…
Guides technology selection and implementation of AI and ML features in .NET 8+ applications using ML.NET, Microsoft.Extensions.AI (MEAI), Microsoft Agent…
Configure OpenTelemetry distributed tracing, metrics, and logging in ASP.NET Core using the .NET OpenTelemetry SDK. Use when adding observability, setting up…