The Sages learn from the verse, “You shall not do any melakha” (Shemot 20:10), that the Torah prohibits the actual performance of a melakha, but if the melakha is done automatically, even if a person caused it to be done, it is considered grama (causation), and it is not prohibited by the Torah. In cases of great necessity, one may use grama to achieve the result of a melakha. For example, if a fire is spreading, one may surround the fire with containers filled with water so that when the fire reaches them, the containers will burst open and the water inside them will pour out, putting out the fire (Shabbat 120b; SA 334:22). All agree that grama is permitted only in exceptional circumstances: to avoid loss, in service of a mitzva, or for some other great need. Barring these circumstances, one may not cause melakha to be done on Shabbat (Rema 334:22).
There are some melakhot whose normal matter of performance is through grama, and so one who performs them, even though grama, is liable. For example, Zoreh (winnowing) is a Torah prohibition even though the separation of grain from chaff is accomplished by the wind; tossing the mixture in the air is merely a grama, yet this is the normal way of performing the melakha (see BK 60a). Similarly, one who places a pot on the fire transgresses a Torah prohibition even though he is only causing the food to be cooked by the fire, since that is the normal way people cook. In other words, grama is relevant only when the melakha is performed in an unusual manner. In such a case, if the melakha is performed via an indirect action, there is no Torah prohibition, and one may use this method in cases of great necessity.
In general, if an action looks like the result of direct human action, it is attributed to the person performing it, and it is prohibited by Torah law. When it is not obvious that his deeds are causing the action, but only that he is indirectly causing the melakha to be done, this is considered grama. For example, if one removes a dam that had been holding back water and the water that is released performs a melakha, if that melakha takes place close at hand it is called ko’aĥ rishon (firsthand force), and the person who performed the initial action is held completely responsible for the melakha. But if the melakha happens at a distance, it is called ko’aĥ sheni (secondhand force), and is considered grama. Along the same lines, if the melakha is done immediately after the causative action, it is considered a direct action and is prohibited by Torah law, while if the person’s initiative leads to a melakha being performed only after some time has passed, it is considered grama. Regardless, if the normal way to perform the melakha – even during weekdays – is by causation, where the initial action is separated from its eventual result by a physical distance or a period of time, this is not considered grama, as this is how the melakha is normally performed. Rather, this is direct melakha and it is prohibited by Torah law. Grama always refers to causing melakha to be performed in an unusual way.
. Some poskim permit grama even le-khatĥila on Shabbat (Taz 514:10 and Vilna Gaon 314). Many others permit it only in case of loss, for the sake of a mitzva, in a case of great need, or for the needs of the ill (Rabbeinu Yoel; Mordechai; Rema 334:22; MA). On Yom Tov, though, many permit grama even le-khatĥila (Ma’amar Mordechai; SHT 514:31).The parameters of grama are explained in San. 77b. If one ties up another person and then drowns him by unleashing water that had been restrained by a dam, he is guilty of murder. However, this is only true if the water killed him with ko’aĥ rishon; if it is a case of ko’aĥ sheni, the crime is merely grama. Similarly, in Ĥullin 16a we read that if one unleashes water whose flow turns a wheel attached to a knife that is poised at an animal’s throat, thus slaughtering the animal, the sheĥita (ritual slaughter) is kosher as long as it is a case of ko’aĥ rishon. This is because the removal of the dam is considered the act of slaughter. However, if the water that turned the wheel was a result of ko’aĥ sheni, the sheĥita was accomplished by grama, and the animal’s meat is deemed neveila (not properly slaughtered) and thus forbidden to eat. Rashi explains that when the melakha is slightly removed from the initial action, it is considered ko’aĥ sheni. Ramah maintains that water that flows directly is ko’aĥ rishon, while water that was delayed on the way to performing the melakha because of an obstacle in its path is ko’aĥ sheni. Similarly, water that flows immediately from where it had been dammed up is considered a result of ko’aĥ rishon, while any later flow is considered ko’aĥ sheni. In Sanhedrin, further explanations are offered. If one throws a stone into the air, and the stone falls straight down and causes damage, this is considered indirect damage; the stone fell on its own, due to the force of gravity, rather than the action of the thrower. But if the stone moved sideways as it fell, he is considered responsible; even though it fell because of gravity, nevertheless the fact that it did not fall straight down demonstrates the impact of his action.