It is written (Romans 5:18): "As by the offense of one, unto all men to condemnation; so also by the justice of one, unto all men to justification of life." But Adam's demerits reached to the condemnation of others. Much more, therefore, does the merit of Christ reach others. [ST III, Q19, A4]Even more clearly:
As the sin of Adam reaches others only by carnal generation, so, too, the merit of Christ reaches others only by spiritual regeneration, which takes place in baptism; wherein we are incorporated with Christ, according to Galatians 3:27, "As many of you as have been baptized in Christ, have put on Christ"; and it is by grace that it is granted to man to be incorporated with Christ. And thus man's salvation is from grace. [ibid., ad 3; emphasis added]So does this mean that how we live has no role to play in the life of a Christian? Certainly not. But it does mean that nothing we do would mean a thing for our salvation apart from grace. I've quoted this before, and I'm sure I'll do so again in this series.
What else but His gifts does God crown when He crowns our merits? [St. Augustine, Letter 194 to Sixtus]And as I've pointed out, this is precisely what the Church has always taught.
The charity of Christ is the source in us of all our merits before God. [CCC §2011]But the main point here is for us to see that our salvation is from grace - not from ourselves at all. Hence those who accuse the Church of teaching a salvation founded upon works are badly misinformed. Any merit we have for salvation is from Christ alone - not from ourselves.