The Shulchan Aruch · Orach Chayim
אורח חיים רכ״זOrach Chayim 227
Siman 227 of 697 in Orach Chayim — 3 se'ifim
הלכות שאר ברכותLaws of Other Blessings· siman 227
Se’if 1א׳
עַל הַזִּקִּים, וְהוּא כְּמִין כּוֹכָב הַיּוֹרֶה כְּחֵץ בְּאֹרֶךְ הַשָּׁמַיִם מִמָּקוֹם לְמָקוֹם וְנִמְשָׁךְ אוֹרוֹ כְּשֵׁבֶט; וְעַל רְעָדַת הָאָרֶץ; וְעַל הַבְּרָקִים; וְעַל הָרְעָמִים; וְעַל רוּחוֹת שֶׁנָּשְׁבוּ בְּזַעַף, עַל כָּל א' מֵאֵלּוּ, אוֹמֵר: בָּרוּךְ אַתָּה ה' אֱלֹהֵינוּ מֶלֶךְ הָעוֹלָם עוֹשֶׂה מַעֲשֵׂה בְרֵאשִׁית; וְאִם יִרְצֶה יֹאמַר: בָּרוּךְ אַתָּה ה' אֱלֹהֵינוּ מֶלֶךְ הָעוֹלָם שֶׁכֹּחוֹ וּגְבוּרָתוֹ מָלֵא עוֹלָם.
Upon a comet, which is like a type of star that is seen like an arrow across the sky from place to place, whose light stretches like a staff, and upon shaking of the earth, and upon lightning, and upon thunder, and upon winds that blow angrily: on each of these one says, "Blessed are you, God our Lord, king of the world, creator of the original (first) creations." And if you'd like, say, "Blessed are you, God our Lord, king of the world, whose strength and might fill the world."
Se’if 2ב׳
כָּל זְמַן שֶׁלֹּא נִתְפַּזְּרוּ הֶעָבִים נִפְטָר בִּבְרָכָה אַחַת; נִתְפַּזְּרוּ בֵּין בָּרָק לְבָרָק וּבֵין רַעַם לְרַעַם, צָרִיךְ לַחֲזֹר וּלְבָרֵךְ.
As long as the clouds have not dispersed, one blessing suffices [for subsequent lightning/thunder]. [However,] if the clouds dispersed between one lightning flash and the next, or between one thunderclap and the next, one must recite the blessing again.
Se’if 3ג׳
הָיָה יוֹשֵׁב בְּבֵית הַכִּסֵא וְשָׁמַע קוֹל רַעַם אוֹ רָאָה בָּרָק, אִם יָכוֹל לָצֵאת וּלְבָרֵךְ תּוֹךְ כְּדֵי דִּבּוּר, יֵצֵא; וְאִם לָאו, לֹא יֵצֵא.
If one was sitting in a restroom and heard the sound of thunder or saw lighting: if it is possible to leave within toch kedei dibbur [the amount of time it takes to greet one's teacher, about two seconds], they should leave, otherwise not.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0