---
name: multi-agent-sync
description: "One-shot sync of the entire multi-agent ecosystem: Claude Code, Copilot CLI, pipeline repo, website, and the multi-agent MCP server. Use when work is finished and should be propagated across Claude Code, Copilot CLI, the repos, the website and the multi-agent-mcp server."
user-invocable: true
argument-hint: 'release | multi-agent-mcp | "change description"'
metadata:
  language: en
---

# Multi-Agent Sync

**Access check, before anything else.** This command can write outside this machine, so a login the site closed is stopped here, before any question or write.

```bash
ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
```

`ACCESS_RC` 3: print `$ACCESS_LINE` as written and stop: no question, no write, attended or unattended. Any other exit continues (the check fails open). Contract: `$HOME/.claude/multi-agent-refs/features/usage-reporting.md` "The access check".

**One command. Full ecosystem sync. No arguments needed.**

It syncs all targets in order, updating only the stale ones, and reports. macOS only (ADR-0012); credential access goes through `~/.claude/lib/credential-store.sh` so no call site names the keychain backend.

**Input**: $ARGUMENTS (optional)

| Arg | Meaning |
|---|---|
| (none) | Full ecosystem sync, every target |
| `release` | Full sync + version bump + tag + npm publish + website deploy (Release Flow) |
| `multi-agent-mcp` | Run Step 3d only: gate, commit and publish the companion MCP server |
| `"change description"` | Apply the description to every target at once |

## Gotchas

- The pre-push gate is timing-sensitive: under heavy load a deadline test fails closed. Re-run it on a quiet machine; never push with `--no-verify`.
- `npm publish` answering 202 means the registry is still processing. Verify with the registry's dist-tags before moving `required`, which is asked for every release.
- The installed tree is localized (Turkish descriptions, `model: opus` while fable is off). Normalize to English and `model: fable` before copying into the repo.
- Synced shell runs on BSD userland: BSD grep has no Perl-regex flag, and `sed` has no `\b` or `\|`. A pattern that silently matches nothing reads as "clean".

## Targets

Claude Code (source of truth) -> Copilot CLI, Codex CLI (path-rewritten), the
pipeline repo (genericized), the website (`{owner}/{website-host}`) and the
multi-agent MCP server (its own repo). Paths, directions, the shared
Claude <-> Copilot sections and the token table: `$HOME/.claude/multi-agent-refs/sync/overview.md`; read it
before Step 1.5.

## Default Behavior (no arguments)

Run every step automatically:

```
Step 0: DOCTOR      doctor.mjs  -  exit 2 or 4 stops the sync
Step 1.5: DETECT    Compare timestamps, find stale targets
Step 2: COPILOT     Claude Code -> Copilot CLI (instructions + 82 sub-command skills)
Step 2b: CODEX      Claude Code -> Codex CLI (router skill + specs as refs + agent TOML)
Step 3: REPO        Claude Code -> pipeline repo (genericized, personal data scrub, bash -n on all sh)
Step 3c: PLUGINS    shared/external -> multi-agent-plugins marketplace (rebuild, bump, push)
Step 3d: DEV-TOOLKIT companion MCP server -> detect movement, run the ship gates, commit + publish
Step 3e: OFFICE      panel page is current, installed copies match it, toolkit version recorded
Step 4: WEBSITE     Version + phase/model counts -> {website-host} (i18n + projects.ts)
Step 5: Commit      Commit + push all changed repos
Step 6: Report      Synced targets, changed files, deploy status, multi-agent-mcp version
```

If nothing is stale → report "All targets up to date" and stop.

Step 0 gate rules and why: `features/doctor.md`.

---

## Sync rules

Read every target's current state before changing anything; keep each target's
own format; summary in Copilot, full spec in Claude, never duplicated; finish
with a short diff summary.

---

## Step procedures (read each file before its step)

| Step | Procedure |
|---|---|
| 2b CODEX (runs after Step 3) | `$HOME/.claude/multi-agent-refs/sync/codex.md` |
| 3 REPO | `$HOME/.claude/multi-agent-refs/sync/repo.md` |
| 3c PLUGINS | `$HOME/.claude/multi-agent-refs/sync/stack-plugins.md` |
| 3d DEV-TOOLKIT (and `multi-agent-mcp` arg) | `$HOME/.claude/multi-agent-refs/sync/dev-toolkit.md` |
| 3e OFFICE (also release step 9c) | `$HOME/.claude/multi-agent-refs/sync/office.md` |

