The tidal wave of layoffs sweeping through the tech industry is putting legal departments to the test, as in-house counsel seek to mitigate risk and ensure their companies carry out the cuts as humanely as possible.

Following years of feverish hiring, tech companies are retrenching. Just in November, 196 companies cut more than 51,000 tech workers, according to Layoffs.fyi, which tracks job losses in the industry.