We almost always build our doors slightly wider than the trim that is currently around your opening. We also build the door slightly taller than the trim. This is because our doors are square and need to be perfectly level when installed or they will roll on their own – not a good thing. Trim is often not perfectly level at the top nor is it totally plumb at the sides. So if the door does not cover this, the reveal looks pretty bad. So the best solution is build a door to cover all trim.
When there is no trim: We usually make the door 2″ wider on each side. This is particularly important if you want privacy. We are not worried about the trim not being plumb, but we do not want a gap that is too big in this situation.