From harness-claude
Implements the Command pattern to encapsulate operations as objects for undo, queue, and logging functionality in JavaScript.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:js-command-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Encapsulate operations as objects to support undo, queue, and logging
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
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeEncapsulates operations as command objects with undo/redo support and command queuing. Provides a Command interface and CommandHistory class for building action history systems, task queues, or job schedulers.
Encapsulates requests as objects for queueing, logging, undo/redo, and transactional behavior. Use when direct method calls cannot be queued, logged, or undone.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.