> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Gentleman-Programming/engram/llms.txt
> Use this file to discover all available pages before exploring further.

# mem_session_summary

> Save a comprehensive end-of-session summary

## Overview

Save a structured summary when a coding session ends or when significant work is complete. This creates a high-level overview that future sessions use to understand what happened, what was learned, and what's left to do.

<Note>
  This is a **core tool** in the agent profile, always loaded in the MCP context.
</Note>

## When to Use

* **Session ending** — when the user is done for the day
* **Major milestone** — when significant work is complete
* **Context checkpoint** — before a long break or context compaction
* **Handoff** — when switching agents or team members

## Parameters

<ParamField path="content" type="string" required>
  Full session summary using the structured format

  Use this exact structure:

  ```markdown theme={null}
  ## Goal
  [One sentence: what were we building/working on in this session]

  ## Instructions
  [User preferences, constraints, or context discovered during this session. Things a future agent needs to know about HOW the user wants things done. Skip if nothing notable.]

  ## Discoveries
  - [Technical finding, gotcha, or learning 1]
  - [Technical finding 2]
  - [Important API behavior, config quirk, etc.]

  ## Accomplished
  - ✅ [Completed task 1 — with key implementation details]
  - ✅ [Completed task 2 — mention files changed]
  - 🔲 [Identified but not yet done — for next session]

  ## Relevant Files
  - path/to/file.ts — [what it does or what changed]
  - path/to/other.go — [role in the architecture]
  ```
</ParamField>

<ParamField path="project" type="string" required>
  Project name

  Associates the session summary with a specific project.

  **Example:** `my-api`, `engram`, `frontend`
</ParamField>

<ParamField path="session_id" type="string">
  Session identifier

  **Default:** `manual-save-{project}`

  Links the summary to a specific coding session.
</ParamField>

## Response

<ResponseField name="result" type="string">
  Confirmation message
</ResponseField>

**Example:**

```
Session summary saved for project "my-api"
```

## Structured Format

### Goal

**One sentence** describing what this session aimed to accomplish.

<Accordion title="Examples">
  * "Build JWT authentication system for the API"
  * "Fix N+1 query performance issues in user list"
  * "Add CSV export feature to admin dashboard"
  * "Investigate and resolve FTS5 search crashes"
</Accordion>

### Instructions (Optional)

User preferences, constraints, or discovered context about **how** the user wants things done.

<Accordion title="Examples">
  * "User prefers TypeScript strict mode — all new files must have explicit types"
  * "Use Zod for validation — no manual type guards"
  * "Follow existing pattern: one service per domain entity"
  * "No external dependencies without approval — prefer stdlib"
</Accordion>

<Tip>
  **Skip this section if there are no notable instructions.** Not every session has user preferences to capture.
</Tip>

### Discoveries

Technical findings, gotchas, and non-obvious learnings. **This is the most valuable section.**

<Accordion title="Examples">
  * "FTS5 MATCH syntax requires quotes around terms with special chars — raw user input crashes"
  * "SQLite WAL mode creates -wal and -shm files — safe to delete only when DB is closed"
  * "Next.js data fetching doesn't auto-optimize joins — always check Network tab for N+1 patterns"
  * "JWT refresh tokens need separate rotation logic — access token expiry alone is insufficient"
  * "Go's fmt.Errorf with %w preserves error chains for errors.Is() — %v does not"
</Accordion>

<Warning>
  Focus on **surprises and gotchas** — things that would save a future agent time. Obvious implementation details don't belong here.
</Warning>

### Accomplished

Completed tasks with **key implementation details** and identified next steps.

<Accordion title="Format">
  Use checkmarks:

  * ✅ **Completed** — tasks that are done
  * 🔲 **Identified but not done** — for next session

  Include:

  * What was done (high-level)
  * Files changed (if relevant)
  * Any important decisions made
</Accordion>

<Accordion title="Examples">
  * ✅ Added JWT authentication middleware — validates tokens on protected routes (src/middleware/auth.ts)
  * ✅ Refactored UserService to repository pattern — separates DB logic from business logic (src/services/UserService.ts, src/repositories/UserRepository.ts)
  * ✅ Fixed N+1 query in user list — added eager loading for relationships (src/api/users.ts line 45)
  * 🔲 Add refresh token rotation — identified security requirement, not yet implemented
  * 🔲 Write tests for auth middleware — covered in next session
