I've always been told NFPA Electrical Code requires 3 feet clear, and have been in a shop where a fire inspector made them move equipment because it was within 3 feet of a circuit breaker box.
I just remembered a caveat to 3 feet. "Or door swing if greater"
I had to help a shop disconnect a long machine that the control panel was a few sections of 3 foot tall by 4 foot wide single-door enclosures across the back.
They placed the machines 3 foot from the back wall but an inspector made them move them out more so the 4 foot wide doors could swing fully.