Under the New Covenant, everyone is deemed a sinner AND have come short of the glory of God, Romans 3: 23. So, no one can save themselves by having done good things, or a good person of their own making, they fall far short of the mark for God's standard for perfection. All the scripture is saying, is that ANY good works of our own, are in God's eyes filthy rags, Isaiah 64: 6. So, leaving our own righteousness behind, we come by faith ALONE to be SAVED. But AFTER salvation, we begin the journey of obedience to what is right and pleasing to the Lord, called works of righteousness. Salvation has already happened back then, when we come to Christ by faith alone, but the maturing IN that new creature is a lifetime endeavor, in which some will fall away, by leaving Christ and embracing the pleasures once again of this world. So the scripture is saying that after salvation, our works of good will PROVE our allegiance. That is what James is talking about in James 2: 17, 24, 26.