go-arch supports monorepos through workspaces: a go-arch.workspace.yaml file at the repository root that maps service names to paths, plus commands that operate across the set.
Single projects are unaffected. Every workspace feature is opt-in — a project without a workspace file behaves exactly as before (ADR-7: the CWD is the project root).
go-arch.workspace.yaml at the monorepo root:
services:
- name: orders
path: services/orders
template: express # optional — pack used at generation
- name: users
path: services/users
template: expressname— required, lowercase alphanumeric with internal dashes (orders,api-gateway).path— required, relative to the workspace file's directory.template— optional metadata; not consumed in v1.- Unknown keys, duplicate names, and invalid slugs are rejected with a clear error.
The CLI locates the workspace file two ways:
--workspace <path>— explicit flag (wins).- Auto-discovery — walks upward from the current directory looking for
go-arch.workspace.yaml.
# From anywhere inside the monorepo, without a flag:
go-arch workspace upgrade
# Or explicitly:
go-arch workspace upgrade --workspace /repo/go-arch.workspace.yamlUpgrades every service in declaration order. Each service runs the standard upgrade logic (plan, dry-run by default; --yes applies). A failing service is reported and the remaining services still run; the command exits non-zero if any failed.
go-arch workspace upgrade # dry-run: print plans only
go-arch workspace upgrade --yes # apply all upgradable filesRuns the architecture check for every service, with per-service summary and continue-on-error semantics.
go-arch workspace checkTarget a single service from anywhere inside the monorepo:
go-arch generate crud User --service orders
go-arch check --service orders
go-arch upgrade --service orders --yesThe CLI changes into the service directory, reloads the service's .go-arch.yaml, runs the command, and restores the previous directory and config. Single-service --service invocations fail fast (unlike multi-service workspace commands).
- Sequential execution — services are processed one at a time, in declaration order. Concurrent execution is not supported in v1.
- Continue-on-error —
workspace upgradeandworkspace checkprocess every service even if one fails; the final summary shows each outcome and the exit code is non-zero if any failed. - Hooks — generator and lifecycle hooks run with the service directory as their working directory, so hook-created files and
PROJECT_PATHtarget the service. - Config isolation — each service uses its own
.go-arch.yaml; the previous config is restored after the operation. - Legacy services — a service without a manifest is reported (
service_no_manifest) and skipped in batch mode. - Pack sources — workspace upgrade re-renders pack-sourced files via the recorded pack (same as standalone upgrade, including PROTECTED classification).
workspace upgradedefaults to dry-run (plans only).workspace upgrade --yesapplies all upgradable files per service.- Legacy per-file interactive prompting is disabled under batch — legacy services are reported and skipped unless
--yesapplies them non-interactively.
- Nested workspaces (workspace inside workspace).
- Concurrent service operations.
- Cross-service template sharing.
MCP workspace tools→ done:workspace_list,workspace_upgrade(chdir-free via root injection),workspace_check, andservice+workspacePathparams onupgrade_project.serviceongenerate_component/check_architectureremains deferred.go-arch newworkspace-aware creation.
| Code | Meaning |
|---|---|
workspace_not_found |
No workspace file found by flag or discovery |
workspace_invalid |
Workspace file schema/validation error |
service_not_found |
--service named a service not in the workspace |
service_path_missing |
A service's declared path does not exist on disk |
service_duplicate |
Two services share a name |
service_no_manifest |
A service lacks a manifest; legacy fallback applies |