Matthew 7:22-23 English Standard Version (ESV)
22 On that day many will say to me, ‘Lord, Lord, did we not prophesy in your name, and cast out demons in your name, and do many mighty works in your name?’ 23 And then will I declare to them, ‘I never knew you; depart from me, you workers of lawlessness.’
If we rely on our works to save us we have failed. If we think that works are a sign of salvation we are deceived. We know who deceives, it is Satan.
Verse 20 says we will be known by our fruits.
Galatians 5:22-23 English Standard Version (ESV) But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, self-control; against such things there is no law.
Note closely that the issue of law is mentioned. These fruits are produced by the Holy Spirit by virtue of His presence in the body and not by obedience on our part. Neither obedience to law nor obedience by faith produce these fruits. It is the primary sign of the indwelling Holy Spirts.
This is the primary sign of our salvation. The Holy Spirit produces them and not we ourselves.
Can they be replicated by the flesh? Sure, but like all things of the flesh they will wither and die. Flesh produces death, they will wither.
Jeremiah 8:13 English Standard Version (ESV) When I would gather them, declares the Lord, there are no grapes on the vine, nor figs on the fig tree; even the leaves are withered, and what I gave them has passed away from them.
Return to Matthew 7:23 again for a moment. Jesus declared that He never knew them. This indicates there is no relationship. They were not His sheep, they harkened to the voice of a different master. The issue of those works being lawless is best understood as not being authorized by the will of God.