Q. Dear Rov. If someone avoids doing an avera (sin) our Sages tell us that it is considered as if a mitzva similar or corresponding was performed. If the mitzva involved was Biblical, does one need to have in mind the Kavana to keep that mitzva, as is required in the performance of all positive Biblical commands?
A. Actually you may be referring to the saying of Rav Ashi quoted in Talmud (Brochos 6a);
“If one thought of performing a mitzvah, yet against his will could not comply with it, it is considered as if he actually did it. That being the case, since he actually was fully committed to the compliance of the mitzvah, it is considered as he actually had the right and proper intention.
Chasam Sofer (Res. C.M. 1) explains that it reflects Hashem’s love to us and it is not a truly a legal Halacha legal obligation.
Horav Shlomo Miller’s Shlit’a opinion is similar.
Rabbi A. Bartfeld as revised by Horav Dovid Pam, Horav Aharon Miller, Horav Chanoch Ehrentreu Shlit’a and Horav Kalman Ochs Shlit’a.