I have experienced CV foints coming off my earlier car. This is an issue that many cars go through. I see threads on this topic from time to time. Most replies involve using new Schorr washers or wiring the bolt head. Some have used longer screws with jam nuts on the back side of the output flange. I do not see the actual cause being discussed and I would like to offer an explanation here.
What I have found is when the CV joint works loose. the stress on the bolts pulling on the output flange of the transmission distorts the flange. This results on a smaller contact surface between the CV and the flange. I corrected this using my lathe years ago an I have never had the work loose again. They worked loose in the past within a year.
Yesterday a local 914 member came over and we addressed his CV joint. One had come off. It did damage the the shift rod and caused considerable him grief. We replaced the shift console bushing and the shift rod. We then installed a replacement CV joint. I removed the output flange and put it in the lathe. Here are 3 shots. The first shows the condition before doing anything. You will see the flange surface is not clean. If it had been in full contact it would have looked better. The second shot shows a very slight clean up cut. Here you can see there is a 10 mm wide section where the flange cleaned up. Around all the bolt holes you can see a slight cleaning. What this means is no matter how tight you make the bolts that this is the only surface that will make contact! This results in allowing the CV to wiggle slightly under load. This leads to the screws backing out. So only a very small percentage of surface is making contact. For the correct results you need 100 percent contact between the two surfaces. The third shot is the final cleanup. I removed about .005" to get there. This metal is not real hard and cleans up easily..
If you do not have a lathe, then a flat surface and abrasive paper may work. Cutting a small countersink at each hole may also be helpful. You want to make certain that the threaded holes are hot high spots on the flange. New washers are advised.