As far as I know, there are no available software options for stopping the battery from charging.
Similarly it is not possible to prevent charging (while simultaneously powering the laptop) by taping or otherwise "blocking" some of the pins in the cable, like it were possible for MagSafe 2.
If you're not a programmer and/or hardware engineer, the only practical solution I can think of is to buy a charger with a low wattage. I.e. if you normally use a MacBook Pro with a 96W charger - find a charger with a lower wattage so that it only covers your normal power consumption while using the laptop. This won't exactly prevent the laptop from ever charging the battery, but it would reduce it to a minimum.
If you can live with the laptop running from battery from time to time, I would suggest getting a programmable power plug (like a Phillips Hue Smart Plug or a WiFI enabled plug). Then you can create a small script or program that turn the plug off (and thus your charger), when the battery charge is at 50+% - and similar turns it on when it reaches 30% or lower.
If you do want to try to make a software solution, please keep in mind that many suggestion you see online point to setting an kIOPMChargeInhibitAssertion that will show up when running pmset -g assertions. However that is only useful for very old Macs - current Macs have the charging handled completely by secondary microprocessors. The main CPU and the operating system is not really involved, and thus you cannot stop the battery from charging this way.
This being said, the official recommendation from Apple is to keep batteries at about 50% charge level when storing them. It is not a recommendation that holds when you're actually powering the battery (the computer will completely automatically handle trickle-charging, and ensure that the battery is not in any way "over charged" or something like that).