spec-kitty

How to Use Operation History

View, undo, and restore operations in your workspace using jj’s operation log.


The Problem

You need to:


Prerequisites

Important: The ops undo and ops restore commands are jj only. Git users can view the operation log (via reflog), but cannot undo through Spec Kitty. See Git Alternative below.


Steps

View Operation History

See recent operations:

spec-kitty ops log

Output (format):

Backend: jj

Operation History (jj)
ID        Time             Description                      Undoable
abc123    2026-01-17 14:32  Rebase 3 commits onto upstream    ✓
def456    2026-01-17 14:27  Commit: add avatar support       ✓

Show More Operations

Increase the limit:

spec-kitty ops log --limit 50

Show Full Details

Get complete operation IDs and details:

spec-kitty ops log --verbose
Backend: jj

Operation History (jj)
ID        Time             Description                      Undoable
abc123    2026-01-17 14:32  Rebase 3 commits onto upstream    ✓
def456    2026-01-17 14:27  Commit: add avatar support       ✓

Full operation IDs:
  abc123def456789...
  def456ghi789012...

Undo the Last Operation

Made a mistake? Undo it:

spec-kitty ops undo

Output:

Undoing operation...
✓ Operation undone successfully

Use 'spec-kitty ops log' to see the updated history.

Undo a Specific Operation

Undo a specific operation by ID:

spec-kitty ops undo def456

Note: This undoes the specified operation, not everything after it.


Restore to a Specific Point

Jump to any point in history:

spec-kitty ops restore ghi789

Output:

Restoring to operation ghi789...
✓ Restored successfully

Use 'spec-kitty ops log' to see the updated history.

Difference: Undo vs Restore

Command What it does
ops undo Reverses the last (or specified) operation
ops restore Jumps directly to a specific historical state

Example scenario:

Operations: A → B → C → D (current)

ops undo        → Undoes D, now at C
ops restore B   → Jumps directly to B (skipping C and D)

Common Use Cases

Undo an Accidental Commit

# Made a commit you didn't want
jj commit -m "Oops, wrong files"

# Undo it
spec-kitty ops undo

Undo a Bad Sync

# Sync introduced problems
spec-kitty sync

# Go back to before the sync
spec-kitty ops undo

Restore After Multiple Mistakes

# View history to find good state
spec-kitty ops log --verbose

# Restore to that point
spec-kitty ops restore abc123

Experiment Safely

# Note your current operation ID
spec-kitty ops log --limit 1

# Try risky changes
# ...

# If it goes wrong, restore
spec-kitty ops restore <saved-id>

Understanding Operation IDs

Operation IDs are unique identifiers for each state change:

Use short IDs for convenience:

spec-kitty ops restore abc123

Git Alternative

For git-based workspaces, Spec Kitty shows the reflog:

spec-kitty ops log
Operation Log (git reflog)
─────────────────────────────────────────────────
HEAD@{0}: commit: Add user avatar
HEAD@{1}: commit: Initial setup
HEAD@{2}: checkout: moving to feature-WP01

However, ops undo and ops restore are not available for git. Use git directly:

# View reflog
git reflog

# Reset to a previous state
git reset --hard HEAD@{2}

Warning: git reset --hard is destructive and loses uncommitted changes.


Troubleshooting

“Operation not found”

The operation ID may be truncated or incorrect. Use verbose mode to see full IDs:

spec-kitty ops log --verbose

“Cannot undo: not a jj workspace”

This command requires jujutsu. Check your VCS:

spec-kitty verify-setup --diagnostics

If using git, see Git Alternative.

“Undo failed: conflicts”

If undoing would create conflicts, jj stores them as non-blocking conflicts. Check:

jj status

And resolve any conflicts (see Handle Conflicts).

“Lost my work after restore”

Don’t worry! The operation that contained your work still exists:

# Find the operation with your work
spec-kitty ops log --verbose

# Restore back to it
spec-kitty ops restore <operation-with-your-work>

Best Practices

  1. Before risky operations: Note your current operation ID
  2. Use undo liberally: jj’s undo is safe and reversible
  3. Prefer restore for complex recovery: When multiple undos are needed
  4. Check status after restore: Verify the state is what you expected

See Also