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.
God the Word, the God-Man, our Lord Jesus Christ, compares our life with a market, and the work of our life on earth He calls trading, and says to us all: Trade till I come (Luke 19:13), redeeming the time, because the days are evil (Ephesians 5:16). That is to say, make the most of your time for getting heavenly blessings through earthly goods. Earthly goods are good works done for Christ's sake and conferring on us the grace of the All-Holy Spirit.
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.