| 1 | --- |
| 2 | name: "distributed-mesh" |
| 3 | description: "How to coordinate with squads on different machines using git as transport" |
| 4 | domain: "distributed-coordination" |
| 5 | confidence: "high" |
| 6 | source: "multi-model-consensus (Opus 4.6, Sonnet 4.5, GPT-5.4)" |
| 7 | --- |
| 8 | |
| 9 | ## SCOPE |
| 10 | |
| 11 | **✅ THIS SKILL PRODUCES (exactly these, nothing more):** |
| 12 | |
| 13 | 1. **`mesh.json`** — Generated from user answers about zones and squads (which squads participate, what zone each is in, paths/URLs for each), using `mesh.json.example` in this skill's directory as the schema template |
| 14 | 2. **`sync-mesh.sh` and `sync-mesh.ps1`** — Copied from this skill's directory into the project root (these are bundled resources, NOT generated code) |
| 15 | 3. **Zone 2 state repo initialization** (if applicable) — If the user specified a Zone 2 shared state repo, run `sync-mesh.sh --init` to scaffold the state repo structure |
| 16 | 4. **A decision entry** in `.squad/decisions/inbox/` documenting the mesh configuration for team awareness |
| 17 | |
| 18 | **❌ THIS SKILL DOES NOT PRODUCE:** |
| 19 | |
| 20 | - **No application code** — No validators, libraries, or modules of any kind |
| 21 | - **No test files** — No test suites, test cases, or test scaffolding |
| 22 | - **No GENERATING sync scripts** — They are bundled with this skill as pre-built resources. COPY them, don't generate them. |
| 23 | - **No daemons or services** — No background processes, servers, or persistent runtimes |
| 24 | - **No modifications to existing squad files** beyond the decision entry (no changes to team.md, routing.md, agent charters, etc.) |
| 25 | |
| 26 | **Your role:** Configure the mesh topology and install the bundled sync scripts. Nothing more. |
| 27 | |
| 28 | ## Context |
| 29 | |
| 30 | When squads are on different machines (developer laptops, CI runners, cloud VMs, partner orgs), the local file-reading convention still works — but remote files need to arrive on your disk first. This skill teaches the pattern for distributed squad communication. |
| 31 | |
| 32 | **When this applies:** |
| 33 | - Squads span multiple machines, VMs, or CI runners |
| 34 | - Squads span organizations or companies |
| 35 | - An agent needs context from a squad whose files aren't on the local filesystem |
| 36 | |
| 37 | **When this does NOT apply:** |
| 38 | - All squads are on the same machine (just read the files directly) |
| 39 | |
| 40 | ## Patterns |
| 41 | |
| 42 | ### The Core Principle |
| 43 | |
| 44 | > "The filesystem is the mesh, and git is how the mesh crosses machine boundaries." |
| 45 | |
| 46 | The agent interface never changes. Agents always read local files. The distributed layer's only job is to make remote files appear locally before the agent reads them. |
| 47 | |
| 48 | ### Three Zones of Communication |
| 49 | |
| 50 | **Zone 1 — Local:** Same filesystem. Read files directly. Zero transport. |
| 51 | |
| 52 | **Zone 2 — Remote-Trusted:** Different host, same org, shared git auth. Transport: `git pull` from a shared repo. This collapses Zone 2 into Zone 1 — files materialize on disk, agent reads them normally. |
| 53 | |
| 54 | **Zone 3 — Remote-Opaque:** Different org, no shared auth. Transport: `curl` to fetch published contracts (SUMMARY.md). One-way visibility — you see only what they publish. |
| 55 | |
| 56 | ### Agent Lifecycle (Distributed) |
| 57 | |
| 58 | ``` |
| 59 | 1. SYNC: git pull (Zone 2) + curl (Zone 3) — materialize remote state |
| 60 | 2. READ: cat .mesh/**/state.md — all files are local now |
| 61 | 3. WORK: do their assigned work (the agent's normal task, NOT mesh-building) |
| 62 | 4. WRITE: update own billboard, log, drops |
| 63 | 5. PUBLISH: git add + commit + push — share state with remote peers |
| 64 | ``` |
| 65 | |
| 66 | Steps 2–4 are identical to local-only. Steps 1 and 5 are the entire distributed extension. **Note:** "WORK" means the agent performs its normal squad duties — it does NOT mean "build mesh infrastructure." |
| 67 | |
| 68 | ### The mesh.json Config |
| 69 | |
| 70 | ```json |
| 71 | { |
| 72 | "squads": { |
| 73 | "auth-squad": { "zone": "local", "path": "../auth-squad/.mesh" }, |
| 74 | "ci-squad": { |
| 75 | "zone": "remote-trusted", |
| 76 | "source": "git@github.com:our-org/ci-squad.git", |
| 77 | "ref": "main", |
| 78 | "sync_to": ".mesh/remotes/ci-squad" |
| 79 | }, |
| 80 | "partner-fraud": { |
| 81 | "zone": "remote-opaque", |
| 82 | "source": "https://partner.dev/squad-contracts/fraud/SUMMARY.md", |
| 83 | "sync_to": ".mesh/remotes/partner-fraud", |
| 84 | "auth": "bearer" |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | ``` |
| 89 | |
| 90 | Three zone types, one file. Local squads need only a path. Remote-trusted need a git URL. Remote-opaque need an HTTP URL. |
| 91 | |
| 92 | ### Write Partitioning |
| 93 | |
| 94 | Each squad writes only to its own directory (`boards/{self}.md`, `squads/{self}/*`, `drops/{date}-{self}-*.md`). No two squads write to the same file. Git push/pull never conflicts. If push fails ("branch is behind"), the fix is always `git pull --rebase && git push`. |
| 95 | |
| 96 | ### Trust Boundaries |
| 97 | |
| 98 | Trust maps to git permissions: |
| 99 | - **Same repo access** = full mesh visibility |
| 100 | - **Read-only access** = can observe, can't write |
| 101 | - **No access** = invisible (correct behavior) |
| 102 | |
| 103 | For selective visibility, use separate repos per audience (internal, partner, public). Git permissions ARE the trust negotiation. |
| 104 | |
| 105 | ### Phased Rollout |
| 106 | |
| 107 | - **Phase 0:** Convention only — document zones, agree on mesh.json fields, manually run `git pull`/`git push`. Zero new code. |
| 108 | - **Phase 1:** Sync script (~30 lines bash or PowerShell) when manual sync gets tedious. |
| 109 | - **Phase 2:** Published contracts + curl fetch when a Zone 3 partner appears. |
| 110 | - **Phase 3:** Never. No MCP federation, A2A, service discovery, message queues. |
| 111 | |
| 112 | **Important:** Phases are NOT auto-advanced. These are project-level decisions — you start at Phase 0 (manual sync) and only move forward when the team decides complexity is justified. |
| 113 | |
| 114 | ### Mesh State Repo |
| 115 | |
| 116 | The shared mesh state repo is a plain git repository — NOT a Squad project. It holds: |
| 117 | - One directory per participating squad |
| 118 | - Each directory contains at minimum a SUMMARY.md with the squad's current state |
| 119 | - A root README explaining what the repo is and who participates |
| 120 | |
| 121 | No `.squad/` folder, no agents, no automation. Write partitioning means each squad only pushes to its own directory. The repo is a rendezvous point, not an intelligent system. |
| 122 | |
| 123 | If you want a squad that *observes* mesh health, that's a separate Squad project that lists the state repo as a Zone 2 remote in its `mesh.json` — it does NOT live inside the state repo. |
| 124 | |
| 125 | ## Examples |
| 126 | |
| 127 | ### Developer Laptop + CI Squad (Zone 2) |
| 128 | |
| 129 | Auth-squad agent wakes up. `git pull` brings ci-squad's latest results. Agent reads: "3 test failures in auth module." Adjusts work. Pushes results when done. **Overhead: one `git pull`, one `git push`.** |
| 130 | |
| 131 | ### Two Orgs Collaborating (Zone 3) |
| 132 | |
| 133 | Payment-squad fetches partner's published SUMMARY.md via curl. Reads: "Risk scoring v3 API deprecated April 15. New field `device_fingerprint` required." The consuming agent (in payment-squad's team) reads this information and uses it to inform its work — for example, updating payment integration code to include the new field. Partner can't see payment-squad's internals. |
| 134 | |
| 135 | ### Same Org, Shared Mesh Repo (Zone 2) |
| 136 | |
| 137 | Three squads on different machines. One shared git repo holds the mesh. Each squad: `git pull` before work, `git push` after. Write partitioning ensures zero merge conflicts. |
| 138 | |
| 139 | ## AGENT WORKFLOW (Deterministic Setup) |
| 140 | |
| 141 | When a user invokes this skill to set up a distributed mesh, follow these steps **exactly, in order:** |
| 142 | |
| 143 | ### Step 1: ASK the user for mesh topology |
| 144 | |
| 145 | Ask these questions (adapt phrasing naturally, but get these answers): |
| 146 | |
| 147 | 1. **Which squads are participating?** (List of squad names) |
| 148 | 2. **For each squad, which zone is it in?** |
| 149 | - `local` — same filesystem (just need a path) |
| 150 | - `remote-trusted` — different machine, same org, shared git access (need git URL + ref) |
| 151 | - `remote-opaque` — different org, no shared auth (need HTTPS URL to published contract) |
| 152 | 3. **For each squad, what's the connection info?** |
| 153 | - Local: relative or absolute path to their `.mesh/` directory |
| 154 | - Remote-trusted: git URL (SSH or HTTPS), ref (branch/tag), and where to sync it to locally |
| 155 | - Remote-opaque: HTTPS URL to their SUMMARY.md, where to sync it, and auth type (none/bearer) |
| 156 | 4. **Where should the shared state live?** (For Zone 2 squads: git repo URL for the mesh state, or confirm each squad syncs independently) |
| 157 | |
| 158 | ### Step 2: GENERATE `mesh.json` |
| 159 | |
| 160 | Using the answers from Step 1, create a `mesh.json` file at the project root. Use `mesh.json.example` from THIS skill's directory (`.squad/skills/distributed-mesh/mesh.json.example`) as the schema template. |
| 161 | |
| 162 | Structure: |
| 163 | |
| 164 | ```json |
| 165 | { |
| 166 | "squads": { |
| 167 | "<squad-name>": { "zone": "local", "path": "<relative-or-absolute-path>" }, |
| 168 | "<squad-name>": { |
| 169 | "zone": "remote-trusted", |
| 170 | "source": "<git-url>", |
| 171 | "ref": "<branch-or-tag>", |
| 172 | "sync_to": ".mesh/remotes/<squad-name>" |
| 173 | }, |
| 174 | "<squad-name>": { |
| 175 | "zone": "remote-opaque", |
| 176 | "source": "<https-url-to-summary>", |
| 177 | "sync_to": ".mesh/remotes/<squad-name>", |
| 178 | "auth": "<none|bearer>" |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | ``` |
| 183 | |
| 184 | Write this file to the project root. Do NOT write any other code. |
| 185 | |
| 186 | ### Step 3: COPY sync scripts |
| 187 | |
| 188 | Copy the bundled sync scripts from THIS skill's directory into the project root: |
| 189 | |
| 190 | - **Source:** `.squad/skills/distributed-mesh/sync-mesh.sh` |
| 191 | - **Destination:** `sync-mesh.sh` (project root) |
| 192 | |
| 193 | - **Source:** `.squad/skills/distributed-mesh/sync-mesh.ps1` |
| 194 | - **Destination:** `sync-mesh.ps1` (project root) |
| 195 | |
| 196 | These are bundled resources. Do NOT generate them — COPY them directly. |
| 197 | |
| 198 | ### Step 4: RUN `--init` (if Zone 2 state repo exists) |
| 199 | |
| 200 | If the user specified a Zone 2 shared state repo in Step 1, run the initialization: |
| 201 | |
| 202 | **On Unix/Linux/macOS:** |
| 203 | ```bash |
| 204 | bash sync-mesh.sh --init |
| 205 | ``` |
| 206 | |
| 207 | **On Windows:** |
| 208 | ```powershell |
| 209 | .\sync-mesh.ps1 -Init |
| 210 | ``` |
| 211 | |
| 212 | This scaffolds the state repo structure (squad directories, placeholder SUMMARY.md files, root README). |
| 213 | |
| 214 | **Skip this step if:** |
| 215 | - No Zone 2 squads are configured (local/opaque only) |
| 216 | - The state repo already exists and is initialized |
| 217 | |
| 218 | ### Step 5: WRITE a decision entry |
| 219 | |
| 220 | Create a decision file at `.squad/decisions/inbox/<your-agent-name>-mesh-setup.md` with this content: |
| 221 | |
| 222 | ```markdown |
| 223 | ### <YYYY-MM-DD>: Mesh configuration |
| 224 | |
| 225 | **By:** <your-agent-name> (via distributed-mesh skill) |
| 226 | |
| 227 | **What:** Configured distributed mesh with <N> squads across zones <list-zones-used> |
| 228 | |
| 229 | **Squads:** |
| 230 | - `<squad-name>` — Zone <X> — <brief-connection-info> |
| 231 | - `<squad-name>` — Zone <X> — <brief-connection-info> |
| 232 | - ... |
| 233 | |
| 234 | **State repo:** <git-url-if-zone-2-used, or "N/A (local/opaque only)"> |
| 235 | |
| 236 | **Why:** <user's stated reason for setting up the mesh, or "Enable cross-machine squad coordination"> |
| 237 | ``` |
| 238 | |
| 239 | Write this file. The Scribe will merge it into the main decisions file later. |
| 240 | |
| 241 | ### Step 6: STOP |
| 242 | |
| 243 | **You are done.** Do not: |
| 244 | - Generate sync scripts (they're bundled with this skill — COPY them) |
| 245 | - Write validator code |
| 246 | - Write test files |
| 247 | - Create any other modules, libraries, or application code |
| 248 | - Modify existing squad files (team.md, routing.md, charters) |
| 249 | - Auto-advance to Phase 2 or Phase 3 |
| 250 | |
| 251 | Output a simple completion message: |
| 252 | |
| 253 | ``` |
| 254 | ✅ Mesh configured. Created: |
| 255 | - mesh.json (<N> squads) |
| 256 | - sync-mesh.sh and sync-mesh.ps1 (copied from skill bundle) |
| 257 | - Decision entry: .squad/decisions/inbox/<filename> |
| 258 | |
| 259 | Run `bash sync-mesh.sh` (or `.\sync-mesh.ps1` on Windows) before agents start to materialize remote state. |
| 260 | ``` |
| 261 | |
| 262 | --- |
| 263 | |
| 264 | ## Anti-Patterns |
| 265 | |
| 266 | **❌ Code generation anti-patterns:** |
| 267 | - Writing `mesh-config-validator.js` or any validator module |
| 268 | - Writing test files for mesh configuration |
| 269 | - Generating sync scripts instead of copying the bundled ones from this skill's directory |
| 270 | - Creating library modules or utilities |
| 271 | - Building any code that "runs the mesh" — the mesh is read by agents, not executed |
| 272 | |
| 273 | **❌ Architectural anti-patterns:** |
| 274 | - Building a federation protocol — Git push/pull IS federation |
| 275 | - Running a sync daemon or server — Agents are not persistent. Sync at startup, publish at shutdown |
| 276 | - Real-time notifications — Agents don't need real-time. They need "recent enough." `git pull` is recent enough |
| 277 | - Schema validation for markdown — The LLM reads markdown. If the format changes, it adapts |
| 278 | - Service discovery protocol — mesh.json is a file with 10 entries. Not a "discovery problem" |
| 279 | - Auth framework — Git SSH keys and HTTPS tokens. Not a framework. Already configured |
| 280 | - Message queues / event buses — Agents wake, read, work, write, sleep. Nobody's home to receive events |
| 281 | - Any component requiring a running process — That's the line. Don't cross it |
| 282 | |
| 283 | **❌ Scope creep anti-patterns:** |
| 284 | - Auto-advancing phases without user decision |
| 285 | - Modifying agent charters or routing rules |
| 286 | - Setting up CI/CD pipelines for mesh sync |
| 287 | - Creating dashboards or monitoring tools |