1.8 KiB
Parallel Worktree Hygiene
This repository is now opinionated about keeping the worktree reviewable during parallel AI-worker runs.
Goal
Keep every slice narrow, make unrelated drift visible immediately, and avoid "who touched what?" cleanup phases before reviews or commits.
Command
Use the root helper:
pnpm worktree:hygiene
It prints the current worktree and, when scopes are declared, splits dirty files into:
stagedunstageduntrackedin scopeoutside scope
Recommended Flow
Before starting a slice:
pnpm worktree:hygiene
When you intentionally work in a narrow area:
pnpm worktree:hygiene -- --scope apps/web/e2e --scope apps/web/src/components/timeline --fail-outside-scope
If the worktree is intentionally shared for a moment, keep the signal but suppress the hard failure:
pnpm worktree:hygiene -- --scope docs --scope scripts --allow-outside-scope
Before committing:
pnpm worktree:hygiene -- --fail-on-dirty
Use --json when another tool or agent should consume the output programmatically.
The helper is also covered by the repo-level script test suite:
pnpm test:scripts
That suite runs in CI before the architecture and import/export guardrails so hygiene regressions fail early.
Parallel-Worker Rules
- Pick an explicit ownership scope before editing files.
- Run the scoped hygiene check before and after each slice.
- Do not mix unrelated files into a commit just because they are already dirty.
- If
outside-scopeis non-empty, either hand off that scope or finish and commit your own slice first. - Prefer multiple small commits over one shared dirty worktree.
Notes
git status --shortremains the fastest human spot check.pnpm worktree:hygieneis the stricter guard when multiple workers operate in parallel.