Replace an undersize rod
If the sag is modest, replace an undersize wood pole with a thicker rod. Standard-size closet rods range from 11.16 inches (27 mm) to 15.8 inches (41 mm) in diameter.
Lift the rod out of the U-shaped pole socket.
Use the existing rod as a guide for cutting the new rod to length with a saw.
Set the new rod in the sockets.
Add a support
Locate a stud on the rear wall near midspan. To do this, shine a bright light at a low angle across the wall and baseboard while looking for the slight indentations that indicate a fastener location. Tap at this location. If the stud is there, the wall will feel firmer when you tap and you will hear a dull rather than a hollow sound.
Hold a rod bracket over the stud and up against the closet shelf. If the new bracket is not in line with the pole sockets, move the pole sockets in or out as needed to align everything.
Mark the bracket mounting holes on the wall and on the underside of the closet shelf.
Drive a nail partway into the wall at the marked locations to verify the presence of a stud. If you do not find a stud there, tap to either side until you hit one, then again drive a nail to confirm.
Drive screws through the bracket into the wall. If you do not own a drill with a driver, bore a pilot hole for the screw with a drill and use a screwdriver to install the screws.