|
2 | 2 | ## Context Management |
3 | 3 |
|
4 | 4 | This project uses [SessionAnchor](https://github.com/calesthio/SessionAnchor) for session continuity. |
5 | | -**Do NOT read large context files at session start.** Use the memory system instead. |
6 | 5 |
|
7 | | -### Session Start Protocol |
| 6 | +### MANDATORY: Session Start (do this FIRST, before any other work) |
8 | 7 |
|
| 8 | +Run this before doing anything else: |
9 | 9 | ```bash |
10 | | -# 1. Get your briefing (~2000 tokens instead of reading all project files) |
11 | 10 | sessionanchor boot |
| 11 | +``` |
| 12 | +- If `command not found`: use the same launcher you used for SessionAnchor for all commands below: |
| 13 | + `uvx sessionanchor ...`, `pipx run sessionanchor ...`, or `python -m sessionanchor ...`. |
| 14 | + If SessionAnchor is not installed yet, run `pip install sessionanchor`, then retry. |
| 15 | +- If `No memory database found`: run the matching init command with the same launcher |
| 16 | + (`sessionanchor init`, `uvx sessionanchor init`, `pipx run sessionanchor init`, |
| 17 | + or `python -m sessionanchor init`), then boot the same way. |
| 18 | +- Read the output — it contains prior decisions, active work, and blockers from previous sessions. |
| 19 | +- Do NOT skip this. Do NOT read large project files as a substitute. |
12 | 20 |
|
13 | | -# 2. If you need deeper context on any topic during the session: |
14 | | -sessionanchor query "search terms" |
| 21 | +### MANDATORY: Save After Every Substantive Action |
15 | 22 |
|
16 | | -# 3. If you need to understand code structure: |
17 | | -sessionanchor index find "topic" |
18 | | -sessionanchor index map |
19 | | -``` |
| 23 | +You MUST save context after each of these — do NOT batch, do NOT wait for session end: |
| 24 | +- A feature, fix, or deliverable is completed |
| 25 | +- A decision is made (technical choice, architecture, tradeoff) |
| 26 | +- A blocker is discovered |
| 27 | +- You learn something non-obvious about the codebase |
| 28 | + |
| 29 | +**How to save:** |
| 30 | +- If your platform supports background agents: spawn one with the save command |
| 31 | +- Otherwise: run the save command inline before continuing |
20 | 32 |
|
21 | | -### Context Saving (MANDATORY - do not skip) |
| 33 | +```bash |
| 34 | +# Decision made |
| 35 | +sessionanchor save add --tier L1 --category decision --title "..." --content "..." |
22 | 36 |
|
23 | | -**Save context continuously, not just at session end.** After completing any substantive work |
24 | | -(a feature, a fix, a decision, a research task), immediately write the relevant context to memory. |
25 | | -Do NOT wait for the user to ask. Do NOT wait for "end of session." The user may close the |
26 | | -window at any time. |
| 37 | +# Task/feature completed (marks the action item as completed) |
| 38 | +sessionanchor save complete --title "..." --category action_item |
27 | 39 |
|
28 | | -**How to save: use a subagent.** Do NOT block the main conversation. Spawn a background agent |
29 | | -with the save commands and continue working. |
| 40 | +# Significant event or milestone worth logging |
| 41 | +sessionanchor save add --tier L1 --category session_log --title "..." --content "..." |
30 | 42 |
|
31 | | -**When to save (trigger immediately after any of these):** |
32 | | -- A decision is made -> `sessionanchor save add --tier L1 --category decision --title "..." --content "..."` |
33 | | -- A task is completed -> `sessionanchor save complete --title "..." --category action_item` |
34 | | -- A new blocker is discovered -> `sessionanchor save add --tier L1 --category blocker --title "..." --content "..."` |
35 | | -- New technical knowledge -> `sessionanchor save add --tier L2 --category technical_note --title "..." --content "..."` |
36 | | -- Significant code changes -> `sessionanchor save add --tier L1 --category session_log --title "..." --content "..."` |
| 43 | +# Blocker found |
| 44 | +sessionanchor save add --tier L1 --category blocker --title "..." --content "..." |
37 | 45 |
|
38 | | -**Session summary (run when work naturally winds down):** |
39 | | -```bash |
40 | | -sessionanchor save session-end --summary "What was accomplished" |
| 46 | +# Technical knowledge learned |
| 47 | +sessionanchor save add --tier L2 --category technical_note --title "..." --content "..." |
41 | 48 | ``` |
42 | 49 |
|
43 | | -### Memory Tiers |
| 50 | +**Self-check: if you have completed 3+ tasks without running a single save command, stop and save now.** |
| 51 | + |
| 52 | +**Scope guard: only save context that is relevant to THIS project.** If the user asks you to |
| 53 | +work on an unrelated repo, fix an external tool, or do research that does not affect this |
| 54 | +codebase, do NOT save that work here — it is noise. Example: if this project is a web app and |
| 55 | +the user asks you to debug a CLI tool in a different repo mid-session, that debugging context |
| 56 | +does not belong in this project's memory. |
44 | 57 |
|
45 | | -- **L0** (~500 tokens): Identity, current phase, top priorities. Always loaded. |
46 | | -- **L1** (~1500 tokens): Recent decisions, active action items, blockers. Loaded at boot. |
47 | | -- **L2** (on-demand): Full history, completed items, deep technical notes. Query when needed. |
| 58 | +### Session End |
48 | 59 |
|
49 | | -### Re-indexing |
| 60 | +When work winds down: |
| 61 | +```bash |
| 62 | +sessionanchor save session-end --summary "What was accomplished" |
| 63 | +``` |
| 64 | + |
| 65 | +### Reference: Querying Deep Context |
50 | 66 |
|
51 | | -Run after major structural changes: |
52 | 67 | ```bash |
| 68 | +# Search memory for a topic |
| 69 | +sessionanchor query "search terms" |
| 70 | + |
| 71 | +# Re-index after major structural changes (new directories, renamed modules) |
53 | 72 | sessionanchor index |
54 | 73 | ``` |
| 74 | + |
| 75 | +### Reference: Memory Tiers |
| 76 | + |
| 77 | +- **L0** (~500 tokens): Identity, current phase, top priorities. Always loaded at boot. |
| 78 | +- **L1** (~1500 tokens): Recent decisions, active items, blockers. Loaded at boot. |
| 79 | +- **L2** (on-demand): Full history, completed items, deep technical notes. Use `sessionanchor query` to retrieve. |
0 commit comments