I get this question a lot and the method of cleaning depends on what you're shooting. If you're shooting PRB's with an organic lubed patch, a good detergent and warm, not hot, water will suffice. The detergent should specifically state that it is in fact clean rinsing in that it does not leave any residue behind.
Warm water rather than hot because hot will cause flash-rusting if you can't get it wiped dry quick enough. Warm water does not evaporate as quickly and will help eliminate the flash-rusting issue. While flash-rust is very thing and easily wiped off, it is in fact removing metal from the barrel and roughing up the bore. You won't see drastic changes post-cleaning but you will notice increased fouling and reduced accuracy over a period of time following several cleaning cycles when flash-rusting occurs.
If you're shooting the pistol bullets wrapped in a condom (sabots) you need to first clean with detergent water to remove the powder fouling; then follow with a chemical solvent that will remove the raw plastic fouling; then follow with another detergent water cleaning to remove the powder fouling that was trapped under the plastic fouling. If you've got burned-on plastic fouling ... lots-o-luck to ya! Standard plastic solvent for use with sabots will not remove carbonized plastic fouling, it has to be done with strong chemical solvents in conjunction with mechanical scrubbing with a stiff bronze brush. I've had customers bring me plastic fouled barrels that required a cleaning regiment of scrubbing & soaking for 3-4 days to get them clean and I'm using a powerful plastic solvent that isn't even available for retail sale.
Use a jag. I can't stress this one enough because the eye type patch holders and worms do not put enough pressure on the patch to effectively clean the rifling grooves. A jag will press the patch into the rifling, patch should be thick enough so you can feel the increase in resistance when pulling it back out - if it comes out as easy as it went in, the patch isn't thick enough or the jag is too small.
As other already said, WD-40 is pretty much useless and the solvents that make it a liquid when it comes out of the can will evaporate leaving a waxy residue behind that will get gummy or turn into a nasty hard varnish type material that is not easy to remove. For long-term and maximum protection, I have gone to a custom blended 100% synthetic oil. Yes, the bore should be wiped well before shooting but if you leave a little behind, it won't turn into the hard carbonized and difficult to remove fouling that petroleum oils produce. For short-term storage under good conditions (within a week or two), use your patch lube provided it's capable of preventing rust.