You could use a directory-local variable. Relevant documentation node.
To use this, you create a file .dir-locals.el in the root of each project dir with contents like:
((nil . ((my/is-local . t))))
Then in your config you need to do two things, you need to set the variable as safe so Emacs doesn't prompt you about it whenever it loads a file in that ...
Define a function that inserts the boilerplate code you want, at the buffer position you want.
Put that function on a relevant hook.
For #2, one of these might be a relevant hook:
window-configuration-change-hook - used when you change buffers
write-file-hooks - used when you write a file to disk
find-file-hook - used when you visit a file
A major mode ...