The command isn’t to never lie, but never to give false testimony AGAINST your neighbor.Hebrews 11:31
[31]By faith the harlot Rahab perished not with them that believed not, when she had received the spies with peace.
It wasn't Rahab's lie that God commended her for. It was her works of faith. She believed on the one true God, and received the spies, and sent them. She most likely didn't know the commandment of God not to lie.
Nowhere in scripture does it say that she was commended for lying, which was a sin. ALL of us have sinned and fallen short, and if we believe on Christ, we have all been recipients of God's mercy, grace, and forgiveness. He blesses us despite out failures, not because of them.
That’s specific and not a generalization.
It’s not a sin to lie to save a life.