关于 dotnet-init
用于为 dotnet-claude-kit 初始化 .NET 项目的交互式技能。它检测项目结构、收集架构与技术选项,并生成或更新定制的 CLAUDE.md,同时检查已有内容。
主要功能
- 01检测项目类型与结构
- 02询问架构和技术栈选择
- 03生成定制的 CLAUDE.md
- 04保留已有自定义章节
- 05验证项目设置
适用场景
- 01为 Claude Code 准备新的 .NET 项目
- 02将 dotnet-claude-kit 添加到现有项目
- 03更新项目指南且不静默覆盖已有内容
MCP 相关
设置时会检查 .mcp.json;如有需要,会为 Roslyn MCP 服务创建该文件。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ codewithmukesh/ dotnet-claude-kit --skill dotnet-init安装后在 Claude Code 中输入/dotnet-init确认已加载。
详细介绍
/dotnet-init
说明
交互式初始化 .NET 项目,以便与 dotnet-claude-kit 配合使用。检测项目类型,针对架构和技术栈提出问题,然后在项目根目录生成完全定制的 CLAUDE.md。
无需手动复制模板。
适用场景
- 使用 Claude Code 开始一个新的 .NET 项目
- 将 dotnet-claude-kit 添加到现有项目
- “init project”、“setup project”、“generate CLAUDE.md”、“configure for dotnet-claude-kit”
使用方法
步骤 1:检测或询问项目类型
分析当前目录,确定这是现有项目还是从零开始的新项目:
→ Look for .slnx / .sln files
→ If found, scan .csproj files for SDK type:
- Microsoft.NET.Sdk.Web → web-api or blazor-app
- Microsoft.NET.Sdk.Worker → worker-service
- Microsoft.NET.Sdk → class-library
- Multiple projects with inter-module references → modular-monolith
- If ambiguous, ask the user
→ If NO solution/project found (greenfield):
- Ask: "What are you building?"
- REST API / microservice → web-api
- Blazor application → blazor-app
- Background worker / queue processor → worker-service
- NuGet package / shared library → class-library
- Multi-module system → modular-monolith
- Ask: "Project name?"
- Scaffold the solution structure:
- dotnet new sln -n ProjectName --format slnx (modern XML solution format)
- dotnet new webapi / worker / classlib as appropriate
- Set up Directory.Build.props with .NET 10 defaults
- Create src/ and tests/ folder structure
步骤 2:架构问卷
加载 architecture-advisor 技能并提出有针对性的问题:
- 领域复杂度 — 以 CRUD 为主、业务规则适中,还是领域模型丰富?
- 团队规模 — 个人、小型团队,还是大型团队?
- 模块边界 — 单个可部署单元,还是多个有界上下文?
- 现有模式 —(仅限现有项目)通过
convention-learner技能检测约定
→ 推荐:VSA、Clean Architecture、DDD 或 Modular Monolith,并说明理由。
步骤 3:选择技术栈
询问具体的技术选项:
- 数据库:PostgreSQL、SQL Server、SQLite,或暂不确定
- 身份验证:JWT、OIDC、Cookie,或暂不确定
- 缓存:HybridCache、Redis,或暂不确定
- 消息传递:Wolverine、MassTransit,或暂不确定
- 测试:确认使用 xUnit + Testcontainers 默认配置
步骤 4:生成 CLAUDE.md
从 templates/ 加载合适的模板作为基础,然后进行定制:
- 将
[ProjectName]替换为实际的项目/解决方案名称 - 设置所选架构
- 配置技术栈部分
- 对于现有项目:添加在步骤 2 中检测到的项目专属约定
- 对于从零开始的新项目:根据所选架构添加建议的约定
写入前,检查是否已有 CLAUDE.md。绝不能在未提示的情况下覆盖。
→ If ./CLAUDE.md does NOT exist:
- Write the generated content to ./CLAUDE.md
→ If ./CLAUDE.md ALREADY exists:
- Read it and identify hand-written / custom sections
(anything not produced by a kit template)
- Ask: "You already have a CLAUDE.md. How should I proceed?"
- Merge (recommended) → keep the user's custom sections, add or refresh the
kit's architecture, tech-stack, and convention sections in place
- Overwrite → replace it entirely with the freshly generated file
- Keep → leave the file untouched and print the generated content so the
user can copy what they want by hand
- For Merge and Overwrite: back the original up to ./CLAUDE.md.bak first.
Never discard user content without a .bak backup.
步骤 5:验证设置
→ Confirm .mcp.json exists or create it (for Roslyn MCP server)
→ For existing projects:
- Verify the solution file is discoverable
- Run a quick health check to establish baseline
- Report: "Project initialized. Run /health-check to see your baseline."
→ For greenfield projects:
- Verify dotnet build succeeds on the scaffolded solution
- Report: "Project created. Run /scaffold to add your first feature."
调用的技能: project-setup、architecture-advisor、convention-learner
Agent: dotnet-architect
示例 — 现有项目
User: /dotnet-init
Claude: Detected:
- Solution: MyApp.slnx (3 projects)
- SDK: Microsoft.NET.Sdk.Web → Web API
- Database: PostgreSQL (from connection string)
- Auth: JWT (from appsettings)
1. Domain complexity? [CRUD-heavy / Moderate / Rich domain]
> Moderate
2. Team size? [Solo / Small / Large]
> Small
Recommendation: Vertical Slice Architecture
Generated: ./CLAUDE.md (MyApp + VSA + PostgreSQL + JWT)
Run /health-check to see your baseline.
示例 — 从零开始的新项目
User: /dotnet-init
Claude: No .sln or .csproj found. Let's set up a new project.
1. What are you building? [REST API / Blazor / Worker / Library / Modular Monolith]
> REST API
2. Project name?
> OrderService
3. Domain complexity? [CRUD-heavy / Moderate / Rich domain]
> CRUD-heavy
Recommendation: Vertical Slice Architecture
Creating solution...
→ dotnet new sln -n OrderService --format slnx
→ dotnet new webapi -n OrderService.Api -o src/OrderService.Api
→ dotnet new xunit3 -n OrderService.Tests -o tests/OrderService.Tests
→ Directory.Build.props with .NET 10 defaults
→ Generated: ./CLAUDE.md (OrderService + VSA + scaffold-ready)
Run /scaffold to add your first feature.
示例 — 已有 CLAUDE.md 的现有项目
User: /dotnet-init
Claude: Detected:
- Solution: MyApp.slnx (3 projects) → Web API
- Found an existing CLAUDE.md (custom "Deployment" and "Team conventions" sections)
You already have a CLAUDE.md. How should I proceed?
[Merge (recommended) / Overwrite / Keep]
> Merge
→ Backed up original to ./CLAUDE.md.bak
→ Kept your Deployment + Team conventions sections
→ Refreshed architecture (VSA), tech-stack (PostgreSQL + JWT), and convention sections
Generated: ./CLAUDE.md
Run /health-check to see your baseline.
相关内容
/plan— 在开发功能前制定计划/health-check— 初始化后评估项目健康状况/scaffold— 使用所选架构搭建功能骨架
评论
支持 Markdown