</Accordion>

### Relevant Files

Files that were **significantly changed** or are **important for context**.

<Accordion title="Format">
  ```
  - path/to/file.ext — [what it does or what changed]
  ```

  Keep it concise:

  * ✅ `src/middleware/auth.ts` — JWT validation logic
  * ✅ `internal/store/store.go` — FTS5 query sanitization added
  * ❌ `src/` — too vague
  * ❌ Full absolute paths like `/Users/me/projects/app/src/...` — use relative paths
</Accordion>

<Tip>
  Only include files that provide context. Don't list every file touched — focus on the important ones.
</Tip>

## Usage Example

```json theme={null}
{
  "content": "## Goal\nAdd JWT authentication to the API and secure protected endpoints\n\n## Instructions\nUser prefers TypeScript strict mode — all new files must have explicit types. Use Zod for request validation.\n\n## Discoveries\n- JWT access tokens need short expiry (15min) to limit exposure — refresh tokens handle re-auth\n- httpOnly cookies prevent XSS but break mobile apps — need to support both cookie and Authorization header\n- express-jwt middleware automatically decodes and attaches user to req.user — no manual verification\n\n## Accomplished\n- ✅ Added JWT authentication middleware — validates tokens and attaches user to request (src/middleware/auth.ts)\n- ✅ Created login endpoint — returns access + refresh tokens (src/routes/auth.ts)\n- ✅ Secured user routes — applied auth middleware to /api/users/* (src/routes/users.ts)\n- 🔲 Refresh token rotation — identified security requirement, implementation pending\n- 🔲 Add tests for auth flows — next session\n\n## Relevant Files\n- src/middleware/auth.ts — JWT validation middleware\n- src/routes/auth.ts — login/logout endpoints\n- src/routes/users.ts — protected user routes\n- src/types/express.d.ts — extended Express.Request with user property",
  "project": "my-api",
  "session_id": "session-2026-03-03-1430"
}
```

## Guidelines

<AccordionGroup>
  <Accordion title="Be Concise">
    Don't lose important details, but avoid verbosity:

    * ✅ "Added eager loading for user relationships to fix N+1 query"
    * ❌ "First I identified the N+1 query by opening the Network tab and seeing 50+ requests, then I researched how to fix it, then I added include: \['profile', 'settings'] to the query..."
  </Accordion>

  <Accordion title="Focus on What and Why, Not How">
    The code is in the repo — focus on context:

    * ✅ "Switched to JWT because session storage doesn't scale across instances"
    * ❌ "I imported jsonwebtoken, then created a secret in .env, then wrote a function to sign tokens with HS256..."
  </Accordion>

  <Accordion title="Capture Non-Obvious Learnings">
    **Discoveries are the most valuable section.** Focus on surprises:

    * ✅ "FTS5 requires quotes around search terms — special chars are operators"
    * ✅ "WAL files are safe to delete only when DB is closed"
    * ❌ "I learned that TypeScript has types" (obvious)
  </Accordion>

  <Accordion title="Relevant Files Should Be Selective">
    Only include files that provide context:

    * ✅ Core files that changed
    * ✅ New architectural pieces
    * ❌ Every file touched (config tweaks, imports, etc.)
  </Accordion>
</AccordionGroup>

## What Gets Stored

The session summary is saved as an observation with:

* **Type:** `session_summary`
* **Title:** `Session summary: {project}`
* **Content:** The structured markdown you provide
* **Project:** The specified project
* **Session ID:** Links to the session

## When Future Sessions See This

Session summaries appear in:

1. **`mem_context`** — shows recent session summaries first
2. **`mem_search`** — can search summary content by keywords
3. **TUI session view** — displays session summaries
4. **HTTP API** — `/api/sessions/{id}` includes the summary

## Related Tools

* [`mem_save`](/mcp/mem-save) - Save individual observations during the session
* [`mem_session_start`](/mcp/mem-session-start) - Register session start
* [`mem_session_end`](/mcp/mem-session-end) - Mark session as completed
* [`mem_context`](/mcp/mem-context) - Retrieve recent session context
