# Template: recover from bad state Copy, fill the `<...>` fields, paste as the task prompt. Recovery is read-then- act: gather facts first, never discard unmerged work. ```text Task: recover repo state for . Do not lose unmerged work. Rules (llm-project-workflow): - Fail closed: if state is unclear or a step would delete unmerged work, STOP. - Never push master. Never discard commits not safely pushed to . Diagnose first: 1. git fetch --prune 2. git status --short; git worktree list 3. git rev-list --left-right --count /master...master # ahead/behind 4. For any PR involved: confirm state (open/closed/merged) AND whether /master actually contains its commits ("closed" != "merged"). Act per case: - Dirty worktree from another issue: leave it; start yours in a new worktree. - Local master ahead of remote: confirm the extra commits live on a branch pushed to , THEN git reset --hard /master. Verify with `git branch --contains ` first. - PR closed but not merged (`merged=false`): stop normal flow and use reconcile-closed-not-merged-pr.md instead. - Branch deleted before merge: recover commits from a local branch/reflog (or git fsck --lost-found), re-push, reopen the PR. - Unauthorized untracked file: do not commit it; leave pre-existing artifacts. Handoff: what was wrong, evidence, action taken, current state, what remains. ```