savenow
Use this skill when the user wants to persist the current conversation into the active agent's daily memory file.
The command name is /savenow.
Scope: OpenClaw + Telegram only. Relies on sessions_list / sessions_history, the runtime MessageThreadId, and Telegram inline keyboards. Vanilla Claude Code, CLI, and web surfaces are not supported by design.
Supported forms:
/savenow — preview only. Extract candidates, compare semantically against today's memory, show markdown diff + Apply/Cancel inline buttons. Writes nothing.
/savenow apply — write the most recent pending preview (within the 30-minute TTL and from the same session/topic).
/savenow cancel — discard the pending preview without writing.
/savenow auto — extract + compare + write directly. Skip preview and buttons.
/savenow auto <sessionKey> — auto on an explicit session.
/savenow list — show same-topic candidate sessions without writing.
/savenow <sessionKey> — preview against an explicit session.
Goal
Write only durable, high-value notes to memory/YYYY-MM-DD.md in the current agent workspace.
Do not patch built-in commands. Do not change Telegram settings. Do not write MEMORY.md.
What counts as durable
Keep:
- resolved root causes and fixes
- stable workflow rules and conventions
- preferences and routing rules
- important system mappings, ids, and file locations
- decisions that will matter again later
Skip:
- chit-chat and acknowledgements
- temporary plans or one-off status updates
- repetitive back-and-forth with no lasting value
- content already saved today in the same or very similar form
Routing
Inspect the raw command argument first and pick a branch:
| Arg |
Branch |
Writes? |
| (empty) |
preview |
no |
list |
list (unchanged) |
no |
apply |
apply |
yes, from pending |
cancel |
cancel |
no, deletes pending |
auto |
auto on resolved session |
yes |
auto <key> |
auto on explicit key |
yes |
| other token |
explicit-session preview |
no |
Preview branch — /savenow (and explicit-session preview)
Resolve the target session.
- If runtime exposes
CommandTargetSessionKey, use it.
- If the raw arg is a non-empty value other than
list/apply/cancel/auto, treat it as the explicit sessionKey.
- Else read the current
MessageThreadId from runtime, call sessions_list, filter strictly:
- same topic/thread only
- exclude keys containing
:slash:
- exclude
cron, hook, node kinds
- exclude command-only or internal helper sessions
- If exactly one clear candidate remains, use it. If multiple, pick the newest non-slash real chat session from the same thread.
- If thread is missing, no same-topic candidate exists, or it stays ambiguous, fail closed and ask the user to rerun
/savenow <sessionKey>. Do not write.
Read the transcript. Call sessions_history against the resolved target session with includeTools: false, limit: 120..180.
Read today's memory file (new step). Use the Read tool on memory/YYYY-MM-DD.md so the agent can perform semantic comparison. If the file does not exist yet, proceed as if empty.
Extract 0..5 candidate memory entries. Each entry must be specific, reusable, short, self-contained. For each candidate, perform semantic comparison against existing sections in the memory file and assign an action:
"add" — net-new durable note
"merge" — substantial overlap with an existing section; adds new bullets to it (set merge_target_title to the exact existing title)
"skip" — semantically already covered, or not durable enough
JSON shape (write to temp/savenow-entries.json):
[
{
"candidate_index": 0,
"title": "Gateway token mismatch fix",
"bullets": [
"Resolved `unauthorized: gateway token mismatch` by updating `gateway.cmd` and the related env variables.",
"Next time a similar error appears, check token and env alignment first."
],
"action": "add",
"reason": ""
},
{
"candidate_index": 1,
"title": "Telegram inline button rules",
"bullets": ["Inline keyboards use a single-row, 3-button layout."],
"action": "merge",
"merge_target_title": "Telegram UI conventions",
"reason": "New rule belongs to the same existing topic."
}
]
Backward-compat: { "title": "...", "bullets": [...] } without action is treated as "add".
Run the preview script from the workspace root:
node "{baseDir}/scripts/preview-diff.mjs" \
--entries-file "temp/savenow-entries.json" \
--memory-path "memory/YYYY-MM-DD.md" \
--pending-file "temp/savenow-pending.json" \
--session-key "<resolved sessionKey>" \
--message-thread-id "<MessageThreadId>" \
--ttl-minutes 30
Pipe the script's stdout to the chat as the user-facing reply.
Render a Telegram inline keyboard below the markdown reply, two buttons in a single row:
✅ Apply → callback /savenow apply
❌ Cancel → callback /savenow cancel
If the script reports 0 candidates, do not render the keyboard (nothing to apply).
Apply branch — /savenow apply
Read temp/savenow-pending.json. Reject with a one-liner if:
- file is missing →
"No pending preview, run /savenow first."
expiresAt < now → "Preview expired (X min ago), rerun /savenow."
sessionKey or messageThreadId mismatches the current runtime → "Pending preview is from a different topic. Rerun /savenow here."
Run the merge script using entriesFile from the pending JSON:
node "{baseDir}/scripts/merge-daily-memory.mjs" --entries-file "<pending.entriesFile>"
On success delete temp/savenow-pending.json (and the entries file if you wish to clean up).
Reply briefly (no buttons):
Saved to memory/2026-05-15.md: Gateway token mismatch fix (+2 bullets to "Telegram UI conventions").
Mini summary: saved gateway auth fix and a Telegram button rule.
Mention added titles, merged titles (with bullet counts), and any fallbackAdded / fallbackSkipped events from the script's JSON output.
Cancel branch — /savenow cancel
- If
temp/savenow-pending.json exists, delete it. Also delete temp/savenow-entries.json if it exists.
- Reply:
Pending preview cancelled. Nothing written.
- If there was no pending file, reply:
No pending preview to cancel. (not an error.)
Auto branch — /savenow auto [sessionKey]
Run steps 1–4 from the preview branch (resolve session, pull transcript, read today's memory, extract candidates with actions).
Skip the preview script and pending file.
Run the merge script directly:
node "{baseDir}/scripts/merge-daily-memory.mjs" --entries-file "temp/savenow-entries.json"
Reply with the same "Saved to memory/… + mini summary" format. No buttons.
List branch — /savenow list
Call sessions_list and return same-topic candidate sessions only. Do not write.
Memory file format
# YYYY-MM-DD
## HH:MM - Short title
- bullet
- bullet
For merges, the script appends new bullets in-place to the matched section and adds a trailing - (merged HH:MM) marker bullet. A second merge into the same section replaces the previous marker rather than stacking.
Important constraints
- Default
/savenow never writes — it previews and shows Apply/Cancel buttons.
- Only auto-resolve within the current topic/thread. If unresolvable, fail closed.
- Do not fall back to a global "most recent session" guess.
- Let the merge script handle same-day dedup, in-place merges, and file creation.
- Do not manually append markdown yourself unless the script is unavailable.
- Always include the mini summary line after a successful
apply or auto.
- Inline buttons only on the preview branch and only when the script reports ≥1 candidate.
1---2name: savenow3description: Save durable notes from the current OpenClaw + Telegram conversation into today's memory/YYYY-MM-DD.md, with a semantic-dedupe preview/apply flow and inline Apply/Cancel buttons. Use for /savenow on Telegram-backed sessions.4user-invocable: true5version: 0.1.16metadata:7 source: https://skillmd.com/skills/lord1egypt/savenow8 openclaw:9 requires:10 bins:11 - node12 surface: telegram13 homepage: https://docs.openclaw.ai/tools/skills14---1516# savenow1718Use this skill when the user wants to persist the current conversation into the active agent's daily memory file.1920The command name is `/savenow`.2122**Scope:** OpenClaw + Telegram only. Relies on `sessions_list` / `sessions_history`, the runtime `MessageThreadId`, and Telegram inline keyboards. Vanilla Claude Code, CLI, and web surfaces are not supported by design.2324Supported forms:2526- `/savenow` — preview only. Extract candidates, compare semantically against today's memory, show markdown diff + Apply/Cancel inline buttons. **Writes nothing.**27- `/savenow apply` — write the most recent pending preview (within the 30-minute TTL and from the same session/topic).28- `/savenow cancel` — discard the pending preview without writing.29- `/savenow auto` — extract + compare + write directly. Skip preview and buttons.30- `/savenow auto <sessionKey>` — auto on an explicit session.31- `/savenow list` — show same-topic candidate sessions without writing.32- `/savenow <sessionKey>` — preview against an explicit session.3334## Goal3536Write only durable, high-value notes to `memory/YYYY-MM-DD.md` in the current agent workspace.3738Do not patch built-in commands. Do not change Telegram settings. Do not write `MEMORY.md`.3940## What counts as durable4142Keep:4344- resolved root causes and fixes45- stable workflow rules and conventions46- preferences and routing rules47- important system mappings, ids, and file locations48- decisions that will matter again later4950Skip:5152- chit-chat and acknowledgements53- temporary plans or one-off status updates54- repetitive back-and-forth with no lasting value55- content already saved today in the same or very similar form5657## Routing5859Inspect the raw command argument first and pick a branch:6061| Arg | Branch | Writes? |62|-------------------|------------------------|--------------------|63| (empty) | preview | no |64| `list` | list (unchanged) | no |65| `apply` | apply | yes, from pending |66| `cancel` | cancel | no, deletes pending|67| `auto` | auto on resolved session | yes |68| `auto <key>` | auto on explicit key | yes |69| other token | explicit-session preview | no |7071## Preview branch — `/savenow` (and explicit-session preview)72731. **Resolve the target session.**74 - If runtime exposes `CommandTargetSessionKey`, use it.75 - If the raw arg is a non-empty value other than `list`/`apply`/`cancel`/`auto`, treat it as the explicit `sessionKey`.76 - Else read the current `MessageThreadId` from runtime, call `sessions_list`, filter strictly:77 - same topic/thread only78 - exclude keys containing `:slash:`79 - exclude `cron`, `hook`, `node` kinds80 - exclude command-only or internal helper sessions81 - If exactly one clear candidate remains, use it. If multiple, pick the newest non-slash real chat session from the same thread.82 - If thread is missing, no same-topic candidate exists, or it stays ambiguous, fail closed and ask the user to rerun `/savenow <sessionKey>`. Do not write.83842. **Read the transcript.** Call `sessions_history` against the resolved target session with `includeTools: false`, `limit: 120..180`.85863. **Read today's memory file (new step).** Use the Read tool on `memory/YYYY-MM-DD.md` so the agent can perform semantic comparison. If the file does not exist yet, proceed as if empty.87884. **Extract `0..5` candidate memory entries.** Each entry must be specific, reusable, short, self-contained. For each candidate, perform **semantic comparison against existing sections in the memory file** and assign an `action`:8990 - `"add"` — net-new durable note91 - `"merge"` — substantial overlap with an existing section; adds new bullets to it (set `merge_target_title` to the exact existing title)92 - `"skip"` — semantically already covered, or not durable enough9394 JSON shape (write to `temp/savenow-entries.json`):9596 ```json97 [98 {99 "candidate_index": 0,100 "title": "Gateway token mismatch fix",101 "bullets": [102 "Resolved `unauthorized: gateway token mismatch` by updating `gateway.cmd` and the related env variables.",103 "Next time a similar error appears, check token and env alignment first."104 ],105 "action": "add",106 "reason": ""107 },108 {109 "candidate_index": 1,110 "title": "Telegram inline button rules",111 "bullets": ["Inline keyboards use a single-row, 3-button layout."],112 "action": "merge",113 "merge_target_title": "Telegram UI conventions",114 "reason": "New rule belongs to the same existing topic."115 }116 ]117 ```118119 Backward-compat: `{ "title": "...", "bullets": [...] }` without `action` is treated as `"add"`.1201215. **Run the preview script** from the workspace root:122123 ```text124 node "{baseDir}/scripts/preview-diff.mjs" \125 --entries-file "temp/savenow-entries.json" \126 --memory-path "memory/YYYY-MM-DD.md" \127 --pending-file "temp/savenow-pending.json" \128 --session-key "<resolved sessionKey>" \129 --message-thread-id "<MessageThreadId>" \130 --ttl-minutes 30131 ```1321336. **Pipe the script's stdout to the chat as the user-facing reply.**1341357. **Render a Telegram inline keyboard** below the markdown reply, two buttons in a single row:136137 - `✅ Apply` → callback `/savenow apply`138 - `❌ Cancel` → callback `/savenow cancel`139140 If the script reports 0 candidates, do not render the keyboard (nothing to apply).141142## Apply branch — `/savenow apply`1431441. Read `temp/savenow-pending.json`. Reject with a one-liner if:145 - file is missing → `"No pending preview, run /savenow first."`146 - `expiresAt < now` → `"Preview expired (X min ago), rerun /savenow."`147 - `sessionKey` or `messageThreadId` mismatches the current runtime → `"Pending preview is from a different topic. Rerun /savenow here."`1481492. Run the merge script using `entriesFile` from the pending JSON:150151 ```text152 node "{baseDir}/scripts/merge-daily-memory.mjs" --entries-file "<pending.entriesFile>"153 ```1541553. On success delete `temp/savenow-pending.json` (and the entries file if you wish to clean up).1561574. Reply briefly (no buttons):158159 ```text160 Saved to memory/2026-05-15.md: Gateway token mismatch fix (+2 bullets to "Telegram UI conventions").161 Mini summary: saved gateway auth fix and a Telegram button rule.162 ```163164 Mention added titles, merged titles (with bullet counts), and any `fallbackAdded` / `fallbackSkipped` events from the script's JSON output.165166## Cancel branch — `/savenow cancel`1671681. If `temp/savenow-pending.json` exists, delete it. Also delete `temp/savenow-entries.json` if it exists.1692. Reply: `Pending preview cancelled. Nothing written.`1703. If there was no pending file, reply: `No pending preview to cancel.` (not an error.)171172## Auto branch — `/savenow auto [sessionKey]`1731741. Run steps 1–4 from the preview branch (resolve session, pull transcript, read today's memory, extract candidates with actions).1752. Skip the preview script and pending file.1763. Run the merge script directly:177178 ```text179 node "{baseDir}/scripts/merge-daily-memory.mjs" --entries-file "temp/savenow-entries.json"180 ```1811824. Reply with the same "Saved to memory/… + mini summary" format. No buttons.183184## List branch — `/savenow list`185186Call `sessions_list` and return same-topic candidate sessions only. Do not write.187188## Memory file format189190```text191# YYYY-MM-DD192193## HH:MM - Short title194- bullet195- bullet196```197198For merges, the script appends new bullets in-place to the matched section and adds a trailing `- (merged HH:MM)` marker bullet. A second merge into the same section replaces the previous marker rather than stacking.199200## Important constraints201202- Default `/savenow` never writes — it previews and shows Apply/Cancel buttons.203- Only auto-resolve within the current topic/thread. If unresolvable, fail closed.204- Do not fall back to a global "most recent session" guess.205- Let the merge script handle same-day dedup, in-place merges, and file creation.206- Do not manually append markdown yourself unless the script is unavailable.207- Always include the mini summary line after a successful `apply` or `auto`.208- Inline buttons only on the preview branch and only when the script reports ≥1 candidate.