King Safety in the Middlegame
Castling gets the king off the center file. It does not finish the job. The middlegame is where pawn moves, trades, and open lines decide whether that king is actually safe. Most attacks that look sudden were prepared by one earlier pawn push or one traded defender.
The pawn shield
After kingside castling the shield is the pawns on f2, g2, and h2, or f7, g7, and h7. Leave them there unless you have a reason. Each step forward gives the enemy pieces a square. h3 stops a pin on g4 and gives the king luft, and it also puts a hook on h3 that a pawn storm can bite on. g3 or f3 is a larger concession, because it weakens the diagonals into the king.
The right time for a shield move is a concrete need: luft against a back-rank mate, or kicking a piece that is already sitting on g4. The wrong time is "the position felt slow, so I pushed a pawn."
Lines toward the king
An attack needs a road. The roads are the g-file after a pawn trade, the h-file, the a2–g8 diagonal, and the b1–h7 diagonal. If you are about to capture on one of those lines, ask who gets the open file afterward. Capturing their h-pawn with your bishop, and then watching their rook land on the open h-file, is a trade you made for them.
Defenders matter as much as pawns. A knight on f6 is one of the best defenders of a castled king. Trading it off, or driving it away, is often the first point of an attack. If you are defending, do not trade that knight unless the replacement defender is already in place.
Same wing or opposite wings
If both kings castled kingside, pawn storms are mutual damage. The side that pushes first often exposes their own king as much as the opponent's. Piece play, a central break, and pressure on a weak pawn are the healthier plans.
If the kings castled on opposite wings, the pawn storm is the plan. Your king is not hiding behind the pawns you are pushing. Speed matters. Do not start the storm with two pieces still on their home squares, and do not meet their storm only by defending. A pawn race is won by the side that opens a file with a piece already aimed down it. The castling choice that creates this race is in how to castle.
A one-minute safety check
Use it when the position stops being an opening. Where is my king, and which file is open next to it? Which of their pieces attack the squares f2, g2, and h2, or the black equivalents? Which of my pieces defend those squares? If the attackers outnumber the defenders and a file can open in one capture, you do not have a middlegame plan yet. You have a king problem, and it comes first.
Frequently Asked Questions
Is the king safer in the center in the ending?
Once queens are off, yes. A centralized king is a fighting piece. While queens are on, the center is where files open onto it. Castle first, centralize later.
Should I castle queenside to attack?
Only if your queenside is not already full of holes and their pieces are not already pointing at c1. Opposite-side castling is a choice you make before their pawn storm has started.
What is the fastest way to see an attack?
Look at forcing moves: checks, captures, and threats against the king. If none of them work, the king is probably safe enough for you to play your plan. Confirm a sharp one with chess hints.
Safety is a count, not a feeling
Attackers, defenders, and the next open file. If those three are acceptable, go ahead with the positional plan. If they are not, fix the king before you fix the queenside. Tactics that exploit an exposed king are drilled on the puzzle ladder.
Try the line on the board with chess hints.