I suspect it is allowed and quite common in areas with separate garages and/or other outbuildings. Last time I looked at the condensed code books (e.g, Home Depot and Lowes) there were instructions for doing that. A separate ground may be required, if it's a building with outlets. 30A is about what a water heater or dryer may draw. What you seem to be proposing is no different than putting the water outside your back door.
In my case, the barn, which is about 150 feet away, has a separate meter, grounding, etc. and over 100A service. That was required at the time, probably by the high current needs. It's a pain because of the minimum billing per meter, and I don't meet that in the Winter. A detached, wood burning boiler for heat is just a branch circuit. It's about 50 ft away.
EDIT: My error. I misread the original post and now see that the proposal is to branch before the main switch. I thought the intent was after the main switch, which is why I made analogy to a water heater, etc. Why not do it after the main switch? If you do that, the breaker for the branch might require a lock out, which is a very inexpensive addition.
EDIT2: This "code" seemed to indicate the branch came after the main breaker: