Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)5.8k · #14616

template-validation

Skill này làm gì

Skill này kiểm tra các file template .NET tùy chỉnh để tìm lỗi khiến template không hoạt động, như thiếu trường hoặc short name trùng nhau. Skill dành cho tác giả template muốn phát hiện vấn đề trước khi xuất bản.

Khi nào nên dùng

  • ✓Khi bạn đã viết file template.json và muốn kiểm tra trước khi xuất bản.
  • ✓Khi một template không xuất hiện trong dotnet new list sau khi đã cài.
  • ✓Khi bạn xem lại các định nghĩa tham số của template trước khi chia sẻ trên NuGet.

Liên kết skill

https://github.com/dotnet/skills/blob/main/plugins/dotnet-template-engine/skills/template-validation/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/dotnet/skills/blob/main/plugins/dotnet-template-engine/skills/template-validation/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi đã viết template.json cho nhóm của mình. Kiểm tra lỗi giúp tôi trước khi tôi xuất bản lên NuGet.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent phân tích file trước, dừng lại nếu cú pháp hỏng, rồi kiểm tra các trường, tham số, short name và ràng buộc theo quy tắc xác thực của mình.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Template 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 .template.config/template.json

Validation Rules

When reviewing a template.json, check ALL of the following categories systematically. Report every finding as an error, warning, or suggestion.

Parse gate — stop on syntax errors. Parse JSON before applying any semantic rule. If parsing fails, report the parser's line and column, show only the smallest concrete syntax correction, and stop. Do not invent required-field, symbol, post-action, or discoverability findings from a document that did not parse. Re-parse after the correction before making any semantic claim.

The malformed-JSON final response has exactly two parts: the one-line parse verdict and a corrected snippet showing the exact edit. Do not append semantic recommendations, optional metadata, or a full replacement manifest.

1. Required Fields

Field Severity Rule
identity ERROR Must be present and non-empty
name ERROR Must be present and non-empty
shortName ERROR Must be present and non-empty
sourceName WARNING Without it, --name won't customize the generated project name
author WARNING Improves template discoverability
description SUGGESTION Helps users understand what the template creates
classifications SUGGESTION Improves search and categorization (e.g., ["Web", "API"])
defaultName SUGGESTION Provides a fallback project name when --name 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

A shortName that matches a dotnet new subcommand conflicts, because dotnet new <name> is then parsed as that subcommand instead of instantiating the template. Read the reserved set for the installed SDK from the Commands: section of dotnet new --help — that is the authoritative source and avoids this rule going stale.

As of current SDKs the subcommands include (illustrative only — version-dependent, do not hardcode this list; the live dotnet new --help output is canonical): install, uninstall, update, list, search, details, create. Note that top-level dotnet verbs like build, run, test, and publish do NOT conflict — dotnet new test does not collide with dotnet test.

  • ERROR if shortName matches any subcommand reported by dotnet new --help (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 type field
  • For type: "parameter":
    • WARNING if no datatype specified (defaults to string)
    • SUGGESTION if no description (improves --help output)
    • If datatype: "choice":
      • ERROR if no choices defined
      • ERROR if choices is empty
      • ERROR if defaultValue is not in the choices list
      • WARNING if optional (not isRequired) and no defaultValue — users get unexpected behavior
    • If datatype: "bool":
      • ERROR if defaultValue is not a valid boolean
    • If datatype: "int":
      • ERROR if defaultValue is not a valid integer
    • Valid datatypes: string, bool, choice, int, float, hex, text
    • ERROR if datatype is not in the valid list
  • For
Câu hỏi thường gặp

Agent báo cáo những gì?

Mỗi phát hiện được đánh dấu là lỗi, cảnh báo hoặc gợi ý, để bạn biết cần sửa gì trước.

Nếu JSON hỏng thì sao?

Agent báo dòng và cột của lỗi, rồi đưa ra cách sửa nhỏ nhất trước khi kiểm tra bất cứ điều gì khác.

Skill có tạo template không?

Không. Skill chỉ xác thực file template có sẵn, còn việc tạo template do một skill riêng đảm nhiệm.

Chi tiết

Mô tả gốc của tác giả

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 templa

repo: dotnet/skills

Độ phổ biến

Sao GitHub
5.8k
Vị trí xếp hạng
#14616
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự