Pre-Deployment Main Sync
Rule
Before any deployment or live environment mutation, sync the working branch with origin/main and prove the result is clean enough to deploy. Do not deploy from a branch that has not incorporated the latest origin/main.
Workflow
- Identify the git repo that owns the files or manifests being deployed.
- Record the current branch and dirty files with
git status --short --branch. - Fetch main:
git fetch origin main
If this fails because a remote ref is locked, retry once after a few seconds. If it still fails, stop.
- Run the bundled checker from the repo root:
python ~/.codex/skills/pre-deployment-main-sync/scripts/pre_deployment_main_sync.py --integrate
This checks whether local dirty changes can survive the main sync, stashes them when needed, integrates origin/main, and restores the changes. If it reports any conflict or unresolved file, stop and resolve that before deployment.
Run the relevant verification for the deployment. Prefer the project’s focused test command plus any smoke test needed for the changed surface. If no focused command is known, inspect project docs and scripts before choosing.
Deploy only after all of these are true:
origin/mainis fetched and integrated.git diff --name-only --diff-filter=Uis empty.- The relevant tests or validation command completed successfully.
- The final
git status --short --branchhas only expected local changes.
Failure Policy
If main integration, replaying dirty changes, or verification fails, do not deploy. Report:
- the branch and
origin/maincommit, - the files that conflict or tests that fail,
- whether the deployment was skipped,
- the exact next action needed.
Do not “deploy anyway” unless the user explicitly overrides after seeing the conflict or failure.
Notes
- If the branch intentionally targets beta but the user asks to deploy, still integrate
origin/mainfirst unless they explicitly say not to. - If the worktree is dirty, prefer the checker script or a stash-based flow over destructive commands.
- Never use
git reset --hardorgit checkout --to make the sync work unless the user explicitly asks for destructive cleanup.