States that you have (or have never) done something at least once in your life — past experience, not a simple past action. Roughly 'I have (ever) done X'.
[Verb ta-form] + ことがある / ことがない
彼女に嘘をついたことがある。
Kanojo ni uso o tsuita koto ga aru.
I have lied to her before.
嘘をついた (lied, ta-form) + ことがある (there is the experience of ~)
寿司を食べたことがありません。
Sushi o tabeta koto ga arimasen.
I have never eaten sushi.
食べた (ate) + ことがありません — negative erases the experience ('never')
一度だけ京都へ行ったことがある。
Ichido dake Kyouto e itta koto ga aru.
I have been to Kyoto just once.
行った (went, ta-form) + ことがある (have the experience of going)
• Use it for notable, rare, or 'have you ever' experiences — not for routine things you just did (you wouldn't say you 'have the experience of' brushing your teeth this morning). • Polite: ことがあります / ことがありません. Plain: ことがある / ことがない.
The JLPT rarely asks whether you recognise a pattern — it asks which of several similar patterns fits. These are the ones たことがある is tested against.
〜た states that a specific action happened ('I ate sushi yesterday'); たことがある states you have ever had the experience ('I have eaten sushi (at some point)').
Dictionary-form + ことがある means 'there are times when ~ happens' (occasional habit); the たform version means 'have done before' (past experience).
Study Japanese grammar on LenGaki

Get the Android app
The app adds offline study, home-screen widgets, stroke-order tracing, speaking practice with pronunciation scoring, and an AI tutor that answers questions in context — none of which fits in a browser tab.