Command Pattern
Teaches the command pattern for decoupling task execution from invocation. Use when you need undo/redo functionality, queued operations, or want to decouple the object that invokes an operation from the one that performs it.
Install
npx skills add PatternsDev/skills --skill command-patterngit clone --depth 1 https://github.com/PatternsDev/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/javascript/command-pattern ~/.claude/skills/command-patternPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Command Pattern
With the **Command Pattern**, we can _decouple_ objects that execute a certain task from the object that calls the method.
Let's say we have an online food delivery platform. Users can place, track, and cancel orders.
## When to Use
- Use this when you need to decouple the object invoking an operation from the object performing it
- This is helpful when commands need a certain lifespan or should be queued and executed at specific times
## When NOT to Use
- For simple one-off operations that don't need undo/redo, queuing, or logging
- When direct function calls are clear enough and the extra abstraction adds complexity without benefit
- When the system has few operations and the command infrastructure would be over-engineering
## Instructions
- Create a Command class with an `execute` method that encapsulates the action
- Replace direct method calls with command objects passed to a single `execute` method on the manager
- Use this pattern sparingly as it can add unnecessary boilerplate in simpler JavaScript applications
## Details
```js
class OrderManager {
constructor() {
this.orders = []
}
placeOrder(order, id) {
this.orders.push(id)
return `You have successfully ordered ${order} (${id})`;
}
trackOrder(id) {
return `Your order ${id} will arrive in 20 minutes.`
}
cancelOrder(id) {
this.orders = this.orders.filter(order => order !== id)
return `You have canceled your order ${id}`
}
}
```Details
- Skill name
command-pattern- Repository
- PatternsDev/skills
- Path
javascript/command-pattern/SKILL.md- Repo updated
- 15 April 2026
FAQ
What does the Command Pattern skill do?
Teaches the command pattern for decoupling task execution from invocation. Use when you need undo/redo functionality, queued operations, or want to decouple the object that invokes an operation from the one that performs it.
How do I install the Command Pattern skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add PatternsDev/skills --skill command-pattern. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Command Pattern popular?
It lives in PatternsDev/skills, which has 259 GitHub stars and 28 forks.
Related skills
AI UI Patterns
259PatternsDev/skills
Teaches design patterns for building AI-powered React interfaces. Use when creating chatbots, intelligent assistants, streaming UIs, or any AI-driven user experience in React.
Async Components
259PatternsDev/skills
Teaches async component loading in Vue for performance optimization. Use when you have heavy components that aren't needed on initial render and can be loaded on demand.
Bundle Splitting
259PatternsDev/skills
Teaches bundle splitting techniques for web performance. Use when your application has a large JavaScript bundle that affects load times or when you need to reduce FCP/LCP.
Compression
259PatternsDev/skills
Teaches JavaScript compression techniques including Gzip and Brotli. Use when optimizing network transfer times or configuring server-side compression for production builds.
Dynamic Import
259PatternsDev/skills
Teaches dynamic import() for on-demand code loading. Use when you need to reduce initial bundle size by lazily loading modules that aren't required at startup.
Trust Wallet SDK
111trustwallet/tw-agent-skills
Trust Wallet open-source libraries — Wallet Core (HD wallets, address derivation, tx signing in Swift/Kotlin/TypeScript/Go for 140+ chains), Web3 Provider (dApp connection for Ethereum/Solana/Cosmos/Bitcoin/Aptos/TON/Tron), deep linking, browser extension integration, WalletConnect, token assets repository, and Barz ERC-4337 smart wallet. Use when working with trustwallet/wallet-core, @trustwallet/wallet-core, trust-web3-provider, Trust Wallet deep links, token logos/metadata from trustwallet/assets, or Barz account abstraction.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.