As the previous writer mentioned, salvation has always been by faith.
This concept is in the Old Testament in Habakkuk:
"Behold, as for the proud one,
His soul is not right within him;
But the righteous will live by his faith." (Habakkuk 2:4)
Also the Bible says:
"Even so Abraham believed God, and it was reckoned to him as righteousness. Therefore, be sure that it is those who are of faith who are sons of Abraham. The Scripture, foreseeing that God would justify the Gentiles by faith, preached the gospel beforehand to Abraham, saying, 'All the nations will be blessed in you.' So then those who are of faith are blessed with Abraham, the believer." (Galatians 3:6-9)
This means:
1. Abraham was credited with righteousness before the time of Christ. God deemed Abraham righteous, because he believed God's word as it was revealed to him.
2. God preached a shortened version of the gospel to Abraham (Galatians 3:8).
3. All who believe by faith, who are born later, are called children of Abraham and blessed with him.
So for Old Testament saints, it can be said, they had something like a credit card. The credit card is their faith in God. The Old Testament saints did not have the full gospel but a partial one. This gospel was slowly revealed to them (whether they understood it or not). If they believed God's word to them (even if they did not see the whole picture), God credited righteousness to them beforehand.
So like a credit card, in which a person gets the goods, but the payment is withdrawn from the bank later, so also Jesus died later for Old Testament saints, but God gave them the goods (heaven) first! Jesus died for people of the past, present and future. He died once and for all.
Jesus said: "I am the way, and the truth, and the life; no one comes to the Father but through Me." (John 14:6)
It is Old Testament people's faith in God's promise that saved them.
---
The confusion might stem from verses in the Old Testament that required strict keeping of the Mosaic law. The Mosaic law, including the ten commandments and lesser commandments, are all in the Torah (or first five books of the Bible). The Torah contains Genesis, Exodus, Leviticus, Numbers, and Deuteronomy.
It is not that the minor laws are outside the Torah. Over 600 laws are inside the Torah itself. The books of Leviticus, Numbers, and Deuteronomy contain many of the minor laws.
So an Old Testament saint was required to keep these laws, as many as he could (though humanly impossible).
This made Old Testament saints realize the need for a Savior and salvation by faith to overcome human shortcomings.
It is humanly impossible to keep these laws, but the laws were there to point to the need for Christ.
---
No one can save himself by his good works, because no good deed can cancel out bad deeds or bad thoughts. That is why salvation has always been by faith.
At the same time, the concept of living out one's faith, by repenting from sin and doing good works, has always been in the Bible too.
Faith is not lip-service. Faith involves action. Faith means believing God's word and being faithful to God too.
"Everyone who names the name of the Lord is to abstain from wickedness." (2 Timothy 2:19)
Jesus said, "Blessed are those who hear the word of God and observe it." (Luke 11:28)
"By this we know that we have come to know Him, if we keep His commandments. The one who says, 'I have come to know Him,' and does not keep His commandments, is a liar, and the truth is not in him; but whoever keeps His word, in him the love of God has truly been perfected. By this we know that we are in Him: the one who says he abides in Him ought himself to walk in the same manner as He walked." (1 John 2:3-6)
These verses show that if someone sins like the devil, but says he believes, is a liar.
The one who truly believes would act accordingly instead of performing lip-service.
If we perform lip-service only, we act like demons, because demons believe God exists and Jesus saves, but their deeds are evil.
“You believe that God is one. You do well; the demons also believe, and shudder” (James 2:19).
So genuine faith is believing and learning to be faithful. It is not our works that save us, because we are not perfect and we cannot atone for our bad deeds. It is Jesus who alone atones for our sins.
---
After we have believed in Jesus, then we should not keep sinning on purpose.
The Bible says: “For if we go on sinning willfully after receiving the knowledge of the truth, there no longer remains a sacrifice for sins, but a terrifying expectation of judgment and the fury of a fire which will consume the adversaries” (Hebrews 10:26-27).
If we continue to sin casually, then we haven't truly believed. Because if we truly believe in Jesus, then we would do what He says. Believing in Jesus is having faith in Him and learning to be faithful too.
But if you have any sins, ask God's forgiveness and repent. "He is faithful and righteous to forgive us our sins and to cleanse us from all unrighteousness" (1 John 1:9).
Repent of any sins and learn to follow Jesus from now on. Rely on God and work with Him by prayer and diligence to overcome any known sins.
Reference: Old Testament Saints resurrection