Skills template-validation
git clone https://github.com/dotnet/skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/dotnet/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/dotnet-template-engine/skills/template-validation" ~/.claude/skills/dotnet-skills-template-validation && rm -rf "$T"
plugins/dotnet-template-engine/skills/template-validation/SKILL.mdTemplate Validation
This 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.
When to Use
- User asks to check or validate a template.json file
- User reports "my template doesn't show up after installing"
- User wants to review a template before packaging and publishing to NuGet
- User encounters unexpected behavior from a custom template
When Not to Use
- User wants to find or use existing templates — route to
template-discovery - User wants to create a project — route to
template-instantiation - User wants to create a template from an existing project — route to
template-authoring
Inputs
| Input | Required | Description |
|---|---|---|
| template.json path | Yes | Path to the template.json file or the template directory containing |
Validation Rules
When reviewing a template.json, check ALL of the following categories systematically. Report every finding as an error, warning, or suggestion.
1. Required Fields
| Field | Severity | Rule |
|---|---|---|
| ERROR | Must be present and non-empty |
| ERROR | Must be present and non-empty |
| ERROR | Must be present and non-empty |
| WARNING | Without it, won't customize the generated project name |
| WARNING | Improves template discoverability |
| SUGGESTION | Helps users understand what the template creates |
| SUGGESTION | Improves search and categorization (e.g., ) |
| SUGGESTION | Provides a fallback project name when is not specified |
2. Identity Format
- ERROR if identity contains spaces — use dots or dashes (e.g.,
)MyCompany.WebApi.CSharp - WARNING if identity has no namespace separator (
or.
) — use reverse-DNS format-
3. ShortName Conflicts
The following short names conflict with dotnet CLI commands and will cause problems:
new, build, run, test, publish, restore, clean, pack, add, remove, list, nuget, tool, sln, help
- ERROR if shortName matches any reserved name (case-insensitive)
- WARNING if shortName is only 1 character — too short for discoverability
- Note: shortName can be a string or an array of strings; check all values
4. Symbol Validation
For each symbol in the
symbols object:
- ERROR if a symbol is missing the
fieldtype - For
:type: "parameter"- WARNING if no
specified (defaults todatatype
)string - SUGGESTION if no
(improvesdescription
output)--help - If
:datatype: "choice"- ERROR if no
definedchoices - ERROR if
is emptychoices - ERROR if
is not in the choices listdefaultValue - WARNING if optional (not
) and noisRequired
— users get unexpected behaviordefaultValue
- ERROR if no
- If
:datatype: "bool"- ERROR if
is not a valid booleandefaultValue
- ERROR if
- If
:datatype: "int"- ERROR if
is not a valid integerdefaultValue
- ERROR if
- Valid datatypes:
,string
,bool
,choice
,int
,float
,hextext - ERROR if datatype is not in the valid list
- WARNING if no
- For
:type: "computed"- ERROR if missing
expressionvalue
- ERROR if missing
- For
:type: "generated"- ERROR if missing
fieldgenerator - Valid generators:
,casing
,coalesce
,constant
,port
,guid
,now
,random
,regex
,regexMatch
,switchjoin
- ERROR if missing
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.
5. Sources Validation
For source modifier conditions:
- WARNING if a condition string doesn't contain parentheses around symbol names — expected format is
, not bare(symbolName)symbolName
6. Post-Action Validation
For each post-action:
- ERROR if missing
actionId - WARNING if missing
— this text is shown to users when the action requires manual stepsdescription - SUGGESTION if missing
— these are shown when the action can't run automatically (e.g., in an IDE)manualInstructions
7. Constraint Validation
For each constraint:
- ERROR if missing
fieldtype - WARNING if missing
— most constraint types require argumentsargs
8. Tags Validation
- SUGGESTION if no
tag — addinglanguage
(e.g.,tags.language
) improves filtering in"C#"dotnet new list --language - SUGGESTION if no
tag — addingtype
(e.g.,tags.type
or"project"
) improves categorization"item"
Workflow
Step 1: Locate the template.json
The file can be at:
- Direct path:
path/to/template.json - In a template directory:
path/to/.template.config/template.json - In a
directory:.template.configpath/.template.config/template.json
Step 2: Parse and validate
Read the JSON. If it's malformed, report the JSON parse error with line number.
Run all 8 validation categories above. Collect errors, warnings, and suggestions separately.
Step 3: Report results
Present findings organized by severity:
- Errors (must fix) — template will not work correctly
- Warnings (should fix) — template may cause confusion or limited functionality
- Suggestions (nice to have) — improvements for discoverability and user experience
Include the total: "X error(s), Y warning(s), Z suggestion(s)"
Common Pitfalls
| Pitfall | Impact |
|---|---|
| ShortName = "test" or "build" | Template can never be created — conflicts with CLI |
Missing | doesn't rename anything in the generated files |
Choice parameter without | Confusing user experience on optional choice params |
Invalid value | Template engine ignores the symbol, causing silent failures |
Computed symbol without | Template engine throws at instantiation time |
Parameter prefix collision ( vs ) | Ambiguous expression evaluation |
| Source condition without parentheses | Condition may not evaluate correctly |
More Info
- template.json reference — full schema
- Available Symbol Generators — generator types
- Post-action registry — action IDs
- Constraints — constraint types