shinyorg/templates/shiny-di

Claude Code and agent skill by shinyorg/templates

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Generate and configure Shiny DI for .NET - attribute-driven service registration with source generators, keyed services, categories, and multi-interface support

Install

npx vskill@latest install shinyorg/templates/shiny-di

SKILL.md

The same SKILL.md was published earlier as shinyorg/templates/shiny-di.

Shiny Dependency Injection Skill

You are an expert in Shiny Extensions Dependency Injection, a .NET library providing attribute-driven service registration with source generators.

When to Use This Skill

Invoke this skill when the user wants to:

  • Register services using [Singleton], [Scoped], or [Transient] attributes with source generation
  • Configure the Shiny DI service registry in their application
  • Use keyed services, categories, TryAdd semantics
  • Register services against multiple interfaces
  • Use open generics with DI attributes

Library Overview

Documentation: https://shinylib.net/extensions/di/ Repository: https://github.com/shinyorg/Shiny.Extensions Package: Shiny.Extensions.DependencyInjection Namespace: Shiny

Registration Attributes

Mark classes with attributes for automatic DI registration via source generation:

csharp
[Singleton] // Singleton lifetime
public class MyService : IMyService { }
[Scoped] // Scoped lifetime
public class MyRepository : IRepository { }
[Transient] // Transient lifetime
public class MyFactory : IFactory { }
Attribute Properties

All registration attributes support these properties:

PropertyTypeDescription
AsSelfboolRegister as the class itself rather than its interface
TypeTypeRegister against a specific interface (when class implements multiple)
KeyedNamestring?Register as a keyed service
Categorystring?Category for conditional registration
TryAddboolUse TryAdd semantics (won't replace existing registrations)
Examples
csharp
// Register as the class itself
[Singleton(AsSelf = true)]
public class AppState { }
// Register against a specific interface
[Singleton(Type = typeof(ISpecificInterface))]
public class MultiInterfaceService : ISpecificInterface, IOtherInterface { }
// Keyed service
[Singleton(KeyedName = "primary")]
public class PrimaryCache : ICache { }
// Category-based conditional registration
[Singleton(Category = "premium")]
public class PremiumFeature : IFeature { }
// TryAdd semantics
[Singleton(TryAdd = true)]
public class DefaultLogger : ILogger { }

Setup

csharp
// Register all source-generated services
builder.Services.AddShinyServiceRegistry();
// Register with specific categories only
builder.Services.AddShinyServiceRegistry("premium", "analytics");

Helper Extensions

csharp
// Register a singleton against all implemented interfaces
services.AddSingletonAsImplementedInterfaces<MyService>();
services.AddSingletonAsImplementedInterfaces<MyService>("keyName");
// Register scoped against all implemented interfaces
services.AddScopedAsImplementedInterfaces<MyService>();
// Check registrations
bool hasService = services.HasService<IMyService>();
bool hasImpl = services.HasImplementation<MyService>();
// Lazy resolution
Lazy<IMyService> lazy = services.GetLazyService<IMyService>(required: true);

Code Generation Instructions

  • Always use attributes ([Singleton], [Scoped], [Transient]) over manual registration
  • Choose appropriate lifetime: Singleton for stateless services, Scoped for per-request (DbContext), Transient for lightweight factories
  • Use Category for optional features that may not always be registered
  • Use KeyedName when multiple implementations of the same interface exist
  • Always call AddShinyServiceRegistry() to activate source-generated registrations

Best Practices

  1. Use source generation - Always prefer [Singleton]/[Scoped]/[Transient] attributes over manual services.Add*() calls
  2. Call AddShinyServiceRegistry() - Required to activate source-generated registrations
  3. Appropriate lifetimes - Singleton for stateless, Scoped for DbContext/unit-of-work, Transient for factories
  4. Use keyed services - When multiple implementations exist, use KeyedName to disambiguate

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
150
Repository forks
14
7-day trend score
25

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 May 2026, 6 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/shinyorg/templates/shiny-di/badge)](https://verified-skill.com/skills/shinyorg/templates/shiny-di)

Something wrong with this skill or its page? Tell us.