Discerning spirits is a gift in which the Holy Spirit helps a person know what they are dealing with. Our natural reason alone is incapable of detecting all that which comes our way and is beyond our control. The Holy Spirit informs us if an issue is due to demonic activity, or if it is a test from God, or if it is a result of a choice we made ourselves.
St. John Chrysostom wrote in the early centuries of the Church:
“What is, “discerning of spirits?” The knowing who is spiritual, and who is not: who is a prophet, and who a deceiver: as he said to the Thessalonians, ‘despise not prophesying:’ (1 Thessalonians 5:20-21) but proving all things, hold fast that which is good.’ For great was at that time the rush of the false prophets, the devil striving underhand to substitute falsehood for the truth.” He says the gift helps, “to discern and know which is he that speaketh by a pure spirit, and which by an impure.”- Homily 29 on 1st Corinthians
Signs to Look For The Congregation for the Clergy at the Vatican published some guidelines for priests in Confession, and part of it addressed some signs to look for that can indicate if something is from God, or an evil spirit. This is good advice that is always good for people to recall when trying to discern. From, The Priest, Minister of Divine Mercy:
**99. The works of the spirit of evil are accompanied by pride, independence, sadness, discouragement, jealousy, confusion, hatred, deception, disdain of others, and selfish preferences. It is very difficult to distinguish these areas especially in the absence of spiritual direction and taking into account temperament, culture, and natural qualities. The areas or themes which are to be discerned are those which belong to the path of vocation (as lived out in ordinary every day circumstances), contemplation, perfection, fraternal life and mission. … **
100. Since the Spirit blows where he wills (Jn 3:28) it is not possible to formulate strict norms about discernment. However, the saints and the spiritual masters continually refer to certain constants or to signs of the actions of the Spirit of love who acts outside of human logic.
No spiritual situation can be well discerned without tranquility of mind which is a gift of the Holy Spirit. It seeks out not one’s own interest or to dominate others, but the best way of serving God and one’s brothers and sisters. Spiritual counsel (in the context of discernment) operates with the guarantee of interior freedom which is not conditioned by selfish interests nor by the fashions of the moment.
Necessary for discernment are: prayer, humility, detachment from preferences, listening ability, study of the life and teaching of the saints, knowledge of the teaching of the Church, careful examination of personal interior inclinations, ability to change, and freedom of heart. In this way we can train a good conscience or form that charity which wells up from a pure heart, from a clear conscience and from a sincere faith (cf. 1 Tim 1:5).