There is no "out of context" at all. Do you now think Paul would contradict himself rather than just James??? If Paul just got done saying we are saved by grace through faith and not works, why-o-why would he immediately contradict that by adding works to being saved? This is not that hard! God created us FOR the works He has prepared for us to walk in, He doesn't say those works are what saves us. What saves us is His grace whereby the gift of God which is eternal life is given to us through faith and not on the basis of our earning, deserving or meriting it.
If someone wants to boast about how his own works of righteousness are saving him, God says he has fallen from grace. Either we are saved by grace or by our works - not both. It can't be both. See Romans 11:6.
It IS BOTH!
Matt 7:21Not everyone who says to me, Lord, Lord, will enter the kingdom of heaven, but only the one who does the will of my Father in heaven.
Ephesians 2:8 For by grace you have been saved through faith, and this is not your own doing; it is the gift of God 9 not the result of works, so that no one may boast. 10 For we are what he has made us, created in Christ Jesus for good works, which God prepared beforehand to be our way of life.
1 Corinthians 9:27 but I punish my body and enslave it, so that after proclaiming to others I myself should not be disqualified.
2 Timothy 2:12 if we endure, we will also reign with him; if we deny him, he will also deny us;
Philippians 2:12 Therefore, my beloved, just as you have always obeyed me, not only in my presence, but much more now in my absence, work out your own salvation with fear and trembling; 13 for it is God who is at work in you, enabling you both to will and to work for his good pleasure.
James 2:14 What good is it, my brothers and sisters, if you say you have faith but do not have works? Can faith save you? 15 If a brother or sister is naked and lacks daily food, 16 and one of you says to them, Go in peace; keep warm and eat your fill, and yet you do not supply their bodily needs, what is the good of that? 17 So faith by itself, if it has no works, is dead.
James 2:24 You see that a person is justified by works and not by faith alone. 25 Likewise, was not Rahab the prostitute also justified by works when she welcomed the messengers and sent them out by another road? 26 For just as the body without the spirit is dead, so faith without works is also dead.