{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/template-authoring",
  "version": "1.0.1",
  "name": "template-authoring",
  "description": "Guides creation and validation of custom dotnet new templates from existing projects. Generates a .template.config/template.json that preserves the source project's conventions. USE FOR: creating a reusable dotnet new template from an existing project, bootstrapping .template.config/template.json with correct identity, shortName, parameters, and post-actions, adding parameters or conditional content to a template you are authoring, validating the template.json you are authoring before publishing, packaging templates as NuGet packages for distribution. DO NOT USE FOR: validating an existing template.json as a standalone task (use template-validation), finding or using existing templates (use template-discovery and template-instantiation), MSBuild project file issues unrelated to template authoring, NuGet package publishing (only template packaging structure).",
  "system_prompt_fragment": "# Template Authoring\n\nThis skill helps an agent create and validate custom `dotnet new` templates. It guides bootstrapping templates from existing projects and validates `template.json` files for authoring issues before publishing.\n\n## When to Use\n\n- User wants to create a reusable template from an existing .csproj\n- User wants to validate a template.json for correctness\n- User is setting up `.template.config/template.json` from scratch\n- User wants to package a template for NuGet distribution\n\n## When Not to Use\n\n- User wants to find or use existing templates — route to `template-discovery` or `template-instantiation`\n- User has MSBuild issues unrelated to template authoring — route to `dotnet-msbuild` plugin\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Source project path | For creation | Path to the .csproj to use as template source |\n| template.json path | For validation | Path to an existing template.json to validate |\n| Template name | For creation | Human-readable name for the template |\n| Short name | Recommended | Short name for `dotnet new <shortname>` usage |\n\n## Workflow\n\n### Step 1: Bootstrap from existing project\n\nAnalyze the source `.csproj` and create a `.template.config/template.json`:\n\n1. Create `.template.config` directory next to the project\n2. Generate `template.json` with `identity` (reverse-DNS), `name`, `shortName`, `sourceName` (project name for replacement), `classifications`, and `tags`\n3. Preserve from source: SDK type, package references with metadata (PrivateAssets, IncludeAssets), properties (OutputType, TreatWarningsAsErrors), CPM patterns\n\nMinimal example:\n```json\n{\n  \"$schema\": \"http://json.schemastore.org/template\",\n  \"author\": \"MyOrg\",\n  \"classifications\": [\"Library\"],\n  \"identity\": \"MyOrg.Templates.MyLib\",\n  \"name\": \"My Library Template\",\n  \"shortName\": \"mylib\",\n  \"sourceName\": \"MyLib\",\n  \"tags\": { \"language\": \"C#\", \"type\": \"project\" }\n}\n```\n\n### Step 2: Validate template.json\n\nRead and review the `template.json` for common authoring issues:\n\nValidation checks to perform:\n- **Required fields** — verify `identity`, `name`, and `shortName` are present\n- **Identity format** — use reverse-DNS format (e.g., `MyOrg.Templates.WebApi`)\n- **Parameter issues** — check datatypes are valid (`string`, `bool`, `choice`, `int`, `float`), choices have defaults, descriptions are present\n- **ShortName conflicts** — avoid names that collide with built-in CLI commands (`build`, `run`, `test`, `publish`). Check with `dotnet new list` to see if the name is already taken\n- **Post-action completeness** — verify post-actions have all required configuration\n- **Tags** — ensure language, type, and classification tags are set for discoverability\n\n### Step 3: Refine the template\n\nBased on validation results and user requirements:\n\n1. **Add parameters** with appropriate types (string, bool, choice), defaults, and descriptions\n2. **Add conditional content** using `#if` preprocessor directives for optional features\n3. **Configure post-actions** for solution add, restore, or custom scripts\n4. **Set constraints** to restrict which SDKs or workloads the template supports\n5. **Add classifications** and tags for discoverability\n\n### Step 4: Test the template locally\n\n```bash\ndotnet new install ./path/to/template/root\ndotnet new mylib --name TestProject --dry-run\ndotnet new mylib --name TestProject --output ./test-output\ndotnet build ./test-output/TestProject\n```\n\n## Validation\n\n- [ ] `template.json` passes manual validation with zero errors\n- [ ] Template identity and shortName are unique and meaningful\n- [ ] All parameters have descriptions and appropriate defaults\n- [ ] Template can be installed, dry-run, and instantiated successfully\n- [ ] Created projects build cleanly with `dotnet build`\n- [ ] Conditional content produces correct output for all parameter combinations\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Identity format issues | Use reverse-DNS format (e.g., `MyOrg.Templates.WebApi`). Avoid spaces or special characters. |\n| ShortName conflicts with CLI commands | Avoid names like `build`, `run`, `test`, `publish`. Check by running `dotnet new list` to see if the name is already taken. |\n| Missing parameter descriptions | Every parameter should have a `description` and `displayName` for discoverability. |\n| Not testing all parameter combinations | Use `dotnet new <template> --dry-run` with different parameter values to verify conditional content works correctly. |\n| Hardcoded versions in template | Use `sourceName` replacement for project names and consider parameterizing framework versions. |\n| Not setting classifications | Add appropriate `classifications` (e.g., `[\"Web\", \"API\"]`) for template discovery. |\n\n## More Info\n\n- [Custom templates for dotnet new](https://learn.microsoft.com/dotnet/core/tools/custom-templates) — official authoring guide\n- [template.json reference](https://github.com/dotnet/templating/wiki/Reference-for-template.json) — full schema reference\n- [Template Engine Wiki](https://github.com/dotnet/templating/wiki) — template engine internals",
  "applicable_domains": [
    "code",
    "dotnet",
    "engineering"
  ],
  "invocation": [
    "/template-authoring"
  ],
  "tags": [
    "dotnet-template-engine",
    "dotnet",
    "csharp",
    "microsoft"
  ],
  "authored_by": "anthropics",
  "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-template-engine/skills/template-authoring/SKILL.md",
  "lifecycle": "stable",
  "category": "dotnet",
  "provenance": {
    "source": "dotnet/skills",
    "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-template-engine/skills/template-authoring/SKILL.md",
    "author": "Microsoft / .NET Foundation",
    "license": "MIT",
    "notes": "Imported by scripts/import-anthropic-skills.py."
  }
}