template-authoring
Skill for creating, maintaining, and validating custom dotnet new templates. Use when a user wants to create a reusable template from an existing project, author template.json manually, add parameters or post-actions, or validate a template before publishing. Covers template.json structure, parameter types, conditional content, post-actions, constraints, and ai.host.json metadata. DO NOT use for using/instantiating existing templates or for MSBuild build issues.
What this skill does
# Template Authoring
## When to Use
Invoke this skill when:
- User wants to create a custom `dotnet new` template
- User wants to reverse-engineer a template from an existing project
- User needs to add parameters, post-actions, or constraints to an existing template
- User wants to validate or test a template before publishing
## Creating a Template from an Existing Project
Use `template_create_from_existing` to analyze a .csproj and generate a complete template:
```
template_create_from_existing with:
projectPath: "C:/repos/MyProject/MyProject.csproj"
templateName: "My Custom Template"
shortName: "mycustomtemplate"
outputDir: "C:/repos/MyProject/.template.config"
```
This generates:
- `template.json` — complete metadata with parameters extracted from project properties
- Templatized `.csproj` — namespace tokens, conditional sections
- `sourceName` set for automatic namespace/filename renaming
- Gaps report showing differences from generic `dotnet new` templates
## Template Directory Structure
```
MyTemplate/
├── .template.config/
│ ├── template.json # Template metadata (required)
│ ├── ide.host.json # VS/Rider IDE integration (optional)
│ ├── dotnetcli.host.json # CLI parameter mappings (optional)
│ └── ai.host.json # AI assistant metadata (optional)
├── MyProject.csproj # Project file (templatized)
├── Program.cs # Source files
└── ...
```
## template.json Structure
```json
{
"$schema": "http://json.schemastore.org/template",
"author": "Your Name",
"classifications": ["Web", "API"],
"identity": "MyOrg.MyTemplate.CSharp",
"name": "My Custom Template",
"shortName": "mytemplate",
"sourceName": "MyTemplate",
"preferNameDirectory": true,
"tags": {
"language": "C#",
"type": "project"
},
"symbols": { },
"sources": [{ "modifiers": [] }],
"postActions": []
}
```
### Key Fields
| Field | Required | Description |
|-------|----------|-------------|
| `identity` | Yes | Unique identifier (use reverse-domain: `Org.Template.Lang`) |
| `shortName` | Yes | CLI name used with `dotnet new <shortName>` |
| `sourceName` | Yes | Token replaced with project name in filenames and content |
| `name` | Yes | Human-readable display name |
| `classifications` | Yes | Categories for discovery (Web, Console, Test, Library) |
| `tags.language` | Yes | Primary language (C#, F#, VB) |
| `tags.type` | Yes | `project`, `item`, or `solution` |
## Parameter Types (symbols)
```json
"symbols": {
"Framework": {
"type": "parameter",
"datatype": "choice",
"defaultValue": "net10.0",
"choices": [
{ "choice": "net10.0", "description": ".NET 10" },
{ "choice": "net9.0", "description": ".NET 9" }
],
"replaces": "net10.0"
},
"EnableAot": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Enable Native AOT publishing"
},
"copyrightYear": {
"type": "generated",
"generator": "now",
"parameters": { "format": "yyyy" },
"replaces": "1975"
}
}
```
### Supported Data Types
| Type | Use Case | Notes |
|------|----------|-------|
| `choice` | Framework, auth mode | Define `choices` array |
| `bool` | Feature toggles | Drives `#if` conditional sections |
| `string` | Namespace, author | Free-form text replacement |
| `integer` | Port numbers | Numeric values |
| `float` | Version numbers | Decimal values |
## Conditional Content
Use C# preprocessor-style directives for conditional content:
```csharp
#if (EnableAot)
[JsonSerializable(typeof(WeatherForecast))]
internal partial class AppJsonContext : JsonSerializerContext { }
#endif
```
In `.csproj` files, use XML comments:
```xml
<!--#if (EnableAot) -->
<PublishAot>true</PublishAot>
<!--#endif -->
```
## Post-Actions
Common post-actions to include:
```json
"postActions": [
{
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"description": "Restore NuGet packages",
"manualInstructions": [{ "text": "Run 'dotnet restore'" }],
"continueOnError": true
},
{
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"description": "Open README in editor",
"args": { "files": "README.md" },
"manualInstructions": [{ "text": "Open README.md" }]
}
]
```
### Post-Action GUIDs
| GUID | Action |
|------|--------|
| `210D431B-...` | Restore NuGet packages |
| `84C0DA21-...` | Open file in editor |
| `3A7C4B45-...` | Run script |
| `D396686C-...` | Add project reference |
| `B17581D1-...` | Add to solution |
| `AC1156F7-...` | chmod (Unix permissions) |
## Constraints
```json
"constraints": {
"sdk-version": {
"type": "sdk-version",
"args": [ "[9.0,)" ]
},
"os": {
"type": "os",
"args": "Windows"
},
"workload": {
"type": "workload",
"args": [ "maui" ]
}
}
```
## Testing a Template
1. Install locally: `dotnet new install ./path/to/template/`
2. List to verify: `dotnet new list mytemplate`
3. Dry run: `template_dry_run` or `dotnet new mytemplate --dry-run`
4. Create and build: `dotnet new mytemplate -n TestProject && dotnet build TestProject`
5. Uninstall: `dotnet new uninstall ./path/to/template/`
## Packaging for NuGet
```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageType>Template</PackageType>
<PackageId>MyOrg.Templates</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
</PropertyGroup>
<ItemGroup>
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" />
</ItemGroup>
</Project>
```
## Cross-Reference
- **Finding templates** → `template-discovery` skill
- **Creating projects from templates** → `template-instantiation` skill
- **MSBuild project file best practices** → `msbuild-style-guide` skill (msbuild-skills plugin)
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.