How “an” works
An eclipses: an bhfuil, an dtagann, an mbeidh, an ndeachaigh. Ar is used with the past of regular verbs and lenites: ar tháinig, ar ith (a vowel cannot change). A negative question is nach with an urú, or nár in the past: nach bhfuil sé fuar?, isn't it cold? To answer, repeat the verb: tá or níl, bhí or ní raibh, tháinig or níor tháinig.
“An” in questions
Other question words
Asking a yes or no question in Irish (an, ar, nach): the questions people ask
How do you say yes and no in Irish?
There is no single word. You answer with the verb of the question: An bhfuil tú réidh? Tá (yes) or níl (no). Ar tháinig sé? Tháinig or níor tháinig. With is: is ea and ní hea.
When is it an and when is it ar?
Ar only goes with the past tense of a regular verb and lenites it: ar chuir tú? Everything else takes an with an urú, including the irregular pasts that have a dependent form: an raibh, an ndeachaigh, an bhfaca.