to know sth perfectly so that you can repeat it at any time without having to think about it
have / know sth off pat
to know sth perfectly so that you can repeat it at any time without having to think about it
He had all the answers off pat.
Definitions from the Oxford Advanced Learner's Dictionary, 9th edition