pattern-template-method

Enforce consistent algorithm skeletons in TypeScript or NestJS services.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/johnnystefan/test-saas-business --skill pattern-template-method
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pattern-template-method
Source: https://github.com/johnnystefan/test-saas-business/tree/main/skills/design-patterns/behaviorals/pattern-template-method
Command: npx skills add https://github.com/johnnystefan/test-saas-business --skill pattern-template-method

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents repeated algorithm steps across subclasses by defining the invariant workflow in a single superclass so that individual variations stay safe and maintainable.

Core Features & Use Cases

  • Template Method Skeleton: Capture the sequence of operations in an abstract base class to keep shared experts centralized.
  • Hook and Abstract Steps: Declare mandatory steps as abstract methods and optional variations as hooks so subclasses can customize behavior without changing the flow.
  • Use Case: Implement a NestJS provider base class for a shared pre/post processing sequence while letting each child handle its domain-specific operations.

Quick Start

Ask the pattern-template-method skill to sketch a base class algorithm before customizing the subclass implementations.

Frequently Asked Questions about pattern-template-method

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

FAQPage Schema
How do I prevent duplicate algorithm steps across TypeScript subclasses?

To prevent duplicate algorithm steps, define the invariant workflow in a single abstract base class so that individual variations stay centralized and maintainable across TypeScript subclasses.

What is the template method pattern in OOP?

The template method pattern captures a sequence of operations in an abstract base class, declaring mandatory steps as abstract methods and optional variations as hooks for subclasses to customize behavior without changing the flow.

How do I structure shared workflows in NestJS services?

Structure shared workflows by implementing a NestJS provider base class for shared pre/post processing sequences while letting each child provider handle its domain-specific operations through overridden methods.

When should I use the template method pattern for code structure?

Use the template method pattern when you have TypeScript or NestJS services that share invariant flows but vary specific steps, requiring abstract base classes with hook methods that subclasses override to customize behavior.

What's the best way to enforce consistent algorithm skeletons in TypeScript?

The best way to enforce consistent algorithm skeletons is to define the invariant workflow in a single superclass, using hook methods so subclasses can safely customize variations without altering the shared logic.