intellectual-property
If I wrote code for a personal project, and use some of it in a program at my company, can they now sue me for using the code in my personal project?
<p>Let's say I developed a web app for a personal endeavour of mine. Soon after, I get a job with a tech company, and my first task is to develop a web app for them. Well, it turns out the functionality of this new company web app is similar to my personal web app, and so I use some of the code from my personal web app in the company's web app. Can the company now sue me or take other legal action if I continue developing my personal web app? If so, how can I put a &quot;license&quot; in my code to protect my intellectual property (since I wrote the code BEFORE I even took the job)?</p>
<p>For the programmers out there, the code language is JavaScript and CSS.</p>

<p>In the US, code that you write in the course of employment is the property of your employer. Otherwise, anything that you create is your property. The gray area is things that you write <em>during</em> your employment but not in the course of your employment (hence the terms of the employment contract are vital).</p>
<p>Something that you write before becoming an employee is not &quot;in the course of employment&quot;. However, if you use that code in the in the course of employment, you invite the argument that in fact the code was written in the course of employment. That argument can be squelched if you have an agreement with the employer that acknowledges that you are <em>licensing</em> your code to the employer in exchange for ... some consideration. It could be $1, or a similar unit of currency.</p>

<p>Is your personal code Published somewhere public? Github?<br />
If not, publish it. Give it a permissible licence.<br />
<strong>Then</strong> ask your employer/project manager/collegues if they would allow a niche <em>public</em> library you wrote yourself, because it seems to solve the problem.</p>

<p>If you wrote it before you started your employment, it is your intellectual property.</p>
<p><em><strong>However</strong></em>, you should not just arbitrarily include intellectual property that the company doesn't own in a project you are building for the company, without their knowledge and agreement.</p>
<p>Often it's expected that you will make use of open source code in the course of building the company's project, but that is explicitly licensed to the company (via being published with an open invitation for anybody to accept the open source license it's published with), and if the company wants you to use open source material it is presumably happy to comply with those license terms. (You <em>also</em> should not include open source material without knowing the company is happy to be bound by the open source licenses for this project; generally it's clear if that's the case because there is already lots of open source code included in the project codebase, but it would never hurt to ask what the policy is explicitly)</p>
<p>Unpublished code you just happen to have access to should <em><strong>never</strong></em> be included in the company's projects. Without a license the company may be on the hook for copyright infringement, and even worse could find itself trapped unable to continue developing its own products because it is unable to make further derivative works of the code it does not own and has no license to use!</p>
<p>Code you just happen to have access to because <strong>you wrote it</strong> is only slightly different, in that you would be able to enter into a license agreement with the company to ensure the above situation does not happen. But the company will want to have an explicit written license agreement, so you <em>absolutely</em> should not include your own code without talking to your boss. And they are unlikely to accept any license less permissive than an open source license (so you won't be able to keep your code private to just yourself and the company; they will need extensive rights to modify and distribute it after you have left the company).</p>
<p>If you do include this code that is owned by you, rather than by the company, you may also be inviting personal trouble. If there is no evidence of the fact that you wrote it prior to your work for this company they may believe you are stealing their property if you later use it, and then engage legal proceedings against you. Strictly speaking this <em>should</em> come out in your favour, but if there's little documented evidence of exactly the circumstances in which the code was first created, then you can't rely on a court to rule that you should be the owner, even if that is the truth. So <strong>you</strong> should want an explicit written license agreement before using this code int he company project too, so that you later have proof that the company acknowledged your prior ownership.</p>
<p>But really, the <em>company</em> does not (or at least should not) want to get into that situation of disputed ownership in the first place. They would much rather you only included code that is either created during the course of your employment (so they own it completely) or is clearly licensed to the company (such as widely published open source code). Code you own but haven't published as open source prior to starting with the company, unless it is quite substantial, is probably just not worth the hassle for them of getting it properly licensed. Most likely paying developers to reinvent that wheel is cheaper than paying lawyers to make sure there are no legal issues.</p>

<p>You <em>can</em> be sued for anything. You will likely <em>get</em> sued if someone believes you caused them damage. With the facts as you describe them (you wrote software in your spare time at your own expenses, you &quot;donated&quot; it to your company) you never caused any damage, but if the company doesn't know the details, and all they know is that some code X is both in their product, and in your private product, they are likely to assume that you damaged them.</p>
<p>So I would strongly recommend that you talk to your manager at least before using any of your own code, and be prepared that the company doesn't allow it and that they don't want anything in their products where they are not the copyright owner. Making sure that you can't turn around in two years time and demand that your code gets removed could easily be more expensive than paying you or someone else to write code with the same functionality.</p>

<p>At least once I was asked to provide a list of code I had already written (standard utility stuff that mostly now happens in libraries) <em>at hire</em>. Other times I supplied it myself, unasked.</p>
<p>A prenup is often a good idea.</p>

<p>I think the key point here is to talk to your employer early, namely the moment you notice that code you already wrote for your personal project is useful for the task you got from the employer. There is potential for a win-win here because if the code the company needs already exists they can get it cheaper and faster than if you have to rewrite it from scratch. You just have to talk to them and find a mutually acceptable agreement. They get the code (and it is their intellectual property afterwards) and you get something from them, cash or some other work priviledges that you want. As both sides can win here this shouldn't be too difficult.</p>

<p>The actual problem here is the liability that you are exposing the company to.  You are including code in their product that someone other than the company (you) has a prior copyright claim to.  You probably signed something saying you wouldn't do this when you joined the company.</p>
<p>I think that making your previously written code public somewhere with an MIT-style open source license (or something else that explicitly says commercial derivatives are fine and obligation-free) would probably eliminate the problem.</p>
<p><strong>It is still best to check</strong>.  Just tell someone the situation and ask them if it's ok to use your code.</p>
