How the dotnet-template-engine Plugin Supports Project Scaffolding

The dotnet-template-engine plugin enables project scaffolding by orchestrating four loosely-coupled skills—template-discovery, template-instantiation, template-authoring, and template-validation—that automate the full lifecycle of generating .NET projects from templates, from intent resolution to Central Package Management adaptation.

The dotnet-template-engine plugin serves as the core scaffolding engine within the dotnet/skills repository. It transforms natural language requests into fully instantiated .NET projects by wrapping the dotnet new CLI workflow with intelligent parameter resolution, workspace analysis, and multi-project solution composition.

Core Architecture: The Four Scaffolding Skills

The plugin organizes its functionality into declarative skills defined in Markdown files under the skills/ directory. Each skill encapsulates a specific phase of the scaffolding lifecycle.

Template Discovery

The template-discovery skill locates and inspects available dotnet new templates. It searches local and NuGet template sources, maps natural-language intent to template short names (e.g., "web API with auth" → webapi), and previews template output before instantiation.

Template Instantiation

The template-instantiation skill handles the core project scaffolding workflow. Defined in skills/template-instantiation/SKILL.md, this skill resolves template names, validates parameters, executes dotnet new with --dry-run previews, adapts projects to Central Package Management (CPM), composes multi-project solutions, and manages template package installation.

Template Authoring

The template-authoring skill supports creating custom templates from existing projects. It bootstraps templates, generates template.json manifests, runs validation checks, and packages templates for NuGet distribution.

Template Validation

The template-validation skill enforces schema compliance for template.json files. It checks required fields, detects short-name conflicts, validates parameter types, verifies post-actions, and ensures proper tagging.

The Project Scaffolding Workflow

When a user requests a new project, the template-instantiation skill executes a nine-step pipeline defined in skills/template-instantiation/SKILL.md:

  1. Resolves the template – If the request uses natural language, the plugin consults template-discovery to map intent to a short name.

  2. Inspects parameters – Executes dotnet new <template> --help to retrieve supported CLI flags, default values, and constraints.

  3. Analyzes the workspace – Detects existing Central Package Management configurations (Directory.Packages.props), SDK pins (global.json), and target frameworks to ensure alignment with the surrounding solution.

  4. Previews the scaffold – Runs dotnet new <template> --dry-run to display files that would be generated, allowing user confirmation before disk changes.

  5. Instantiates the project – Calls dotnet new with resolved parameters, including --output, --framework, authentication options, and AOT flags.

  6. Adapts to CPM – If Directory.Packages.props exists, automatically strips inline <PackageReference> versions from the generated .csproj and migrates them to <PackageVersion> entries in the central props file.

  7. Composes multi-project solutions – For complex solutions, sequentially creates each project and wires them together using dotnet sln add and dotnet add <project> reference <other>.

  8. Manages template packages – Provides commands for installing or uninstalling template packages via dotnet new install and dotnet new uninstall.

  9. Validates the result – Runs dotnet build and optionally dotnet list package --outdated to verify clean builds and current package versions.

Practical Scaffolding Examples

Scaffold a Web API with Authentication and AOT

Preview the scaffold before creation:

dotnet new webapi --name MyApi --framework net10.0 --auth Individual --aot --dry-run

Create the project with CPM adaptation:

dotnet new webapi \
  --name MyApi \
  --output ./src/MyApi \
  --framework net10.0 \
  --auth Individual \
  --aot

Build a Multi-Project Solution

Create an API project with companion unit tests:


# Create the API project

dotnet new webapi -n MyApi -o src/MyApi --framework net10.0

# Create the test project

dotnet new xunit -n MyApi.Tests -o tests/MyApi.Tests

# Wire projects together

dotnet sln add src/MyApi src/MyApi.Tests
dotnet add tests/MyApi.Tests reference src/MyApi

# Verify build

dotnet build

Install Community Template Packages

Add third-party templates to your local environment:

dotnet new install Microsoft.DotNet.Web.ProjectTemplates.10.0
dotnet new list | grep -i webapi

Key Configuration Files

The plugin's declarative architecture relies on specific files within plugins/dotnet-template-engine/:

File Path Purpose
plugin.json plugins/dotnet-template-engine/plugin.json Declares plugin metadata, version, and skills directory location
template-instantiation skill skills/template-instantiation/SKILL.md Defines the full project scaffolding workflow
template-discovery skill skills/template-discovery/SKILL.md Implements intent-to-template mapping
template-authoring skill skills/template-authoring/SKILL.md Supports custom template creation
Agent definition agents/template-engine.agent.md Orchestrates skill execution

Summary

  • The dotnet-template-engine plugin provides comprehensive project scaffolding through four specialized skills that cover discovery, instantiation, authoring, and validation.
  • Template instantiation follows a nine-step pipeline that includes dry-run previews, CPM adaptation, and multi-project solution composition.
  • The plugin automatically detects workspace conventions like Directory.Packages.props and global.json to ensure new projects align with existing solutions.
  • All logic is declaratively defined in Markdown skill files, making the architecture extensible without code changes.

Frequently Asked Questions

How does the plugin handle natural language requests for project creation?

The plugin routes natural language through the template-discovery skill, which maps intents like "web API with auth" to specific template short names (e.g., webapi). This resolved short name is then passed to the template-instantiation skill for execution.

What is Central Package Management (CPM) adaptation in the scaffolding process?

When the plugin detects a Directory.Packages.props file in the workspace, it automatically strips version attributes from <PackageReference> elements in the newly generated .csproj file. It then adds corresponding <PackageVersion> entries to the central props file, ensuring consistency with the existing solution's package management strategy.

Can the plugin scaffold solutions with multiple interconnected projects?

Yes. The template-instantiation skill supports multi-project solutions by sequentially creating individual projects. It then wires them together using dotnet sln add for solution membership and dotnet add reference for project dependencies, followed by a validation build to ensure proper connectivity.

Where is the scaffolding logic defined in the source code?

The primary scaffolding workflow is defined in skills/template-instantiation/SKILL.md, while the orchestrating agent configuration resides in agents/template-engine.agent.md. The plugin descriptor in plugin.json binds these components together and points to the skills directory.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →