“We went out to fight alongside the Messenger of Allah (ﷺ), and we passed by a slain woman whom the people had gathered around. They parted (to let the Prophet (ﷺ) through) and he said: ‘This (woman) was not one of those who were fighting.’ Then he said to a man: ‘Go to Khalid bin Walid and tell him that the Messenger of Allah (ﷺ) commands you: “Do not kill any children or women, or any (farm) laborer.’”

Another chain reports a similar hadith.
Sunan Ibn Majah Book 24, Hadith 90