togorashi45/gbrain/schema-unify
Claude Code and agent skill by togorashi45/gbrain
- community
Checking that the SKILL.md file is still in the repository.
Migrate a brain from gbrain-base (or any pack) to gbrain-base-v2's 14-canonical-type taxonomy via gbrain onboard --check + the unify-types Minion handler. Collapses 94 noisy types to 15 canonical with subtypes, alias rows, and link rows. Triggers when an agent notices pack_upgrade_available, type_proliferation, or asks "what is the canonical taxonomy / how do I clean up my page types".
Install
npx vskill@latest install togorashi45/gbrain/schema-unifySKILL.md
The same SKILL.md was published earlier as togorashi45/gbrain/schema-unify.
Schema Unification (gbrain-base → gbrain-base-v2)
v0.41.22 ships gbrain-base-v2 — a 15-type DRY/MECE taxonomy (14 canonical + note catch-all) — as the install default for new brains. Existing brains on gbrain-base can opt in via the pack_upgrade_available onboard finding + the unify-types PROTECTED Minion handler.
This skill is the playbook for that migration.
brain_first: exempt
This skill is ABOUT the brain's shape — it can't depend on the brain it's reshaping. No gbrain search lookup first; jump straight to onboard.
When this skill fires
- Agent runs
gbrain onboard --checkand seespack_upgrade_availableortype_proliferationwarnings - User asks "what is the canonical taxonomy / how do I clean up my page types / migrate to v2"
- A
dangling_aliasesfinding surfaces (post-unify GC) - An agent ingesting from a custom pack wants to consult the v2 taxonomy as a reference
Mental model (one paragraph)
A production gbrain brain accreted 94 distinct `pages.type` values over years of ingestion: tweet / tweet-thread / tweet-bundle / tweet-single / media/x-tweet/bundle / tweet-stub all coexisting; 5.5K concept-redirect pages; atom-partner-link pages that should be links; civic / framework / insight / memo / anecdote one-offs. The cure: collapse to 15 canonical types (person, company, media, tweet, social-digest, analysis, atom, concept, source, deal, email, slack, writing, project, note) with subtypes/format/origin pushed to frontmatter, alias-rows for redirects, real link-rows for edge-shaped pages, and a catch-all that bins long-tail unknowns to note with frontmatter.legacy_type = <original> for rollback.
Workflow
Phase 1: Discovery
Confirm the brain is actually on gbrain-base (not already on v2).
Expected: gbrain-base@1.0.0+<sha>. If you see gbrain-base-v2@..., the brain is already on v2 — skip the migration.
Then run onboard to see what would change:
Look for the pack_upgrade_available finding. If it's ok, there's no successor declared for the active pack — done.
Phase 2: Preview
Run the per-cluster narrative:
This invokes the unify-types handler in dry-run mode and prints:
- How many pages would retype per cluster (tweets, articles, companies, etc.)
- How many concept-redirect pages would become alias rows
- How many edge-shaped pages would convert to real links
- The synthesized catch-all rules for unknown types
Review the output. If the proposed changes look wrong, don't proceed — file an issue or write a custom pack with adjusted mapping_rules.
Phase 3: Apply
The handler is PROTECTED (manual_only per D17) — autopilot will never auto-fire it. Submit explicitly:
apply defaults to false (dry-run) per the handler contract, so "apply":true is required here or the job reports success having retyped nothing and left the active pack unflipped. Omit it to preview.
Watch progress per phase:
On a 186K-page brain expect ~10 minutes. The handler runs:
- Preflight (validate target pack has
mapping_rules:) - Stats snapshot (pre-state for celebration summary)
- Acquire
gbrain-unifydb-lock (60min TTL) - Apply phases:
- Explicit retype rules (tweets, articles, companies, etc.)
- Catch-all retype (unknown types → note with legacy_type)
- Page-to-link rules (atom-partner-link, symlink)
- Page-to-alias rules (concept-redirect)
- Final sync (untyped rows by path-prefix)
- Flip active pack to gbrain-base-v2 (D13)
- Verify + celebration summary
Phase 4: Verify
Expected:
pack_upgrade_available→ok(active pack is now v2)type_proliferation→ok(≤16 distinct typed values)dangling_aliases→ok(slug_aliases all point at active canonicals)gbrain schema statsshows ≤16 distinct types
Phase 5: Post-migration
Anything that used --type article keeps working post-unify if your CLI calls go through the expandTypeFilter helper (it expands article to media+subtype=article automatically). Direct SQL against pages.type needs updating to the canonical types.
Search queries get a small ranking signal: pages reached via slug_aliases (canonicals of one or more aliases) get a 1.05x boost. Visible via gbrain search --explain.
Rollback
Every retyped page preserves frontmatter.legacy_type = <original> per D8. Restore types via:
Page-to-alias and page-to-link source pages soft-delete with 72h TTL. Restore within that window:
Revert the active pack flip:
Anti-patterns
- Don't run unify-types under autopilot. It's manual_only by design. Autopilot remediation should never silently change your taxonomy.
- Don't expect mapping_rules to cover every legacy type explicitly. Use the catch-all (
*unknown*) for the long tail. Pages get retyped tonotewithlegacy_typepreserved. - Don't rewrite body-text wikilinks. D15: the slug_aliases table IS the resolver.
[[old-redirect-slug]]keeps working viaengine.resolveSlugWithAliasshort-circuit. - Don't bypass the dry-run. Always run
--explainbefore applying. The trust delta is real. - Don't run two unify jobs concurrently. The
gbrain-unifydb-lock serializes them; the second submission rejects with "already in progress."
Decision tree
Contract
Inputs:
- A brain on
gbrain-base(or any pack withmigration_from: gbrain-base-v2). - Write access to submit a PROTECTED Minion handler (
--allow-protected). - ~10 min wallclock on a 186K-page brain.
Outputs:
- Pages retyped to canonical types with
frontmatter.legacy_typepreserved (per-page rollback signal). slug_aliasesrows for concept-redirect pages (alias table IS the resolver — no link rewrite).- Real
linksrows for edge-shaped pages (atom-partner-link,symlink, etc.). - Active pack flipped to
gbrain-base-v2atomically at end of successful run.
Side effects:
- Source pages soft-deleted with 72h restore TTL (
gbrain restore <slug>). - One-time cache invalidation on KNOBS_HASH_VERSION bump (5→6); self-healing in
cache.ttl_seconds. - Query-time
--type Xalias-expands viaexpandTypeFilter(D14 back-compat).
Failure modes:
- Concurrent submission rejected by the
gbrain-unifydb-lock; second call exits gracefully. - Catch-all retype excludes
page_to_link+page_to_aliassource types (caught in E2E pre-merge). - Phase failures abort the run before
active_pack_flipped; partial state restorable via op_checkpoint resume.
Anti-Patterns
DON'T:
- Submit
unify-typesdirectly via the MCPsubmit_jobop without--allow-protected. PROTECTED handlers require trusted local callers; remote MCP rejection is the intentional trust boundary. - Edit
mapping_rulesingbrain-base-v2.yamlto skip clusters you don't trust. Fork the pack instead (gbrain schema fork) so the source-of-truth migration stays consistent across brains. - Run
unify-typesfrom inside an autopilot tick. The check ismanual_onlyper D17 — autopilot deliberately never auto-fires it because pack upgrades are one-time consenting taxonomy decisions. - Hard-delete soft-deleted source pages before the 72h restore window. Use
gbrain restore <slug>first if rollback is needed. - Assume
frontmatter.legacy_typesurvives every roundtrip. The marker is canonical for the immediate post-migration window; downstream re-imports may overwrite it.
Output Format
Per phase, the handler emits to stderr:
Final celebration summary to stderr:
JSON output (gbrain jobs follow <id> --json) returns the structured UnifyTypesResult shape with per_phase, pack_identity_after, active_pack_flipped.
Reference
- Plan + decisions:
~/.claude/plans/system-instruction-you-are-working-transient-elephant.md - Architecture:
docs/architecture/type-taxonomy.md - Pack-upgrade mechanism:
docs/architecture/pack-upgrade-mechanism.md - Issue: https://github.com/garrytan/gbrain/issues/1479
Security
- Security scanPassed, 96 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/schema-unify/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/togorashi45/gbrain/schema-unify)