Skip to content

[recipes] Session boot sequence with priority-based loading#353

Closed
gleesonb wants to merge 327 commits into
NateBJones-Projects:mainfrom
gleesonb:contrib/gleesonb-aurea/session-boot-sequence
Closed

[recipes] Session boot sequence with priority-based loading#353
gleesonb wants to merge 327 commits into
NateBJones-Projects:mainfrom
gleesonb:contrib/gleesonb-aurea/session-boot-sequence

Conversation

@gleesonb

@gleesonb gleesonb commented Jun 9, 2026

Copy link
Copy Markdown

What it does

Adds a priority-based memory loading system (P1-P4) that configures AI agents to load the right context at the right time during session boot. Includes a /refresh pattern for context drift recovery in long sessions.

What it requires

  • Working Open Brain setup
  • An AI agent that reads instructions at session start (Claude Code, Cursor, Claude Desktop, or similar)
  • No additional services or API keys

Tested on my own instance

Yes — I use this pattern daily with Claude Code and Open Brain.

Pattern attribution

Priority-based loading pattern adapted from open-brain-template by Tony Finley.

🤖 Generated with Claude Code

matthallett1 and others added 30 commits March 14, 2026 07:47
…ltering

- Canonical OB1 MCP server with 4 tools: capture_thought, search_thoughts, list_thoughts, thought_stats
- Source filtering on search_thoughts, list_thoughts, thought_stats (optional source param)
- Auth via x-brain-key header and ?key= query param against MCP_ACCESS_KEY
- deno.json with pinned canonical dependency versions
- Update .gitignore to track Edge Function source files while ignoring Supabase temp/config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaced custom monkeyrun Edge Function with OB1 canonical MCP server.
4 tools (capture_thought, search_thoughts, list_thoughts, thought_stats),
source filtering on 3 tools, auth via query param and header.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Supabase Edge Functions pass the function name as part of the request
path (e.g., /professional-crm/mcp), but all extensions used explicit
routes like app.post("/mcp") which only matches /mcp. This caused every
extension to return 404 when deployed.

Changed to wildcard routing (app.post("*"), app.get("*")) to match
regardless of path prefix, consistent with the core open-brain-mcp
server pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
z.record(z.any()) in the details parameter breaks with Zod 4.x and
MCP SDK 1.24.3 (_zod property error). Changed to z.string() accepting
a JSON string, which is compatible and functionally equivalent since
the JSONB column accepts string input.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Local deployment copies of the 4 extension MCP servers with fixes
applied: edge runtime import, wildcard routing for Supabase path
handling, and z.record compatibility fix for household-knowledge.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deployment-ready copies with edge runtime import and wildcard routing
fix applied. All 6 OB1 extensions now deployed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same wildcard routing fix as the other 4 extensions — Supabase passes
the function name in the request path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
server.tool() wraps params in z.object() internally. Passing a
z.object() schema double-wraps it, producing empty parameter schemas.
Changed all 8 tool registrations to pass schema.shape instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tool handlers returned raw strings instead of MCP content objects
({ content: [{ type: "text", text: "..." }] }). Added wrap() helper
to all 8 tool registrations with error handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OB1 pattern: users copy from extensions/ and deploy themselves.
Removed supabase/functions/ from tracking — these are local
deployment copies, not part of the repo standard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove .planning/ files from tracking (already gitignored), fix broken
link to nonexistent recurring-tasks primitive, add numbered step list
to source-filtering README for review check compliance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… guide

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…uide

Three categories of fixes:

1. STEP ORDERING FIX: Moved `supabase secrets set MCP_ACCESS_KEY` from
   Step 5 to Step 6 — it previously told users to run a Supabase CLI
   command before telling them to install the CLI.

2. CODE BLOCK CLEANUP: Every code block now contains exactly one
   copy-pasteable command. Previously, Mac/Linux/Windows commands were
   jammed into single blocks with comment headers, forcing users to
   visually parse which line to copy. Affected sections:
   - Access key generation (Mac/Linux vs Windows separated)
   - Supabase CLI install (Mac, Windows Scoop setup, Windows Scoop
     bucket, Windows Scoop install, and Linux each get their own block)
   - Login and project linking (split into separate steps)
   - Secret setting (each secret gets its own block with context)

3. CLICKABLE LINKS: Bare-text URLs converted to markdown links:
   supabase.com, openrouter.ai, openrouter.ai/keys,
   openrouter.ai/models, chatgpt.com (x2)

