module 04 memory layer

startup-skill

System Text-to-Speech Ready
Slide: 0:00 / 0:00
Slide 1 of 0Interactive Deck

Full Lesson Reference

Startup - Session Context Loader

Trigger: User says "startup", "load memory", "load context", or at the beginning of a new session.

What This Skill Does

Loads project context, recent session history, and relevant rules so the current session starts fully briefed. Auto-detects the memory backend:

  • If Supabase credentials are configured in .env → load from Supabase
  • Otherwise → load from local memory/ folder (markdown files)

Run through the steps below in order. Do NOT skip any.

Compression bypass (CRITICAL)

Memory load must be full-fidelity. Before doing ANY work:

  • If RTK is installed, prefix every curl call in this skill with rtk proxy so Supabase responses are not truncated to summaries like string[768]. Truncated responses give Claude partial context for the session.
  • If Caveman mode is active, leave it alone during the load step itself (it only affects Claude's output, not the data being read). But when you present the synthesised context summary at the end, use full sentences so the user can read it clearly.

If neither tool is installed, ignore this step.

Step 0: Detect Memory Backend

First, check which memory backend is active:

terminal
if [ -n "$SUPABASE_URL" ] && [ -n "$SUPABASE_SERVICE_ROLE_KEY" ]; then
  echo "Using Supabase backend"
else
  echo "Using local markdown backend"
fi

Or read the .env file in the current project folder and check for SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY lines with non-empty values.

If Supabase is NOT configured, skip Supabase-specific steps and read from the local memory/ folder instead. The local folder lives at the root of the user's Claude Code folder - wherever they set up markdown memory.

Step 1: Identify the Project

Determine which project the user wants to work on, using:

  • The current working directory name (most common signal)
  • The first message or request
  • Any project name mentioned explicitly

Look for a matching record - a project_key in Supabase, or a ## project-name section in memory/projects.md for the local backend.

If no specific project is identified, load a summary of all projects so the user can pick.

Step 2: Pull Project Context

Supabase backend

terminal
curl -s "$SUPABASE_URL/rest/v1/projects?project_key=eq.<KEY>&select=*" \
  -H "apikey: $SUPABASE_SERVICE_ROLE_KEY" \
  -H "Authorization: Bearer $SUPABASE_SERVICE_ROLE_KEY"

Returns the project's context, pending_items, rules, and category sub-documents.

Local backend

Read the entire memory/projects.md file and find the section matching the project name. Extract context, pending_items, and rules from the markdown.

Step 3: Pull Global Rules

Supabase backend

terminal
curl -s "$SUPABASE_URL/rest/v1/global_rules?select=rule_key,category,content" \
  -H "apikey: $SUPABASE_SERVICE_ROLE_KEY" \
  -H "Authorization: Bearer $SUPABASE_SERVICE_ROLE_KEY"

Local backend

Read the entire memory/rules.md file. Group rules by category (feedback, pattern, reference).

These apply across every project.

Step 4: Pull Last Session for This Project

Supabase backend

terminal
curl -s "$SUPABASE_URL/rest/v1/session_memories?project_name=eq.<PROJECT>&select=session_date,summary,actions_taken,decisions_made,rules_learned,pending_items&order=session_date.desc&limit=1" \
  -H "apikey: $SUPABASE_SERVICE_ROLE_KEY" \
  -H "Authorization: Bearer $SUPABASE_SERVICE_ROLE_KEY"

Local backend

List files in memory/sessions/ sorted by date (newest first). Find the most recent file matching the current project (by filename or by reading the file's project_name field). Read its full contents.

Step 5: Cross-Check CLAUDE.md

Read the project's CLAUDE.md file (if one exists) and compare its pending_items / status against what memory says. If they conflict:

  • Memory is the source of truth (it was updated at the end of the last session)
  • Flag the discrepancy to the user
  • Suggest updating the CLAUDE.md if it's clearly stale

Step 6: If No Specific Project Mentioned

Supabase backend

Pull all projects with non-empty pending_items + last 5 sessions.

Local backend

Parse memory/projects.md and list every project that has pending items. List the 5 most recent session filenames in memory/sessions/.

Show the user what's outstanding so they can pick what to work on.

Step 7: Surface Key Rules

From the data you just loaded, surface these as a brief "Rules for this session" list:

  1. Project-specific rules from the project record
  2. Key rules_learned from the last session that are relevant to today's work
  3. Critical global_rules that apply to this type of work
  4. Any CLAUDE.md session rules (like voice guides, format requirements)

Step 8: Compile and Present Context

Synthesise a short context summary:

Project: [display name]

  • Current status (brief)
  • Pending items (from project record + last session)
  • Project-specific rules

Last session: [date] - [one-sentence summary]. Pending from last time: [items]

Rules for this session: [bullet list]

Memory backend: Supabase (or Local markdown)

Keep it concise. Don't dump raw data. If no specific project was identified, show a menu of active projects instead.

Rules

  • Project record is the PRIMARY context source - not sessions, not CLAUDE.md
  • Always pull global_rules alongside the project
  • Always pull the last session - don't start blind
  • Always cross-check CLAUDE.md against memory - flag staleness
  • Keep the summary concise - don't dump raw JSON or full markdown
  • Highlight pending_items prominently - these are the open tasks
  • If Supabase is configured but unreachable, fall back to local markdown if present
  • If neither backend has data, tell the user + offer to start fresh

If Memory Is Empty

First-time users have nothing in memory yet. In that case:

  • Don't error out
  • Acknowledge: "No prior sessions found for this project - starting fresh"
  • Offer to create an initial project entry if it makes sense
  • Proceed normally - session work will populate memory via /wrapup