One way to determine this, used by the Freedesktop tools, is to check first if the env variable exists (XDG_CONFIG_HOME), and if not, check if the `$HOME/.config`folder exits. That's the implementation in `pyxdg`. I mention it here[1]
Regarding the alternative option of a Clojure CLI-specific environment: Although I would personally prefer XDG taking precedence over `.clojure`, I would prefer that specific option over the current situation, and I'm just going to point to Haskell#Stack as one example doing that[1]
The reason is that I, as an XDG user, have more software than just Clojure, and I don't want Clojure to determine whether or not I have to set the` XDG_CONFIG_HOME`. I think It should be backward. I decide whether I set that variable or not, I decide whether I take advantage or not of XDG, and then I install Clojure, and maybe tell it to respect XDG or not. I still would prefer not to tell that last part to Clojure, but I understand the compromises.
Notice most other examples in that Archlinux table made the full migration, where the `$HOME/.name-of-the-software` is considered Legacy and the default behavior is to follow XDG.
I think that from Clojure point of view, the new ideas would be something like:
<xdg-config-path>/clojure exists? and ~/.clojude doesn't exist? use the existing one.
<xdg-config-path>/clojure doesn't exist and ~/.clojure exists? use the existing one.
But Both exists? ... well, you decide.
But Nothing exists? ... you also decide :D.
[1]
https://clojureverse.org/t/opinion-about-xdg-support-by-the-clojure-tools-deps-cli/9814/3?u=jgomo3
[2] In the table that @sg-qwt shared from the Archwiki, search for Haskell#Stack:
https://wiki.archlinux.org/title/XDG_Base_Directory