From Rabbi Chaim Vital’s Sha’arei Kedushah (“Gates of Holiness”), translated by Rabbi Aryeh Kaplan in “Meditation and the Kabbalah” (Jason Aronson or Samuel Weiser editions). (Footnotes have been omitted.)
Eighth Gate: Methods of Sanctifying Oneself
One must purify himself in four ways:
First, one must repent all of his sins, whether they involve violating the Torah's prohibitions, neglecting its positive commandments, or even transgressing rabbinical laws or adhering to unworthy traits. Such repentance must include a resolve never to repeat the sin or return to the bad trait. Such repentance is especially important for sins for which the Torah prescribes a penalty of being [spiritually] "cut off," or those which involve a desecration of God's Name. This includes violation of the Sabbath, the menstrual rules, sexual pollution, oaths -- even if they involve the truth -- gazing at forbidden members of the opposite sex, malicious gossip, talebearing, mockery and idle chatter. One must also keep himself from pride, anger, oversensitivity, and depression, behaving with modesty and humility and rejoicing in his portion.
The second purification involves the meticulous observance of all 248 commandments of the Torah [which parallel the 248 parts of the human body], as well as the legislated commandments. Particularly, it involves keeping set times for Torah study, praying with Kavanah (concentration or mindfulness – ed.), reciting all blessings and grace after meals with Kavanah, loving one's fellow man, and honoring the Sabbath in every detail. One should also wake up each night at midnight to study Torah and mourn for Jerusalem. Whatever one does should be with love, for the sake of heaven.
The third and fourth purifications involve specific preparations through which one sanctifies himself for Ruach HaKodesh (“divine inspiration” or higher consciousness – ed.).
The first of these involves purification of the body, through immersion in the Mikvah (ritual bath) and clean clothing.
The second should be done when one actually prepares to receive Ruach HaKodesh, after the other good traits have become part of his nature.
You should be in a room by yourself, after immersion and sanctification. It should be a place where you will not be distracted by the sound of human voices or the chirping of birds. The best time to do this is shortly after midnight.
Close your eyes and divest your thoughts of all worldly things. It should be as if your soul had left your body, and you should be as devoid of sensation as a corpse. Then strengthen yourself with a powerful yearning, meditating on the supernal universe. There you should attach yourself to the Root of your soul and to the Supernal Lights.
It should seem as if your soul had left your body and had ascended on high. Imagine yourself standing in the supernal universes.
If you make use of a Yichud (“unification,” a theurgic method of the Kabbalah – ed.), have in mind that through it you are transmitting Light and Sustenance to all universes. Keep in mind that you, too, will receive your portion in the end.
Meditate (hitboded) in thought for a short time, and attempt to sense if the Spirit had rested on you.
If you do not feel anything, it can be assumed that your are not fit and ready for it. You should therefore strengthen yourself all the more with worship and holiness. After a few days, you should meditate again in this manner, until you are worthy that the Spirit should rest upon you.
When the spirit rests on you, you must still discern if it is pure and clean, or from the Other Side, a mixture of good and evil. Keep in mind what happened to Ben Zoma and Ben Azzai when they ascended to the Orchard (Talmud: Chagigah 14b). You can discern this through what is revealed. It can consist completely of truth, or it can be truth mixed with falsehood. Occasionally, the revelation will consist of idle concepts, dealing with worldly vanities, or ideas that do not conform to the teachings of the Torah. When this occurs, you must repel yourself from it. You must then continue to fortify yourself with worship, until the revelation is faithful, based on the fear of heaven.
At first, the spirit [of Ruach HaKodesh] will rest on you occasionally, at distant intervals. The revelation will only involve simple concepts, and not deep ideas. Very little will be revealed, but as you progress, your power will likewise increase.