There are many kinds of kidney stones, but the most common is a calcium oxide stone, which can be prevented through lifestyle, diet, and certain supplements. The key here is to reduce urinary calcium.
Here’s how you do this: reduce calcium intake from dietary supplements, avoid foods high in oxalate (see below), increase foods with a high magnesium and calcium ratio including nuts, seeds and beans, and increased intake of vitamin K foods (green leafy vegetables). It is also critical to increase urinary volume to at least 2 liters a day, which means drinking plenty of clean water. The best way to improve your diet is to increase the intake of fiber, whole plant-based diet, and green leaf eating vegetables.
You also want to reduce your intake of sugars and flours and processed carbohydrates, and purines, which are compounds in meat, fish, poultry, and particularly organ meats. You also want to increase your consumption of foods high in magnesium/calcium ratio by bran, oats, corn, buckwheat, rice, soy, oats, brown rice, avocado, banana, cashew, coconut, peanuts, sesame seeds, lima beans, and potatoes. You can lower oxalate levels reduce in consumption of oxalate-rich foods including black tea, cocoa, spinach, beets leaves, rhubarb, parsley, cranberry, and most nuts.
I would also recommend a few supplements including vitamin B6 25 mg daily, vitamin K 10 mg a day, magnesium 600 mg a day, and calcium about 300 mg a day, although you have to be careful with supplemental calcium as it can lead to increased stones.