Also fixed stale "step-10" placeholder references → "step-5" in three
places (MCP Connection URL, Claude Code header, mcp-remote config).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two sections rewritten for zero-ambiguity copy-paste:

1. ADD DEPENDENCIES: Previously said "Create supabase/functions/
   open-brain-mcp/deno.json:" followed by a JSON block — unclear to
   beginners who've never created a file from a terminal. Now provides
   a single terminal command per OS (Mac/Linux heredoc, Windows
   PowerShell here-string) that creates the file directly.

2. WRITE THE SERVER: Previously linked to an external guide for the
   MCP server code, requiring users to navigate away, find the right
   block, copy it, figure out how to open index.ts, and paste. Now
   includes the full server code inline as a terminal command per OS
   — one copy, one paste, file is written. No text editor needed.

Both sections follow the pattern established by the rest of the guide:
one code block = one action = one copy-paste.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Added 🟩 to all Mac/Linux labels and 🟦 to all Windows labels
  throughout the guide for quick visual scanning (9 labels total)
- Collapsed all three SQL queries in Step 2 (thoughts table, search
  function, RLS policy) into <details> blocks
- Server code and deno.json OS-specific blocks were already collapsed
  from the previous commit
Major rewrite of the MCP server deployment flow:

1. NEW: "Create a Project Folder" section teaches users to create a
   folder in Finder/Explorer, copy the path, and cd into it. Bridges
   the GUI they know into the terminal they're learning.

2. NEW: "Initialize and Link" adds `supabase init` before linking,
   establishing the project structure in their chosen folder.

3. NEW: "Download the Server Files" replaces ~750 lines of heredoc
   blocks with curl/Invoke-WebRequest commands that pull index.ts
   and deno.json directly from the repo's new server/ directory.

4. NEW: server/index.ts and server/deno.json added to the repo as
   the canonical source files for the core MCP server.

File reduced from 1441 to 642 lines. Every code block is still one
copy-paste action, but users no longer create files manually.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three-part change to formalize the curl-from-GitHub deployment pattern:

1. PRIMITIVE REWRITE: primitives/deploy-edge-function/ now uses curl/
   Invoke-WebRequest to download server files directly from the repo.
   Includes project folder reminders, OS-specific commands with color
   indicators, and guidance on reusing access keys across extensions.

2. EXTENSION TABLES: All 6 extension READMEs updated from
   "Server code | This extension's index.ts" to
   "Download path | extensions/{name}" — consumed by the primitive
   to construct the download URLs automatically.

3. AGENT SPEC: New extensions/_template/AGENT_SPEC.md provides a
   machine-readable specification for generating new extensions. Covers
   all 5 required files (deno.json, metadata.json, schema.sql,
   index.ts, README.md) with exact patterns, naming conventions,
   validation checklist, and example prompt. Designed so an AI agent
   can produce a complete, correctly-formatted extension in one pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Full formatting rewrite for scannability and visual hierarchy:

- Shield badges (for-the-badge style) for all 8 main step headers
- Numbered sub-steps (6.1, 6.2, etc.) replacing unnamed ### headings
- GitHub alert callouts replacing plain blockquotes:
  > [!IMPORTANT] for must-do actions
  > [!TIP] for helpful context
  > [!WARNING] for security/data concerns
  > [!CAUTION] for easy-to-miss gotchas
  > [!NOTE] for supplementary info
- Emoji markers: ✅ Done when (step completion), ❌ (troubleshooting),
  🔖 (credentials to save), 🔗 (links/references), 📋 (SQL blocks)
- Section emoji headers: ❓ Troubleshooting, 🔍 Under the Hood,
  ➕ Optional, 🎉 What You Built, ➡️ Next Step
- Collapsible SQL blocks now labeled "(click to expand)"

No content changes — same guide, dramatically easier to scan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Step 6 was a visual nightmare — OS-specific commands interleaved
throughout made it easy to grab the wrong block (confirmed by testing).

Now Step 6 has two collapsible sections: "Step 6 — Mac / Linux" and
"Step 6 — Windows". Each contains the complete flow for that OS with
no cross-references. Users click their OS once and follow a clean,
linear path:

  6.1 Create a Project Folder (OS-specific instructions)
  6.2 Install the Supabase CLI (brew vs scoop)
  6.3 Log In
  6.4 Initialize and Link
  6.5 Set Your Secrets
  6.6 Download the Server Files (curl vs Invoke-WebRequest)
  6.7 Deploy

