The Torah commands us to refrain from melakha on Shabbat. The Sages added a protective fence by prohibiting deriving benefit from melakha done on Shabbat (ma’aseh Shabbat), as it is improper to benefit on Shabbat from Shabbat desecration. Whether the melakha was done knowingly (be–mezid) or unknowingly (be-shogeg), it is forbidden for any Jew to benefit from the melakha for the rest of that Shabbat. Some maintain that if the melakha was done be-shogeg, one may benefit from it. Some rely on this opinion under pressing circumstances (as explained in the next section). For our purposes, shogeg means that one was aware of his actions but forgot that it was Shabbat or was unaware that this act is a forbidden melakha on Shabbat; we have translated it, here and elsewhere, as “unknowing.”
After Shabbat, anyone may benefit from a melakha that was done on Shabbat except for the perpetrator, if he did it be-mezid, who may never benefit from it (SA 318:1, as explained in section 7 below).
If a small child performed a melakha on Shabbat on behalf of an adult, during Shabbat no one may benefit from it. On Saturday night, anyone may benefit once enough time has passed that the melakha could have been completed after Shabbat. If the child did the melakha for his own sake, an adult may benefit from it on Shabbat (above, 24:4).
If a non-Jew did melakha on Shabbat for a Jew, no Jew may benefit from it until enough time has elapsed after Shabbat for the melakha to have been completed, so that no one benefits from melakha done on Shabbat and no one profits from work done by a non-Jew on Shabbat (above, ch. 25 n. 2). If a non-Jew did a melakha for himself, a Jew may benefit from it on Shabbat (above, 25:2). In some cases, one may hint to a non-Jew to do melakha on Shabbat (above 25:3). For the sake of a mitzva, or to avoid great loss or suffering, one may ask a non-Jew to do a rabbinically prohibited melakha (25:4).