Here is the NCAA rule (because it's what I have easiest access to). FED and OBR (for Minor Leagues) are very similar:
c. Batter’s-Box Rule. This rule is designed to speed up play by controlling the
actions of the batter between pitches.
(1) The batter must keep at least one foot in the batter’s box throughout the
time at bat.
Exceptions
—A batter may leave the batter’s box but not the dirt area
surrounding home plate when:
(a) The batter swings at a pitch.
(b) The batter is forced out of the box by the pitch.
(c) A member of either team requests and is granted time.
(d) A defensive player attempts a play on a runner at any base.
(e) A batter feints a bunt.
(f) A wild pitch or passed ball occurs.
(g) The pitcher leaves the dirt area of the pitching mound after receiving
the ball.
(h) The catcher leaves the position to give defensive signals.
PENALTY for (1)—If the batter intentionally leaves the batter’s box and
delays play, and none of these exceptions applies, the plate
umpire shall award a strike. The pitcher shall not pitch but the
ball is live (e.g., a pick-off attempt).
(2) The batter may leave the batter’s box and the dirt area when time is
granted for the purpose of:
(a) Making a substitution.
(b) An offensive conference.
(c) A defensive timeout or conference.
d. If the batter’s-box penalty is applied, and the batter then refuses to re-enter the
batter’s box, the umpire shall award an additional strike. The pitcher shall not
pitch but the ball is live.