Shared steps (login, init, secrets, deploy) are duplicated in both
sections — small cost for zero ambiguity.

Also added a warning to Step 5's key generation reminding users to
copy only the command for their OS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each AI client (Claude Desktop, ChatGPT, Claude Code, Other Clients)
is now in its own collapsible <details> block. Users click the client
they use and see only those instructions — no scrolling past
irrelevant setup for other clients.

Callout blocks (NOTE, WARNING, CAUTION, TIP) nested inside the
collapsible sections for inline context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Troubleshooting, How It Works, Optional Capture Sources, and What You
Built are now collapsible <details> blocks. Keeps the post-setup
content out of the way — users who need it can expand it, everyone
else sees a clean ending with the Next Step section visible.

"Your Next Step" stays visible (not collapsed) since it's the main
call to action after completing the guide.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each step badge now walks the spectrum — grey number label with a
colored title background that progresses through the rainbow:

  Step 1: Red (#E53935)
  Step 2: Deep Orange (#F4511E)
  Step 3: Orange (#FB8C00)
  Step 4: Green (#43A047)
  Step 5: Teal (#00897B)
  Step 6: Blue (#1E88E5)
  Step 7: Indigo (#5C6BC0)
  Step 8: Purple (#8E24AA)

Gives instant visual progress cues — you can tell where you are in
the guide at a glance by the color alone.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Removed the copy-paste text block and old .docx file. Replaced with
a prominent CAUTION callout and download link for the new .xlsx
credential tracker spreadsheet.

The tracker is now impossible to miss — it's a giant warning block
that tells users to stop and download before proceeding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🛑🛑🛑

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Removed: If You Get Stuck, How This Works, After You're Done, and
Cost Breakdown sections. All redundant with content already at the
end of the guide. People arriving here know what they want.

Reframed "What You're Building" as the core foundation that
everything else in the repo builds on — not a standalone project
description. Two lines, two services, go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Straight to the point.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Visual guide showing exactly where the download button is on GitHub.
Because if we're going to make a huge deal out of downloading it,
we should show them how.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
justfinethanku and others added 23 commits April 21, 2026 18:51
…lanshurafa/entity-wiki

[recipes] Entity wiki pages from knowledge graph
…lanshurafa/wiki-synthesis

[recipes] Wiki synthesis + autobiography pipeline
…odex/wiki-compiler

[recipes] Add wiki compiler orchestration recipe
…odex/chatgpt-mcp-compat

Improve ChatGPT MCP compatibility
- Fixed edge classifier source-aware sampling (0 → 3290 candidate pairs)
- Fixed edge classifier RPC fallback for parameter mismatch
- Added gpt-4o-mini to PRICING table
- Rewrote n8n Substack workflow (direct Supabase REST)
- Added n8n Gmail daily ingestion workflow
- Added n8n DOK refinement loop workflow
- Daily digest script, AI memory import script
- Server index.ts: OpenAI direct (replaces OpenRouter)
- Updated .gitignore to exclude exports/backup/compiled-wiki

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…nclaw-launch'

# Conflicts:
#	.gitignore
#	dashboards/open-brain-dashboard-next/app/thoughts/[id]/page.tsx
#	dashboards/open-brain-dashboard-next/components/KanbanBoard.tsx
#	dashboards/open-brain-dashboard-next/lib/api.ts
#	dashboards/open-brain-dashboard-next/lib/types.ts
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a P1-P4 priority loading system for AI agent memory boot sequences.
P1 rules load every session, P2 reference on-demand, P3 runbooks before
touching systems, P4 integrations only when needed. Includes /refresh
pattern for context drift recovery in long sessions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added dashboard Contribution: frontend template documentation Improvements or additions to documentation labels Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Hey @gleesonb — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

@gleesonb-aurea

Copy link
Copy Markdown

Closing — this was meant for an internal project, not the public repo. Sorry for the noise.

1 similar comment
@gleesonb

gleesonb commented Jun 9, 2026

Copy link
Copy Markdown
Author

Closing — this was meant for an internal project, not the public repo. Sorry for the noise.

@gleesonb gleesonb closed this Jun 9, 2026
@gleesonb gleesonb deleted the contrib/gleesonb-aurea/session-boot-sequence branch June 9, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Contribution: frontend template documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.