I totally agree with this. I also find it’s best to take the lane in urban traffic where you’re not impeding the flow of traffic. The people I see getting in trouble/hurt are those (curiously, largely boomers) who insist on weaving around cars or moving up on the right without room. Just get in with the cars and move predictably.
Cycling is my primary mode of transportation, and I've found a couple things help with this:
1. Take the lane any time there's a chance of conflict such as a right hook, and when there is not enough space for a car to safely pass [1][2]
2. Use a headlight all the time, even during the day. This is what motorcyclists do, and when I made this change I noted a major drop in the number of drivers that turn without noticing me.
[1] https://en.wikipedia.org/wiki/Vehicular_cycling#Lane_control
[2] This page has descriptions of several types of collision, with example videos and how to choose a lane position that avoids them: https://iamtraffic.org/engineering/behaviors-and-risk/