One of the most harmful processes in inertial confinement fusion is Rayleigh–Taylor instability (RTI), and an efficient way to mitigate it is pulse shaping. However, because shaped laser pulses lead to unsteady ablation, it is insufficient to evaluate RTI based solely on the instability growth rate. Here, for better prediction of RTI during linear growth, hydrodynamic equations for laser ablation (including both balance and linearized perturbation equations) are solved numerically and used to optimize the laser pulse shape for direct-drive inertial confinement fusion. For given target conditions and laser energy, simulations show that a picket pulse before the main laser pulse can reduce RTI significantly, and it is clear that the reduction comes from two aspects: (i) the lower RTI seed due to rarefaction at the descending edge of the picket in the imprint stage and (ii) the smaller growth rate due to enhanced ablation velocity at the main pulse in the acceleration stage. It is found that the perturbed laser deposition in an underdense plasma also has a profound influence on RTI seeds in the imprint stage.