Hard rules for Step 3, whatever `repo.md` adds:

- Genericize BEFORE writing to `~/multi-agent-pipeline/pipeline/`; the personal/corporate data scan must return 0 results.
- Never sync a `local-only: true` SKILL.md, local config, or `~/.claude/office/`. A leaked wrapper, sidecar or localized description aborts the sync.
- Synced shell follows the BSD / bash 3.2 contract in `repo.md` (`grep -P` banned, keychain I/O only via `credential-store.sh`). A failed smoke gate aborts the push; fix the `~/.claude/` source, re-sync.

## Website Sync (Step 4)

```bash
gh auth switch --user {owner}
WEBSITE_DIR="$HOME/{website-host}"
[ ! -d "$WEBSITE_DIR" ] && gh repo clone {owner}/{website-host} "$WEBSITE_DIR"
cd "$WEBSITE_DIR" && git pull origin main
```

Files: `src/lib/i18n.tsx` (counts, feature copy EN + TR) and `src/data/projects.ts` (version, features); detail in `overview.md`.

```bash
# {identity} is the one routed to {owner}, not the run's own.
# Why, signature, recovery: `$HOME/.claude/multi-agent-refs/website-deploy.md`.
bash "$HOME/.claude/scripts/website-deploy-commit.sh" "{identity.name}" "{identity.email}" "{VERSION}" "$WEBSITE_DIR"
```

---

## Release Flow

When invoked with the `release` argument:

```
1. REPO          Claude Code -> pipeline repo (genericized)
2. VERIFY        Personal data scan -> 0 results; config-hygiene scan (scan-agent-config.sh) -> 0 HIGH
3. LINT + TEST   ESLint + smoke tests (re-sign .skill-manifest.json with sign-skills.sh when a SKILL.md moved)
4. VERSION       package.json version bump (patch/minor/major)
5. Commit + TAG  git commit + git tag v{VERSION}
6. PUSH          git push --tags; publish is local (release.yml off)
7. DEV-TOOLKIT   Ship the companion MCP server if it moved (Step 3d gates, then publish)
8. WEBSITE       Version + features -> {website-host} (maintainer identity, build verified Ready)
9. COPILOT       Copilot CLI instructions + skills sync
9b. CODEX        Codex CLI router skill + refs + agent TOML (node install.js --codex)
9c. OFFICE       Step 3e: the installed panel matches the release
10. Report       Summary: version, touched repos, deploy status
```

---

## Sub-Command Sync (Claude Code <-> Copilot CLI Skills)

Claude <-> Copilot axis only; Codex takes Step 2b (`cross-cli-contract.md` 2.6).

`~/.claude/commands/multi-agent/{cmd}/SKILL.md` <-> `~/.copilot/skills/multi-agent-{cmd}/SKILL.md`.

**82 commands are synced** (canonical inventory  -  must match `cross-cli-contract.md` section 1; drift = contract violation):

```
address-review, analysis, analysis-jira, analysis-resolve, autopilot-off, autopilot-on,
autopilot-status, bug-bash, build-optimize, channels, clean-disk, complaint-analysis, create-jira,
design-check, diff-explain, doctor, estimate, fable-off, fable-on, fable-status, feedback, forget, garbage-collect, graph, health, help,
ios-coding-standard, issue, jira, kill, language, log,
manual-test, office-off, office-on, office-status, pair, postmortem, prune-logs, prune-prompts, purge, refactor, research, resume, review, review-analysis, review-issue, review-jira, review-priority, review-rounds, route-off, route-on, route-status,
routines, routines-browse, routines-delete, routines-import, routines-share, routines-update,
save, scaffold, scan, scenario-audit, search, security-review, serve, setup, stack, status, steer, store-ready, sync, test,
test-accessibility, test-dark-mode, test-dynamic-type, test-gen, test-screenshots,
testflight-validation, uninstall, update, version
```

**NOT synced**: `$HOME/.claude/multi-agent-refs/*`  -  lazy-load references, Claude Code specific

Frontmatter conversion between the two forms: `overview.md`, "Sub-command paths".

---

## Keychain Token Access

Token sources per operation: `overview.md`. Personal repos run under
`gh auth switch --user {owner}`; tokens are read only through `credential-store.sh`.
