In this part, we will be looking at checkmates with the queen against the castled king. For this tutorial, we will be assuming that the king has castled on the kingside, but these checkmates are equally applicable in mirror-image if the king has castled on the queenside instead.
After castling, the king is usually much safer than it is at the beginning of the game in the centre of the board, so these checkmates are not usually easy to arrange. The easiest square to reach for checkmating purposes is the h7 square (for white) or the h2 square (for black). Take a look at the example below.
This checkmate can sometimes also be achieved by advancing a pawn to support the queen, as in the following example.
The knight is the best defender of the castled king position, and has a natural square on f6 (for black) or f3 (for white) where it can defend against this type of checkmate. Therefore, part of the plan for achieving this kind of checkmate often involves exchanging this knight or chasing it away.
As seen previously, the knight is a natural defender of the h7 square, so long as we can prevent the opponent from getting rid of it. A good way to maintain the defensive knight is to have a second knight ready to replace it if need be.
If no knight is available, the enemy attack can sometimes be obstructed by a pawn advance to block the route of one of the attacking pieces.
If all else fails, the defence of last resort is to make room for your king to flee his palace and seek refuge on the other side of the board. Usually this means moving the rook away to make space for a retreat.