Skip to content

Replay the Last Execution with pets redo

pets redo re-runs the most recent pets exec invocation, optionally overriding arguments or output flags.

Use it to iterate on a tool call without retyping the full command.

What It Solves

  • Quickly repeat an exec with tweaked parameters
  • Change output format without rebuilding the whole command
  • Shallow-merge new args into the previous invocation
  • Preview the reconstructed command before running

How It Works

Every successful pets exec persists its invocation to .pets/last-exec.json:

json
{
  "tool": "maps-geocode",
  "args": { "address": "Athens, Greece" },
  "plugin": "@openpets/maps",
  "flags": ["--json"]
}

pets redo reads this file, applies any overrides you pass, and delegates to pets exec.

Command

bash
pets redo [options]

Options

FlagDescription
--args '{"k":"v"}'Shallow-merge JSON args into last exec's args
--args-file <file>Merge args from a file (- for stdin)
--args @<path>Merge args from a file path (shorthand)
--args @-Merge args from stdin
--plugin <name|path>Override the plugin from last exec
--dry-runValidate without executing
--showPrint the reconstructed command without running
--jsonOverride output format to JSON
--toonOverride output format to TOON
--rawOverride output format to raw
--compactOverride output format to compact
--tableOverride output format to table

Argument Merging

--args on redo performs a shallow merge into the saved args:

  • Existing keys are overridden
  • New keys are added
  • Keys not mentioned are preserved
bash
# Original exec
pets exec maps-search-nearby --args '{"location":"37.98,23.73","radius":1000,"keyword":"museum"}' --json

# Override just the keyword — location and radius stay
pets redo --args '{"keyword":"restaurant"}'
# Runs: maps-search-nearby {"location":"37.98,23.73","radius":1000,"keyword":"restaurant"} --json

# Add a new arg
pets redo --args '{"keyword":"cafe","radius":500}'
# Runs: maps-search-nearby {"location":"37.98,23.73","radius":500,"keyword":"cafe"} --json

Output Flag Override

If you pass any output flag (--json, --toon, --raw, --compact, --table), it replaces the saved flags entirely:

bash
# Original used --json
pets exec maps-geocode --args '{"address":"Athens"}' --json

# Switch to table output
pets redo --table

If you pass no output flag, the saved flags are reused.

Plugin Override

Pass --plugin to override the plugin from the last exec:

bash
pets redo --plugin @openpets/maps

Preview with --show

Print the full reconstructed command without executing:

bash
pets redo --show
# pets exec maps-geocode --plugin @openpets/maps --args '{"address":"Athens, Greece"}' --json

Examples

Repeat the last call exactly

bash
pets redo

Change one argument

bash
pets exec maps-geocode --args '{"address":"Athens, Greece"}' --compact
pets redo --args '{"address":"London, UK"}'

Switch output format

bash
pets redo --table

Preview before running

bash
pets redo --args '{"address":"Paris"}' --show
pets redo --args '{"address":"Paris"}'

Dry-run validation

bash
pets redo --args '{"address":"Berlin"}' --dry-run

Pipe override args from stdin

bash
echo '{"address":"Tokyo"}' | pets redo --args @-

Error Cases

No previous exec

❌ No previous exec to redo
   Run "pets exec <tool-name> [--args ...]" first

Mutually exclusive output flags

Same rules as pets exec — only one of --json, --toon, --raw, --compact, --table is allowed.

State File

The state is stored at .pets/last-exec.json in the current working directory. This file is inside .pets/ which is already gitignored.

The state updates on every successful pets exec (including calls initiated by pets redo).

CommandPurpose
pets exec <tool>Execute a tool directly (saves state for redo)
pets toolsList available tools
pets workflow runRun multi-step workflows