The pacer posted a picture of his wife on Facebook and Twitter on Sunday, with the words "beautiful moments".
But some users told him to "follow Islam" and "ensure that she wears the hijab and modest clothes".
The cricketer on Monday tweeted that he "knows what to do and what not to do for his family".
Some people commented that the cricketer should be "shameful" for "allowing his wife to wear revealing clothes".
"Shame on you. As a Muslim, keep your wife in purdah [covered clothing]. Learn from others," one user commented.
Shami responded that the trolls needed to "look inside".
"My child and my wife are my companions in life. I exactly know what to do and what not to do for them. We all need to look inside to know how good we are," he tweeted.
Other users, including fellow cricketer Mohammad Kaif, have also criticised people for posting "shameful comments" on Shami's social media accounts.