The Scripture says: "For we are God's handiwork, created in Christ Jesus to do good works, which God prepared in advance for us to do" (Ephesians 2:10). This follows verse 8 and 9:
"For it is by grace you have been saved through faith, and this not from yourselves; it is the gift of God, not by works, so that no one can boast."
This means that although we are saved by grace and not by works, we receive the Holy Spirit who work in us to produce the good works which God has prepared for us to do. Once we are saved by grace through faith, there is a transformation that occurs within us that causes us to hate sin and to love righteousness, causing us to demonstrate our conversion to Christ by conducting ourselves commensurate with it.
This is what James is saying: that if we say we have been saved by grace through faith, and don't show evidence of it through a transformation from doing the works of the flesh to the good works that result from walking in the Spirit, then our faith is in vain, or as James says, dead.