Persist the last agent message to disk for cross-agent visibility.
Instructions
-
Parse the user's input after
/cmd-latest-msg. -
help(or no argument) — print usage and stop:Usage: /cmd-latest-msg save — save your last message /cmd-latest-msg use — read latest from the current agent /cmd-latest-msg use <agent> — read latest from claude|codex|gemini /cmd-latest-msg help — show this usage -
save— save the last assistant message:
a. Determine which agent you are from runtime context:
- Claude Code → claude
- Codex CLI → codex
- Gemini CLI → gemini
- If inference fails, default to codex
b. Create the output directory:
mkdir -p /tmp/agents/<agent>
c. Capture your last assistant message — the response you gave immediately before the user invoked this skill.
d. Write it to two files using the Write tool:
- /tmp/agents/<agent>/latest.md — always overwrite
- /tmp/agents/<agent>/<unix_timestamp>.md — timestamped copy (use date +%s to get the timestamp)
e. Confirm with:
Stored to:
/tmp/agents/<agent>/latest.md
/tmp/agents/<agent>/<timestamp>.md
-
use— display the latest message for the current agent:a. Infer the current agent using the same runtime-context rules as
save.b. Read and display
/tmp/agents/<agent>/latest.md.c. If the file doesn't exist, say:
No messages found for <agent>. -
use <agent>— display another agent's latest message:a. Validate
<agent>is one of:claude,codex,gemini.b. Read and display
/tmp/agents/<agent>/latest.md.c. If the file doesn't exist, say:
No messages found for <agent>.