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

# Session Context Loading

> Load relevant context at the start of each session.

Load memories relevant to the current session when an agent starts.

## Use Case

An AI coding assistant that loads context about:

* Current project being worked on
* Recent files being edited
* Current task goals

## Implementation

### Store Session Summary

<CodeGroup>
  ```bash CLI theme={null}
  memoclaw store "Session 2026-02-13: Working on memoclaw-api, added rate limiting. Files: src/routes/store.ts, tests/api.test.ts" \
    --importance 0.7 \
    --type observation \
    --session session-123 \
    --tags session,project-memoclaw-api
  ```

  ```python Python theme={null}
  from memoclaw import MemoClaw

  client = MemoClaw()

  session_summary = client.store(
      content="Session 2026-02-13: Working on memoclaw-api, added rate limiting. Files: src/routes/store.ts, tests/api.test.ts",
      importance=0.7,
      memory_type="observation",
      session_id="session-123",
      tags=["session", "project-memoclaw-api"]
  )
  ```

  ```typescript TypeScript theme={null}

  import { MemoClawClient } from "memoclaw";

  const client = new MemoClawClient();

  const sessionSummary = await client.store({
    content: "Session 2026-02-13: Working on memoclaw-api, added rate limiting. Files: src/routes/store.ts, tests/api.test.ts",
    importance: 0.7,
    memory_type: "observation",
    session_id: "session-123",
    metadata: { tags: ["session", "project-memoclaw-api"] },
  });
  ```
</CodeGroup>

### Load Context at Session Start

<CodeGroup>
  ```bash CLI theme={null}
  memoclaw recall "recent work on memoclaw-api project" \
    --limit 5 \
    --tags project-memoclaw-api
  ```

  ```python Python theme={null}
  recent_memories = client.recall(
      query="recent work on memoclaw-api project",
      limit=5,
      filters={
          "tags": ["project-memoclaw-api"]
      }
  )

  context = "Recent context:\n"
  for m in recent_memories.memories:
      context += f"- {m.content}\n"
  ```

  ```typescript TypeScript theme={null}

  const recentMemories = await client.recall({
    query: "recent work on memoclaw-api project",
    limit: 5,
    filters: { tags: ["project-memoclaw-api"] },
  });

  let context = "Recent context:\n";
  for (const m of recentMemories.memories) {
    context += `- ${m.content}\n`;
  }
  ```
</CodeGroup>

### Track Session History

<CodeGroup>
  ```bash CLI theme={null}
  # List all session memories
  memoclaw list --tags session --limit 20

  # Recall from a specific session
  memoclaw recall "" --session session-123
  ```

  ```python Python theme={null}
  all_sessions = client.list(
      filters={"tags": ["session"]},
      limit=20
  )

  session_memories = client.recall(
      query="",
      session_id="session-123"
  )
  ```

  ```typescript TypeScript theme={null}

  const allSessions = await client.list({
    filters: { tags: ["session"] },
    limit: 20,
  });

  const sessionMemories = await client.recall({
    query: "",
    session_id: "session-123",
  });
  ```
</CodeGroup>

## Best Practices

1. **Use session IDs** to scope memories to specific conversations
2. **Store summaries** at session end for faster retrieval later
3. **Set importance** based on relevance to future sessions
4. **Use namespaces** to separate different projects or clients

## Related Endpoints

* [Store](/api-reference/store) — Store session memories
* [Recall](/api-reference/recall) — Search memories
* [List](/api-reference/list-memories) — List by filters
