The way to attain compunction is an attentive life. ‘The beginning of repentance comes from the fear of God and attention,’ as the holy martyr Boniface says.
Great is this mystery, and great is the mercy of God towards man. If all the people of the earth knew how deeply the Lord loves man their hearts would be filled with love of Christ and Christ’s humility, and they would seek to be like Him in all things. But man cannot do this by himself, for it is only in the Holy Spirit that he can become like unto Christ. Man that is fallen purifies himself through repentance, and is made new by the grace of the Holy Spirit, and in all things becomes like unto the Lord.
But if you give a strong body rest and ease and idleness, all the passions dwelling in the soul are intensified. Then, even if the soul has a great desire for good, even the very thought of the good that is desired will be taken from you.
If you examine your life well, you will find many instances when God showed His unmistakable mercy to you. Trouble was brewing, but it passed you by for some reason. God delivered you. Acknowledge these and thank God, Who loves you.
Our enemies (demons) fell because of their pride, and call us to follow them, and bring us feelings of praise. And if your soul accepts that praise, then grace will depart, until the soul becomes humble again. And so all your life you must learn the humility of Christ.
Even if we have thousands of acts of great virtue to our credit, our confidence in being heard must be based on God's mercy and His love for men. Even if we stand at the very summit of virtue, it is by mercy that we shall be saved.
Compunction comes when you consider how much you have grieved God Who is so good, so sweet, so merciful, so kind, and entirely full of love; Who was crucified and suffered everything for us. When you meditate on these things and other things the Lord has suffered, they bring compunction.
A treasure that is known is quickly spent: and even so any virtue that is commented on and made a public show of is destroyed. Even as wax is melted before the face of fire, so is the soul enfeebled by praise, and loses the toughness of its virtue.