Great question! It is completely legal to ride outside of the bike lane.
According to MGL ch. 85 § 11B, bikers have the right to ride anywhere that a car could legally drive (except on state highways where signs are posted). This applies whether there’s a bike lane or not.
This section further states that cyclists must follow all of the traffic laws that cars do. However, the statute grants us the following three exceptions: 1) bikers can pass on the right, 2) bikers must use hand signals, unless it’s too dangerous to do so, and 3) bikers can ride on the sidewalks if necessary for safety, as long as it’s outside of the town’s “business districts,” and there is no local ordinance prohibiting it.
Now, the next important question: can cars be in the bike lane?
MGL ch. 90E § 1 defines a “bike lane” as being restricted to bicycles (defined as “a two-wheel nonmotor-powered vehicle”).
[EDIT: the law also allows for “motorized bicycles" (ebikes, certain mopeds, etc.) to use bike lanes, though they are restricted from using bike paths.]
So there you have it: bikes can go (almost) anywhere cars can go, as well as in the bike lanes where they cannot.
Riding on the edge of the bike lane is definitely a good idea, especially during rush hour. I bike to work at the same time, and I always avoid the “door zone” at all costs. Sometimes it’s safest to leave the bike lane altogether, so feel free to “take the lane,” so to speak.
Hope that answered your question!