patternscommand
Command Pattern pattern for C development
When & Why to Use This Skill
This Claude skill facilitates the implementation of the Command Pattern in C programming, enabling developers to encapsulate requests as objects. It streamlines the creation of modular, extensible codebases by supporting features like command queuing, undo/redo functionality, and decoupled execution logic, which are essential for robust systems architecture.
Use Cases
- REPL Slash Commands: Implementing discrete operations like /clear or /mark in a command-line interface using function pointers and argument structs.
- Undo/Redo Systems: Managing an execution stack that allows users to reverse or repeat actions by storing command objects.
- Task Queuing and Scheduling: Parameterizing requests to be queued, logged, or executed asynchronously in resource-constrained C environments.
- Macro Recording: Capturing a sequence of operations as serialized command objects for later playback and automation.
| name | patterns/command |
|---|---|
| description | Command Pattern pattern for C development |
Command Pattern
Encapsulate a request as an object, allowing parameterization, queuing, and undo. In C, a struct containing function pointer plus arguments.
ikigai Application
Slash commands: Each command (/clear, /mark, /rewind) is a discrete operation:
typedef struct {
const char *name;
res_t (*execute)(ik_repl_ctx_t *repl, const char *args);
const char *help;
} ik_command_t;
Input actions: Parser emits action structs that REPL executes.
Future uses:
- Undo/redo stack for input editing
- Queued tool executions
- Macro recording and playback
Benefit: Commands become first-class, can be logged, serialized, or replayed.