Start bracing rafters or trusses on the first end installed. Nail long 2-by-4-inch boards to the outside edge of each rafter and to stakes in the ground outside to hold the rafter pair or truss vertically plumb. Use a hammer and framing nails. Fasten rafters or truss ends to the wall caps on each side with framing nails once rafters are plumb. Remove temporary braces once the entire roof is framed.
Brace other rafters as they are installed down the roof by nailing temporary 2-by-4 supports to rafter edges and to roof joists, if rafters are being installed separately. Use 1-by-4-inch boards called purlins as temporary braces for rafter trusses. Nail these temporarily to the outside edges of the rafter sides, starting with the third truss. Secure trusses in sets of three down the roof.
Install a ridge board for lateral bracing. Use a board at least the width of the rafter and preferably one size larger, a 2-by-6-inch ridge board on 2-by-4 rafters, for instance. Rafters with ridge boards typically are nailed only to the side walls and allowed to rest against each other at the top or plumb cut. Slide a ridge board between the rafters from the bottom and nail rafters to it. Set a ridge board after installing rafters on each roof end, then add intervening rafters nailed to it in pair. Install a ridge board on rafter trusses by placing all trusses first, then setting the ridge in slots engineered into the tops of the truss rafters.
Make collar ties to brace individual rafters; this will not be needed on truss rafters. Cut rafter boards to fit horizontally between rafters a third of the way down from the peak. Use a level to set them level and nail to rafters on both sides. Install king posts on end rafters, vertical braces between the wall cap and the ridge board or collar tie.
Cross brace individual rafters by nailing 1-by-4-inch purlins from the top of one rafter to the bottom of the next, with purlins inside the rafters for solid decking of plywood or oriented strand board (OSB). Nail purlins lengthwise across the outsides of the rafters for support and for "strip sheathing" to hold wood shingles or metal roof panels. Space these purlins to the size of shingle or panel. Use outside purlins under roof decking if desired.
Brace truss rafters with purlins nailed across the interior framing supports of the trusses. Fasten them in clusters of three. Add purlins across the bottom chords of rafter trusses to tie them together. Finish either individual rafters or trusses with metal hurricane clips, brackets which are nailed to the wall caps and to the rafter ends where they intersect with the wall cap.