The passé composé is used for completed actions and events that occurred at a specific time, whereas the imperfect is used for actions that were interrupted, or happened on a non-specific basis.
Examples:
Passé composé: Il y a deux jours, j'ai mangé le petit déjeuner avec mes amis. (Two days ago, I ate breakfast with my friends). This is an event occurring on a specific, one-off basis.
Imperfect: Je mangeais le petit dejeuner avec mes amis quand je me suis cassé le bras. (We were eating breakfast when I broke my arm). The action is interrupted by a clean-cut, one-off happening (breaking my arm)
OR
Je mangeais le petit déjeuner a sept heurs quand j'étais plus jeune. (I ate/ I used to eat my breakfast at 7 when I was younger). Eating breakfast in this case happened on multiple occassions when I was younger, not on a specific occassion.