Obviously, the best way to help your frame last is to avoid twisting it out of shape in an accident. A good bike frame has considerable resilience but cannot be expected to regain its original shape after being wrapped around a tree. If you’re unlucky enough to crash and bend your frame or fork, take it to a mechanic for evaluation. A shop with alignment tools can sometimes straighten metal frames and rigid (non-suspension) forks enough that they still ride fine.
Metal dropouts in carbon fiber frames may be fixable, but only by experts. Under no circumstances should you try to align the frame or fork itself. Bent suspension forks can often be repaired by replacing the damaged parts.
Paint chips can allow rust to start even on a dry, salt-free steel frame. To prepare the surface for touch-up paint, don’t sand the chipped area except to remove rust. Most manufacturers treat their frames’ bare surfaces with a very thin phosphate coating that inhibits rust; sanding will remove it.
Instead of sanding, use a solvent, such as lacquer thinner, to clean any oil from the chipped area. Then cover the chip with one or more coats of almost any type of paint that matches your bike’s original color. If rust has already reared its ugly head through the hole in your frame’s finish, use fine sandpaper to remove all of it before you touch up the frame. Don’t expect miracles: The main purpose of your touch-up work is to minimise rust damage to your frame until you have it professionally repainted.
There are some other steps worth taking to protect the paint on your frame. Because the bike chain is close to the right rear chainstay, it can slap against it when you hit bumps. This makes a metallic clanking sound and can lead to chipping paint on the chainstay. A simple way to protect the stay and muffle the chain slap is to put a vinyl or foam chainstay protector over the stay. These are adhesive-backed and cost only a couple of dollars at your local bike shop.
Another good way to protect paint is to stick tape beneath cables where they rub the frame, such as shifter cables that strike the frame by the head tube. This will prevent them from wearing a hole in the paint. Just cut a small oval of tape (get clear tape or tape the same color as your frame so it’s not noticeable) and stick it on under the housing.
To stop the rattling and resultant paint scratches you might get from bare cable sections (such as the rear brake cable under the top tube), install cable O-rings. Shops should have these. These tiny rubber doughnut-shaped O-rings slip over the cable and prevent it from vibrating when you’re riding.

Sometimes a crash dents a frame tube. Though unsightly, these dents rarely weaken the frame much. If you can’t stand looking at a dent and you have a steel frame, you can have a frame-builder fill the dent with brazing material. After painting over it, for all practical purposes your frame will be as good as new.
Again, for carbonfibre frames, any sign of surface damage could mean a crack and failure. Have your frame professionally examined. There are many carbonfibre builders who can repair carbonfibre frames.