Marshall has been keenly chased by Romans chief Gary Owers throughout the summer and committed ahead of Saturday's 1-1 friendly draw with Oxford United.
The youngster came up through the Robins' ranks and made his debut in 2014 during a Capital One Cup clash with Luton Town.
He would go on to make two starts in six games for Swindon, but was released by manager Luke Williams at the end of last season.
The 19-year-old has turned out in five of Bath's six pre-season friendlies to date, and also played once for Cheltenham Town during an unsuccessful trial.
And Owers revealed that Marshall had agreed a contract and put pen-to-paper.