This paper examines how employer- and worker-specific productivity shocks transmit to earnings and employment in an economy with search frictions and firm commitment. We develop an equilibrium search model with worker and firm shocks and characterize the optimal contract offered by competing firms to attract and retain workers. In equilibrium, risk-neutral firms provide only partial insurance against shocks to risk-averse workers and offer contingent contracts, where payments are backloaded in good times and frontloaded in bad times. We prove that there exists a unique spot target wage, which serves as an attraction point for smooth wage adjustments. The structural model is estimated on matched employer-employee data from Sweden. The estimates indicate that firms absorb persistent worker and firm shocks, with respective passthrough values of 27 and 11%, but price permanent worker differences, a large contributor (32%) to variations in wages. A large share of the earnings growth variance can be attributed to job mobility, which interacts with productivity shocks. We evaluate the effects of redistributive policies and find that almost 40% of government-provided insurance is undone by crowding out firm-provided insurance.