Adopt Existing Repositories
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
setup,doctor,new, andcheck.
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 setup --yessetup --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 | setup/new/check/doctor scripts are missing |
config-file | repoctl.config.ts and monorepo.config.ts coexist |
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 setup, team docs can use:
pnpm doctor
pnpm new
pnpm 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 for compatibility with older projects.
Local Tooling Loader
If doctor reports local source tooling loaders, migrate with:
pnpm exec repo upgrade --yesWorkspace Pattern Gaps
Run:
pnpm exec repo setup --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.
