cl-clos-patterns

Apply CLOS design patterns to Lisp class definitions and method implementations.

1|Updated Dec 8, 2025
One-click install
npx skills add https://github.com/cxxxr/.claude --skill cl-clos-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cl-clos-patterns
Source: https://github.com/cxxxr/.claude/tree/main/skills/cl-clos-patterns
Command: npx skills add https://github.com/cxxxr/.claude --skill cl-clos-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

CLOS の設計パターンを適用することで、クラス設計・メソッド実装の一貫性と拡張性を高めます。

Core Features & Use Cases

  • クラス定義と継承戦略: 基本クラス、継承、CPL の理解
  • メソッド定義と組み合わせ: :before / :after / :around の活用
  • 特化と初期化プロトコル: initialize-instance, make-instance のカスタム挙動
  • デザインパターン: プロトコル、ミックスイン、ビジター、シングルトン

Quick Start

簡易クラスとメソッドを定義し、パターン0〜4の設計手法を適用して動作を確認します。

Frequently Asked Questions about cl-clos-patterns

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

FAQPage Schema
How do I apply CLOS design patterns to structure Lisp class hierarchies?

CLOS design patterns organize Common Lisp Object System class definitions through inheritance strategies, method combination (:before/:after/:around), and slot semantics. Apply patterns like protocols, mixins, and visitor to achieve consistent, extensible OO designs with explicit defgeneric usage and proper slot options.

What's the difference between defclass, defgeneric, and defmethod in Common Lisp?

defclass defines class structure and slots; defgeneric declares method signatures and dispatch points; defmethod implements behavior for specific class combinations. Together they enable CLOS method combination, allowing multiple implementations to coexist and be selected at runtime based on argument types.

How do I customize object initialization in CLOS with initialize-instance and make-instance?

initialize-instance and make-instance protocols let you hook custom setup logic into object creation. Override initialize-instance via :after methods to run post-construction steps, or use make-instance wrapper patterns to enforce invariants and control slot initialization order.

When should I use method combination patterns like :before, :after, and :around in CLOS?

:before executes pre-checks or side effects before primary methods; :after handles cleanup or post-conditions; :around wraps primary execution for logging, caching, or control flow. Choose based on whether your logic must run first, last, or wrap the entire call.

Can I implement visitor and singleton patterns in Common Lisp Object System?

Yes. Visitor pattern uses defgeneric with methods dispatching on object type to separate logic from structure. Singleton pattern leverages CLOS slot allocation (:class slots) and initialization protocols to enforce single-instance constraints across the object hierarchy.

What are Class Precedence Lists (CPL) and why do they matter in CLOS inheritance?

CPL determines the order in which parent classes are consulted during method lookup and slot inheritance. Understanding CPL prevents ambiguous method resolution in multiple inheritance, ensures predictable method combination semantics, and clarifies which slot definitions take precedence.