Yes, AI companies buy access to private source code, and the normal way to sell it is a licence, not a transfer of ownership. Labs want real production repositories with their history: commits, tests, issues, pull requests and review threads, because that is what teaches and tests coding agents. Before you share anything, you must prove you own the code, strip out third-party open-source code, remove secrets and personal data, and agree terms that stop the buyer redistributing your code or letting a model repeat it verbatim. The code is rarely the hard part. The clean-up and the paperwork are.
Key takeaways
- Labs pay for context around code: commit history, tests, linked issues and code review. A bare snapshot of files is worth far less.
- Ownership comes first. Employee code usually belongs to the employer, but contractor code often does not unless there is a signed assignment.
- Exclude third-party code. GPL and AGPL code you hand over cannot be bound by your "no redistribution" terms. Permissive code carries notice duties and adds nothing a lab can't get for free.
- Scan the whole git history for secrets, not just the latest files, and rotate anything you find before you rewrite history.
- Commit author names and emails are personal data under UK and EU GDPR. Customer data in fixtures, logs and comments is a bigger risk still.
Can you sell source code to AI companies?
Yes. AI labs and the vendors that supply them do acquire private codebases, mostly through licences that let them use a copy for training or evaluation while you keep ownership.
The clearest public evidence comes from research. Scale AI's SWE-Bench Pro benchmark includes "a commercial set of 18 proprietary repositories where we have formal partnership agreements with early-stage startups". The authors say this is "the only set containing proprietary repositories from startups, which we cannot release for legal reasons." In other words, a buyer licensed private code and agreed not to publish it.
The market has also reached companies that are closing. MIT Technology Review reported in October 2026 that wind-down services such as SimpleClosure help founders "sell their code and workspace data", and that buyers include foundation AI labs and "vendors that construct simulated workspaces for AI training". If your company is shutting down, see our guide to selling startup data after a shutdown. Code is one category within the wider market for selling company data to AI labs.
"Selling" here almost always means licensing: a defined right to use a copy, for a defined purpose and time. That matters for code, because it may still run your business.
Why do AI labs want private code when GitHub is public?
Because public code is already in their training sets, and private code is not. Labs need fresh, realistic material to train coding agents and to test them on problems they have not seen before.
Coding models now learn from tasks, not just files
Coding benchmarks now test whole software tasks, not single functions. SWE-bench, published in 2023, built 2,294 test problems from real GitHub issues and the pull requests that fixed them, across 12 Python repositories. A model has to edit a real codebase so that the project's own tests pass.
Training environments follow the same pattern. SWE-Gym (2024) describes each task as "a codebase with an executable runtime environment, unit tests, and a task specified in natural language." That needs an issue, the code before the fix, the fix and tests. Only a repository with real history supplies all four. Labs also use these tasks to build reinforcement-learning environments; see our overview of RL environment companies.
History and review are training data too
The OctoPack paper (2023) built a dataset of Git commits by "leveraging the natural structure of Git commits, which pair code changes with human instructions." Another team trained a model on code changes and reviews from open-source projects to handle "code change quality estimation, review comment generation and code refinement." Review threads show what experienced engineers reject, and why.
Public code is used up, and contaminated
Open datasets already cover public code at scale. The Stack v2, used to train StarCoder2, draws on the Software Heritage archive, "spanning 619 programming languages", plus GitHub pull requests. That creates a testing problem called contamination. If a model has seen a repository in training, scoring it on that repository proves little. SWE-Bench Pro tackled this in two ways. Its public set uses GPL-licensed repositories so that the content is "unlikely to appear in proprietary model training sets". Its commercial set uses private startup code. The authors report "a significant performance gap between the public and commercial set", which they put down to "the difficulty of navigating enterprise codebases." Private, real-world code is what models still struggle with, so labs seek it out.
How the public datasets handled rights
The Stack is a useful contrast. Its creators described it as "permissively licensed source code", built a tool called "Am I in The Stack" and offered "a process for code to be removed from the dataset." StarCoder's authors added "an improved PII redaction pipeline" to remove personal information. Public datasets rely on open licences and opt-outs. A private licence works the other way round: you opt in, on terms you negotiate. MIT Technology Review reported that demand rose as AI labs "hit the limits of public and synthetic datasets."
What makes a codebase valuable for AI training?
Value comes from how many realistic, checkable tasks a buyer can build from your repository. MIT Technology Review reported that buyers value code on "research theses" about how many useful tasks it can yield. There is no public price list, and most deals stay under NDA.
- Real production use. Code that shipped, broke and got fixed beats a side project.
- Long commit history. Years of small commits with clear messages give many before-and-after examples. One squashed commit gives almost none.
- Tests that run. Tests let a buyer check automatically whether a model's change works.
- Linked issues and pull requests. A bug report linked to its fix and review comments is a ready-made task.
- Documentation. Design docs and READMEs explain intent.
- Language and domain. Python dominates the best-known coding benchmarks: SWE-bench and SWE-Gym are both built from Python repositories. SWE-Bench Pro's authors note that their own benchmark under-represents Java, C++ and Rust. Specialist domains such as finance, healthcare back-ends, embedded systems and industrial software are hard to find in public.
- Human-written code. Code from before AI coding assistants were common is easier to vouch for as human work. If much of your code was generated by an assistant, say so.
- Clean rights. A repo with documented ownership and no third-party code is easier for a buyer to use, and so worth more to them.
What rarely sells: public open-source code, forks and templates, tiny repos with no history or tests, and code you can't clean or don't own.
Do you actually own the code you want to sell?
Only if every contributor's rights reached your company. Employee code usually belongs to the employer automatically. Contractor and freelancer code often does not, unless a signed written agreement transferred it.
United States
Under US copyright law, a "work made for hire" includes "a work prepared by an employee within the scope of his or her employment". For such works, the employer "is considered the author" and owns the copyright unless a signed written agreement says otherwise.
Commissioned work by an independent contractor is different. It only counts as work made for hire if it falls into one of nine listed categories, such as a contribution to a collective work or a translation, and the parties sign a written agreement. Software is not one of the listed categories. So contractor code usually needs an assignment. US law requires that a transfer of copyright be "in writing and signed by the owner of the rights conveyed".
United Kingdom
Under the Copyright, Designs and Patents Act 1988, the author is the first owner of copyright. Where a work is made "by an employee in the course of his employment, his employer is the first owner of any copyright in the work subject to any agreement to the contrary." Section 11 has no similar rule for contractors, so again you need a written assignment.
What to check
- Contributors. Run
git shortlog -sneto list everyone who committed, and match each to an employment contract or signed assignment. - Agencies and founders. Check agency IP clauses, and make sure code written before incorporation was assigned to the company.
- Acquired code. Check the purchase agreement covers the code and any licence limits.
- Client work. The contract may give the client ownership or restrict reuse. You need the client's written release.
If you are an individual developer, code you wrote for an employer is normally the employer's to license, not yours.
What about open-source code inside your repo?
Remove it. Third-party code adds nothing a lab can't get for free, and some licences conflict directly with the terms a code licence needs. License your own code only, and give the buyer a list of dependencies instead of the dependencies themselves.
Vendored libraries and copied snippets keep their own licences when you hand them over.
Why copyleft licences are the main problem
The GNU GPL version 3 defines "convey" as "any kind of propagation that enables other parties to make or receive copies." Handing a repository to a lab does that. The licence then says that "Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work". It also says "You may not impose any further restrictions on the exercise of the rights granted".
So your "no redistribution" term can't bind the buyer for any GPL code in the delivery. If your own code is a modified version of GPL code, the GPL's rules on modified versions say "You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy." That is a risk you don't want in a commercial deal.
The AGPL version 3 adds a network clause: if you modify the program, your version "must prominently offer all users interacting with it remotely through a computer network" a way to get its source code.
Permissive licences still carry duties
The MIT licence requires that "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software". The Apache License 2.0 requires anyone who redistributes the work to "give any other recipients of the Work or Derivative Works a copy of this License" and to keep copyright, patent, trademark and attribution notices. Easy to meet, but they add work and no value for the buyer.
| What you find in the repo | Main licence obligation | What to do |
|---|---|---|
| Vendored GPL code | Recipients get GPL rights automatically; no further restrictions allowed | Remove from the delivery; list it in a dependency manifest |
| Your code that modifies or is built on GPL code | The whole modified work must be licensed under the GPL to anyone who receives a copy | Get legal advice before including it; often best excluded |
| AGPL v3 code (for example, a modified server component) | GPL duties plus source access for remote network users | Remove; flag if your own product depends on a modified version |
| MIT, BSD-style or similar permissive code | Keep copyright and permission notices in copies | Remove; if a file must stay for the build to work, keep its notices intact |
| Apache 2.0 code | Give a copy of the licence, mark changes, keep notices and any NOTICE file | Remove; if it must stay, include LICENSE and NOTICE files |
| Commercial SDKs and vendor code | Set by the vendor's contract, which may restrict redistribution | Remove; check the vendor agreement before sharing even headers |
| Snippets with no licence or unknown origin | No written permission to share | Remove, or rewrite them if you need the repo to build |
| Dependency lockfiles and manifests | Usually just names and versions | Keep; they tell the buyer what the code depends on without shipping it |
A software composition analysis tool or a licence scanner will find most of this. Look for folders such as vendor/, third_party/ and node_modules/, and for licence headers in individual files. The Frankfurt Kurnit Klein & Selz briefing on selling company data warns that "Licensed data, open source and vendor code" may "come with restrictions or competing ownership claims."
Recall that SWE-Bench Pro picked GPL repositories precisely because they are unlikely to be in proprietary training sets. Removing copyleft code makes your repo easier for a buyer to accept.
How do you find and remove secrets and credentials?
Scan every commit in the history, not just the current files, then revoke and rotate anything you find before you rewrite the history. A password deleted from today's code is still sitting in last year's commit.
Scan the whole history
Two open-source scanners do this:
- Gitleaks. Its
gitcommand scans repositories and "uses thegit log -pcommand to scan patches", so it checks every change in the history. Itsdircommand checks only the current files. - TruffleHog. Its documentation says it "classifies over 800 secret types". It can also check whether a key still works: "For every secret TruffleHog can classify, it can also log in to confirm if that secret is live or not." It labels results as verified, unverified or unknown.
Scanners use patterns, so also check configuration files and test fixtures by hand.
Rotate first, then clean
GitHub's own guidance is that "as a first step you need to revoke and/or rotate that secret." Rewriting history does not reach copies you can't control. GitHub warns that "You cannot remove sensitive data from other users' clones of your repository."
For the delivery copy, GitHub recommends git-filter-repo. Its --replace-text option replaces given strings across the history. Its path options with --invert-paths remove whole files, such as an old .env. Its --sensitive-data-removal mode is "intended to remove sensitive data from a repository". Do this on a separate copy made for the buyer, never on your working repository.
Why it matters for AI training
Models can repeat what they were trained on. The paper "Unveiling Memorization in Code Models" found that "A code model memorizes and produces source code verbatim", and that such output "potentially contains vulnerabilities, sensitive information, or code with strict licenses". A key left in your data could resurface in someone else's autocomplete.
What personal and customer data hides in a codebase?
More than most teams expect. Every commit carries a name and an email address, and repos often hold customer data in test fixtures, database dumps, logs and comments. Each needs a decision before you share.
Commit metadata is personal data
UK and EU GDPR define personal data as "any information relating to an identified or identifiable natural person", and list identifiers such as "a name, an identification number, location data, an online identifier." A commit author's name and work email fall squarely within that. So do usernames in issue threads and review comments.
You can rewrite author names and emails across the history with git-filter-repo --mailmap, which uses a mailmap file "when rewriting author, committer, and tagger names and emails." Replacing names with stable codes is pseudonymisation, and pseudonymised data is still personal data while anyone holds the key. Our main guide explains how de-identification works under UK and EU law. Check, too, what your privacy notices and employment contracts told staff. For a wider view, see is it legal to sell company data for AI?
Export formats can add more. GitLab's project export includes "Direct project members" alongside issues and merge requests. Review every file in an export, not only the code.
Customer data and confidential information
- Test fixtures and seed data copied from production.
- Database dumps and backups committed by mistake.
- Logs and stack traces pasted into issues, often with emails, IP addresses and account IDs.
- Customer names in branch names, comments, feature flags and configuration.
- Customer-specific code written under contracts that make it confidential or the customer's property.
Delete whole files rather than redacting lines, and search the full history for emails and customer names.
Trade secrets
In the US, information only qualifies as a trade secret if "the owner thereof has taken reasonable measures to keep such information secret". The Frankfurt Kurnit briefing warns that a sale may "jeopardize trade secret protection for pricing logic, strategy documents, and source code." Keep core code out, and insist on strict confidentiality.
Export controls
Most commercial code raises no export issue, but check code tied to defence or dual-use technology. Under the US Export Administration Regulations, releasing "technology" or source code to a foreign person inside the United States is a "deemed export". Under the EU Dual-Use Regulation, export includes "transmission of software or technology by electronic media" to a destination outside the EU. The UK runs its own export control regime. If your code is controlled, a licence to a lab abroad, or one with foreign staff, may need an export licence.
How should you package a codebase for a buyer?
Deliver the full git history together with the issues, pull requests and review threads, linked to each other, in a cleaned copy made just for the buyer. A ZIP of the latest files throws away most of the value.
| Component | Why buyers want it | How to prepare it |
|---|---|---|
| Git repository with full history | Every commit is a before-and-after example with a message explaining it | Clone a fresh mirror, remove third-party paths and secrets with git-filter-repo, rewrite author identities |
| Issues or tickets | Natural-language task descriptions and bug reports | Export from GitHub, GitLab or Jira; scrub personal and customer details from text and attachments |
| Pull or merge requests with reviews | The link between task and fix, plus expert feedback | Export diffs and review comments; keep the IDs that link them to issues and commits |
| Tests and build setup | Lets a buyer check automatically whether a change works | Provide a Dockerfile or build instructions; confirm tests run without live services or secrets |
| CI history | Shows which changes broke the build and how they were fixed | Export pipeline results and logs separately; scan them for secrets and personal data |
| Manifest and data card | Tells the buyer what is included, excluded and why | List repos, date ranges, languages, line counts, exclusions and the cleaning steps applied |
Watch what exports leave out
GitLab's project export includes issues, "Merge requests" with diffs, comments, reviewers and approvers, and archived CI/CD pipelines. It does not include "CI/CD job traces and artifacts", "Links between issues and linked items" or "Links to related merge requests". You may need the API to export those links, which are what turn a repo into usable tasks.
GitHub's organisation migration API produces an archive with git data and metadata, with options to exclude metadata, git data, attachments or releases. GitHub notes that "Migration archives are automatically deleted after seven days." Plan your download.
Start with one cleaned repository, or a slice of one, under NDA. A sample is itself a disclosure, so it must pass every check above first.
What licence terms matter most for code?
Four terms do most of the work: no redistribution, no verbatim output, limits on competitive use, and deletion. Code is easy to copy and can still run your product, so these matter more than for most data. Our guide to AI data licensing deal terms covers the general clauses in depth.
| Term | What it covers | What to push for |
|---|---|---|
| Scope | Which repos, branches, date ranges and related data are licensed | A written schedule; anything not listed is not licensed |
| Field of use | Training, evaluation, or both | A named purpose; evaluation-only is a lower-risk first step |
| No redistribution | Whether the buyer can share, publish or resell the code | A ban, except named subcontractors bound by the same terms; no publishing as an open benchmark |
| No verbatim regurgitation | Whether models may output long passages of your code | A duty to apply output filters and deduplication; tools that match outputs against known code already exist |
| Competitive use | Whether the buyer may use the code to build a rival product | A ban on using it to clone or compete with your product |
| Deletion | When raw copies are destroyed | A fixed date and written certification; be clear it covers copies, not models already trained |
| Warranties | What you promise about ownership and contents | Promises limited to what you checked, backed by your manifest of exclusions, with a cap on liability |
On regurgitation, a filter is a realistic ask. GitHub Copilot, for example, can compare a suggestion "and approximately 150 characters of surrounding code" against an index of public code, and "matching suggestions can be blocked or shown with information about the matching code." A similar check against your licensed code is a reasonable contractual requirement.
SWE-Bench Pro also shows that "use it but never release it" is a workable term: its authors evaluate on private startup code they cannot publish.
What does the process look like, and how long does it take?
Deals typically take 30 to 90 days from first sample to signed licence. Rights checks, the buyer's evaluation and contract rounds take most of that time.
- Inventory repos, languages, years of history, contributors, tests and linked trackers.
- Clear rights: ownership, third-party code, export and trade-secret exposure.
- Clean secrets, personal data and customer data from a delivery copy.
- Send a sample under NDA. The buyer tests the build, the tests and how many tasks it yields.
- Negotiate scope, field of use, redistribution, regurgitation, deletion and warranties.
- Deliver securely with a manifest, and diary the deletion date.
When you shouldn't sell
Don't license code that is your competitive edge, code your clients own, or repos so full of customer data that cleaning would strip out the value.
If you also hold engineering files or written archives, see our guides to selling CAD files to AI companies, CAD datasets for machine learning and licensing a text corpus for LLM training.
Disclosure: Glasa Lab is a data broker and helps companies license code and other data to AI teams. We have tried to describe the checks and terms neutrally, whichever route you choose.
This guide is general information, not legal advice. It refers to US, UK and EU law, which differ and change. Copyright ownership, open-source licence obligations, data protection and export controls all depend on your facts and contracts. Have a qualified lawyer review your plans before you share any code.
FAQ
Do AI companies buy code?
Yes. Labs and the vendors that build training environments license private codebases. Research benchmarks such as SWE-Bench Pro openly use proprietary startup repositories obtained through partnership agreements, and wind-down services help closing startups sell their code.
Can I sell code I wrote at my job?
Usually not. Under US and UK law, code an employee writes in the course of their employment normally belongs to the employer. Only the owner can license it.
Do I need to remove open-source code first?
You should. GPL and AGPL code can't be bound by a no-redistribution term, and permissive code carries notice duties while adding nothing the buyer can't get free. License your own code and supply a dependency list instead.
Will the AI model leak my code?
Models can memorise and repeat training data, so ask for a ban on verbatim output, output filtering and strict confidentiality. Never include code you can't afford to see repeated, and never include live secrets.
How long does a code licensing deal take?
Deals typically take 30 to 90 days from first sample to signed licence. Ownership checks and the buyer's evaluation of your sample usually take longest.
Sources
- Jimenez et al., "SWE-bench: Can Language Models Resolve Real-World GitHub Issues?", arXiv:2310.06770, October 2023. arxiv.org
- Deng, Da et al. (Scale AI), "SWE-Bench Pro: Can AI Agents Solve Long-Horizon Software Engineering Tasks?", arXiv:2509.16941v2, November 2025. arxiv.org
- "Training Software Engineering Agents and Verifiers with SWE-Gym", arXiv:2412.21139, December 2024. arxiv.org
- "OctoPack: Instruction Tuning Code Large Language Models", arXiv:2308.07124, August 2023. arxiv.org
- "Automating Code Review Activities by Large-Scale Pre-training", arXiv:2203.09095, ESEC/FSE 2022. arxiv.org
- Kocetkov et al., "The Stack: 3 TB of permissively licensed source code", arXiv:2211.15533, November 2022. arxiv.org
- "StarCoder: may the source be with you!", arXiv:2305.06161, May 2023. arxiv.org
- "StarCoder 2 and The Stack v2: The Next Generation", arXiv:2402.19173, February 2024. arxiv.org
- "Unveiling Memorization in Code Models", arXiv:2308.09932, August 2023. arxiv.org
- Matthew King, "AI labs are buying data from dead startups to train their models", MIT Technology Review, 13 October 2026. technologyreview.com
- Daniel Goldberg, Frankfurt Kurnit Klein & Selz, "Selling Company Data for AI Training: What to Know Before You Say Yes", 1 October 2026. technologylaw.fkks.com
- Free Software Foundation, GNU General Public License, version 3. gnu.org
- Free Software Foundation, GNU Affero General Public License, version 3, section 13. gnu.org
- Apache Software Foundation, Apache License, Version 2.0, sections 2 and 4. apache.org
- Open Source Initiative, The MIT License. opensource.org
- 17 U.S.C. § 101 (definition of "work made for hire"), via Cornell Legal Information Institute. law.cornell.edu
- 17 U.S.C. §§ 201(b) and 204(a), via Cornell Legal Information Institute. law.cornell.edu
- Copyright, Designs and Patents Act 1988, section 11. legislation.gov.uk
- Gitleaks, project documentation, accessed 17 November 2026. github.com
- Truffle Security, TruffleHog documentation, accessed 17 November 2026. github.com
- GitHub Docs, "Removing sensitive data from a repository", accessed 17 November 2026. docs.github.com
- git-filter-repo, manual page, accessed 17 November 2026. github.com
- UK GDPR, Article 4(1). legislation.gov.uk
- 18 U.S.C. § 1839(3) (definition of "trade secret"), via Cornell Legal Information Institute. law.cornell.edu
- Export Administration Regulations, 15 C.F.R. § 734.13, via Cornell Legal Information Institute. law.cornell.edu
- Regulation (EU) 2021/821 (Dual-Use Regulation), Article 2(2). eur-lex.europa.eu
- GitLab Docs, "Migrate projects and groups by using file exports", accessed 17 November 2026. docs.gitlab.com
- GitHub Docs, "REST API endpoints for organization migrations", accessed 17 November 2026. docs.github.com
- GitHub Docs, "GitHub Copilot code referencing", accessed 17 November 2026. docs.github.com
Updated 17 November 2026: first published.