Writes .NET logs using the LoggerMessage source generator for compile-time-validated, allocation-free ILogger calls. Use when adding or reviewing structured log statements with message templates, log levels, event IDs, exceptions, and scopes.
Ships in dotnet-advanced. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use the LoggerMessage source generator (part of Microsoft.Extensions.Logging) to declare log statements as partial methods.
Generated methods allocate nothing when the level is disabled, validate the message template against the typed parameters at compile time, and preserve structured fields for queries.
logger.LogInformation($"...") allocates on every call and flattens the arguments into a string.
Trace, Debug, Information, Warning, Error, lifecycle).logger.LogInformation($"..."), logger.Log(...), or an interpolated template.Add partial to the class that declares the log methods; the generator emits their bodies.
public sealed partial class UserService(ILogger<UserService> logger)
private static partial void method with [LoggerMessage].ILogger as the first parameter.{Placeholder} names match the remaining typed parameters in order.string.Format the template.[LoggerMessage(LogLevel.Information, "User {UserId} created")]
private static partial void LogUserCreated(ILogger logger, Guid userId);
Add an Exception parameter (any position after the logger).
The generator binds it as the entry's exception; it does not format it into the message text.
[LoggerMessage(LogLevel.Error, "Failed to create user {UserId}")]
private static partial void LogUserCreationFailed(ILogger logger, Exception exception, Guid userId);
When several entries share the same context, open a BeginScope; do not repeat the value in every template.
using var scope = logger.BeginScope(new Dictionary<string, object?>
{
["Email"] = user.Email,
["Phone"] = user.Phone
});
Call the method at the log site and build once — a template/parameter mismatch is a compile error.
LogUserCreated(logger, user.Id);
partial.[LoggerMessage] methods, not direct logger.Log* calls.{Placeholder} tokens matching the typed parameters — no interpolation or string.Format.Exception parameter, not concatenated into the message.| Pitfall | Correct approach |
|---|---|
logger.LogInformation($"Created {userId}") | LogUserCreated(logger, userId) with a [LoggerMessage] method. |
| Interpolating into the template | Named {Placeholder} tokens bound to typed parameters. |
| Formatting the exception into the message string | Add an Exception parameter; the generator attaches it. |
Non-static or non-partial log method | [LoggerMessage] methods must be static partial, and the type partial. |
| Placeholder names or count differ from parameters | Match names and order; the build fails otherwise. |
What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/binding-and-validating-optionsBind a configuration section to a typed options class and validate it at startup with the .NET options pattern. USE FOR: adding an options type, binding it from configuration, applying DataAnnotations or custom validation, and failing fast on invalid configuration with ValidateOnStart. DO NOT USE FOR: general host composition and the order of builder extensions (use configuring-dotnet-hosting).
/configuring-dotnet-dependency-injectionRegister and review .NET dependency-injection services and lifetimes on IServiceCollection. USE FOR: adding a registration, choosing singleton/scoped/transient, grouping registrations behind a feature extension, assembly scanning with Scrutor, or validating a service graph. DO NOT USE FOR: choosing which kind of type to declare (use designing-dotnet-types), or configuring the host builder and its lifecycle (use configuring-dotnet-hosting).
/configuring-dotnet-hostingConfigure a .NET application host and its feature-registration extensions on IHostApplicationBuilder. USE FOR: composing HostApplicationBuilder/WebApplicationBuilder, writing IHostApplicationBuilder extension methods, registering shared service defaults, and host startup and lifecycle. DO NOT USE FOR: choosing a service lifetime or a single registration (use configuring-dotnet-dependency-injection), or binding and validating an options section (use binding-and-validating-options).
/designing-dotnet-typesChoose the right kind of .NET type for new behavior — static class, extension method, injected service, hosted service, options type, record, or interface. USE FOR: deciding how to shape a new unit of behavior or data before writing it, or reviewing that an existing type has the right shape for its dependencies and lifecycle. DO NOT USE FOR: registering a type or choosing its DI lifetime (use configuring-dotnet-dependency-injection).
/dotnet-advanced:dotnet-source-generated-loggingfrom dotnet-advanced
npx claudepluginhub nice3point/revit-skills --plugin dotnet-advancedOther plugins' skills for the same job