The Buddha divides kamma ethically right down the middle into two different classes, wholesome kamma ("kusala kamma") and unwholesome kamma ("akusala kamma"). Unwholesome kamma is action which is spiritually harmful and morally blameworthy. Wholesome kamma is action which is spiritually beneficial and morally praiseworthy.
There are two basic criteria for distinguishing wholesome and unwholesome kammas. One is the intention behind the action. If an action is intended to bring harm to oneself, harm to others or harm to both oneself and others, that is unwholesome kamma. Kamma which conduces to the good of oneself, to the good of others or to the good of both is wholesome kamma.
The other criterion is the roots of action. All action arises from certain mental factors called roots. These are the causal factors underlying action or the sources of action. All unwholesome actions come from three unwholesome roots, greed, aversion and delusion. Greed is selfish desire aimed at personal gratification, expressed as grasping, craving and attachment. Aversion is ill will, hatred, resentment, anger and a negative evaluation of the object. Delusion is ignorance, mental unclarity and confusion.
We also find the roots in the wholesome side: non-greed, non-aversion and non-delusion. Non-greed becomes manifest as detachment and generosity. Non-aversion is expressed positively as good will, friendliness and loving kindness. Non-delusion is manifested as wisdom, understanding and mental clarity.
Due to these roots we have to be very careful when we judge actions of our own and of others. Often there can be a sharp difference between the outer action and the state of mind from which the action springs. We might be doing a lot of good work for others outwardly, but the underlying motive behind our good work might be a desire to gain fame and recognition, a form of the unwholesome root greed and craving. Someone else might be sitting quietly meditating, seemingly aloof, but inwardly he might be developing a mind of loving kindness and compassion. He might be criticised for seeking only his own good, but he might be doing more to benefit the world than the active do-gooder who is driven by desire for name and fame.

The working of kamma is so complex and so subtle that it is almost impossible to make definite predictions. All that we can know with certainty are the tendencies, but that is enough to guide our actions.