Wizard lock is a magical way to close and lock a door; in doing so it repairs broken doors, and it can even create a locked door in an empty doorway. Wizard lock can also close trapdoors; to do so you must be levitating over them, and zap downwards. This spell is useful for creating a barricade between you and some monsters, so that the monsters are unable to enter or exit a room of the main Dungeons of Doom. Very few monsters can open locked doors (although any intelligent monster can use a skeleton key); only a handful can pass them through other means.
Wizard lock will also repair and engage the locks on chests and large boxes. This use is not generally beneficial. Locking a chest or large box does nothing to protect your stash, because at present, no monsters in NetHack 3.4.3 ever try to open a container, locked or not. (A gelatinous cube swallowing a container doesn't care if it's locked.) One use for locking a container is to prevent a reviving troll from escaping, thereby killing it permanently. Another is to lock a container that may have a loadstone in, hoping to break it whilst forcing the lock.
Few characters will find a spellbook of wizard lock early in the game, when it is most useful. A few other characters will find a wand of locking but will need to identify it. It is good practice to be engrave-testing your wands; five types of wands do nothing special when engraving (including the wand of secret door detection unless it detects something). Test these wands by zapping them toward an unlocked door or doorway.
Wizard lock is also useful in order to intentionally break a cursed weapon (by #forcing the lock on a chest) or practice #unlocking locked containers, if your key can only be used to unlock (such as a credit card).
In Minetown Edit
Minetown has many rooms; wizard lock can be an important lifesaver if you need to lock yourself in a room to heal, or if you need to lock some monsters in a room. Most players will find and use a skeleton key for this purpose. If you broke one of the doors, then wizard lock may be useful even though a key is not.
Doorways versus empty squares Edit
Wizard lock only creates locked doors on squares that NetHack believes were doors or doorways. If something digs away walls in the Dungeons of Doom, then you may use wizard lock to fill the gaps with locked doors. If something digs away walls in the Gnomish Mines, then wizard lock is of no use.
Objects where the door would be Edit
Any single object can prevent a door from forming or closing. If you want to use wizard lock to create a door on a certain square, then you need to remove any objects from there. This is mostly an issue if you want to lock a door after slaying some monster there, and the monster dropped something. If the monster dropped a heavy corpse or a loadstone, then you might not be capable of clearing the square manually, although a wand of teleportation or the teleport away spell can potentially vacate objects from the doorway.
Monsters that can pass locked doors Edit
Other than xorns, most of these monsters are slow, so you should still be able to flee them. You might consider fighting one, knowing that the other monsters remain stuck behind the door. Also, giants can crash open doors.
Monsters with wands of striking Edit
If a monster happens to carry a wand of striking, then they might break down a locked door. Currently monsters do not aim for locked doors, but they might zap at you and hit the door by accident.