Listed below are uses with examples, and the structure of the past perfect tense.
Something that had happened before something else took place
I had eaten lunch before they arrived.
Susan had already finished the project when he asked for help.
Something that had happened over a period of time in the past before another point in the of past
I had lived abroad for twenty years when I received the transfer.
Jane had studied in England before she did her master's at Harvard.
Something that had happened as a precondition to something else
I had prepared for the exams and was ready to do well.
Tom had lost twenty pounds and could begin anew.
In the third conditional to express imagined conditions
If I had known that, I would have acted differently.
She would have come to the party if she had been invited.
With wish to express a desire about the past
I wish you had told me.
She wishes she had known about his problems.
Common time expressions used with the past perfect:
already, just, before, when
Subject + had + past participle
I, You, He, She, We, They had finished before I arrived.
Subject + had + not (hadn't) + past participle
I, You, He, She, We, They hadn't eaten before he finished the job.
Question word + had + subject + past participle
What -> had he, she, you, we, they thought before I asked the question?