Mark the lower border of the current shelf (if applicable) using a pencil. Remove the existing shelf and brackets and find the studs in the closet side walls using the stud finder. Mark the location of the studs using the pencil, being sure to mark when each stud begins and ends.
Hold the 2x4 support boards up to the markings on the wall, and determine if the supports extend beyond the shelf itself. Trim the edge of the support to the desired length using the saw.
Transfer the markings for the stud locations onto the support boards, and mark two locations on each stud to attach wood screws. Place the carpenter's level on top of the supports to ensure that they are level. Predrill these spots using a drill bit with a slightly smaller diameter than the wood screws you will be attaching the closet supports with.
Attach the support boards to both walls using the wood screws. Set the shelf on top of the new supports and place the carpenter's level on top of the shelf to check the balance and make any necessary adjustments.