If the chain hesitates between sprockets, the derailleur may not need replacing. Cable stretch, a misaligned hanger, worn parts or incorrect limit screws are common causes. Work slowly and never force a shift under heavy load.
Find the pattern first
Place the bike on a stand or lift the rear wheel safely. Turn the crank by hand and shift one gear at a time. A delay moving to a larger sprocket can indicate insufficient cable tension; a delay moving back can indicate excessive tension. Check that the cable housing moves freely before changing an adjustment.
Set the limit screws
The H and L screws limit the derailleur's travel at the smallest and largest sprockets. The guide pulley should sit below the selected sprocket without allowing the chain to move toward the spokes or fall outside the cassette. Make quarter-turn changes and test after each one.
Fine-tune cable tension
Put the barrel adjuster near its middle position and shift from the smallest sprocket. If the chain does not climb cleanly, add a small amount of tension. If it climbs by itself or rattles against the next sprocket, reduce tension. Test the complete cassette rather than judging the adjustment from one gear.
Know when to stop
A bent hanger, damaged housing, worn chain or cassette may not be corrected by adjustment. If the chain can reach the spokes, the derailleur is unstable or the problem began after a crash, stop riding and ask a mechanic to check alignment. Clean the drivetrain and lubricate the chain after the adjustment.