Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions plugin/claude-code/scripts/post-compaction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ Call `mem_save` IMMEDIATELY after ANY of these:
- Starting work on something that might have been done before
- User mentions a topic you have no context on

### SESSION CLOSE — before saying "done"/"listo":
### SUB-AGENT SCOPE
If you are a sub-agent or delegated task (launched by an orchestrator/parent agent):
- DO NOT call `mem_session_start`, `mem_session_end`, or `mem_session_summary`
- You MAY call `mem_save` once for important discoveries, and `mem_search`/`mem_context` as needed
- Return your result to the parent agent when done — that is your only "close" action

### SESSION CLOSE — TOP-LEVEL AGENT ONLY, before saying "done"/"listo":
Call `mem_session_summary` with: Goal, Discoveries, Accomplished, Next Steps, Relevant Files.

---

CRITICAL INSTRUCTION POST-COMPACTION — follow these steps IN ORDER:
CRITICAL INSTRUCTION POST-COMPACTION (TOP-LEVEL AGENT ONLY) — follow these steps IN ORDER:
PROTOCOL

printf "\n1. FIRST: Call mem_session_summary with the content of the compacted summary above. Use project: '%s'.\n" "$PROJECT"
Expand Down
8 changes: 7 additions & 1 deletion plugin/claude-code/scripts/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ Call `mem_save` IMMEDIATELY after ANY of these:
- User mentions a topic you have no context on
- User's FIRST message references the project, a feature, or a problem — call `mem_search` with keywords from their message to check for prior work before responding

### SESSION CLOSE — before saying "done"/"listo":
### SUB-AGENT SCOPE
If you are a sub-agent or delegated task (launched by an orchestrator/parent agent):
- DO NOT call `mem_session_start`, `mem_session_end`, or `mem_session_summary`
- You MAY call `mem_save` once for important discoveries, and `mem_search`/`mem_context` as needed
- Return your result to the parent agent when done — that is your only "close" action

### SESSION CLOSE — TOP-LEVEL AGENT ONLY, before saying "done"/"listo":
Call `mem_session_summary` with: Goal, Discoveries, Accomplished, Next Steps, Relevant Files.
PROTOCOL

Expand Down
17 changes: 14 additions & 3 deletions plugin/claude-code/skills/memory/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,20 @@ Also search memory PROACTIVELY when:
- The user mentions a topic you have no context on — check if past sessions covered it
- The user's FIRST message references the project, a feature, or a problem — call `mem_search` with keywords from their message to check for prior work before responding

## SESSION CLOSE PROTOCOL (mandatory)
## SUB-AGENT / DELEGATED TASK SCOPE

Before ending a session or saying "done" / "listo" / "that's it", you MUST:
If you are running as a sub-agent, delegated task, or background worker (i.e., you were launched by an orchestrator or parent agent to perform a specific task):
- **DO NOT** call `mem_session_start`, `mem_session_end`, or `mem_session_summary`
- **DO NOT** follow the SESSION CLOSE PROTOCOL below
- You MAY call `mem_save` for genuinely important discoveries (once, not repeatedly)
- You MAY call `mem_search` or `mem_context` if needed for your task
- When your task is complete, return your result to the parent agent. That is your only "close" action.

Session lifecycle (start, summary, end) is the responsibility of the TOP-LEVEL agent that directly interacts with the human user.

## SESSION CLOSE PROTOCOL (mandatory — TOP-LEVEL AGENT ONLY)

Before ending a TOP-LEVEL session (direct human conversation) or saying "done" / "listo" / "that's it", you MUST:
1. Call `mem_session_summary` with this structure:

## Goal
Expand All @@ -113,7 +124,7 @@ Before ending a session or saying "done" / "listo" / "that's it", you MUST:

This is NOT optional. If you skip this, the next session starts blind.

## AFTER COMPACTION
## AFTER COMPACTION (TOP-LEVEL AGENT ONLY)

If you see a message about compaction or context reset:
1. IMMEDIATELY call `mem_session_summary` with the compacted summary content — this persists what was done before compaction
Expand Down