command-pattern-undo

Implement the Command pattern with undo/redo history for reversible operations.

71|11|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/nlelouche/Unity-SkillForge --skill command-pattern-undo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: command-pattern-undo
Source: https://github.com/nlelouche/Unity-SkillForge/tree/main/.agent/skills/01-architecture/command-pattern-undo
Command: npx skills add https://github.com/nlelouche/Unity-SkillForge --skill command-pattern-undo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a robust implementation of the Command Pattern, enabling operations to be easily undone and redone, crucial for user-facing actions in editors or games.

Core Features & Use Cases

  • Encapsulates Operations: Turns requests into objects, allowing for parameterization, queuing, and logging of operations.
  • Undo/Redo Functionality: Manages a history stack to revert or reapply executed commands.
  • Use Case: In a Unity Editor tool, a user can place or delete objects, and then use Ctrl+Z to undo the action, or Ctrl+Y to redo it, maintaining a seamless workflow.

Quick Start

Use the command-pattern-undo skill to generate a C# script for a 'PlaceBuildingCommand' that takes a grid, cell coordinates, and building type.

Frequently Asked Questions about command-pattern-undo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement undo and redo functionality for editor tools in C#?

Undo and redo functionality is implemented using the Command Pattern with a history stack. This Skill provides an ICommand interface and CommandHistory class to manage reversible operations like placing or deleting objects in a Unity Editor tool.

What is the command pattern and when should I use it for gameplay systems?

The command pattern encapsulates operations into objects, enabling parameterization, queuing, and logging. Use it for gameplay systems like strategy game moves or crafting systems when discrete operations must be reversible and tracked.

Can I use this command pattern undo implementation for strategy game moves?

Yes, this command pattern undo implementation supports strategy game moves. It manages a full undo and redo history stack, allowing discrete gameplay operations to be reverted or reapplied seamlessly.

How do I create a reversible PlaceBuildingCommand for a grid system?

To create a reversible PlaceBuildingCommand, instantiate the command with a grid, cell coordinates, and building type. The provided ICommand interface allows the operation to be executed, undone, or redone via the CommandHistory class.

Does this undo redo history stack work without additional dependencies?

Yes, this undo redo history stack works without additional dependencies. It operates independently using the provided scripts and references to manage command execution and history tracking.

What are the limitations of using a command history stack for reversibility?

A command history stack handles discrete reversible operations but may consume significant memory if unbounded. It is best suited for editor tools and gameplay systems requiring distinct action tracking rather than continuous state transitions.