3“Abraham believed God (about the promise of a son), and it was
credited (or counted) to him as righteousness.” Romans 4:3
When we believe in and receive God's forgiveness our unrighteousness is wiped away by that forgiveness and God deposits a perfect and complete measure of
His righteousness in our heavenly 'righteousness' account.
22 ...this righteousness
from God comes through faith in Jesus Christ to all who believe. Romans 3:22
It's not the righteousness of our faithful works that gets put in to that account. It's God's perfect righteousness being credited to our account
before and apart from any consideration of our works. And it is upon that deposit of righteousness, God's righteousness gifted to us through faith in the cross, that we are declared to be in good standing with God, prepared to meet Him in judgement in the perfect righteousness of Christ, not our inadequate righteousness, at the end of the age.