In our compassion training, we lead the participants through a guided meditation to help engender this kind of genuine self-forgiveness:

To do this guided meditation, readjust your sitting position so that you feel comfortable and relaxed. Take 3-5 deep breaths, bringing each one all the way down to your abdomen, and then gently releasing it. Pause for a little while in silence.

Now think of a time when you did something that you wish you hadn't, and as a result, reproached yourself for it. Perhaps you snapped at someone you love, and later felt bad about it. Or it could be something that affected only you, such as overspending on something you bought and feeling guilty and ashamed after. Recalling the specifics of the incident is not important, unless they help you to evoke the emotional reaction you felt then. What is important is the recollection of how you engaged in negative self-judgment. Silently stay with this reflection.

Then ask yourself, "Why is it that I reacted so harshly then?" "What was the unmet need I was trying to fulfill when I did this thing?" When you lost your temper, it could be that you needed respect and felt disrespected by the other person. It could be you needed to be heard and felt that this was not happening. Stay with these reflections for a little while.

Now, recognize that, although what you did, such as using abusive language, was not skillful, the underlying need that prompted your action was legitimate. In the case of overspending and feeling ashamed about it, although what you did was unskillful, there again was underlying need – perhaps you were feeling disempowered and down, and needed a psychological boost. With awareness, allow yourself to experience feelings such as sadness, disappointment, and remorse, rather than guilt and shame. Pause with these feelings.

As you touch upon the underlying need that led to the action that brought about the negative self-judgment, stay with it for a while.

Now, breathing out slowly and completely, let go of any tension in the body, let go of any tightness in the mind, and, reflecting on your earlier self-reproachful thoughts, silently say to yourself, "I can let this go. I will let it go."

Finally, imagine that you feel free and expansive in your chest, and then breathe out fully a few more times.

Thupten Jinpa in A Fearless Heart