skills/monorepo-strategy/SKILL.md
Deploy multi-service monorepo applications — service discovery, dependency ordering, shared build contexts, selective deployment, and compose generation. Use when the repository contains multiple deployable services, apps, or packages.
npx skillsauth add nixopus/agent monorepo-strategyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A repository is a monorepo if any of these are present:
| Signal | Type |
|---|---|
| apps/ or services/ directory with multiple subdirectories | Conventional structure |
| packages/ with shared libraries | Shared code |
| workspaces in root package.json | npm/yarn/bun workspaces |
| pnpm-workspace.yaml | pnpm workspaces |
| turbo.json | Turborepo |
| nx.json | Nx |
| lerna.json | Lerna |
| rush.json | Rush |
| go.work | Go workspaces |
| Multiple Dockerfile files in subdirectories | Multi-service |
| Multiple Cargo.toml with [workspace] in root | Rust workspace |
workspaces array in root package.jsonpackages list in pnpm-workspace.yamlpackage.jsonstart script or a main/module entrygo.work for module listmain package (main.go or cmd/ directory) is deployableCargo.toml → [workspace].members[[bin]] target or src/main.rs is deployableapps/, services/, packages/ for subdirectoriespackage.json, go.mod, Cargo.toml, etc.) is a potential serviceDockerfile is a deployable serviceBuild the service dependency graph before deploying:
In package.json, workspace dependencies use:
"@scope/package": "workspace:*" (pnpm)"@scope/package": "*" with the package in workspaces (npm/yarn)In each module's go.mod, require directives pointing to other workspace modules (matched by module path from go.work).
The Docker build context for monorepo services should usually be the repository root, not the service subdirectory:
services:
api:
build:
context: . # repo root
dockerfile: apps/api/Dockerfile # service-specific Dockerfile
This ensures shared packages, root lockfiles, and workspace configuration are available during build.
FROM node:22-slim AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY apps/api/package.json ./apps/api/
COPY packages/shared/package.json ./packages/shared/
RUN corepack enable && pnpm install --frozen-lockfile
FROM deps AS build
COPY packages/shared ./packages/shared
COPY apps/api ./apps/api
RUN pnpm --filter api build
FROM node:22-slim
WORKDIR /app
COPY --from=build /app/apps/api/dist ./dist
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/apps/api/package.json ./
EXPOSE 3001
CMD ["node", "dist/index.js"]
Key: copy ALL workspace package.json files in the deps stage so the lockfile resolves correctly.
Not every push requires deploying every service:
apps/api/** → deploy apipackages/shared/** → deploy ALL services that depend on sharedpackage.json, lockfile, tsconfig.json) → deploy ALL servicesGenerate docker-compose.yml with one service per deployable app:
services:
api:
build:
context: .
dockerfile: apps/api/Dockerfile
ports:
- "3001:3001"
depends_on:
db:
condition: service_healthy
web:
build:
context: .
dockerfile: apps/web/Dockerfile
ports:
- "3000:3000"
depends_on:
- api
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: app
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 3s
retries: 5
volumes:
pgdata:
If turbo.json or nx.json is present:
turbo run build --filter=<service> for targeted buildsnx build <service> or nx affected --target=build for selective builds--shamefully-hoist may be needed for some packagestsconfig.json with references must be present for TypeScript project references to work--filter uses package names from package.json, not directory namesgo.work.sum must also be committed alongside go.workaffected needs git history in the Docker build — use --base=HEAD~1 or copy .git (adds size).env across services that need different configscompose-setup — Base compose patterns for databases and cachesdockerfile-generation — Ecosystem-specific Dockerfile patterns to adapt for monorepo servicesnode-deploy — Node.js monorepo support (workspaces, package managers)go-deploy — Go workspace supporttools
Compressed catalog of all Nixopus API operations for the nixopus_api() tool
development
Deploy static file sites — Caddy/nginx serving, Staticfile config, and Dockerfile patterns. Use when deploying a static HTML site with no server-side runtime, or when index.html or a Staticfile is detected at the project root.
devops
Deploy shell script applications — interpreter detection, setup scripts, and Dockerfile patterns. Use when deploying a shell script project, or when start.sh is detected.
development
Self-healing loop for failed deployments — diagnose, fix, redeploy up to 3 attempts, then escalate or rollback. Load when a deployment fails or build errors occur.