cl-condition-system

Manage Common Lisp errors with conditions, restarts, and handlers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Common Lisp の条件システムを活用して、エラー処理を「通知」と「回復」に分離します。条件の定義・ハンドラ・リスタートを組み合わせることで、堅牢で再利用可能なエラーハンドリングを実装できます。

Core Features & Use Cases

  • define-condition の定義: カスタムエラー/警告の階層を作成
  • restart-case の提供: 回復手段を明示的に提供
  • handler-bind / handler-case の使い分け: ロギング、再試行、デフォルト動作の分離
  • 実践パターン: 再試行機構や検証フローの実装

Quick Start

基本的な parse 関数でエラーを発生させ、restart-case を用いて回復オプションを追加します。handler-bind/handler-case を組み合わせて、エラー時の挙動を分岐させます。

Frequently Asked Questions about cl-condition-system

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

FAQPage Schema
How do I implement error handling with Common Lisp's condition system?

The condition system separates error notification from recovery by defining custom conditions, providing restart options with restart-case, and binding handlers with handler-bind or handler-case. This enables robust, reusable error handling across input validation, file IO, configuration parsing, and retry logic.

What's the difference between handler-bind and handler-case in Common Lisp?

handler-bind executes handler code in the dynamic context where the condition occurred, allowing inspection and restart selection; handler-case catches conditions and executes clauses in the caller's context. Use handler-bind for logging and recovery delegation, handler-case for immediate branching on specific condition types.

How do I define custom error hierarchies in Common Lisp?

Use define-condition to create custom error and warning types organized in hierarchies. Structure conditions with slots for error details and parent types to establish inheritance, enabling precise condition matching and targeted handler binding across your application.

Can I implement retry logic using Common Lisp conditions and restarts?

Yes. Wrap code in restart-case to define restart options like retry or skip, then use handler-bind to invoke those restarts on specific conditions. This pattern decouples error detection from recovery strategy, making retry flows composable and reusable across validation, IO, and transactional operations.

When should I use the condition system instead of traditional exception handling?

Use the condition system when you need non-local recovery, interactive restart selection, or separation of error signaling from handling policy. It excels in scenarios requiring multiple recovery paths, unwind-protect coordination, and reporting—tasks where traditional exceptions force handler placement at the call site.

How do conditions interact with unwind-protect in Common Lisp?

Restarts invoked by handlers respect unwind-protect cleanup forms, ensuring resources are released before transfer of control. This allows handlers and restarts to coexist safely with resource-cleanup code, enabling robust patterns for file operations and transactional cleanup.