Ship an Agent Skill That Installs Itself with Your Library Developers are shipping AI agent skills inside NuGet packages so that when a library is installed, the skill automatically teaches coding agents how to use it correctly. This approach, pioneered by Daniel Cazzulino for the StructId library and adopted by Mockly's maintainer, eliminates the need for separate plugins and improves agent-generated code quality. Table Of Contents Introduction Link to heading introduction Like many developers, my approach to software development has changed a lot with the rise of AI. However, whenever I am using a library, I notice that the quality of AI Coding Agents drops. Deprecated or old ways of working are used, code is generated that doesn’t flow nicely with the code around it, etc. But the main problem is that often, the model just doesn’t really know what to do with the library. For example, let’s say you installed a library to help you write better tests for a specific part of your system. In my case, I was using Mockly https://github.com/dennisdoomen/mockly/?WT.mc id=DT-MVP-5005050 by Dennis Doomen https://www.dennisdoomen.com/ to make testing HttpClient code easier. But even though I installed that library, the agent didn’t use it, opting instead for a more verbose technique. This makes sense. The dataset of the model probably doesn’t contain the latest information about the library. Another reason is that AI tries to write code similarly to existing code, so the more you use agents to write code, the more “incorrect” code is generated and the new version of the library gets ignored. In this post, I’ll discuss several approaches I have found helpful to deal with this problem. But most importantly, I want to talk about a powerful concept I’ve not seen a lot of people talking about, which is shipping Agent Skills together with your library . I saw Daniel Cazzulino https://www.cazzulino.com/ talking about this method on Twitter https://x.com/kzu/status/2044527401481261345 for the StructId library https://github.com/devlooped/StructId?WT.mc id=DT-MVP-5005050 , and I discussed it with Mockly’s maintainer who then adopted it too. Since then, my agents have gotten noticeably better Here’s the part I find most exciting, and the reason for the title: in .NET, you can ship that skill inside the NuGet package itself . When a developer adds your library, the skill installs into their repository automatically. No plugin to discover, no extra command, nothing to remember. We’ll build up to that, but first let me cover what a library consumer can reach for today. Agent Skills https://agentskills.io , they are a way to teach AI coding agents how to perform a specific task. Basically, a skill is just a folder with a Markdown file and optionally some scripts or extra files that contains focused instructions the agent can load on demand. Teaching Agents About Your Dependencies Link to heading teaching-agents-about-your-dependencies As a consumer, you have a few ways to give an agent better information about a library you’ve installed. Each one helps, and each has a catch: | Approach | What it does | Why it’s not enough | |---|---|---| | AGENTS.md rules dotnet-inspect https://github.com/richlander/dotnet-skills/blob/main/skills/dotnet-inspect/SKILL.md?WT.mc id=DT-MVP-5005050 Aspire https://aspire.dev ’s Agent Integrations That last row is the clue. If a skill is the right tool, why should every consumer write the same one? The library author already knows how their library should be used, so they can write the skill once and everyone shares a single definition. But how do you ship it? One option is the plugin systems of agents like GitHub Copilot https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/plugins-creating and Claude Code https://code.claude.com/docs/en/plugins . But that doubles the work: the consumer installs the library and the plugin, and they can forget the plugin or never learn it exists. There’s a better way. Shipping Agent Skills Together With Your Library Link to heading shipping-agent-skills-together-with-your-library If a library author already knows how their library should be used by an agent, why should that knowledge live in a separate plugin you have to find and install? It should come along with the package. When you add the library, your coding agent immediately has the right instructions. No web search, no decompilation, no separate plugin to remember. Libraries already ship human-readable READMEs for developers. This is the same idea, aimed at AI coding agents instead. So how does this work? You pack a SKILL.md file into your library, together with instructions on where the build/install system should store the skill. In .NET, we’d use the buildTransitive .targets file. If you’re not a .NET developer: a NuGet package is the standard way to distribute .NET libraries, and a .targets file is an MSBuild file that can run extra steps during a build. Here, the extra step is conceptually simple: copy the Agent Skill to the right place in the repository that’s consuming your library. Here’s what the package looks like, conceptually: YOUR LIBRARY.nupkg |- lib/... |- buildTransitive/YOUR LIBRARY.targets +- skills/YOUR LIBRARY/SKILL.md +- skills/YOUR LIBRARY/.gitignore Your project file .csproj tells NuGet to include those files in the package: php