From harness-claude
Encapsulates JavaScript operations as objects for undo/redo, queuing, logging, and decoupling invokers from executors. Use in editors or apps needing reversible actions or operation history.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Encapsulate operations as objects to support undo, queue, and logging
Implements GoF Command pattern in TypeScript: encapsulate operations as objects for undo/redo, queuing, transaction logs, and parameterizing methods. Use for task queues or action histories.
Teaches ES6+ features like arrow functions, destructuring, async/await, promises, and functional patterns for refactoring legacy JavaScript and optimizing web apps.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Encapsulate operations as objects to support undo, queue, and logging
execute() and optionally undo() methods.command.execute() without knowing the implementation.class AddTextCommand {
constructor(editor, text) {
this.editor = editor;
this.text = text;
this.prevContent = null;
}
execute() {
this.prevContent = this.editor.content;
this.editor.content += this.text;
}
undo() {
this.editor.content = this.prevContent;
}
}
const editor = { content: 'Hello' };
const history = [];
const cmd = new AddTextCommand(editor, ' World');
cmd.execute();
history.push(cmd);
console.log(editor.content); // 'Hello World'
history.pop().undo();
console.log(editor.content); // 'Hello'
The Command pattern turns function calls into first-class objects. This makes operations serializable, loggable, and reversible. Redux actions are a functional variant of this pattern.
Trade-offs:
When NOT to use:
https://patterns.dev/javascript/command-pattern