He eats snacks on the sly when he is on a diet.
on the sly
idiomSlyly, in an inconspicuous manner, so as not to be seen; secretly; stealthily.
The employees were using their phones on the sly during the long meeting, hoping the manager would not notice.
Although the treaty strictly forbade the trade of weapons, the two nations continued to exchange supplies on the sly to avoid international sanctions.