Where should I write custom functions

https://discourse.roots.io/t/is-your-function-or-hook-not-working-in-sage-read-this/3376