|
| 1 | +# Bring Your Own Context |
| 2 | + |
| 3 | +<!-- markdownlint-disable MD013 --> |
| 4 | + |
| 5 | +Portable context workflow for extracting what your AI already knows, |
| 6 | +turning it into a structured operating profile, and carrying that profile |
| 7 | +across AI clients. |
| 8 | + |
| 9 | +> [!IMPORTANT] |
| 10 | +> This is a composition recipe. It does not introduce a new MCP server or a |
| 11 | +> new tool surface in v1. |
| 12 | +
|
| 13 | +It packages existing Open Brain pieces into one entrypoint: |
| 14 | + |
| 15 | +- focused extraction prompts in [extraction-prompts.md](./extraction-prompts.md) |
| 16 | +- the canonical [Work Operating Model skill](../../skills/work-operating-model/) |
| 17 | +- the paired [Work Operating Model Activation recipe](../work-operating-model-activation/) |
| 18 | +- the existing [Remote MCP Connection](../../primitives/remote-mcp/) pattern |
| 19 | + |
| 20 | +## What It Does |
| 21 | + |
| 22 | +Bring Your Own Context gives you one publishable workflow for portable AI context inside OB1. |
| 23 | + |
| 24 | +You first seed Open Brain with reviewed context using the extraction prompts in this folder. Then you run the existing Work Operating Model workflow to turn that raw context into a reusable bundle with a documented contract: |
| 25 | + |
| 26 | +- `operating-model.json` |
| 27 | +- `USER.md` |
| 28 | +- `SOUL.md` |
| 29 | +- `HEARTBEAT.md` |
| 30 | +- `schedule-recommendations.json` |
| 31 | + |
| 32 | +The machine-readable schema for that bundle lives in [context-profile.schema.json](./context-profile.schema.json). |
| 33 | + |
| 34 | +## Prerequisites |
| 35 | + |
| 36 | +- Working Open Brain setup ([guide](../../docs/01-getting-started.md)) |
| 37 | +- Existing core Open Brain connector with `search_thoughts` and `capture_thought` |
| 38 | +- AI client that supports reusable skills or prompt packs |
| 39 | +- Supabase CLI installed and linked to your project |
| 40 | +- Canonical [Work Operating Model skill](../../skills/work-operating-model/) |
| 41 | +- Optional source material to import: existing AI memory, exported notes, Obsidian vault content, Notion exports, text files, or similar context sources |
| 42 | + |
| 43 | +## Credential Tracker |
| 44 | + |
| 45 | +Copy this block into a text editor and fill it in as you go. |
| 46 | + |
| 47 | +```text |
| 48 | +BRING YOUR OWN CONTEXT -- CREDENTIAL TRACKER |
| 49 | +-------------------------------------------- |
| 50 | +
|
| 51 | +FROM YOUR OPEN BRAIN SETUP |
| 52 | + Project URL: ____________ |
| 53 | + Project ref: ____________ |
| 54 | + MCP Access Key: ____________ |
| 55 | + Core connector available: yes / no |
| 56 | + Core search tool visible: yes / no |
| 57 | + Core capture tool visible: yes / no |
| 58 | +
|
| 59 | +GENERATED DURING SETUP |
| 60 | + Prompt source used: memory / import / both |
| 61 | + DEFAULT_USER_ID: ____________ |
| 62 | + Function URL: ____________ |
| 63 | + MCP Connection URL: ____________ |
| 64 | + Latest session ID: ____________ |
| 65 | + Current profile version: ____________ |
| 66 | +
|
| 67 | +-------------------------------------------- |
| 68 | +``` |
| 69 | + |
| 70 | +## Recipe Assets |
| 71 | + |
| 72 | +- [extraction-prompts.md](./extraction-prompts.md) — the two prompt assets promised in the article |
| 73 | +- [context-profile.schema.json](./context-profile.schema.json) — machine-readable contract for the portable bundle returned by `generate_operating_model_exports` |
| 74 | +- [Work Operating Model Activation](../work-operating-model-activation/) — the profiling engine this recipe reuses |
| 75 | + |
| 76 | +## Steps |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +Pick the right prompt from [extraction-prompts.md](./extraction-prompts.md): |
| 81 | + |
| 82 | +- Use **Memory Extraction** if the AI platform already knows a lot about you from past chats or built-in memory. |
| 83 | +- Use **Context Import** if you are bringing in notes, exports, or another second-brain system. |
| 84 | +- If both are true, run **Memory Extraction first** and **Context Import second**. |
| 85 | + |
| 86 | +These prompts are intentionally upstream of profile generation. They create durable, searchable Open Brain context. They do **not** generate the final portable bundle by themselves. |
| 87 | + |
| 88 | +✅ **Done when:** You know which extraction pass you are running and your core Open Brain connector is enabled in the client you will use. |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +Run the chosen prompt in your AI client with the core Open Brain connector enabled. |
| 95 | + |
| 96 | +Rules to keep the BYOC corpus clean: |
| 97 | + |
| 98 | +- review the preview batches before saving |
| 99 | +- store self-contained statements, not shorthand fragments |
| 100 | +- preserve names, dates, and decision context |
| 101 | +- skip noise, templates, and obviously stale junk |
| 102 | + |
| 103 | +This stage should leave you with durable raw context that the later profiling pass can search against. |
| 104 | + |
| 105 | +✅ **Done when:** `search_thoughts` can find a few recent captures about your people, projects, decisions, or workflow. |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +Install the canonical [Work Operating Model skill](../../skills/work-operating-model/) before doing anything else. BYOC reuses that exact interview behavior instead of inventing a second profiling prompt. |
| 112 | + |
| 113 | +If you have not installed it yet, follow the installation steps in the skill README and confirm your client can load reusable prompt packs or skills. |
| 114 | + |
| 115 | +✅ **Done when:** The Work Operating Model skill is available in your client and ready to use once the paired MCP tools are connected. |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +BYOC reuses the [Work Operating Model Activation](../work-operating-model-activation/) recipe as its structured profiling engine. |
| 122 | + |
| 123 | +### 4.1 Run the schema |
| 124 | + |
| 125 | +Run [`recipes/work-operating-model-activation/schema.sql`](../work-operating-model-activation/schema.sql) in the Supabase SQL Editor. |
| 126 | + |
| 127 | +### 4.2 Generate a Default User ID |
| 128 | + |
| 129 | +```bash |
| 130 | +uuidgen | tr '[:upper:]' '[:lower:]' |
| 131 | +``` |
| 132 | + |
| 133 | +Then set it as a secret: |
| 134 | + |
| 135 | +```bash |
| 136 | +supabase secrets set DEFAULT_USER_ID=your-generated-uuid |
| 137 | +``` |
| 138 | + |
| 139 | +### 4.3 Deploy the Function |
| 140 | + |
| 141 | +Use the [Deploy an Edge Function](../../primitives/deploy-edge-function/) pattern with these values: |
| 142 | + |
| 143 | +| Setting | Value | |
| 144 | +| ------- | ----- | |
| 145 | +| Function name | `work-operating-model-mcp` | |
| 146 | +| Download path | `recipes/work-operating-model-activation` | |
| 147 | + |
| 148 | +### 4.4 Connect It to Your AI Client |
| 149 | + |
| 150 | +URL-based connector example: |
| 151 | + |
| 152 | +```text |
| 153 | +https://YOUR_PROJECT_REF.supabase.co/functions/v1/work-operating-model-mcp?key=your-access-key |
| 154 | +``` |
| 155 | + |
| 156 | +Header-based connector example for Claude Code: |
| 157 | + |
| 158 | +```bash |
| 159 | +claude mcp add --transport http work-operating-model \ |
| 160 | + https://YOUR_PROJECT_REF.supabase.co/functions/v1/work-operating-model-mcp \ |
| 161 | + --header "x-access-key: your-access-key" |
| 162 | +``` |
| 163 | + |
| 164 | +Use the full [Remote MCP Connection](../../primitives/remote-mcp/) guide if your client needs a different setup path. |
| 165 | + |
| 166 | +> [!IMPORTANT] |
| 167 | +> Keep your base Open Brain connector enabled too. BYOC uses the existing Work Operating Model tools for structure, but it still depends on your core `search_thoughts` and `capture_thought` tools for memory hints and summary captures. |
| 168 | +
|
| 169 | +✅ **Done when:** Your client can see all six required tools: |
| 170 | + |
| 171 | +- `search_thoughts` |
| 172 | +- `capture_thought` |
| 173 | +- `start_operating_model_session` |
| 174 | +- `save_operating_model_layer` |
| 175 | +- `query_operating_model` |
| 176 | +- `generate_operating_model_exports` |
| 177 | + |
| 178 | +--- |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | +With both connectors enabled and the skill installed, prompt your AI client: |
| 183 | + |
| 184 | +```text |
| 185 | +Use the Work Operating Model workflow to interview me and build my operating model. |
| 186 | +``` |
| 187 | + |
| 188 | +The workflow should: |
| 189 | + |
| 190 | +1. call `start_operating_model_session` |
| 191 | +2. search for hints in your seeded Open Brain context |
| 192 | +3. interview you through the five fixed layers |
| 193 | +4. show a checkpoint summary before every save |
| 194 | +5. persist each approved layer with `save_operating_model_layer` |
| 195 | +6. review contradictions with `query_operating_model` |
| 196 | +7. return the final bundle with `generate_operating_model_exports` |
| 197 | + |
| 198 | +BYOC is strongest when you treat the earlier extraction pass as raw material and this interview as the normalization pass. Do not skip the confirmation gates. |
| 199 | + |
| 200 | +✅ **Done when:** The workflow reaches export generation without missing layers and returns a session ID plus a profile version. |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | +The current portable bundle contract is: |
| 207 | + |
| 208 | +- `operating-model.json` — structured JSON representation of the full profile |
| 209 | +- `USER.md` — operator-facing profile summary |
| 210 | +- `SOUL.md` — guardrails, heuristics, and knowledge to respect |
| 211 | +- `HEARTBEAT.md` — recurring and event-driven check recommendations |
| 212 | +- `schedule-recommendations.json` — machine-readable recommendation output |
| 213 | + |
| 214 | +The transport shape returned by `generate_operating_model_exports` is documented in [context-profile.schema.json](./context-profile.schema.json). The schema also defines the parsed JSON contracts for `operating-model.json` and `schedule-recommendations.json` inside `$defs`. |
| 215 | + |
| 216 | +This is the honest v1 BYOC story inside OB1: |
| 217 | + |
| 218 | +- the **portable context profile** is the export bundle above |
| 219 | +- the **context server pattern** is the existing remote MCP deployment flow you already use in Open Brain |
| 220 | + |
| 221 | +✅ **Done when:** You can point to one export bundle, one schema file, and one recipe URL as the canonical BYOC entrypoint for the article. |
| 222 | + |
| 223 | +## Expected Outcome |
| 224 | + |
| 225 | +When this recipe is working correctly: |
| 226 | + |
| 227 | +- your Open Brain contains reviewed context captured through the extraction prompts |
| 228 | +- the Work Operating Model workflow can pull that context in as hints during the interview |
| 229 | +- `query_operating_model` returns structured entries for rhythms, decisions, dependencies, institutional knowledge, and friction |
| 230 | +- `generate_operating_model_exports` returns all five portable artifacts |
| 231 | +- [context-profile.schema.json](./context-profile.schema.json) documents the response shape and the parsed JSON artifact contracts |
| 232 | + |
| 233 | +## Troubleshooting |
| 234 | + |
| 235 | +**Issue: `capture_thought` is not visible when I run the extraction prompt** |
| 236 | +Solution: The BYOC prompt stage only works with your base Open Brain connector enabled. Re-enable the core connector first, then rerun the prompt. |
| 237 | + |
| 238 | +**Issue: The Work Operating Model skill is loaded, but the profile tools are missing** |
| 239 | +Solution: The skill and the recipe are paired. Install the skill from [skills/work-operating-model](../../skills/work-operating-model/) and deploy/connect the MCP server from [Work Operating Model Activation](../work-operating-model-activation/) before starting the interview. |
| 240 | + |
| 241 | +**Issue: Export generation says layers are missing** |
| 242 | +Solution: Every one of the five layers must be approved before `generate_operating_model_exports` can succeed. Resume the session, finish the missing layer, then export again. |
| 243 | + |
| 244 | +**Issue: The connector works in one client but not another** |
| 245 | +Solution: Use the connection style your client actually supports. Some clients want the URL with `?key=...`, while Claude Code prefers the header-based form. The [Remote MCP Connection](../../primitives/remote-mcp/) guide covers both. |
| 246 | + |
| 247 | +## Next Steps |
| 248 | + |
| 249 | +- Feed `USER.md`, `SOUL.md`, and `HEARTBEAT.md` into any agent workflow that accepts operating files or durable system context. |
| 250 | +- Re-run the workflow after a major role change or workflow shift so your portable context stays current. |
| 251 | +- Use the [MCP Tool Audit & Optimization Guide](../../docs/05-tool-audit.md) once you add the second connector so the tool surface stays manageable. |
| 252 | + |
| 253 | +<!-- markdownlint-enable MD013 --> |
0 commit comments