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
execwith 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:
{
"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
pets redo [options]Options
| Flag | Description |
|---|---|
--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-run | Validate without executing |
--show | Print the reconstructed command without running |
--json | Override output format to JSON |
--toon | Override output format to TOON |
--raw | Override output format to raw |
--compact | Override output format to compact |
--table | Override 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
# 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"} --jsonOutput Flag Override
If you pass any output flag (--json, --toon, --raw, --compact, --table), it replaces the saved flags entirely:
# Original used --json
pets exec maps-geocode --args '{"address":"Athens"}' --json
# Switch to table output
pets redo --tableIf you pass no output flag, the saved flags are reused.
Plugin Override
Pass --plugin to override the plugin from the last exec:
pets redo --plugin @openpets/mapsPreview with --show
Print the full reconstructed command without executing:
pets redo --show
# pets exec maps-geocode --plugin @openpets/maps --args '{"address":"Athens, Greece"}' --jsonExamples
Repeat the last call exactly
pets redoChange one argument
pets exec maps-geocode --args '{"address":"Athens, Greece"}' --compact
pets redo --args '{"address":"London, UK"}'Switch output format
pets redo --tablePreview before running
pets redo --args '{"address":"Paris"}' --show
pets redo --args '{"address":"Paris"}'Dry-run validation
pets redo --args '{"address":"Berlin"}' --dry-runPipe override args from stdin
echo '{"address":"Tokyo"}' | pets redo --args @-Error Cases
No previous exec
❌ No previous exec to redo
Run "pets exec <tool-name> [--args ...]" firstMutually 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).
Related Commands
| Command | Purpose |
|---|---|
pets exec <tool> | Execute a tool directly (saves state for redo) |
pets tools | List available tools |
pets workflow run | Run multi-step workflows |