Skip to main content

react-amnesia

AI-friendly application undo/redo (Ctrl+Z) for React

Application undo/redo for React, designed so coding assistants and humans can both reach for it without writing custom history glue. Pairs with react-mnemonic for persistence-aware undoable state.

npm install react-amnesia

AI-friendly by design

Coding assistants get canonical invariants, decision matrices, recipes, and anti-patterns — so they pick the right history shape without inventing semantics.

useState-shaped

useUndoableState returns [value, set, reset] — the same mental model as useState, with Ctrl+Z + coalescing built in.

Multi-scope, async, single-flight

One provider, many independent scopes. Async commands cancel cleanly via AbortSignal. Transactions collapse N mutations into one undoable composite.

Reversible state in two hooks

App.tsx
import { AmnesiaProvider, AmnesiaShortcuts, useUndoableState } from "react-amnesia";

function TitleEditor() {
const [title, setTitle] = useUndoableState("Untitled", {
label: "Edit title",
coalesceKey: "edit:title",
});

return <input value={title} onChange={(e) => setTitle(e.target.value)} />;
}

export default function App() {
return (
<AmnesiaProvider capacity={200}>
<AmnesiaShortcuts />
<TitleEditor />
</AmnesiaProvider>
);
}

Ctrl+Z / Cmd+Z undoes; Ctrl+Shift+Z / Cmd+Shift+Z / Ctrl+Y redoes. Rapid keystrokes sharing a coalesceKey collapse into a single history entry.

AI Resources

react-amnesia ships dedicated retrieval surfaces for coding assistants, DeepWiki, and local MCP-style documentation setups.

AI Docs

Canonical invariants, decision matrix, recipes, anti-patterns, and setup guidance.

Open AI Docs

llms.txt

Compact retrieval index for tight context windows and first-pass tool loading.

Open llms.txt

llms-full.txt

Long-form export for indexing, retrieval, and larger prompt contexts.

Open llms-full.txt

ai-contract.json

Machine-readable contract for tooling and agent integrations.

Open ai-contract.json

DeepWiki Priorities

DeepWiki steering file pointing retrieval toward the highest-signal sources.

Open DeepWiki Priorities

Assistant Setup

Generated instruction packs plus the documented MCP-friendly retrieval path.

Open Assistant Setup