using add_action without having custom plugin or theme

There is no built in “user code” mechanism is WordPress. Your options for running your code are the theme’s functions.php file, a plugin, or a mu-plugin.

You are aware of the first two options, the first of which you reasonably want to avoid. Writing a simple plugin is pretty trivial so I would not be afraid to try that.

The third option is less well known. If you create a directory called mu-plugins in the wp-content directory– in other words, /wp-content/mu-plugins/— and place PHP files in there, WordPress will execute them automatically.