Let Claude write your .NET skills
The best way to create Claude skills in .NET
The best way to write a Claude skill is not to write it yourself. Give Claude Code a prompt, and it builds the skill for you.
I tried this on an ASP.NET Core Web API and created two skills. One adds a new Entity Framework Core entity, and the other adds a new Minimal API endpoint. Here is how the first one came together.
Start in plan mode
Before giving Claude Code the prompt, I put it into plan mode by starting the prompt with /plan. In this mode, Claude Code reads the project and plans the changes, but it doesn't make any of them until you're happy with the plan.
This is the prompt I gave it:
The user must give an entity name and configuration values. These must be provided otherwise the entity cannot be created.
- Table name
- Primary key
- Properties and their column types. If it's a string, max length must be specified.
The configuration will be stored in its own class which implements IEntityTypeConfiguration.
It will also add it as a DbSet to EcommerceDbContext. There will also be a new repository class called {EntityName}Repository which will be added to the Repositories folder. This will inject the DbContext into the class through the constructor and store it as a private readonly field. It will not contain any methods.
The interface will be set up in the Application project. The class will implement the interface and it will be added to dependency injection.
A new test class will be set up for the repository in InfrastructureTests. This will create the repository and create an in-memory instance of the DbContext. An instance to the repository will be created as a private readonly field. No test methods will be added.
The prompt does two jobs. It lists the values the skill must be given before it can create an entity, and it describes each file the skill needs to create or change.
Claude asked about soft deletes
My project already has a Product entity with a Deleted property for soft deletes. Claude Code spotted this and asked how the new skill should handle soft deletes. It gave me three options:
Deleted column and a query filter to every entityI chose to be asked for each entity. That question wasn't in my prompt, but the answer is now part of the skill.
This is why I like plan mode for creating skills. It asks about things I haven't even thought of that need to go into the skill.
The plan
Claude Code then came up with a plan. The skill would be saved in .claude/skills/add-entity/SKILL.md, and it would follow three steps:
Product filesThe plan also included mapping rules, such as using HasMaxLength for strings and HasColumnType for every other column. The skill doesn't generate a migration, but it tells you that one is needed.
I was happy with the plan, so I got Claude Code to implement it.
What the skill stops you forgetting
When you add a string property to an entity, Entity Framework Core sets the column type to nvarchar(max) unless you give it a max length. It also picks the table name for you unless you override it.
I've forgotten both of these many times in the past. The whole point of a skill is to make sure they aren't forgotten. It's why my prompt says the table name must be given, and that every string must have a max length.
Testing it with missing data
To test the skill, I left that information out with this prompt to see what would happen:
Claude Code didn't create anything. It explained that the skill won't guess or fill in defaults for missing details, and it listed what was missing:
IdNameIt also asked me to confirm that the entity could be soft deleted, because the skill only adds Deleted when you ask for it.
Finally, it gave me a short format to reply with all the values on one line. I used that format:
That gives a table called Categories with a key of Id, and a Name stored as nvarchar with a max length of 100. The entity can also be soft deleted. With every value supplied, Claude Code went ahead and created the files.
In the full article, I show the code the skill generated, then create a second skill for Minimal API endpoints. With that skill, Claude Code builds the solution, runs the tests and calls the new endpoint to prove it works.
Both skills are also in this week's video. I get Claude Code to create them and test them by adding a category entity and a category endpoint.
You can watch it below:
Thanks for reading,
David Grace
Want to reach .NET and C# developers? Sponsor this newsletter