strategy-registry

Implement Strategy pattern dispatch with registry-based strategy selection.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/101mare/skill-library --skill strategy-registry
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: strategy-registry
Source: https://github.com/101mare/skill-library/tree/main/skills/patterns/strategy-registry
Command: npx skills add https://github.com/101mare/skill-library --skill strategy-registry

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides robust patterns for implementing the Strategy pattern with registry-based dispatch, enabling extensible systems where new handlers or strategies can be added without modifying core logic. It solves the problem of hard-to-maintain if/elif chains and promotes the Open/Closed Principle.

Core Features & Use Cases

  • Extensible Dispatch: Easily add new handlers for file types, event types, or commands.
  • Multiple Registry Patterns: Demonstrates dict-based, decorator-based, and auto-discovery (__init_subclass__) registration.
  • Protocol Definition: Enforces a clear interface for strategies using typing.Protocol.
  • Use Case: Building a plugin system for a code editor where new language support can be added by simply dropping in new handler modules.

Quick Start

Use the strategy-registry skill to implement a file handler that dispatches based on file extension.

Frequently Asked Questions about strategy-registry

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace if/elif chains with a strategy pattern for file extension dispatch?

You can replace monolithic if/elif chains by implementing a strategy pattern with a registry-based dispatch system, enabling dynamic handler selection based on file extensions while adhering to the Open/Closed Principle for extensible architectures.

What is the best way to build an extensible plugin system for a code editor?

The best way to build an extensible plugin system is using registry-based dispatch, allowing new language support handlers to be added by simply dropping in new modules without modifying core logic or conditional statements.

How does auto-discovery with __init_subclass__ work for registering strategies?

Auto-discovery with __init_subclass__ automatically registers new strategy classes into the registry upon definition, eliminating manual registration steps and ensuring dynamic strategy selection is maintained without decorator or dictionary updates.

Can I enforce a consistent interface for multiple dispatch handlers in Python?

Yes, you can enforce a consistent interface for dispatch handlers by defining a clear protocol using typing.Protocol, ensuring all registered strategies adhere to the required methods for reliable execution.

What are the different ways to register handlers in a registry pattern?

Registry patterns support multiple registration methods including dictionary-based mapping, decorator-based tagging, and auto-discovery via __init_subclass__, providing flexibility for different plugin architecture designs.