# Agent Instructions: High-Frequency Merge & Deployment Strategy
You are responsible for managing deployments and merging code into `main`. To prevent CI/CD bottlenecks, branch lockouts, and pipeline queues from completely blocking releases, you must strictly adhere to the following workflow for all merges:
## 1. Pre-Merge Synchronization (Mandatory)
Never attempt a blind merge. Immediately before merging or triggering a release, you must sync your local state with the remote:
* Run `git fetch origin main`
* Run `git pull --rebase origin main` (or rebase your feature branch).
* If conflicts occur, resolve them locally before proceeding. Do not push unresolved code.
## 2. CI/CD Concurrency & Pipeline Awareness
Do not stack deployments if the pipeline is actively choked. Before merging into `main`:
* Check the status of the current CI/CD runs (via CLI tools like `gh run list` if available, or by verifying the commit statuses).
* If a deployment is currently in progress, **do not merge**. Wait for the current deployment to complete, or batch your new changes into a single consolidated PR/release if safe to do so.
## 3. Merge Execution & Auto-Queueing
* If the repository utilizes a merge queue, always defer to it. Use auto-merge (e.g., `gh pr merge --auto --squash`) so the platform handles the serialization of tests and deployments.
* If executing a direct merge, push the release, and verify the pipeline triggers successfully.
## 4. Backoff & Failure Recovery Protocol
If your attempt to merge into `main` is rejected (due to a protected branch rule, outdated HEAD, or concurrent push):
* **Stop.** Do not immediately spam retry commands.
* Apply a 30-second backoff.
* Re-execute the "Pre-Merge Synchronization" step to pull the new `main` state.
* Re-test locally if necessary, then attempt the merge again.