Adopt an existing workspace
When To Use
Use this task when a workspace already has scripts, hooks, or configuration that you need to keep while introducing repoctl.
Prerequisites
- Run commands from the workspace root.
- Commit or stash unrelated local changes.
- Confirm that Node.js 22.12 or newer and pnpm are available.
Smallest Command
repo doctor --markdown --redact --out reports/baseline.mdExpected Output
The report records the detected package manager, workspace layout, task runner, tooling files, and release setup without exposing local paths.
Common Branches
- Existing conventions are healthy: keep them and add only the missing managed assets.
- A file is already managed locally: use
repo upgrade --no-overwriteand review the diff. - Tooling is split across loaders: resolve the loader first, then rerun the diagnosis.
repoctl is not only for newly generated repositories. It can be adopted gradually in existing pnpm workspaces by using diagnostics and conservative asset syncs.
Good Candidates
A repository is a good fit when:
- It already uses pnpm, or is ready to move to pnpm.
- It has a root
package.json. - It can use workspace folders such as
apps/*,packages/*, orexamples/*. - The team wants stable daily entries such as
repo:init,repo:doctor,repo:new, andrepo:check.
If the repository is not yet a pnpm workspace, start with a minimal pnpm-workspace.yaml:
packages:
- apps/*
- packages/*Step 1: Install And Setup
pnpm add -D repoctl
pnpm exec repo init --yesrepo init --yes uses safe defaults. It adds recommended scripts and workspace patterns, but it does not blindly overwrite existing README, package.json, pnpm-workspace.yaml, or tooling files.
Step 2: Save The First Diagnostic Report
pnpm exec repo doctor --markdown --redact --out reports/doctor-before.md
pnpm exec repo doctor --json --out reports/doctor-before.jsonPrefer saving the first report as a PR comment or CI artifact instead of relying only on terminal output.
Watch these checks:
| Check | Common Issue |
|---|---|
package-json | Current directory is not the repository root |
workspace-manifest | pnpm-workspace.yaml is missing |
node-version | Root package has no engines.node, or the version does not match |
tool-package | repoctl is not installed |
root-scripts | repo:init/repo:new/repo:check/repo:doctor scripts are missing |
config-file | A stale monorepo.config.ts file is still present |
commit-hooks | Husky and lint-staged are only partially configured |
workspace-package-coverage | Some package.json files are not covered by workspace patterns |
Step 3: Sync Conservatively
pnpm exec repo upgrade --no-overwrite
pnpm exec repo doctor --markdown --redact --out reports/doctor-after.mdUse --no-overwrite for the first adoption pass. It syncs missing assets while preserving changed managed files.
Step 4: Preview Verification
pnpm exec repo check --dry-run
pnpm exec repo check --json --out reports/check-plan.json
pnpm exec repo check --markdown --redact --out reports/check-plan.mdReview the plan before wiring hooks or CI.
Step 5: Use Root Scripts
After repo init, team docs can use:
pnpm run repo:doctor
pnpm run repo:new -- sdk
pnpm run repo:checkCI and automation should still prefer explicit commands:
pnpm exec repo doctor --strict
pnpm exec repo check --fullStep 6: Resolve Legacy Config
Config Conflicts
Keep only:
repoctl.config.tsmonorepo.config.ts is no longer loaded at runtime; rename it to repoctl.config.ts.
Local Tooling Loader
If doctor reports local source tooling loaders, migrate with:
pnpm exec repo upgrade --yesThe same migration also converts simple wrappers from @icebreakers/commitlint-config, @icebreakers/eslint-config, and @icebreakers/stylelint-config to repoctl/tooling. Complex ESLint configs keep their rules, ignores, overrides, and extra flat config semantics.
Workspace Pattern Gaps
Run:
pnpm exec repo init --yesor manually extend pnpm-workspace.yaml.
Recommended PR Shape
- Install
repoctland add root scripts. - Attach
doctor-beforeanddoctor-afterreports. - Sync or migrate tooling config.
- Wire hooks and CI.
- Verify scaffolding paths with
repo new --dry-run.