patternsadapter

Adapter (Wrapper) Pattern pattern for C development

⭐1stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026

When & Why to Use This Skill

This Claude skill facilitates the implementation of the Adapter (Wrapper) design pattern specifically for C development. It enables developers to bridge incompatible interfaces, isolate external dependencies, and create stable internal APIs, which is essential for maintaining clean architecture and improving code testability in systems programming.

Use Cases

  • Legacy System Integration: Wrapping existing or third-party C libraries to match a new internal API specification without modifying the original source code.
  • Unit Testing and Mocking: Creating mockable wrappers for system calls (e.g., read, write) or external libraries (e.g., libcurl) to inject failures and verify behavior in isolated test environments.
  • API Standardization: Adapting multiple external service providers (such as different LLM APIs) into a single, unified internal message format to allow for easy implementation swapping.
namepatterns/adapter
descriptionAdapter (Wrapper) Pattern pattern for C development

Adapter (Wrapper) Pattern

Convert interface of one module to interface expected by another. Enables integration of incompatible interfaces without modifying either.

ikigai Application

wrapper.h: Adapts system calls to mockable interface:

  • posix_read_() wraps read()
  • curl_easy_perform_() wraps libcurl
  • yyjson_read_file_() wraps yyjson

Purpose: Real implementations in production, mock implementations in tests via weak symbol linking.

LLM providers: Adapt different API formats (OpenAI, Anthropic) to unified internal message format.

Benefit: External dependencies isolated behind stable internal interface. Swap implementations without changing callers.

Testing: Inject failures, control responses, verify calls.