Install
openclaw skills install agent-collaboration-protocolStructured multi-agent collaboration for backend + frontend builds. Use when an orchestrator needs to coordinate a backend engineer and frontend engineer on the same feature. Triggered by multi-role build requests like "build a dashboard with an API and UI" or "create a full-stack feature" or any task requiring both backend (API, data, infra) and frontend (UI, templates, design) work.
openclaw skills install agent-collaboration-protocolThree roles collaborate through a shared workspace:
| Role | Responsibility |
|---|---|
| Orchestrator | Defines the contract, spawns both builders, verifies integration, merges |
| Backend Engineer | Writes API code, data models, infrastructure |
| Frontend Engineer | Writes UI components, templates, styles |
The contract lives in a shared/build-{YYYYMMDD}/ directory on the filesystem. The orchestrator MUST provide the full absolute path (e.g. /home/user/project/shared/build-{YYYYMMDD}/) in all handoff messages — isolated subagent sessions do not resolve relative paths reliably. Both builders write to the same directory. The orchestrator inspects and merges when both are done.
shared/build-{YYYYMMDD}/
SPEC.md ← Integration contract (orchestrator writes)
backend/ ← Backend Engineer writes here
frontend/ ← Frontend Engineer writes here
backend-log.md ← Backend Engineer updates (own file, no conflicts)
frontend-log.md ← Frontend Engineer updates (own file, no conflicts)
integration.md ← Orchestrator merges findings here
Write SPEC.md with these sections:
# SPEC: {Feature Name}
## Contract
- API base path, auth scheme, content type
- Data models (all entities, fields, types, relationships)
- Endpoints (method, path, request/response shapes)
- Shared constants (status enums, error codes, feature flags)
- Error format
## Routes
Backend Engineer implements these. Frontend Engineer consumes them.
## UI Components
Frontend Engineer builds these. Backend Engineer doesn't touch them.
## Shared Constants
Both agents use these. Status enums, error codes, UI state labels.
## Success Criteria
Observable behavior. Not "tests pass" — "user can log in and see calendar."
For the full spec template with examples, see references/spec-template.md.
Spawn two subagents with sessions_spawn:
Backend Engineer:
task: >
Implement the API spec at {ABSOLUTE_BUILD_DIR}/SPEC.md.
Write all backend code to {ABSOLUTE_BUILD_DIR}/backend/.
Log your progress to {ABSOLUTE_BUILD_DIR}/backend-log.md.
FIRST: Reply "ACK — confirmed build directory: {ABSOLUTE_BUILD_DIR}" before starting any work.
IMPORTANT: Use the full absolute path for ALL file writes. Verify files exist after writing.
Use {backend framework} (FastAPI, Express, etc.).
Frontend Engineer:
task: >
Implement the UI for the spec at {ABSOLUTE_BUILD_DIR}/SPEC.md.
Write all frontend code to {ABSOLUTE_BUILD_DIR}/frontend/.
Use the API contract in SPEC.md for your fetch calls.
Log your progress to {ABSOLUTE_BUILD_DIR}/frontend-log.md.
FIRST: Reply "ACK — confirmed build directory: {ABSOLUTE_BUILD_DIR}" before starting any work.
IMPORTANT: Use the full absolute path for ALL file writes. Verify files exist after writing.
Use {frontend stack} (HTMX+Tailwind, React, etc.).
Set mode: "run" for one-shot completion.
Handoff acknowledgment is mandatory. Each agent must confirm receipt and verify the build directory path exists before beginning work. If an agent does not ACK within a reasonable window (< 2 minutes), re-spawn it. See references/handoff-format.md for the full handoff template.
Important: Identity comes from context, not the label. The
labelparameter passed tosessions_spawnis a runtime tag for orchestrator tracking — it does NOT determine the agent's role. The subagent's role (Backend Engineer vs Frontend Engineer) is determined entirely by the orchestrator's context injection: thetaskmessage you provide tells the subagent what role to play, what files to write, and what contract to follow. Two subagents spawned with the samelabelcan have completely different tasks and roles.
Backend Engineer writes to {ABSOLUTE_BUILD_DIR}/backend/:
{ABSOLUTE_BUILD_DIR}/backend-log.mdFrontend Engineer writes to {ABSOLUTE_BUILD_DIR}/frontend/:
{ABSOLUTE_BUILD_DIR}/frontend-log.mdEach agent has its own log file — no simultaneous-write conflicts possible.
backend-log.md and frontend-log.md for progressintegration.md for orchestrator notesbackend/ and frontend/The build is not done until the server reads from the new build. Follow these steps in order:
5a. Determine: full build or incremental?
| Build Type | What it means | Action |
|---|---|---|
| Full build | The build directory contains ALL project files (new + existing) | Point server at new build directly |
| Incremental build | The build directory contains ONLY new/changed files | Integrate new files into the live tree first |
Most collaborative builds are incremental — the backend and frontend agents only write the files they changed.
5b. Integrate incremental builds into the live tree
Copy new files from the build directory into the active deployment path. Use your platform's copy tool (cp, rsync, robocopy) with flags that preserve existing files. Only overwrite files that changed.
After integration, verify the deployment is intact:
# Quick sanity: key endpoints still respond
curl -s -o /dev/null -w "%{http_code}" https://example.com/api/health
5c. Point server at the new build (full builds)
Update your server's deployment target to the new build directory. On Unix systems this is typically a symlink swap (e.g. ln -snf build-{YYYYMMDD}/ current). On other platforms, update the server configuration directly.
5d. Configure server to use the deployment target
Any server config that references build paths should point to the deployment target (e.g. current/), never to a date-stamped directory. This is a one-time config change — set it once, then only the target changes on each deploy.
Example pattern:
# ✅ Correct — never needs updating after initial setup
TEMPLATES = Path("/home/user/project/deploy/current/frontend")
# ❌ Wrong — bakes in a date, breaks after every deploy
TEMPLATES = Path("/home/user/project/deploy/build-20260501/frontend")
5e. Restart the service
Restart your application server to pick up the new deployment. Use your platform's service manager (systemctl, supervisor, docker restart, etc.).
5f. Create workspace shortcuts (once per project)
Set up convenient access paths so the live deployment is easy to find and edit. On Unix: ln -snf deploy/current/ ~/myproject. On other platforms, create a shortcut or bookmark.
5g. Verify deploy
# Confirm the deployment target points to the new build
ls -la /path/to/deploy/current
# Check the server responds with the new code
curl -s https://example.com/health
When something goes wrong during a parallel build, follow these steps:
integration.md — did it log progress before failing?SPEC.mdSPEC.md with the correct contract, then correct bothintegration.mdIf both agents edit integration.md simultaneously and create a conflict:
references/integration-log.md)Before declaring the build complete, verify:
# Test each endpoint from the spec
curl -s http://localhost:8000/api/v1/{resource} | jq .
curl -X POST http://localhost:8000/api/v1/{resource} -d '{...}' | jq .
Run once per project to initialize the collaboration structure:
scripts/init_collab.sh /path/to/project
Creates shared/ with template SPEC.md and .gitignore.
Every deployed project follows a three-tier filesystem pattern:
| Path | Type | Purpose | Edit? |
|---|---|---|---|
shared/build-{YYYYMMDD}/ | Directory | Historical snapshot / rollback point | Read-only after deploy |
shared/current/ | Symlink → active build | The server's source of truth | Set via ln -snf during deploy |
~/<project>/ | Symlink → shared/current/ | Your editing workspace | This is where you edit |
Rules:
shared/current/ is the heartbeat. Every build deploy ends with an atomic symlink swap to shared/current/. The previous build is preserved as a dated snapshot.
Server config uses current, never a date. Any import, mount, or path reference in server code (e.g., RTS_BASE, template directories, static file mounts) points to shared/current/. This is set once and never changes.
~/<project>/ is the intuitive path. All human-facing workspaces are symlinks to the deployment target. When you edit ~/myproject/frontend/..., you are writing to the live build. No indirection.
This pattern applies ONLY to projects deployed via shared/build-*/. Server code edited directly in agent workspaces (e.g., myagent/workspace/) does not use the shared/current/ symlink — those directories ARE the live paths already.
⚠️ Symlink swap replaces the entire tree. ln -snf does not merge — it atomically points current at a new destination. If the new build only contains the files that changed (incremental build), the server will lose access to all other files. Always integrate incremental builds into the live tree (Step 5b) before changing the deployment target.
Common pitfall: You add a login page to build-20260508/ and swap current to it. The login page works, but every other page returns 404 because the new build directory doesn't contain them. This is the #1 deploy-time failure mode.
Rollback procedure:
If the new build is broken, point your deployment target back to the last known good build directory, then restart the service. On a Unix system using symlinks:
ln -snf /path/to/deploy/build-{PREVIOUS_DATE}/ /path/to/deploy/current
# Then restart your service via your platform's service manager
The dated build directories are your safety net — each one is a complete, verifiable snapshot you can roll back to instantly.
For deeper patterns and templates:
references/spec-template.md — Full SPEC.md template with examplesreferences/integration-log.md — integration.md status formatreferences/handoff-format.md — Task handoff message templateUse the full protocol (build dir → verify → symlink deploy) when:
shared/build-*/ directoriesDo NOT use when:
workspace-*/ directories (those are the live paths; no build/deploy step needed)sessions_spawn tool (OpenClaw v1.0+)