Skip to content

Instantly share code, notes, and snippets.

@Reebz
Created June 19, 2026 14:17
Show Gist options
  • Select an option

  • Save Reebz/69977190e9e1a537babc59862f16ac6f to your computer and use it in GitHub Desktop.

Select an option

Save Reebz/69977190e9e1a537babc59862f16ac6f to your computer and use it in GitHub Desktop.
prep-clear — Claude Code slash command: persist durable memory before /clear, then emit a handoff prompt. Drop into ~/.claude/commands/
description Prep to /clear: persist durable memory to disk, optionally MemPalace (--mp flag), emit continuation prompt if work remains
argument-hint [--mp] [what's next / handoff focus]

Output contract

Think silently. Print only:

  1. One status line: Disk: <files|none> | MemPalace: <wing/room|none|skipped|pending> | Handoff: <yes|no>
  2. If Handoff yes: one ```text ``` block, 50–150 words, labeled — NEXT: ARTIFACTS: DONE: GOTCHAS: (omit empty fields), optional GOAL: when NEXT doesn't imply it. Imperative voice.
  3. Optional: Skipped: <thing> (≤8 words why) if borderline save rejected.

Nothing else. No preamble, no narration.

Arguments: $ARGUMENTS — treat --mp as a flag (activates step 2), remainder as handoff focus.

1. Disk memory

Claude Code keeps per-project file memory at ~/.claude/projects/<project-slug>/memory/, auto-loaded each session through MEMORY.md. Write durable, cross-session facts there — facts not already in code, git history, or CLAUDE.md.

Format — one file per fact:

---
name: <short-kebab-case-slug>
description: <one-line summary, used to judge relevance on recall>
metadata:
  type: user | feedback | project | reference
---

<the fact. For feedback/project, follow with **Why:** and **How to apply:** lines.
Link related memories with [[their-name]].>
  • user = who the user is (role, preferences). feedback = how you should work (corrections/confirmed approaches + the why). project = ongoing work, goals, constraints not derivable from code. reference = pointers to external resources (URLs, tickets, dashboards).
  • After writing a file, add a one-line pointer to MEMORY.md: - [Title](file.md) — hook. Never put fact content in MEMORY.md; it's an index.
  • Check for an existing file that already covers it — update over duplicating. Delete memories proven wrong.

Save: decisions, project state/goal/constraint changes, non-obvious gotchas, surfaced preferences, external refs (PR/URL/ticket) that matter later. Skip: one-offs, pure exploration, already-captured, anything the repo already records. Convert relative dates to absolute. Verify any named file/function/flag still exists before recording advice about it.

2. MemPalace (--mp only)

Skip unless --mp present — surface as MemPalace: skipped in status line. Requires the MemPalace MCP server connected; if absent, treat as skipped.

Wing = project snake_case, room = aspect (backend, plans, decisions, build_env, etc.). Run mempalace_check_duplicate first, then mempalace_add_drawer or mempalace_update_drawer. Store verbatim, not summarized. On MCP error/timeout → MemPalace: pending, move on; the disk write is the durable fallback.

3. Continuation

If an obvious next phase exists: write the labeled block. If not: Handoff: no. Common handoff points: brainstorm→plan, plan→impl, impl→review, PR awaiting CI, debug→fix pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment