I can't vouch for code, but that's certainly something I would expect would meet code -- you're just using the first switchbox as an unswitched junction box (which should be legitimate), and Red is being used correctly as second/switched hot.
Then of course your smart switch in the other box connects between black and red, with white used as the neutral for its electronics and otherwise not going anywhere.
Assuming you make the connections properly, and unless I'm missing something....
Quick point: Remember that junction boxes must be accessible for service, so you can't plaster over that repurposed switchbox. You can cover it with a blank plate painted/papered to match the wall, hang art over it, put freestanding furniture in front of it, or a combination of these... but an electrician has to be able to find it and open it up without having to break into the wall.
(Thanks for making me think this through, by the way. I have several two-way circuits, and I too have plans for home automation eventually. Unfortunately I think I have to wait until most of these non-dimmable CFLs burn out and I can replace them with dimmable LEDs.)