How do you add a receptacle to a single pole switch that controls a light?
You need three things in that box: a conductor that is hot all the time, a grounded neutral, and an equipment grounding conductor. Whether the job takes ten minutes or a new home run depends entirely on which of the two common wiring arrangements you find when you pull the switch.
Case one: power comes into the switch box
This is the easy version. The incoming cable brings a hot, a neutral, and a ground. The outgoing cable carries the switched hot and the neutral up to the luminaire. Pigtail the incoming hot to both the switch and the receptacle brass terminal, pigtail the neutral to the receptacle silver terminal and to the outgoing neutral, and pigtail the grounds. The light still switches, the receptacle stays hot, and nothing about the circuit changes.
Check box fill before you close it. Section 314.16(B) counts each conductor entering the box as one, each device yoke as two based on the largest conductor connected to it, all grounds together as one, and internal cable clamps as one. A 3 inch by 2 inch by 2.5 inch device box holds 12.5 cubic inches, which allows six 14 AWG conductors. Two cables plus two devices plus grounds will exceed it, so plan on a deeper box or an old work box with more volume.
Case two: it is a switch loop
In a switch loop, power lands at the light and only two conductors run down to the switch. The white is re-identified as an ungrounded conductor per 200.7(C)(1), the black returns switched power to the fixture, and there is no neutral in the box. You cannot legally add a receptacle here without pulling a neutral, because 250.146 and the receptacle itself require a grounded conductor for the load to have a return path.
This is exactly the problem 404.2(C) was written to prevent. Since the 2011 edition, the NEC has required a grounded conductor to be provided at most switch locations that control lighting loads, so that later occupancy sensors, timers, and dimmers have a neutral. The 2023 text keeps the requirement with exceptions where the wiring is in a raceway that has capacity to add a neutral, or where cable assemblies enter through a framing cavity that is open at the top or bottom, or is accessible.
If your box is a switch loop, your options are to fish a new two conductor cable from the light box down to the switch box, to pull a neutral through the existing raceway if there is one, or to relocate the receptacle to a wall where a neutral already exists.
Do not feed a receptacle from the switched leg
Connecting a receptacle to the switched hot makes it a switch controlled receptacle. Section 210.52 requires receptacle outlets in a dwelling to be counted toward wall space spacing, and 210.70(A)(1) Exception 1 only allows switched receptacles to replace a required lighting outlet in habitable rooms other than a kitchen and bathroom. A switched receptacle also violates the reasonable expectation of anyone plugging in a charger. Use a constant hot.
Field takeaway
Pull the switch and look for a white bundle capped in the back of the box. If it is there, you have a neutral and the job is a pigtail. If the box has only a black and a re-identified white on the switch, you have a switch loop and you need to run a neutral before anything else. Recheck box fill either way.