The rule
Passé composé marks a completed action, something that happened and finished. Imparfait describes a state, a habit, or the background scenery of a story.
In practice
Il pleuvait quand je suis sorti.
It was raining (ongoing background) when I left (one finished event). One sentence, two camera angles.
The mistake almost everyone makes
Treating it as a vocabulary problem instead of a framing problem. The verb does not decide the tense, your framing of the action does.
J'ai été fatigué toute la journée.
J'étais fatigué toute la journée.
Practice, the way you will use it
Tell me about yesterday. Not a worksheet, a real five-minute story, corrected live, so the rule attaches to something you actually said.