type: rule
status: active
timestamp: 2026-06-29
tags: [global, workspace, mcp, sync, derived, hard-rule]

Globals derived from workspace by script (with grill on drift)

.mcp.json + workspace anchors canonical. Globals synced by scripts/sync-globals.mjs. Fires grill-me on drift

Globals derived from workspace

Rule

chirag127/workspace files are canonical for agent configuration. Global config files (~/.claude.json, ~/.opencode/config.json, ~/.kilocode/, ~/.gemini/, etc.) are derived caches written by scripts/sync-globals.mjs.

You never edit a global file directly. The script reads workspace ? writes global ? diffs ? fires grill-me if drift is detected.

What “canonical” maps to

ConcernWorkspace sourceGlobal target (derived)
MCP servers.mcp.json~/.claude.json mcpServers; ~/.opencode/config.json mcp; etc.
Claude Code settings.agents/claude/settings.template.json~/.claude/settings.json (merge per host)
Agent rulesAGENTS.md + knowledge/rules/~/.claude/CLAUDE.md (pointer)
Skillsrepos/own/infra/agent-skills/~/.claude/skills/ (junction)

When the script runs

Manual only. User invokes explicitly: node scripts/sync-globals.mjs. No auto-trigger from session start, no cron, no hook. Per user instruction 2026-06-29: “don’t sync automatically or anyway anything for now i will do it individually.”

If/when auto-sync is wanted, grill-me first to decide trigger shape (session-start hook vs cron vs file-watcher).

How grill-me fires

Script detects diff ? prints diff ? calls grill-me (via claude CLI invocation, or interactive PS prompt fallback) with the question:

“Workspace has X but global doesn’t (or vice versa). Migrate / keep both / delete from workspace?”

The answer is committed back to the script’s allow/deny registry so the same diff doesn’t re-prompt on the next session.

Why this rule, not “workspace-only”

Tried workspace-only (rule deleted in this commit). Real failure modes:

  1. Per-agent schema drift — OpenCode’s mcp shape ? Claude Code’s; sync script must transform per agent. Workspace-only meant manually maintaining N adapters.
  2. Per-machine variation — auth tokens, absolute binary paths (codebase-memory.exe), model env vars vary per laptop. Forcing them into workspace = either commits secrets or commits a per-machine config file that doesn’t work elsewhere.
  3. Repo cleanliness — workspace root should hold minimum essential files. Stuffing every agent’s global content into workspace would bloat the root.

Workspace-canonical + derived-globals keeps both: clean workspace root + reproducible globals via script.

Anti-patterns

First-run / new-laptop bootstrap

cd C:\D\oriz
node scripts/sync-globals.mjs --bootstrap

--bootstrap skips the grill-me on every new item (you just cloned; everything is new) and just writes globals from workspace. After bootstrap, the next session-start run uses normal grill-on-drift.

Cross-refs


Edit on GitHub · Back to index