{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/template-validation",
  "version": "1.0.1",
  "name": "template-validation",
  "description": "Validates custom dotnet new templates for correctness before publishing. Catches missing fields, parameter bugs, shortName conflicts, constraint issues, and common authoring mistakes that cause templates to fail silently. USE FOR: checking template.json files for errors before publishing or testing, diagnosing why a template doesn't appear after installation, reviewing template parameter definitions for type mismatches and missing defaults, finding shortName conflicts with dotnet CLI commands, validating post-action and constraint configuration. DO NOT USE FOR: finding or using existing templates (use template-discovery), creating projects from templates (use template-instantiation), creating templates from existing projects (use template-authoring).",
  "system_prompt_fragment": "# Template Validation\n\nThis skill helps validate custom `dotnet new` templates for correctness before publishing. It encodes the validation rules that catch common authoring mistakes — issues that cause templates to silently fail, produce broken projects, or not appear in `dotnet new list`.\n\n## When to Use\n\n- User asks to check or validate a template.json file\n- User reports \"my template doesn't show up after installing\"\n- User wants to review a template before packaging and publishing to NuGet\n- User encounters unexpected behavior from a custom template\n\n## When Not to Use\n\n- User wants to find or use existing templates — route to `template-discovery`\n- User wants to create a project — route to `template-instantiation`\n- User wants to create a template from an existing project — route to `template-authoring`\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| template.json path | Yes | Path to the template.json file or the template directory containing `.template.config/template.json` |\n\n## Validation Rules\n\nWhen reviewing a template.json, check ALL of the following categories systematically. Report every finding as an error, warning, or suggestion.\n\n### 1. Required Fields\n\n| Field | Severity | Rule |\n|-------|----------|------|\n| `identity` | ERROR | Must be present and non-empty |\n| `name` | ERROR | Must be present and non-empty |\n| `shortName` | ERROR | Must be present and non-empty |\n| `sourceName` | WARNING | Without it, `--name` won't customize the generated project name |\n| `author` | WARNING | Improves template discoverability |\n| `description` | SUGGESTION | Helps users understand what the template creates |\n| `classifications` | SUGGESTION | Improves search and categorization (e.g., `[\"Web\", \"API\"]`) |\n| `defaultName` | SUGGESTION | Provides a fallback project name when `--name` is not specified |\n\n### 2. Identity Format\n\n- ERROR if identity contains spaces — use dots or dashes (e.g., `MyCompany.WebApi.CSharp`)\n- WARNING if identity has no namespace separator (`.` or `-`) — use reverse-DNS format\n\n### 3. ShortName Conflicts\n\nThe following short names conflict with dotnet CLI commands and will cause problems:\n\n`new`, `build`, `run`, `test`, `publish`, `restore`, `clean`, `pack`, `add`, `remove`, `list`, `nuget`, `tool`, `sln`, `help`\n\n- ERROR if shortName matches any reserved name (case-insensitive)\n- WARNING if shortName is only 1 character — too short for discoverability\n- Note: shortName can be a string or an array of strings; check all values\n\n### 4. Symbol Validation\n\nFor each symbol in the `symbols` object:\n\n- ERROR if a symbol is missing the `type` field\n- For `type: \"parameter\"`:\n  - WARNING if no `datatype` specified (defaults to `string`)\n  - SUGGESTION if no `description` (improves `--help` output)\n  - If `datatype: \"choice\"`:\n    - ERROR if no `choices` defined\n    - ERROR if `choices` is empty\n    - ERROR if `defaultValue` is not in the choices list\n    - WARNING if optional (not `isRequired`) and no `defaultValue` — users get unexpected behavior\n  - If `datatype: \"bool\"`:\n    - ERROR if `defaultValue` is not a valid boolean\n  - If `datatype: \"int\"`:\n    - ERROR if `defaultValue` is not a valid integer\n  - Valid datatypes: `string`, `bool`, `choice`, `int`, `float`, `hex`, `text`\n  - ERROR if datatype is not in the valid list\n- For `type: \"computed\"`:\n  - ERROR if missing `value` expression\n- For `type: \"generated\"`:\n  - ERROR if missing `generator` field\n  - Valid generators: `casing`, `coalesce`, `constant`, `port`, `guid`, `now`, `random`, `regex`, `regexMatch`, `switch`, `join`\n\n**Parameter prefix collisions**: WARNING if any parameter name is a prefix of another parameter name (e.g., `Auth` and `AuthMode`) — this creates ambiguous parsing in expression contexts.\n\n### 5. Sources Validation\n\nFor source modifier conditions:\n- WARNING if a condition string doesn't contain parentheses around symbol names — expected format is `(symbolName)`, not bare `symbolName`\n\n### 6. Post-Action Validation\n\nFor each post-action:\n- ERROR if missing `actionId`\n- WARNING if missing `description` — this text is shown to users when the action requires manual steps\n- SUGGESTION if missing `manualInstructions` — these are shown when the action can't run automatically (e.g., in an IDE)\n\n### 7. Constraint Validation\n\nFor each constraint:\n- ERROR if missing `type` field\n- WARNING if missing `args` — most constraint types require arguments\n\n### 8. Tags Validation\n\n- SUGGESTION if no `language` tag — adding `tags.language` (e.g., `\"C#\"`) improves filtering in `dotnet new list --language`\n- SUGGESTION if no `type` tag — adding `tags.type` (e.g., `\"project\"` or `\"item\"`) improves categorization\n\n## Workflow\n\n### Step 1: Locate the template.json\n\nThe file can be at:\n- Direct path: `path/to/template.json`\n- In a template directory: `path/to/.template.config/template.json`\n- In a `.template.config` directory: `path/.template.config/template.json`\n\n### Step 2: Parse and validate\n\nRead the JSON. If it's malformed, report the JSON parse error with line number.\n\nRun all 8 validation categories above. Collect errors, warnings, and suggestions separately.\n\n### Step 3: Report results\n\nPresent findings organized by severity:\n1. **Errors** (must fix) — template will not work correctly\n2. **Warnings** (should fix) — template may cause confusion or limited functionality\n3. **Suggestions** (nice to have) — improvements for discoverability and user experience\n\nInclude the total: \"X error(s), Y warning(s), Z suggestion(s)\"\n\n## Common Pitfalls\n\n| Pitfall | Impact |\n|---------|--------|\n| ShortName = \"test\" or \"build\" | Template can never be created — conflicts with CLI |\n| Missing `sourceName` | `--name MyProject` doesn't rename anything in the generated files |\n| Choice parameter without `defaultValue` | Confusing user experience on optional choice params |\n| Invalid `datatype` value | Template engine ignores the symbol, causing silent failures |\n| Computed symbol without `value` | Template engine throws at instantiation time |\n| Parameter prefix collision (`Auth` vs `AuthMode`) | Ambiguous expression evaluation |\n| Source condition without parentheses | Condition may not evaluate correctly |\n\n## More Info\n\n- [template.json reference](https://github.com/dotnet/templating/wiki/Reference-for-template.json) — full schema\n- [Available Symbol Generators](https://github.com/dotnet/templating/wiki/Available-Symbols-Generators) — generator types\n- [Post-action registry](https://github.com/dotnet/templating/wiki/Post-Action-Registry) — action IDs\n- [Constraints](https://github.com/dotnet/templating/wiki/Constraints) — constraint types",
  "applicable_domains": [
    "code",
    "dotnet",
    "engineering"
  ],
  "invocation": [
    "/template-validation"
  ],
  "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-validation/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-validation/SKILL.md",
    "author": "Microsoft / .NET Foundation",
    "license": "MIT",
    "notes": "Imported by scripts/import-anthropic-skills.py."
  }
}