skills/initialize-monorepo/SKILL.md
Bootstrap .context/ for a monorepo with multiple packages or services. Use when setting up the agent system for a monorepo — triggered by "initialize this monorepo", "set up context for our monorepo", "we have a packages/ directory and need context docs", "our Nx/Turborepo/Lerna workspace needs bootstrapping", or any time a multi-package repo has no .context/ and needs to be onboarded. Creates both a root-level overview and per-package context directories.
npx skillsauth add maestria-co/ai-playbook initialize-monorepoInstall 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.
Bootstrap .context/ for a monorepo by creating both a root-level overview and per-package
context directories. This skill extends initialize-repo to handle repositories with multiple
packages or services that need coordinated but separate documentation. Prevents the common
mistake of merging all package context into a single jumbled document.
Run these checks from the initialize-repo skill first:
.context/ directory (warn if exists, don't overwrite)~/.copilot/skills/_shared/context_template/ or ~/.claude/skills/_shared/context_template/)Stop if any check fails — resolve issues before proceeding.
| Build Tool | Detection Method | Output |
| ------------------------ | ---------------------------------------------- | -------------------------- |
| npm/yarn/pnpm workspaces | Read workspaces field in root package.json | List of glob patterns |
| Nx | Read nx.json and project.json files | List of project paths |
| Turborepo | Read turbo.json and workspace config | List of package paths |
| Lerna | Read lerna.json packages field | List of glob patterns |
| Maven | Read parent pom.xml modules | List of module directories |
| Gradle | Read settings.gradle include statements | List of project paths |
packages/*, expand to actual directories## Detected Monorepo Structure
Tool: [npm workspaces / Nx / Maven / etc.]
Packages found: [N]
| Package Path | Name | Purpose |
| --------------- | --------- | -------------------- |
| packages/ui-lib | @acme/ui | Shared UI components |
| packages/api | @acme/api | REST API service |
| apps/web | @acme/web | Main web application |
Understand which packages depend on which others to document relationships and build order.
| Language | Method | Command |
| --------------------- | ------------------------------------------- | -------------------------------------- |
| JavaScript/TypeScript | Read dependencies in package.json | npm list --all --json or parse files |
| Java (Maven) | Read <dependencies> in pom.xml | mvn dependency:tree |
| Java (Gradle) | Read dependencies block | gradle dependencies |
| Python | Read requirements.txt or pyproject.toml | Parse dependencies |
## Package Dependencies
### Dependency Graph
[package-a] → [shared-lib]
[package-b] → [shared-lib]
[app] → [package-a], [package-b]
### Build Order
1. [shared-lib]
2. [package-a], [package-b] (parallel)
3. [app]
.context/overview.mdTemplate:
# [Monorepo Name] Overview
## Repository Type
Monorepo containing [N] packages/services
## Build Tool
[npm workspaces / Nx / Maven / etc.]
## Package Directory
| Package | Purpose | Consumers |
| ------- | -------------- | ------------- |
| [name] | [what it does] | [who uses it] |
## Tech Stack
- [Language/framework for each type of package]
- [Build tool]
- [Testing frameworks]
- [CI/CD platform]
## Getting Started
```bash
# Clone and install
git clone [repo-url]
cd [repo-name]
[install command]
# Build all packages
[build command]
# Run tests
[test command]
```
### Root `.context/architecture.md` (Monorepo section)
Add a "Package Structure" section to the root `architecture.md` documenting the dependency relationships discovered in Phase 2, with a diagram if helpful.
### Root `.context/workflows/monorepo-workflow.md`
```markdown
# Monorepo Workflow
## Building
- **Individual package**: [command to build one package]
- **All packages**: [command to build all]
- **Changed packages only**: [command if supported]
## Testing
- **Individual package**: [command]
- **All packages**: [command]
- **Affected tests only**: [command if supported]
## Releasing
- [Versioning strategy — independent vs. fixed]
- [Release process — manual vs. automated]
- [Changelog generation]
## Common Tasks
- Adding a new package: [steps]
- Moving code between packages: [steps]
- Deprecating a package: [steps]
For each package/service:
.context/overview.mdTemplate:
# [Package Name]
## Purpose
[What this package does, why it exists]
## Public Interface
- Entry point: [main file or module]
- Exports: [key functions/classes/components]
- API surface: [list or link to API docs]
## Consumers
- [Other packages that depend on this one]
- [External systems if a service]
## Development
```bash
# Run package tests
[command]
# Run package locally (if a service)
[command]
# Build package
[command]
```
[Any package-specific quirks, performance notes, security considerations]
### Package `.context/domains/` (optional)
Create domain documents only if this package has significant domain knowledge not shared
across the monorepo. If domain knowledge applies to multiple packages, put it in the root
`.context/domains/` instead.
### Skip Generated Packages
Do not create context documentation for:
- Packages containing only generated code
- Build artifacts directories
- Node_modules or vendor directories
---
## Phase 5: Configure AI Tools
### Root `CLAUDE.md` or `.github/copilot-instructions.md`
Template addition:
```markdown
## Monorepo Structure
This is a monorepo containing [N] packages. Context documentation is organized as:
- **Root context** (`.context/` at repo root): Monorepo-wide architecture, workflows, decisions
- **Package context** (`packages/[name]/.context/`): Package-specific details — uses the same flat-file structure (`overview.md`, `standards.md`, `testing.md`, `architecture.md`)
When working on a specific package, consult both the root context and the package-specific context.
### Package Index
[List packages with one-line descriptions]
### Build Commands
- Build all: `[command]`
- Test all: `[command]`
- Build single package: `[command]`
Package-level CLAUDE.md files are optional — root instructions are the primary entry point.
Only add per-package instructions if the package has unique conventions that override root conventions.
.context/overview.md exists and lists all packages.context/architecture.md has a "Package Structure" section documenting package relationships.context/workflows/monorepo-workflow.md explains build/test/release.context/overview.mdCLAUDE.md or .github/copilot-instructions.md points to context directoriesinitialize-repo checklist exist at root# List all context directories created
find . -name ".context" -type d
# Verify context files exist
ls -la .context/
ls -la packages/*/.context/ 2>/dev/null
## Monorepo Initialization Complete
### Root Context
- `.context/overview.md` — [N] packages documented
- `.context/architecture.md` — package relationships and dependency graph documented
- `.context/workflows/monorepo-workflow.md` — build/test/release documented
### Package Context
- `packages/[name]/.context/overview.md` — [repeated for each package]
### AI Tool Configuration
- `CLAUDE.md` — configured with monorepo structure
### Build Order
[shared-lib] → [package-a] → [app]
### Next Steps
1. Review generated context for accuracy
2. Fill in any [TODO] placeholders
3. Add domain-specific documentation to `.context/domains/` as needed (optional — only for complex domains)
4. Commit context documentation to version control
development
Writes and runs a test suite for a piece of code, covering happy path, edge cases, error cases, and security cases. Use when: implementation is complete and needs test coverage, a bug needs a reproduction test and fix validation, or code needs coverage before a refactor. Do not use when: the code under test is not yet implemented, or the spec is still unclear.
testing
Use when creating a new skill, editing an existing skill, or helping a user author a skill for this system. Covers structure, discoverability, quality, and discipline hardening.
development
Evidence-based verification process to run before marking any task complete. Use this skill every time you're about to report that work is done — for features, bug fixes, refactoring, or any code change. This catches the most common failure mode: declaring "done" without proof. If you're finishing up and about to tell the user the task is complete, run this checklist first.
development
Teaches agents how to discover, select, and invoke skills from the skill library. Use this skill whenever you're uncertain which skill applies to a task, when composing multiple skills for complex work, or when you need to understand what skills are available. This is your go-to when facing an ambiguous task and need to figure out the right approach before diving into implementation.