Here's what I did: Write your exclusions in the NDA or contract agreement. Be clear about what your doing with them. If your not a real competitor to them, they should go along with it. Negotiate this with the person needing your work, not their legal or HR people.
I did contract work as chief architect for Fortune 100 companies while I was building up assets for my startup in the 90s. My work for these megacorps including my building and licensing them some of those assets with the understanding that I could continue using the IP on my own. I never had a problem.