[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GT67XK2HAC6J920TM7SDJ":3,"skill-same:01M71GT67XK2HAC6J920TM7SDJ":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":14,"repositoryHtmlUrl":55,"repositoryHomepageUrl":6,"ownerHtmlUrl":56,"ownerBlogUrl":6,"ownerDescription":57,"updatedAt":58,"install":59,"resources":71},"01M71GT67XK2HAC6J920TM7SDJ","setup",null,"Set up GBrain with auto-provision Supabase or PGLite, AGENTS.md injection, first import","weareturnone\u002Fgbrain","weareturnone","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106660686?v=4","01M71GRFW4YZ9DFYK6J17YXQNB","Roelof Stoelwinder ","01M71GRFWVQF5ASVB08TP5VKWG",0,"MIT","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Fskills\u002Fsetup\u002FSKILL.md",[],[5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"true","sync","with","pglite","import","gbrain","brain","get","up","auto","initialize","page","health","first","injection","SET","supabase","stats","2026-11-10 10:12:30",false,"---\nname: setup\ndescription: Set up GBrain with auto-provision Supabase or PGLite, AGENTS.md injection, first import\ntriggers:\n  - \"set up gbrain\"\n  - \"initialize brain\"\n  - \"gbrain setup\"\ntools:\n  - get_stats\n  - get_health\n  - sync_brain\n  - put_page\nmutating: true\n---\n\n# Setup GBrain\n\nSet up GBrain from scratch. Target: working brain in under 5 minutes.\n\n## Contract\n\n- Setup completes with a working brain verified by `gbrain doctor --json` (all checks OK).\n- The brain-first lookup protocol is injected into the project's AGENTS.md or equivalent.\n- Live sync is configured and verified (a test change pushed and found via search).\n- Schema state is tracked in `~\u002F.gbrain\u002Fupdate-state.json` so future upgrades know what the user adopted or declined.\n- No Supabase anon key is requested; GBrain uses only the database connection string.\n\n## Install (if not already installed)\n\n```bash\nbun add github:garrytan\u002Fgbrain\n```\n\n## How GBrain connects\n\nGBrain connects directly to Postgres over the wire protocol. NOT through the\nSupabase REST API. You need the **database connection string** (a `postgresql:\u002F\u002F` URI),\nnot the project URL or anon key. The password is embedded in the connection string.\n\nUse the **Shared Pooler** connection string (port 6543), not the direct connection\n(port 5432). The direct hostname resolves to IPv6 only, which many environments\ncan't reach. Find it: go to the project, click **Get Connected** next to the\nproject URL, then **Direct Connection String** > **Session Pooler**, and copy\nthe **Shared Pooler** connection string.\n\n**Do NOT ask for the Supabase anon key.** GBrain doesn't use it.\n\n## Why Supabase\n\nSupabase gives you managed Postgres + pgvector (vector search built in) for $25\u002Fmo:\n- 8GB database + 100GB storage on Pro tier\n- No server to manage, automatic backups, dashboard for debugging\n- pgvector pre-installed, just works\n- Alternative: any Postgres with pgvector extension (self-hosted, Neon, Railway, etc.)\n\n## Prerequisites\n\n- A Supabase account (Pro tier recommended, $25\u002Fmo) OR any Postgres with pgvector\n- An OpenAI API key (for semantic search embeddings, ~$4-5 for 7,500 pages)\n- A git-backed markdown knowledge base (or start fresh)\n\n## Available init options\n\n- `gbrain init --supabase` -- interactive wizard (prompts for connection string)\n- `gbrain init --url \u003Cconnection_string>` -- direct, no prompts\n- `gbrain init --non-interactive --url \u003Cconnection_string>` -- for scripts\u002Fagents\n- `gbrain doctor --json` -- health check after init\n\nThere is no `--local`, `--sqlite`, or offline mode. GBrain requires Postgres + pgvector.\n\n## Phase A: Supabase Setup (recommended)\n\nGuide the user through creating a Supabase project:\n\n1. \"Go to https:\u002F\u002Fsupabase.com and sign up or log in.\"\n2. \"Click 'New Project' in the top left.\"\n   - Name: `gbrain`\n   - Region: pick the one closest to you\n   - Database password: generate a strong one and save it\n3. \"Wait about 2 minutes for the project to initialize.\"\n4. \"Find the connection string: go to your project, click **Get Connected** next\n   to the project URL, then **Direct Connection String** > **Session Pooler**,\n   and copy the **Shared Pooler** connection string (port 6543).\"\n5. Initialize gbrain:\n   ```bash\n   gbrain init --non-interactive --url \"postgresql:\u002F\u002Fpostgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:6543\u002Fpostgres\"\n   ```\n6. Verify: `gbrain doctor --json`\n\n**OpenClaw\u002FHermes agent instructions:** Store the Supabase access token in your persistent\nenv as `SUPABASE_ACCESS_TOKEN`. gbrain doesn't store it, you need it for future\n`gbrain doctor` runs. Generate at: https:\u002F\u002Fsupabase.com\u002Fdashboard\u002Faccount\u002Ftokens\n\n## Phase B: BYO Postgres (alternative)\n\nIf the user already has Postgres with pgvector:\n\n1. Get the connection string from the user.\n2. Run: `gbrain init --non-interactive --url \"\u003Cconnection_string>\"`\n3. Verify: `gbrain doctor --json`\n\nIf the connection fails with ECONNREFUSED and the URL contains `supabase.co`,\nthe user probably pasted the direct connection (IPv6 only). Guide them to the\nSession pooler string instead (see Phase A step 4).\n\n## Phase C: First Import\n\n1. **Discover markdown repos.** Scan the environment for git repos with markdown content.\n\n```bash\necho \"=== GBrain Environment Discovery ===\"\nfor dir in \u002Fdata\u002F* ~\u002Fgit\u002F* ~\u002FDocuments\u002F* 2>\u002Fdev\u002Fnull; do\n  if [ -d \"$dir\u002F.git\" ]; then\n    md_count=$(find \"$dir\" -name \"*.md\" -not -path \"*\u002Fnode_modules\u002F*\" -not -path \"*\u002F.git\u002F*\" 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n    if [ \"$md_count\" -gt 10 ]; then\n      total_size=$(du -sh \"$dir\" 2>\u002Fdev\u002Fnull | cut -f1)\n      echo \"  $dir ($total_size, $md_count .md files)\"\n    fi\n  fi\ndone\necho \"=== Discovery Complete ===\"\n```\n\n2. **Import the best candidate.** For large imports (>1000 files), use nohup to\n   survive session timeouts:\n   ```bash\n   nohup gbrain import \u003Cdir> --no-embed --workers 4 > \u002Ftmp\u002Fgbrain-import.log 2>&1 &\n   ```\n   Then check progress: `tail -1 \u002Ftmp\u002Fgbrain-import.log`\n\n   For smaller imports, run directly:\n   ```bash\n   gbrain import \u003Cdir> --no-embed\n   ```\n\n3. **Prove search works.** Pick a semantic query based on what you imported:\n   ```bash\n   gbrain search \"\u003Ctopic from the imported data>\"\n   ```\n   This is the magical moment: the user sees search finding things grep couldn't.\n\n4. **Start embeddings.** Refresh stale embeddings (runs in background). Keyword\n   search works NOW, semantic search improves as embeddings complete.\n\n5. **Backfill the knowledge graph.** Populate typed links and structured timeline\n   from the imported pages. Auto-link maintains both going forward, but historical\n   pages need a one-time backfill.\n\n   ```bash\n   gbrain extract links --source db --dry-run | head -20    # preview\n   gbrain extract links --source db                         # commit\n   gbrain extract timeline --source db                      # dated events\n   gbrain stats                                             # verify links > 0\n   ```\n\n   After this, `gbrain graph-query \u003Cslug> --depth 2` works and search ranks\n   well-connected entities higher. Idempotent — safe to re-run anytime.\n   Supports `--since YYYY-MM-DD` for incremental runs on huge brains.\n\n   Skip if Phase C imported zero pages (auto-link handles new writes).\n\n6. **Offer file migration.** If the repo has binary files (.raw\u002F directories with\n   images, PDFs, audio):\n   > \"You have N binary files (X GB) in your brain repo. Want to move them to cloud\n   > storage? Your git repo will drop from X GB to Y MB. All links keep working.\"\n\n   If the user agrees, configure storage and run migration:\n   ```bash\n   # Configure storage backend (Supabase Storage recommended)\n   gbrain config set storage.backend supabase\n   gbrain config set storage.bucket brain-files\n   gbrain config set storage.projectUrl \u003Csupabase-url>\n   gbrain config set storage.serviceRoleKey \u003Cservice-role-key>\n\n   # Migrate binary files to cloud (3-step lifecycle)\n   gbrain files mirror \u003Cbrain-dir>       # Upload to cloud, keep local\n   gbrain files redirect \u003Cbrain-dir>     # Replace local with .redirect.yaml pointers\n   # (optional) gbrain files clean \u003Cbrain-dir> --yes   # Remove pointers too\n   ```\n\n   After migration, `gbrain files upload-raw` handles new files automatically:\n   small text\u002FPDFs stay in git, large\u002Fmedia files go to cloud with `.redirect.yaml`\n   pointers. Files >= 100 MB use TUS resumable upload for reliability.\n\nIf no markdown repos are found, create a starter brain with a few template pages\n(a person page, a company page, a concept page) from docs\u002FGBRAIN_RECOMMENDED_SCHEMA.md.\n\n## Phase C.5: One-step autopilot + Minions install (v0.11.1+)\n\nRun the migration runner once, then install autopilot. Two commands, done:\n\n```bash\ngbrain apply-migrations --yes       # applies any pending migrations; idempotent on healthy installs\ngbrain autopilot --install          # supervises itself + forks the Minions worker; env-aware\n```\n\nWhat `gbrain autopilot --install` does:\n\n- On **macOS**: writes a launchd plist at `~\u002FLibrary\u002FLaunchAgents\u002Fcom.gbrain.autopilot.plist`.\n- On **Linux with systemd**: writes `~\u002F.config\u002Fsystemd\u002Fuser\u002Fgbrain-autopilot.service`\n  with `Restart=on-failure`.\n- On **ephemeral containers** (Render \u002F Railway \u002F Fly \u002F Docker): writes\n  `~\u002F.gbrain\u002Fstart-autopilot.sh` and prints the one-line your agent's\n  bootstrap should source to launch autopilot on every container start.\n  Auto-injects into OpenClaw's `hooks\u002Fbootstrap\u002Fensure-services.sh` if\n  detected (use `--no-inject` to opt out).\n- On **Linux without systemd**: installs a crontab entry (every 5 min).\n\nAutopilot then supervises the Minions worker as a child process. Users get\nsync + extract + embed + backlinks + durable Postgres-backed job processing\nfrom ONE install step. No separate `gbrain jobs work` daemon to manage.\n\nOn PGLite, autopilot runs inline (PGLite's exclusive file lock blocks a\nseparate worker process). Everything else still works.\n\nIf `apply-migrations` prints \"N host-specific items need your agent's\nattention,\" read `~\u002F.gbrain\u002Fmigrations\u002Fpending-host-work.jsonl` + walk\n`skills\u002Fmigrations\u002Fv0.11.0.md` + `docs\u002Fguides\u002Fplugin-handlers.md` to\nregister host-specific handlers. Re-run `apply-migrations` after each\nbatch.\n\n## Phase D: Brain-First Lookup Protocol\n\nInject the brain-first lookup protocol into the project's AGENTS.md (or equivalent).\nThis replaces grep-based knowledge lookups with structured gbrain queries.\n\n### BEFORE (grep) vs AFTER (gbrain)\n\n| Task | Before (grep) | After (gbrain) |\n|------|---------------|-----------------|\n| Find a person | `grep -r \"Pedro\" brain\u002F` | `gbrain search \"Pedro\"` |\n| Understand a topic | `grep -rl \"deal\" brain\u002F \\| head -5 && cat ...` | `gbrain query \"what's the status of the deal\"` |\n| Read a known page | `cat brain\u002Fpeople\u002Fpedro.md` | `gbrain get people\u002Fpedro` |\n| Find connections | `grep -rl \"Brex\" brain\u002F \\| xargs grep \"Pedro\"` | `gbrain query \"Pedro Brex relationship\"` |\n\n### Lookup sequence (MANDATORY for every entity question)\n\n1. `gbrain search \"name\"` -- keyword match, fast, works without embeddings\n2. `gbrain query \"what do we know about name\"` -- hybrid search, needs embeddings\n3. `gbrain get \u003Cslug>` -- direct page read when you know the slug from steps 1-2\n4. `grep` fallback -- only if gbrain returns zero results AND the file may exist outside the indexed brain\n\nStop at the first step that gives you what you need. Most lookups resolve at step 1.\n\n### Sync-after-write rule\n\nAfter creating or updating any brain page in the repo, sync immediately so the\nindex stays current:\n\n```bash\ngbrain sync --no-pull --no-embed\n```\n\nThis indexes new\u002Fchanged files without pulling from git or regenerating embeddings.\nEmbeddings can be refreshed later in batch (`gbrain embed --stale`).\n\n### gbrain vs memory_search\n\n| Layer | What it stores | When to use |\n|-------|---------------|-------------|\n| **gbrain** | World knowledge: people, companies, deals, meetings, concepts, media | \"Who is Pedro?\", \"What happened at the board meeting?\" |\n| **memory_search** | Agent operational state: preferences, decisions, session context | \"How does the user like formatting?\", \"What did we decide about X?\" |\n\nBoth should be checked. gbrain for facts about the world. memory_search for how\nthe agent should behave.\n\n## Phase E: Load the Production Agent Guide\n\nRead `docs\u002FGBRAIN_SKILLPACK.md`. This is the reference architecture for how a\nproduction agent uses gbrain: the brain-agent loop, entity detection, enrichment\npipeline, meeting ingestion, cron schedules, and the five operational disciplines.\n\nInject the key patterns into the agent's system context or AGENTS.md:\n\n1. **Brain-agent loop** (Section 2): read before responding, write after learning\n2. **Entity detection** (Section 3): spawn on every message, capture people\u002Fcompanies\u002Fideas\n3. **Source attribution** (Section 7): every fact needs `[Source: ...]`\n> **Convention:** See `skills\u002Fconventions\u002Fquality.md` for Iron Law back-linking.\n\nTell the user: \"The production agent guide is at docs\u002FGBRAIN_SKILLPACK.md. It covers\nthe brain-agent loop, entity detection, enrichment, meeting ingestion, and cron\nschedules. Read it when you're ready to go from 'search works' to 'the brain\nmaintains itself.'\"\n\n## Phase F: Health Check\n\nRun `gbrain doctor --json` and report the results. Every check should be OK.\nIf any check fails, the doctor output tells you exactly what's wrong and how to fix it.\n\n## Error Recovery\n\n**If any gbrain command fails, run `gbrain doctor --json` first.** Report the full\noutput. It checks connection, pgvector, RLS, schema version, and embeddings.\n\n| What You See | Why | Fix |\n|---|---|---|\n| Connection refused | Supabase project paused, IPv6, or wrong URL | Use Session pooler (port 6543), or supabase.com\u002Fdashboard > Restore |\n| Password authentication failed | Wrong password | Project Settings > Database > Reset password |\n| pgvector not available | Extension not enabled | Run `CREATE EXTENSION vector;` in SQL Editor |\n| OpenAI key invalid | Expired or wrong key | platform.openai.com\u002Fapi-keys > Create new |\n| No pages found | Query before import | Import files into gbrain first |\n| RLS not enabled | Security gap | Run `gbrain init` again (auto-enables RLS) |\n\n## Phase G: Auto-Update Check (if not already configured)\n\nIf the user's install did NOT include setting up auto-update checks (e.g., they\nused the manual install path or an older version of the OpenClaw\u002FHermes paste), offer it:\n\n> \"Would you like daily GBrain update checks? I'll let you know when there's a\n> new version worth upgrading to — including new skills and schema recommendations.\n> You'll always be asked before anything is installed.\"\n\nIf they agree:\n1. Test: `gbrain check-update --json`\n2. Register daily cron (see GBRAIN_SKILLPACK.md Section 17)\n\nIf already configured or user declines, skip.\n\n## Phase H: Live Sync Setup (MUST ADD)\n\nThe brain repo is the source of truth. If sync doesn't run automatically, the\nvector DB falls behind and gbrain returns stale answers. This phase is not optional.\n\nRead `docs\u002FGBRAIN_SKILLPACK.md` Section 18 for the full reference. Key points:\n\n1. **Check the connection pooler first.** Sync uses transactions on every import.\n   If `DATABASE_URL` uses Supabase's Transaction mode pooler, sync will throw\n   `.begin() is not a function` and silently skip most pages. Verify the connection\n   string uses Session mode (port 6543, Session mode) or direct (port 5432).\n\n2. **Set up automatic sync.** Choose the approach that fits your environment:\n   - **Cron** (recommended for agents): register a cron every 5-30 minutes:\n     `gbrain sync --repo \u002Fdata\u002Fbrain && gbrain embed --stale`\n   - **Watch mode**: `gbrain sync --watch --repo \u002Fdata\u002Fbrain` under a process\n     manager. Pair with a cron fallback (watch exits after 5 consecutive failures).\n   - **Webhook or git hook**: if available in your environment.\n\n3. **Verify sync works.** Don't just check that the command ran. Check that it\n   worked:\n   - `gbrain stats` should show page count close to syncable file count in the repo.\n   - If page count is way too low, the pooler bug is silently skipping pages.\n   - Push a test change and confirm it appears in `gbrain search`.\n\n4. **Chain sync + embed.** Always run both: `gbrain sync --repo \u003Cpath> && gbrain\n   embed --stale`. For small syncs, embeddings are generated inline. The `embed\n   --stale` is a safety net for any stale chunks.\n\nTell the user: \"Live sync is configured. The brain will stay current automatically.\nI'll verify it's working in the next phase.\"\n\n## Phase I: Full Verification\n\nRun the full verification runbook to confirm the entire installation is working.\n\n1. Read `docs\u002FGBRAIN_VERIFY.md`\n2. Execute each check in order\n3. Report results to the user\n4. Fix any failures before declaring setup complete\n\nEvery check in the runbook should pass. The most important one is check 4 (live\nsync actually works): push a change, wait for sync, search for the corrected text.\n\"Sync ran\" is not the same as \"sync worked.\"\n\nTell the user: \"I've verified the full GBrain installation. Here's the status of\neach check: [list results]. Everything is working \u002F [specific item] needs attention.\"\n\nIf already configured or user declines, skip.\n\n## Schema State Tracking\n\nAfter presenting the recommended directories (Phase C\u002FE) and the user selects which\nones to create, write `~\u002F.gbrain\u002Fupdate-state.json` recording:\n- `schema_version_applied`: current gbrain version\n- `skillpack_version_applied`: current gbrain version\n- `schema_choices.adopted`: directories the user created\n- `schema_choices.declined`: directories the user explicitly skipped\n- `schema_choices.custom`: directories the user added that aren't in the recommended schema\n\nThis file enables future upgrades to suggest new schema additions without\nre-suggesting things the user already declined.\n\n## Anti-Patterns\n\n- **Asking for the Supabase anon key.** GBrain connects directly to Postgres over the wire protocol, not through the REST API. Only the database connection string is needed.\n- **Skipping live sync setup.** If sync doesn't run automatically, the vector DB falls behind and search returns stale answers. Phase H is not optional.\n- **Declaring setup complete without verification.** \"The command ran\" is not the same as \"it worked.\" Push a test change, wait for sync, search for the corrected text.\n- **Using Transaction mode pooler.** Sync uses transactions on every import. Transaction mode pooler causes `.begin() is not a function` errors and silently skips pages. Always use Session mode (port 6543).\n- **Importing without proving search.** The magical moment is the user seeing search find things grep couldn't. Don't skip it.\n\n## Output Format\n\n```\nGBRAIN SETUP COMPLETE\n=====================\n\nEngine: [PGLite \u002F Supabase Postgres]\nConnection: [verified \u002F pooler mode confirmed]\nPages imported: N\nEmbeddings: N\u002FN (keyword search active, semantic improving)\nLive sync: [configured \u002F method]\nHealth check: all OK \u002F [specific failures]\nVerification: [GBRAIN_VERIFY.md results]\n\nNext steps:\n- Read docs\u002FGBRAIN_SKILLPACK.md for production agent patterns\n- [any pending items]\n```\n\n## Tools Used\n\n- `gbrain init --non-interactive --url ...` -- create brain\n- `gbrain import \u003Cdir> --no-embed [--workers N]` -- import files\n- `gbrain search \u003Cquery>` -- search brain\n- `gbrain doctor --json` -- health check\n- `gbrain check-update --json` -- check for updates\n- `gbrain embed refresh` -- generate embeddings\n- `gbrain embed --stale` -- backfill missing embeddings\n- `gbrain sync --repo \u003Cpath>` -- one-shot sync from brain repo\n- `gbrain sync --watch --repo \u003Cpath>` -- continuous sync polling\n- `gbrain config get sync.last_run` -- check last sync timestamp\n- `gbrain stats` -- page count + embed coverage\n","# Setup GBrain\n\nSet up GBrain from scratch. Target: working brain in under 5 minutes.\n\n## Contract\n\n- Setup completes with a working brain verified by `gbrain doctor --json` (all checks OK).\n- The brain-first lookup protocol is injected into the project's AGENTS.md or equivalent.\n- Live sync is configured and verified (a test change pushed and found via search).\n- Schema state is tracked in `~\u002F.gbrain\u002Fupdate-state.json` so future upgrades know what the user adopted or declined.\n- No Supabase anon key is requested; GBrain uses only the database connection string.\n\n## Install (if not already installed)\n\n```bash\nbun add github:garrytan\u002Fgbrain\n```\n\n## How GBrain connects\n\nGBrain connects directly to Postgres over the wire protocol. NOT through the\nSupabase REST API. You need the **database connection string** (a `postgresql:\u002F\u002F` URI),\nnot the project URL or anon key. The password is embedded in the connection string.\n\nUse the **Shared Pooler** connection string (port 6543), not the direct connection\n(port 5432). The direct hostname resolves to IPv6 only, which many environments\ncan't reach. Find it: go to the project, click **Get Connected** next to the\nproject URL, then **Direct Connection String** > **Session Pooler**, and copy\nthe **Shared Pooler** connection string.\n\n**Do NOT ask for the Supabase anon key.** GBrain doesn't use it.\n\n## Why Supabase\n\nSupabase gives you managed Postgres + pgvector (vector search built in) for $25\u002Fmo:\n- 8GB database + 100GB storage on Pro tier\n- No server to manage, automatic backups, dashboard for debugging\n- pgvector pre-installed, just works\n- Alternative: any Postgres with pgvector extension (self-hosted, Neon, Railway, etc.)\n\n## Prerequisites\n\n- A Supabase account (Pro tier recommended, $25\u002Fmo) OR any Postgres with pgvector\n- An OpenAI API key (for semantic search embeddings, ~$4-5 for 7,500 pages)\n- A git-backed markdown knowledge base (or start fresh)\n\n## Available init options\n\n- `gbrain init --supabase` -- interactive wizard (prompts for connection string)\n- `gbrain init --url \u003Cconnection_string>` -- direct, no prompts\n- `gbrain init --non-interactive --url \u003Cconnection_string>` -- for scripts\u002Fagents\n- `gbrain doctor --json` -- health check after init\n\nThere is no `--local`, `--sqlite`, or offline mode. GBrain requires Postgres + pgvector.\n\n## Phase A: Supabase Setup (recommended)\n\nGuide the user through creating a Supabase project:\n\n1. \"Go to https:\u002F\u002Fsupabase.com and sign up or log in.\"\n2. \"Click 'New Project' in the top left.\"\n   - Name: `gbrain`\n   - Region: pick the one closest to you\n   - Database password: generate a strong one and save it\n3. \"Wait about 2 minutes for the project to initialize.\"\n4. \"Find the connection string: go to your project, click **Get Connected** next\n   to the project URL, then **Direct Connection String** > **Session Pooler**,\n   and copy the **Shared Pooler** connection string (port 6543).\"\n5. Initialize gbrain:\n   ```bash\n   gbrain init --non-interactive --url \"postgresql:\u002F\u002Fpostgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:6543\u002Fpostgres\"\n   ```\n6. Verify: `gbrain doctor --json`\n\n**OpenClaw\u002FHermes agent instructions:** Store the Supabase access token in your persistent\nenv as `SUPABASE_ACCESS_TOKEN`. gbrain doesn't store it, you need it for future\n`gbrain doctor` runs. Generate at: https:\u002F\u002Fsupabase.com\u002Fdashboard\u002Faccount\u002Ftokens\n\n## Phase B: BYO Postgres (alternative)\n\nIf the user already has Postgres with pgvector:\n\n1. Get the connection string from the user.\n2. Run: `gbrain init --non-interactive --url \"\u003Cconnection_string>\"`\n3. Verify: `gbrain doctor --json`\n\nIf the connection fails with ECONNREFUSED and the URL contains `supabase.co`,\nthe user probably pasted the direct connection (IPv6 only). Guide them to the\nSession pooler string instead (see Phase A step 4).\n\n## Phase C: First Import\n\n1. **Discover markdown repos.** Scan the environment for git repos with markdown content.\n\n```bash\necho \"=== GBrain Environment Discovery ===\"\nfor dir in \u002Fdata\u002F* ~\u002Fgit\u002F* ~\u002FDocuments\u002F* 2>\u002Fdev\u002Fnull; do\n  if [ -d \"$dir\u002F.git\" ]; then\n    md_count=$(find \"$dir\" -name \"*.md\" -not -path \"*\u002Fnode_modules\u002F*\" -not -path \"*\u002F.git\u002F*\" 2>\u002Fdev\u002Fnull | wc -l | tr -d ' ')\n    if [ \"$md_count\" -gt 10 ]; then\n      total_size=$(du -sh \"$dir\" 2>\u002Fdev\u002Fnull | cut -f1)\n      echo \"  $dir ($total_size, $md_count .md files)\"\n    fi\n  fi\ndone\necho \"=== Discovery Complete ===\"\n```\n\n2. **Import the best candidate.** For large imports (>1000 files), use nohup to\n   survive session timeouts:\n   ```bash\n   nohup gbrain import \u003Cdir> --no-embed --workers 4 > \u002Ftmp\u002Fgbrain-import.log 2>&1 &\n   ```\n   Then check progress: `tail -1 \u002Ftmp\u002Fgbrain-import.log`\n\n   For smaller imports, run directly:\n   ```bash\n   gbrain import \u003Cdir> --no-embed\n   ```\n\n3. **Prove search works.** Pick a semantic query based on what you imported:\n   ```bash\n   gbrain search \"\u003Ctopic from the imported data>\"\n   ```\n   This is the magical moment: the user sees search finding things grep couldn't.\n\n4. **Start embeddings.** Refresh stale embeddings (runs in background). Keyword\n   search works NOW, semantic search improves as embeddings complete.\n\n5. **Backfill the knowledge graph.** Populate typed links and structured timeline\n   from the imported pages. Auto-link maintains both going forward, but historical\n   pages need a one-time backfill.\n\n   ```bash\n   gbrain extract links --source db --dry-run | head -20    # preview\n   gbrain extract links --source db                         # commit\n   gbrain extract timeline --source db                      # dated events\n   gbrain stats                                             # verify links > 0\n   ```\n\n   After this, `gbrain graph-query \u003Cslug> --depth 2` works and search ranks\n   well-connected entities higher. Idempotent — safe to re-run anytime.\n   Supports `--since YYYY-MM-DD` for incremental runs on huge brains.\n\n   Skip if Phase C imported zero pages (auto-link handles new writes).\n\n6. **Offer file migration.** If the repo has binary files (.raw\u002F directories with\n   images, PDFs, audio):\n   > \"You have N binary files (X GB) in your brain repo. Want to move them to cloud\n   > storage? Your git repo will drop from X GB to Y MB. All links keep working.\"\n\n   If the user agrees, configure storage and run migration:\n   ```bash\n   # Configure storage backend (Supabase Storage recommended)\n   gbrain config set storage.backend supabase\n   gbrain config set storage.bucket brain-files\n   gbrain config set storage.projectUrl \u003Csupabase-url>\n   gbrain config set storage.serviceRoleKey \u003Cservice-role-key>\n\n   # Migrate binary files to cloud (3-step lifecycle)\n   gbrain files mirror \u003Cbrain-dir>       # Upload to cloud, keep local\n   gbrain files redirect \u003Cbrain-dir>     # Replace local with .redirect.yaml pointers\n   # (optional) gbrain files clean \u003Cbrain-dir> --yes   # Remove pointers too\n   ```\n\n   After migration, `gbrain files upload-raw` handles new files automatically:\n   small text\u002FPDFs stay in git, large\u002Fmedia files go to cloud with `.redirect.yaml`\n   pointers. Files >= 100 MB use TUS resumable upload for reliability.\n\nIf no markdown repos are found, create a starter brain with a few template pages\n(a person page, a company page, a concept page) from docs\u002FGBRAIN_RECOMMENDED_SCHEMA.md.\n\n## Phase C.5: One-step autopilot + Minions install (v0.11.1+)\n\nRun the migration runner once, then install autopilot. Two commands, done:\n\n```bash\ngbrain apply-migrations --yes       # applies any pending migrations; idempotent on healthy installs\ngbrain autopilot --install          # supervises itself + forks the Minions worker; env-aware\n```\n\nWhat `gbrain autopilot --install` does:\n\n- On **macOS**: writes a launchd plist at `~\u002FLibrary\u002FLaunchAgents\u002Fcom.gbrain.autopilot.plist`.\n- On **Linux with systemd**: writes `~\u002F.config\u002Fsystemd\u002Fuser\u002Fgbrain-autopilot.service`\n  with `Restart=on-failure`.\n- On **ephemeral containers** (Render \u002F Railway \u002F Fly \u002F Docker): writes\n  `~\u002F.gbrain\u002Fstart-autopilot.sh` and prints the one-line your agent's\n  bootstrap should source to launch autopilot on every container start.\n  Auto-injects into OpenClaw's `hooks\u002Fbootstrap\u002Fensure-services.sh` if\n  detected (use `--no-inject` to opt out).\n- On **Linux without systemd**: installs a crontab entry (every 5 min).\n\nAutopilot then supervises the Minions worker as a child process. Users get\nsync + extract + embed + backlinks + durable Postgres-backed job processing\nfrom ONE install step. No separate `gbrain jobs work` daemon to manage.\n\nOn PGLite, autopilot runs inline (PGLite's exclusive file lock blocks a\nseparate worker process). Everything else still works.\n\nIf `apply-migrations` prints \"N host-specific items need your agent's\nattention,\" read `~\u002F.gbrain\u002Fmigrations\u002Fpending-host-work.jsonl` + walk\n`skills\u002Fmigrations\u002Fv0.11.0.md` + `docs\u002Fguides\u002Fplugin-handlers.md` to\nregister host-specific handlers. Re-run `apply-migrations` after each\nbatch.\n\n## Phase D: Brain-First Lookup Protocol\n\nInject the brain-first lookup protocol into the project's AGENTS.md (or equivalent).\nThis replaces grep-based knowledge lookups with structured gbrain queries.\n\n### BEFORE (grep) vs AFTER (gbrain)\n\n| Task | Before (grep) | After (gbrain) |\n|------|---------------|-----------------|\n| Find a person | `grep -r \"Pedro\" brain\u002F` | `gbrain search \"Pedro\"` |\n| Understand a topic | `grep -rl \"deal\" brain\u002F \\| head -5 && cat ...` | `gbrain query \"what's the status of the deal\"` |\n| Read a known page | `cat brain\u002Fpeople\u002Fpedro.md` | `gbrain get people\u002Fpedro` |\n| Find connections | `grep -rl \"Brex\" brain\u002F \\| xargs grep \"Pedro\"` | `gbrain query \"Pedro Brex relationship\"` |\n\n### Lookup sequence (MANDATORY for every entity question)\n\n1. `gbrain search \"name\"` -- keyword match, fast, works without embeddings\n2. `gbrain query \"what do we know about name\"` -- hybrid search, needs embeddings\n3. `gbrain get \u003Cslug>` -- direct page read when you know the slug from steps 1-2\n4. `grep` fallback -- only if gbrain returns zero results AND the file may exist outside the indexed brain\n\nStop at the first step that gives you what you need. Most lookups resolve at step 1.\n\n### Sync-after-write rule\n\nAfter creating or updating any brain page in the repo, sync immediately so the\nindex stays current:\n\n```bash\ngbrain sync --no-pull --no-embed\n```\n\nThis indexes new\u002Fchanged files without pulling from git or regenerating embeddings.\nEmbeddings can be refreshed later in batch (`gbrain embed --stale`).\n\n### gbrain vs memory_search\n\n| Layer | What it stores | When to use |\n|-------|---------------|-------------|\n| **gbrain** | World knowledge: people, companies, deals, meetings, concepts, media | \"Who is Pedro?\", \"What happened at the board meeting?\" |\n| **memory_search** | Agent operational state: preferences, decisions, session context | \"How does the user like formatting?\", \"What did we decide about X?\" |\n\nBoth should be checked. gbrain for facts about the world. memory_search for how\nthe agent should behave.\n\n## Phase E: Load the Production Agent Guide\n\nRead `docs\u002FGBRAIN_SKILLPACK.md`. This is the reference architecture for how a\nproduction agent uses gbrain: the brain-agent loop, entity detection, enrichment\npipeline, meeting ingestion, cron schedules, and the five operational disciplines.\n\nInject the key patterns into the agent's system context or AGENTS.md:\n\n1. **Brain-agent loop** (Section 2): read before responding, write after learning\n2. **Entity detection** (Section 3): spawn on every message, capture people\u002Fcompanies\u002Fideas\n3. **Source attribution** (Section 7): every fact needs `[Source: ...]`\n> **Convention:** See `skills\u002Fconventions\u002Fquality.md` for Iron Law back-linking.\n\nTell the user: \"The production agent guide is at docs\u002FGBRAIN_SKILLPACK.md. It covers\nthe brain-agent loop, entity detection, enrichment, meeting ingestion, and cron\nschedules. Read it when you're ready to go from 'search works' to 'the brain\nmaintains itself.'\"\n\n## Phase F: Health Check\n\nRun `gbrain doctor --json` and report the results. Every check should be OK.\nIf any check fails, the doctor output tells you exactly what's wrong and how to fix it.\n\n## Error Recovery\n\n**If any gbrain command fails, run `gbrain doctor --json` first.** Report the full\noutput. It checks connection, pgvector, RLS, schema version, and embeddings.\n\n| What You See | Why | Fix |\n|---|---|---|\n| Connection refused | Supabase project paused, IPv6, or wrong URL | Use Session pooler (port 6543), or supabase.com\u002Fdashboard > Restore |\n| Password authentication failed | Wrong password | Project Settings > Database > Reset password |\n| pgvector not available | Extension not enabled | Run `CREATE EXTENSION vector;` in SQL Editor |\n| OpenAI key invalid | Expired or wrong key | platform.openai.com\u002Fapi-keys > Create new |\n| No pages found | Query before import | Import files into gbrain first |\n| RLS not enabled | Security gap | Run `gbrain init` again (auto-enables RLS) |\n\n## Phase G: Auto-Update Check (if not already configured)\n\nIf the user's install did NOT include setting up auto-update checks (e.g., they\nused the manual install path or an older version of the OpenClaw\u002FHermes paste), offer it:\n\n> \"Would you like daily GBrain update checks? I'll let you know when there's a\n> new version worth upgrading to — including new skills and schema recommendations.\n> You'll always be asked before anything is installed.\"\n\nIf they agree:\n1. Test: `gbrain check-update --json`\n2. Register daily cron (see GBRAIN_SKILLPACK.md Section 17)\n\nIf already configured or user declines, skip.\n\n## Phase H: Live Sync Setup (MUST ADD)\n\nThe brain repo is the source of truth. If sync doesn't run automatically, the\nvector DB falls behind and gbrain returns stale answers. This phase is not optional.\n\nRead `docs\u002FGBRAIN_SKILLPACK.md` Section 18 for the full reference. Key points:\n\n1. **Check the connection pooler first.** Sync uses transactions on every import.\n   If `DATABASE_URL` uses Supabase's Transaction mode pooler, sync will throw\n   `.begin() is not a function` and silently skip most pages. Verify the connection\n   string uses Session mode (port 6543, Session mode) or direct (port 5432).\n\n2. **Set up automatic sync.** Choose the approach that fits your environment:\n   - **Cron** (recommended for agents): register a cron every 5-30 minutes:\n     `gbrain sync --repo \u002Fdata\u002Fbrain && gbrain embed --stale`\n   - **Watch mode**: `gbrain sync --watch --repo \u002Fdata\u002Fbrain` under a process\n     manager. Pair with a cron fallback (watch exits after 5 consecutive failures).\n   - **Webhook or git hook**: if available in your environment.\n\n3. **Verify sync works.** Don't just check that the command ran. Check that it\n   worked:\n   - `gbrain stats` should show page count close to syncable file count in the repo.\n   - If page count is way too low, the pooler bug is silently skipping pages.\n   - Push a test change and confirm it appears in `gbrain search`.\n\n4. **Chain sync + embed.** Always run both: `gbrain sync --repo \u003Cpath> && gbrain\n   embed --stale`. For small syncs, embeddings are generated inline. The `embed\n   --stale` is a safety net for any stale chunks.\n\nTell the user: \"Live sync is configured. The brain will stay current automatically.\nI'll verify it's working in the next phase.\"\n\n## Phase I: Full Verification\n\nRun the full verification runbook to confirm the entire installation is working.\n\n1. Read `docs\u002FGBRAIN_VERIFY.md`\n2. Execute each check in order\n3. Report results to the user\n4. Fix any failures before declaring setup complete\n\nEvery check in the runbook should pass. The most important one is check 4 (live\nsync actually works): push a change, wait for sync, search for the corrected text.\n\"Sync ran\" is not the same as \"sync worked.\"\n\nTell the user: \"I've verified the full GBrain installation. Here's the status of\neach check: [list results]. Everything is working \u002F [specific item] needs attention.\"\n\nIf already configured or user declines, skip.\n\n## Schema State Tracking\n\nAfter presenting the recommended directories (Phase C\u002FE) and the user selects which\nones to create, write `~\u002F.gbrain\u002Fupdate-state.json` recording:\n- `schema_version_applied`: current gbrain version\n- `skillpack_version_applied`: current gbrain version\n- `schema_choices.adopted`: directories the user created\n- `schema_choices.declined`: directories the user explicitly skipped\n- `schema_choices.custom`: directories the user added that aren't in the recommended schema\n\nThis file enables future upgrades to suggest new schema additions without\nre-suggesting things the user already declined.\n\n## Anti-Patterns\n\n- **Asking for the Supabase anon key.** GBrain connects directly to Postgres over the wire protocol, not through the REST API. Only the database connection string is needed.\n- **Skipping live sync setup.** If sync doesn't run automatically, the vector DB falls behind and search returns stale answers. Phase H is not optional.\n- **Declaring setup complete without verification.** \"The command ran\" is not the same as \"it worked.\" Push a test change, wait for sync, search for the corrected text.\n- **Using Transaction mode pooler.** Sync uses transactions on every import. Transaction mode pooler causes `.begin() is not a function` errors and silently skips pages. Always use Session mode (port 6543).\n- **Importing without proving search.** The magical moment is the user seeing search find things grep couldn't. Don't skip it.\n\n## Output Format\n\n```\nGBRAIN SETUP COMPLETE\n=====================\n\nEngine: [PGLite \u002F Supabase Postgres]\nConnection: [verified \u002F pooler mode confirmed]\nPages imported: N\nEmbeddings: N\u002FN (keyword search active, semantic improving)\nLive sync: [configured \u002F method]\nHealth check: all OK \u002F [specific failures]\nVerification: [GBRAIN_VERIFY.md results]\n\nNext steps:\n- Read docs\u002FGBRAIN_SKILLPACK.md for production agent patterns\n- [any pending items]\n```\n\n## Tools Used\n\n- `gbrain init --non-interactive --url ...` -- create brain\n- `gbrain import \u003Cdir> --no-embed [--workers N]` -- import files\n- `gbrain search \u003Cquery>` -- search brain\n- `gbrain doctor --json` -- health check\n- `gbrain check-update --json` -- check for updates\n- `gbrain embed refresh` -- generate embeddings\n- `gbrain embed --stale` -- backfill missing embeddings\n- `gbrain sync --repo \u003Cpath>` -- one-shot sync from brain repo\n- `gbrain sync --watch --repo \u003Cpath>` -- continuous sync polling\n- `gbrain config get sync.last_run` -- check last sync timestamp\n- `gbrain stats` -- page count + embed coverage\n",{"name":5,"tools":42,"mutating":47,"triggers":48,"description":7},[43,44,45,46],"get_stats","get_health","sync_brain","put_page",true,[49,50,51],"set up gbrain","initialize brain","gbrain setup","master","1fd9e273fe234ffb8d2a7705955f087f861a5c3d","skills\u002Fsetup","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain","https:\u002F\u002Fgithub.com\u002Fweareturnone","I have a passion for operations, systems and doing good for the world.","2026-07-08 23:38:19",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":47},[61,64,67],{"tool":62,"command":63},"npx","npx skills add weareturnone\u002Fgbrain --skill setup",{"tool":65,"command":66},"bunx","bunx skills add weareturnone\u002Fgbrain --skill setup",{"tool":68,"command":69},"pnpm","pnpm dlx skills add weareturnone\u002Fgbrain --skill setup","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Fskills\u002Fsetup\u002FSKILL.md",[],[73,90,103,118,133,153],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":37},"01M71GTZ2PH49PD2R6RR7MHJZP","signal-detector","Always-on ambient signal capture for the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fsignal-detector\u002FSKILL.md",[],[80,81,82,83,84,85,86,87,88,89],"signal","signal detector","detector","for","openclaw","capture","reference","message","fixture","ambient",{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":37},"01M71GTY1250DC73PGRWDE82KW","query","Look up brain pages in the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fquery\u002FSKILL.md",[],[92,97,86,98,84,99,100,27,25,101,102,83,88],"do","lookup","look","pages","search","about",{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":37},"01M71GTX0T1T9224P29SD7CSG7","context-now","ALWAYS-ON time-sensitivity discipline for the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fcontext-now\u002FSKILL.md",[],[110,111,112,113,114,84,83,115,86,88,116,117],"context","context now","now","time","how","discipline","sensitivity","long",{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":37},"01M71GTVZJTSWXBM4ZRF4A7QVA","brain-ops","Core read\u002Fwrite cycle for the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fbrain-ops\u002FSKILL.md",[],[125,25,126,127,98,84,128,86,19,83,129,130,131,88,132],"brain ops","ops","Citation","people","read","cycle","core","write",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":37},"01M71GTT4F64V9RMNZ0WRTKWNG","webhook-transforms","Generic framework for converting external events (SMS, meetings, social mentions)\ninto brain-ingestible signals. Define a transform function, register a webhook URL,\nand incoming events get processed through the brain pipeline.","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Fskills\u002Fwebhook-transforms\u002FSKILL.md",[],[140,141,142,34,143,27,144,145,146,147,19,148,101,149,150,30,83,151,152,26],"webhook","transforms","webhook transforms","register","meetings","signals","URL","define","social","event","pipeline","sms","generic",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":172,"publishedAt":37},"01M71GTRDKSM500PRZEXFNQHF9","testing","Skill validation framework. Validates every skill has SKILL.md with frontmatter,\nevery reference exists, every env var is declared. The testing contract for the\nskill system itself.","https:\u002F\u002Fgithub.com\u002Fweareturnone\u002Fgbrain\u002Fblob\u002Fmaster\u002Fskills\u002Ftesting\u002FSKILL.md",[159,164,167],{"categoryNo":160,"categoryName":161,"taxonomyType":162,"taxonomyTypeDesc":163},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":165,"categoryName":166,"taxonomyType":162,"taxonomyTypeDesc":163},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":168,"categoryName":169,"taxonomyType":170,"taxonomyTypeDesc":171},"01JBSEEDCAT000000000000037","律师与法务","PROFESSION","适用职业",[155,173,174,175,176,177,21,31,178,179,180,181,182,183,100,184,101,185,186,83],"test skills","validation","run","health check","test","check","env","skill validation","false","contract","tests","skill health","system","validate skills"]