The straightforward answer is when the normal order is swapped, and the object comes before the past participle. This means that you would say "J'ai écrit une lettre", but you would talk about "la lettre que j'ai écrite", "la chose que j'ai faite", "l'idée que j'ai eue". The object ("une lettre", "une chose", "une idée") being placed in an unusual place in the sentence (ie. not after the verb where it is normally) triggers agreement.Often I find it easiest to think of it as: when your main verb comes after 'que' then you should watch out for agreement! This doesn't cover all scenarios, but works well as a rule of thumb.