Yarn.lock Conflict Resolution
When To Use
Use this skill when:
- •
yarn.lockhas merge/rebase conflicts; - •conflict resolution should be repeatable and low-risk;
- •the same conflict appears in multiple rounds of one rebase/merge sequence.
Source Of Truth Policy
- •Rebase: take
yarn.lockfrom the branch you rebase onto. - •Merge: take
yarn.lockfromHEAD(current target branch). - •After taking baseline, run
yarn installto reconcile lock metadata with current manifests.
Required Rules
- •Do not manually resolve conflict markers inside
yarn.lock. - •Replace
yarn.lockcompletely from the selected baseline. - •Reuse previous successful resolution for repeated rounds in the same sequence.
- •If dependency updates were intentional in the rebased commit, replay dependency commands after conflict resolution.
Workflow
- •Ensure conflict exists:
bash
git status --short
- •(Optional) Ensure Yarn config exists:
bash
make .yarnrc.yml
- •Resolve first conflict round for rebase:
bash
ONTO=$(cat .git/rebase-merge/onto 2>/dev/null || cat .git/rebase-apply/onto) git show "$ONTO:yarn.lock" > yarn.lock yarn install git add yarn.lock cp yarn.lock .git/yarn-lock-resolution-base
- •Resolve first conflict round for merge:
bash
git show "HEAD:yarn.lock" > yarn.lock yarn install git add yarn.lock cp yarn.lock .git/yarn-lock-resolution-base
- •Resolve repeated rounds in the same sequence:
bash
cp .git/yarn-lock-resolution-base yarn.lock yarn install git add yarn.lock cp yarn.lock .git/yarn-lock-resolution-base
- •Continue operation:
bash
git rebase --continue # or git merge --continue
- •Cleanup after finish:
bash
rm -f .git/yarn-lock-resolution-base
- •If dependency updates must be replayed, run original dependency command and commit lockfile update with an English Conventional Commit message, for example:
bash
yarn up <packages> git add yarn.lock git commit -m "chore: refresh yarn.lock"
Validation
- •
git status --shorthas no unresolved conflicts foryarn.lock. - •
yarn.lockis staged before--continue. - •Resolution follows source-of-truth policy above.