Kak is mostly self-documenting, but there are a few :doc pages that give more detail. Of particular interest are the commands [0] and command parsing [1] pages. Those will get you started.
Kakscript does not have any control flow beyond a simple try/catch mechanism - for anything complex, you use shell scripting [2]. It is both a blessing and a curse - making it extremely easy to integrate with other tools, but causing some pain if you don't know shell scripting already.