Use the new company's code base not your code base
The new company you are going to should already have a baseline of code available for you to use. If you have an awesome utility function that you love and add it into the company's code base, you could have easily created technical debt, unnecessary code complexity, or other bugs. This is because:
- The company might have already had a utility function that did the same thing, and now they have two utility functions that do the same thing.
- There may have been a reason why they did not do it your way, like special cases which are going to break on your code.
- When you added your little function, was there any refactoring done across the entire project to make sure that it is used everywhere it can be benefited from? If not then you created technical debt, if yes then you have spent company time on something that was not broken.
Learn the new company's code base don't bring your own.
Legal issues
I am not a lawyer, but I have worked with multiple contracts, and have seen the legal barriers pop up time to time. Anything you write at work is owned either by that company or by the customer. When I say at work that includes if you did work from home for said company. Since the company or customer owns the code you wrote, you must ask for permission to retain any copies of it.
Example of customer ownership of code in action:
While I was doing government contract work, we had an awesome set of common utility libraries we created for a contract with US Government agency A, and the customer owned the code. I still had access to that baseline, but was now on a contract for US Government agency B. Even though I still had access to the first code baseline, I could not legally copy any code over even the rather useful libraries, without written authorization from Agency A, despite it being for the same government which already paid for it.