Ketones have been shown spare the breakdown of muscle protein and potentially stimulate protein synthesis which is why the diet has been considered to be a muscle sparing diet. If formulated correctly there is no reason why you would lose muscle on the ketogenic diet. If you feel you are losing muscle on keto you could be making the following mistakes.
Under eating protein: Eating too little protein is a common mistake made on keto for the fear of gluconeogenesis and that it will kick you out of ketosis. Do not be afraid to eat high quality sourced protein. The body can produce glucose from excess amino acids from protein, a process known as gluconeogenesis; however, the body will only activate this process to the degree needed to meet the demands of the body. It has not been supported in the literature that consuming a higher protein diet will impair your state of ketosis. In fact, it may actually lead to better results for some.
Under eating calories: Eating too little calories is another mistake commonly made because of the satiety effect of Keto. Eating in a calorie deficit can be safe but too much of a calorie deficit could cause you body to break down muscle for fuel. This is particularly an issue if you don’t have a lot of fat to lose.