The root of bondage through action, in Shankara's account, is not action itself but the sense of agency — the "I am the doer" that accompanies ordinary action and generates the expectation of personal reward or the fear of personal failure. This sense of agency is itself a product of superimposition: it arises when the unchanging witness-consciousness is identified with the active, striving body-mind complex. The body acts, the mind plans and deliberates, but neither the body nor the mind is the self — and so neither their actions nor their failures belong to the self. The self, as pure consciousness, is in reality the uninvolved witness of all that the body-mind complex does.
For a person of established knowledge (sthitaprajna), the continued activity of the body-mind complex in the world is simply the unfolding of prior tendencies and present circumstances — what Shankara, following earlier Vedantic tradition, calls the "exhaustion of prarabdha karma" (the portion of past action whose results have already been set in motion). Such a person does not choose to act and does not choose to refrain from acting: they move through the world as the wind moves, as a river flows — following the logic of their situation without an inner agent who could have done otherwise. This is not passivity or fatalism but the absolute equanimity of one who has no stake in any particular outcome because they have understood that the one who was staking was itself an appearance.
Before the full establishment in knowledge, however, the practice of nishkama karma is a genuine discipline and not merely a description of the liberated state. To practise action without desire for its fruits — to perform duty because it is duty, without calculating what advantage will accrue to the performer — gradually erodes the habit of agent-identification. Each act performed without the claim of ownership loosens the grip of the ego slightly; each renunciation of fruit makes the fiction of a separate self slightly less plausible. This is the preparatory function of karma yoga: not liberation itself but a progressive dissolution of the structures that stand in liberation's way.
The doctrine of nishkama karma is introduced in Chapter II of the Gita (2.47: "You have a right to perform your prescribed duties, but you are not entitled to the fruits of your actions"). Shankara's commentary on this verse and the surrounding passages is among the most influential discussions of action-ethics in the entire Indian philosophical tradition.
