Write code as rules, that is, as preconditions and consequents, and let a separate interpreter examine these rules and decide which to run.
This is how Business Rule Management Systems work, and Logic Programming is a stone's throw away.
https://www.toomuchcode.org/blog/2013/09/24/rules-as-a-control-structure/
http://www.metasimple.org/2017/02/28/clarifying-rules-engines.html
Clara Rules (CLJ)
quoll/naga: Datalog based rules engine (CLJ)
oakes/odoyle-rules: A rules engine for Clojure(Script)