Some of your scripts could possibly use `origin/HEAD` and reflect whatever origin thinks is the default branch. (Though obviously that assumes you always have an `origin` remote or something remote-like.) Including using the commit referenced by `origin/HEAD` to find the `origin/{branch-name}` that matches if you want a name to check locally.
I had a few frustrated evenings of debugging when Github changed the default to main and my local scripts expected "master".
All fixed now, but still an annoyance. Don't think about it much anymore.