There was two years of war before the British had figured out how to do trench raiding effectively. By late 1916 they had the “storm trooper” tactics completely figured out, something the Germans wouldn’t manage until 1918. The Germans on the other hand, developed very good defense in depth tactics.

A trench system is made of three lines of trenches in parallel, covering a mile or more in depth. The front line trench is the combat trench, where the fighting is supposed to take place. Then there is the support trench, which houses units for work parties and counterattacks and so on. Then the reserve trench which houses more work parties and has units resting from front line duty. Units would spent a week or two in the trenches, then rotate into the rear for a while to rest and receive replacements.

As the war progressed everyone basically learned that the front line trench was rubbish. It would be destroyed, overrun, shot up, etc. There was no point in holding it with a lot of troops because they’d get wiped out before they could do much of anything. The Germans switched to a front line that was just fortified shell holes with machine guns. This was very safe against artillery because there was no trench to target. It was effective against infantry attacks because the machine guns could wreak havoc on men with rifles. The support and reserve trenches would be real trenches.

This system of fortified shell holes with supporting strong points from the support trench was “defense in depth.” The opposition could “overrun” the front line, but they’d still have pockets of machine gun nests on their flanks and behind them. Eliminating every single machine gun nest was extremely slow and so… that is how defense was achieved. Not with a single strong trench, but with a system that could absorb an attack, slow it down, and reduce it with machine guns.

[anecdote: during an offensive one officer solved the “eliminate all the machine gun nests” problem by taking a German prisoner and making him stand up on a stump in no mans land pointing out every nest. The officer would prod him with his pistol and demand more information, until all the machine guns were located and neutralized. Only then was the poor German allowed to get off the elevated and exposed position.]

The offensive solution to this system was with artillery box barrages, storm trooper infiltration, and tanks (to some degree). The real solution was to spend years besieging Germany and bleeding her dry so that by late 1918 there was no manpower, materiel or morale to fight. Attrition wins.

Infiltration tactics were basically sending small units of men, say a section (8 men) or platoon (40 men) through the fortified shell hole system at night. That way when the attack began, the men were miles inside enemy territory already and could ambush the strong points, etc. This was what the British began doing by late 1916. Germany gets credit for inventing it almost two years later because, they had a really cool name (storm troopers!) and the enemy always has cooler better stuff than you do. And the British didn’t like a system that gave all the initiative to young officers, particularly the officers later in the war who came from civilian life to fight only for the duration, can’t have those types ruining things for the career officers from good families, etc. etc,

The trench raid was the primary way of defeating the trench system. It begins with a creeping barrage and the box barrage. The artillery fires on the front line trenches until the time when the infantry assault elements are supposed to arrive. Then it lifts and moves to targets further back. It stays on those until the time when the infantry is supposed to arrive then, and then lifts and moves forward again. Creeping barrage. The box baggage was where the artillery fences the area being assaulted with fire along the flanks. This produces a sort of box, where artillery is firing along two sides and one creeping barrage at the back. The idea is that the area within the box will be dealt with by the infantry assault units while the artillery prevents reinforcements and counterattacks.

It is a brittle system because there is so little information flow between the front line assault units and the artillery. If the times scheduled for the advances don’t match with reality the infantry can fall behind the protective screen. When this happens, I.e. the creeping barrage walks too far forward for the infantry to keep up, then the enemy can come up from their dugouts and man their defensive positions. This is, obviously, very bad for the Poor Bloody Infantry.

Anyway, the short answer is that trenches were attacked all the time and clearing trenches was an important activity. There were night raids as well, which is a whole other thing. That’s where the hand to hand fighting comes into it. That’s an entire other subject, including how the armies had to invent modern hand to hand combat training.

These days if you’re in the military you’re taught basically two technica, one to incapacitate and one to kill. Then everything else you learn is a way to setup either of those two techniques. Guy standing up? Ok, get him on the ground and crush his throat. Guy has a knife? Get him on the ground, safely, and crush his throat. Guy has a bayonet? Get him on… and so on. The French system was based on crushing the throat. With thumbs. Very… brutal. I’m not sure how much it was used, but that is what was taught,