OpenCode commands: /safe-git-commit and /clear-safe-git — safe git commits with automatic backup snapshots OpenCode introduced two new commands, /safe-git-commit and /clear-safe-git, that enable developers to safely commit changes with automatic backup snapshots. The /safe-git-commit command creates a backup ref before staging and committing, allowing recovery if anything goes wrong. The /clear-safe-git command cleans up backup refs when no longer needed. | description | Safely commit changes with automatic backup snapshot | | agent | build | BRANCH=$ git rev-parse --abbrev-ref HEAD && BASE=$ git rev-parse HEAD && REF NAME="$BRANCH-$ date +%s -$$" && ORIG INDEX=$ git write-tree && git add -A && STASH=$ git stash create -u && git read-tree $ORIG INDEX && if -n "$STASH" ; then git update-ref "refs/safe-git/$REF NAME" $STASH && printf 'BACKUP CREATED\nBase: %s\nStash: %s\nRef: refs/safe-git/%s\nRecovery: "git reset --hard %s && git stash apply --index refs/safe-git/%s && git update-ref -d refs/safe-git/%s"\nCleanup: "git update-ref -d refs/safe-git/%s"\n' "$BASE" "$STASH" "$REF NAME" "$BASE" "$REF NAME" "$REF NAME" "$REF NAME"; else echo 'NO CHANGES — working tree is clean. Nothing to snapshot.'; fi If the output above says NO CHANGES, tell the user "Nothing to snapshot — working tree is clean" and stop. Do nothing else. If the output says BACKUP CREATED, follow this procedure: - Echo the recovery and cleanup commands to the user BEFORE making any changes. Copy the exact Recovery and Cleanup lines from the output above and show them to the user. This ensures they can recover or clean up manually if needed. - Process the current changes and split them into logical, well-described commits. Stage hunks, make individual commits with meaningful messages. - If anything goes wrong — a bad commit, incorrect staging, validation failure, or any error — run the recovery commands shown above to automatically restore the working directory and staging area to the state before any changes were made . Then stop and report what happened. - Do NOT clean up the backup ref automatically after committing. Leave the backup ref in place. Only delete it if the user explicitly asks with a command like "clean up the backup" or by running the Cleanup command themselves.