Start with the question: what is the problem that you want to solve? Next, find codebases that solve that problem and study how they do it.

Good design is so deeply tied to the domain details. Wonham's Internal Model Principle applies to code.

Example: I wanted to solve the problem of unit testing for embedded targets. I found open source projects that do this and read the code critically to see how and why it is written. As I build my own approach, I revisit theirs to learn more as my understanding of the domain deepens.