One important thing to do when starting to use cloth is to get rid of your fabric softener. Fabric softener leaves waxes and perfumes on the fabric that can lead to buildup, rashes and repelling. Even fabric softener residue left in your dryer can cause issues, so it is better to eliminate it from your household altogether. Some people swear by adding a little vinegar to the rinse cycle to soften things up. Also dryer balls (wool ones are popular) are helpful to soften up your fabrics as well.
The standard wash cycle recommended by a large number of diaper manufacturers is to do a cold rinse (some say warm works better as long as it is below body temperature, if it is too hot it can set the stains) followed by a hot wash and rinse with detergent, followed by a 2nd rinse. The first rinse washes away any urine and feces attached to the diapers, the hot wash gets them clean, and the final rinse gets rid of any soap residue on your diapers.
Not all machines are the same, and depending on the make you have you may find you need to vary the routine a little bit, or add in an extra step. When deciding what cycles to set your machine on remember the more water the better, the more agitation the better and to avoid any super hot sterilizing settings that are hard on PUL covers or elastics.
Deciding what detergent to use can be like a chemistry experiment. If your machine is HE or top loading plays a role as well as if your water is hard or soft. HE machines use way less water, which means you need less detergent. Soft water means detergents function almost too well, and you have to be careful about buildup. Often HE machines with soft water less is more when it comes to detergent and extra rinses will be needed. If you have hard water you will need more detergent and possibly a stronger detergent to get the job done. There are many "natural" detergents on the market, some sold at inflated prices as they are supposed to be the magic cure for smelly diapers. Many of the more common brands of detergents we are all familiar with in the supermarket will work just as well. It is really a process of trial and error to find what works for your situation. When you find a detergent you like, that isn't giving your baby rashes, that is getting out stains, keeping the diaper stinkies away, and rinsing away clean so as not to cause repelling, stick with it. If you use a detergent for a while and start having issues, change it up and experiment.