Constructing a closet on the second floor adjacent to stairs can make use of space that is often wasted. Accessing the closet without having the door open into walking space is a concern. But there are numerous ways to locate the closet to avoid that. It's also possible to use overhead room of the stairwell itself for a closet, if you allow sufficient head clearance for those walking up and down the stairs.
Adjacent space surrounding the stairs can yield usable closet space. For example, as you ascend a staircase, you can build a closet directly above the lower part of the stairs and access it from an upstairs room. Picture walking to the top of a staircase and making a left-hand turn. The closet's front door might be inside a bedroom on the left side of the stairs.
Hallway Blank Wall
A closet will fit at the top of the stairs facing the landing. In this case, you might ascend the stairs to a landing that is five-feet square. The blank wall in front of you can be a good place to install a closet. Use sliding pocket doors over a linen closet, for example. Don't install standard doors that open out, because this conflicts with stairway foot traffic. Stepping back to open such a door might cause you to trip and fall down the stairs.
Don't build a closet to the immediate left or right of a staircase, unless you move the closet door. Placing items inside or retrieving something can distract you from the staircase itself. You can build a closet to the right of the staircase at the very top, but install the closet door inside a bathroom or bedroom. Unless your house has generous floor space and there are no issues with landing room, avoid placing a standard closet door to open into stairway foot traffic.
Replacing Side Railing
A closet unit can be constructed at the top of stairs in lieu of side railing. For instance, if your second-floor landing has a hallway next to the stairs separated by a railing, you can build a closet cabinet attached to flooring and do away with the railing. The closet cabinet will prevent anyone from falling over. Envision this closet structure as a large armoire with well-crafted moldings and crown molding, so it looks like a piece of furniture. It does not have to reach the ceiling. Secure its framework to the floor joists with four-inch screws, so it serves as a solid barrier between the stairs and upstairs hallway space.
Exception to the Rule
A seldom-used, locked closet can fit at the top of a stairwell. Although you don't want a door to swing open to hit someone ascending the stairs, you can build a closet off to one side and create a door with hinges on the side away from the stairs. This is a good place to install a closet-type safe for valuable paperwork or other items. Due to the fact that you will access it only occasionally via a lock system, the door issue is not a real problem.