The passé composé, compared to the imparfait, is used when talking about finished actions in the past. The imperfect, therefore, is used when we want to talk about past actions that had no obvious completion, or occurred habitually. For example, in the sentence "I was playing football yesterday, when the phone rang", "I was playing football yesterday" would be imparfait (je jouais) as it is an unfinished action. "When the phone rang" would be passé composé (quand le téléphone a sonné) as it is a finished action in the past. Further, the imparfait is often known as the "descriptive tense". Thus, when talking about descriptive elements, like the weather (in the past), you would use "il faisait chaud" rather than "il a fait chaud".
As for habitual actions in the past, the imparfait is used. For example: "I used to write stories about my role models" (J'écrivais), or "When I was younger I played the guitar" (Je jouais). However, if these sentences are changed slightly to have a more determined end to the action, the verb becomes the passé composé: "I once wrote a story about my role models" (J'ai écrit), or "I played the guitar one time when I was 6 [and then realised I didn't like it" (J'ai joué).
Certain phrases can help to indicate whether the imparfait or the passé composé should be used. Phrases which suggest repeated actions like "chaque jour" of course demand the use of the imparfait, whereas more specific phrases like "un jour" or a certain day "mercredi" necessitate the use of the passé composé.