GitHub Code in a Commercial Product: Licenses and What to Check
MarkdownPermissive licenses MIT, Apache, and BSD, copyleft GPL/AGPL, the absence of a LICENSE file, and checking the origin of code added by AI.
Read full article
You’re building a product and find a ready-made piece on GitHub: a library, a template, an entire project that does exactly what you need. Claude suggests pulling it into your project. And then you pause: the code seems to be publicly available, but can you actually use it, let alone sell a product that includes it? Could the author come after you later?
I’ll go through this in order: why open code on GitHub isn’t permission by itself, which licenses let you use code and sell a product, which copyleft conditions can require corresponding source for a covered work, and how to check a license in a minute before using the code. No “it depends on the situation.”
Practical information about working with Ailoot is in the documentation.
Attention
This material is for reference; I’m not a lawyer. Below, I describe the terms of popular licenses and rules, with links to primary sources, but check your specific situation against the license text and, if the product is large and commercial, with a lawyer. You make the decision yourself.
Is it true that if code is on GitHub, you can use it for free?
Main point
No. The fact that code is available to view doesn’t mean you’re allowed to use it in your own work. By default, all code is protected by copyright, and you may not use it unless the author has separately granted permission. Publishing on GitHub by itself only lets others view the repository and make a copy within GitHub. The right to put that code in your product comes from the license the author attached to the repository. GitHub itself doesn’t grant it.
The main trap here is the word “open.” You can see the source code, so it seems that because it wasn’t hidden, you’re allowed to use it. That logic is wrong. “Open to read” and “licensed for use” are different things.
By default, any creative work, including code, is protected by copyright from the moment it is created. Until the author explicitly grants permission, you may not use it. That’s how GitHub describes it on its own license reference page.
When you create a creative work (and code is a creative work too), by default it is protected by exclusive copyright. Unless you attach a license that says otherwise, nobody else can copy, distribute, or modify your work without risking a claim or a lawsuit.
The second layer is GitHub itself. People think that because they agreed to GitHub’s rules by publishing code, they can also use other people’s code from there. The rules say exactly the opposite. By making a repository public, the author lets others only view and fork it—that is, make a copy within GitHub itself. That doesn’t authorize using the code in your own work.
By making a repository public, you grant other users a non-exclusive, worldwide license to use, display, and reproduce (by forking) your materials through the service, within GitHub’s features. You can grant additional rights by attaching a license.
The key words are in the last sentence: “within GitHub’s features” and “additional rights come from a license.” A fork stays within GitHub. As soon as you want to use the code in your own product, let alone sell it, you need a separate license from the author. No license, no right—even if the code is right there in plain sight.
What determines whether you can use someone else’s code?
Main point
It’s the license file in the repository, usually called LICENSE or LICENSE.md. It’s the author’s permission, specifying what you can and can’t do with the code. The license answers three questions: can you use the code in a commercial product, can you modify it, and can you keep your own source code closed? Different licenses answer these differently, so the first thing to check is this file; only then should you open the code itself.
It all comes down to one file. A properly maintained repository contains a license file—usually LICENSE, sometimes LICENSE.md, or a mention directly in the README. This is the author’s permission, which states the terms under which you may use the code. GitHub usually displays the license name in the repository page’s sidebar, before you even open the file itself.
To avoid getting lost in legal language, it’s useful to read the license through three questions about your situation:
- Can you use this code in a commercial product that people pay for?
- Can you modify the code for your needs?
- Do you have to open your product’s source code afterward, or can you keep it closed?
Almost all the differences between licenses come down to different answers to the third question. For the first two, popular open licenses most often say “yes”: use it, modify it, sell it. But whether the license will make you open your own code is where people stumble. Next, we’ll go through the main types using these three questions.
Which licenses let you use code and sell a product?
Main point
The most convenient for a commercial product are permissive licenses: MIT, Apache 2.0, and BSD. They allow almost everything: using the code, modifying it, selling the product, and keeping your own source code closed. There’s one obligation: preserve the license text and attribution. Apache 2.0 also protects against patent claims and requires you to mark modified files. If someone else’s code has one of these licenses, you can safely use it in a commercial product.
Let’s start with good news. For someone building a product to sell, the best option is a group of licenses called permissive licenses. There are several, but three are most common: MIT, Apache 2.0, and BSD. All three answer “yes” to the first two questions and let you keep your own source code closed.
The most common and simplest is MIT. Its text fits in a single paragraph.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software, to use it without restriction, including the rights to use, copy, modify, merge, publish, distribute, sublicense, and sell copies, provided that the above copyright notice and this permission notice are included in all copies.
In simpler terms, MIT lets you do almost anything with the code, including selling the product and keeping your own source code closed. The only obligation is to include the license text and attribution line. Babel, .NET, and Rails, for example, are released under MIT, so you’ve almost certainly used code under this license already.
Apache 2.0 works similarly, but adds two important points. First, explicit protection against patent claims: the code’s authors promise not to sue you over patents on this code. Second, a few more formal requirements for use.
You may reproduce and distribute copies of the work or derivative works in any medium, with or without modifications, provided that you give recipients a copy of this license, mark modified files, retain copyright and patent notices, and include a readable copy of the NOTICE file, if there is one.
BSD (in its 2-clause and 3-clause versions) is essentially similar to MIT: use it, modify it, sell it, preserve the copyright notice. I’ve put all three in a table so you can see the difference at a glance.
| License | Sell the product | Keep source code closed | What you must do | Patent protection |
|---|---|---|---|---|
| MIT | yes | yes | preserve copyright notice and license text | no clause |
| Apache 2.0 | yes | yes | copyright notice, NOTICE file, mark modifications | yes |
| BSD (2 and 3 clauses) | yes | yes | preserve copyright notice | no |
How to read this for your own use: if you see MIT, Apache 2.0, or BSD on someone else’s code, you can relax: you can use it in a commercial product, modify it, and keep your own source code closed. You only need to avoid removing the license file and attribution from the part you took.
How do GPL and AGPL source obligations apply?
Main point
GPL and AGPL allow commercial use. GPL source obligations arise when you convey a covered work; ordinary server use without transferring a copy is not that trigger. AGPLv3 adds a source-offer requirement for users interacting remotely with a modified version. Determine which combined work is covered: separate, independent components are not automatically all part of it.
Copyleft keeps a covered work and its derivatives under the same license when the relevant conditions apply. Under GPLv3, distributing source or object-code copies of a covered or combined derivative work requires compliance with its license and corresponding-source obligations. It does not automatically apply to every independent program in the same product or server.
Take the web-service example. Hosting a GPL library on your own server without giving users copies does not, by itself, require publishing the whole service. Distributing a covered combined application to customers can trigger GPL duties; check the code’s integration and license before deciding what source must accompany it. A browser client delivered to users is a separate distribution question.
AGPLv3 adds a network condition: if you modify the program and users interact with that version remotely, it must prominently offer those users its corresponding source. This is more precise than saying that merely hosting any AGPL component opens every independent part of a service.
For a proprietary product, examine the covered work, how components combine, whether copies are distributed, and whether AGPL network interaction applies. Choose a compatible permissive alternative or obtain separate permission if you cannot meet the relevant obligations. Commercial use itself is allowed; the issue is compliance with the actual license and integration.
What should you do if the repository has no license file at all?
Main point
No license file means you may not use the code. This doesn’t mean “it’s free”: on the contrary, without a license, the code remains under the author’s full copyright, and you have no right to use, copy, or modify it. Permission to view and fork within GitHub doesn’t help here—it doesn’t give you the right to put the code in your product. If you really need the code, the only clean path is to write to the author and ask for permission, or wait until they add a license.
A common mistake is to assume that if there’s no license, there are no restrictions and you can use the code freely. It’s the opposite. No license is not permission; by default, it means no permission. The code without a license remains under the author’s full copyright, and you may not touch it.
The rule we started with applies again: by default, code is protected by copyright, and without explicit permission you may not copy, modify, or distribute it. The ability to view and fork it within GitHub doesn’t break through that barrier—it doesn’t grant you the right to use the code in your own product.
What to do in practice if the code has no license but you really need it:
- Write to the author. Directly in the repository’s discussions section or by email, ask whether you can use the code and under what terms. Sometimes the author simply forgot to add a license and will add one if asked.
- Look for a replacement. For almost any task, there’s a second, third, and tenth similar repository—you’ll find one with a proper MIT or Apache license among them.
- Don’t use it. If you don’t have permission and there’s no replacement, the code isn’t yours, and you can’t put it in a product you intend to sell. The temptation to think “who’s going to find out?” ends badly right when the product starts making money and attracting attention.
What if Claude itself added someone else’s code to the project?
Main point
This is a separate case, and it’s important not to confuse it with directly copying a repository. When you take code from a specific repository yourself, you have to comply with its license. When Claude or another AI generates code in response to your request, it usually produces its own text, assembled for the task, rather than a copy of someone else’s file, and the question shifts to the rights in the generated code. But if the AI clearly reproduced a recognizable piece of someone else’s licensed code, the license terms still apply. It’s worth checking the source in both cases.
There’s a second layer here, and it’s easy to confuse with the first. It’s one thing when you visit a repository and copy a file from it: then everything above about the license is your direct obligation. It’s another when Claude writes code for you in response to a request.
In ordinary cases, AI produces its own text, assembled for your task, rather than a copy of someone else’s file. Then the question shifts to a different area: who owns the generated code, and can you sell it? That’s a large topic of its own, and I covered it in an article about who owns code written by AI.
But there’s an exception to keep in mind. Sometimes AI produces a recognizable piece of someone else’s code almost word for word—a whole function from a well-known library. In that case, the library’s license still applies, regardless of who physically pressed the keys. So large ready-made blocks that Claude pulled in wholesale should be checked just as if you had copied them yourself.
How to check a license before using code: steps to follow
Main point
The process is: open the repository page and check the license name in the sidebar, open the LICENSE file itself, identify the type—permissive (MIT, Apache, BSD) or copyleft (GPL, AGPL)—compare it with your situation, and decide whether to use the code or look for a replacement. If there’s no license at all, don’t use the code. The whole check takes a couple of minutes and should happen before the code enters your project, not afterward.
Let’s put it all into a short checklist for checking any third-party code before you bring it into your project. Go from top to bottom.
Find the license name on the repository page
Open the repository on GitHub. The license name is usually visible in the right column or below the file list—for example, “MIT License,” “Apache-2.0,” or “GPL-3.0.” If it’s blank and there’s no license file, that’s already a red flag; come back to it in the last step.
Open the license file itself
Find LICENSE, LICENSE.md, or COPYING in the file list and open it. Make sure the name matches what’s shown in the sidebar and that the license applies to the code you’re using, not just to a separate part of the repository.
Identify the type: permissive or copyleft
MIT, Apache 2.0, and BSD are permissive; you can use the code in a closed commercial product. GPL and AGPL are copyleft; check the covered work, distribution, and any AGPL network condition before determining the source obligations. The name alone does not establish which independent components are covered.
Compare it with your situation
Answer three questions: are you selling the product, are you modifying the code, and do you want to keep the source code closed? MIT, Apache, and BSD work for a closed product for sale. For GPL and AGPL, determine which covered or combined work would need corresponding source and when the obligation is triggered; assess whether you can meet those conditions.
No license means don’t use it
If there’s no license file and the README says nothing about permission, you may not use the code. Write to the author and ask for permission or find an equivalent with a proper license. “It’s publicly available” is not permission.
This check seems tedious right up until the first time your product grows, starts making money, and someone asks about the third-party code inside it. Two minutes at the start cost less than dealing with a dispute later. I cover separately what to do with your product after that so it doesn’t stall after launch: I built a product with AI; what’s next.
Frequently asked questions
Can you sell a product that contains someone else’s code from GitHub?
Yes, if the code has a permissive license—MIT, Apache 2.0, or BSD. They allow you to use code in a commercial product, sell it, and keep your own source code closed, requiring only that you preserve the license text and attribution. GPL and AGPL also allow commercial use, but source duties depend on the covered work and the distribution or applicable AGPL network trigger. Without a license file, you may not use the code at all.
What does it mean if a GitHub repository has no license?
It means you may not use the code. No license means no permission by default; it doesn’t mean “free.” The code remains under the author’s full copyright. The ability to view and fork the repository within GitHub doesn’t give you the right to use the code in your product. If you need the code, write to the author and ask for permission, or find an equivalent with an open license.
How is MIT different from GPL for my product?
MIT lets you use and modify the code, sell the product, and keep your own source code closed—the only obligation is to preserve the license text. GPL also permits commercial use, but conveying a covered combined or derivative work requires compliance with its corresponding-source and same-license obligations. Mere hosting without transferring a copy is different, and separate independent components are not automatically covered.
Do I have to do anything if I use code under the MIT license?
Yes, one small thing: preserve the MIT license text and the attribution line from the code you used in your project. Usually that’s the same LICENSE file attached to the original. MIT doesn’t require anything else—you can modify the code, sell the product, and keep your source code closed.
What if Claude itself added someone else’s code, rather than me?
You should still check the source. AI usually produces its own text for your task, and then the question shifts to rights in generated code—that’s a separate topic. But if AI reproduced a recognizable piece of someone else’s code from a well-known library almost word for word, that library’s license still applies. Check large ready-made blocks pulled in wholesale as you would your own copy-and-paste.
Sources
- choosealicense.com - GitHub reference project for choosing a license
- choosealicense.com - what it means to have no license
- GitHub Terms of Service, Section D (License Grant to Other Users)
- MIT License (opensource.org)
- Apache License 2.0 (apache.org)
- GNU General Public License v3.0 (gnu.org)
- GNU Affero General Public License v3.0 (gnu.org)
More details
Questions about GitHub Code in a Commercial Product: Licenses and What to Check
Does hosting a GPL library force me to publish my entire web service?
Hosting alone, without transferring copies, is not the GPL distribution trigger. If you distribute a covered combined or derivative application, source obligations may apply to that work; independent components are not automatically covered.
What extra condition does AGPLv3 add for a web service?
A modified AGPL program that supports remote network interaction must offer its corresponding source to those users. Check the covered program and integration rather than assuming either that no source is needed or that every independent service must be opened.