# What is code masking?

> Code masking is partial repository access with a working build: part of the source stays out of a person's view, and the build still uses it. What it is not.

Source: https://occlude.dev/blog/what-is-code-masking/ · 3 November 2026, updated 28 November 2026 · By Aman Sharma


Code masking means giving a person or an AI agent a working copy of a codebase in which some source files are out of their view, while the compiler, the tests and the running app still use every file. The person sees part of the repository. The build sees all of it.

![One repository drawn twice. On the person's side, the web app's files and package.json are listed, and the card form and billing files are solid bars. On the build's side every file is present, including the billing code, while .env and the data seeds are marked never mounted](https://occlude.dev/figures/code-masking.webp)

*The same repository, two views: the person works in the task's files, the build reads all of them, and credentials and seeds are on neither side.*

The term is ours, borrowed on purpose from data masking, and it gets confused with three older ideas. This page separates them.

## The short definition

A setup counts as code masking only if both of these hold:

- **Part of the source is unreadable to the person.** Not discouraged, not logged after the fact. They cannot open it, list it or search it.
- **The build does not notice.** Code that imports the masked files still compiles, the tests still run and the app still boots, with no mocks to maintain.

The first property on its own is ordinary path permissions, which version control has offered for decades. The second on its own is ordinary full access. The point of the term is the two together.

## What it is not

| Term | What it protects | From whom | What it changes |
|---|---|---|---|
| **Code masking** | Source files in a repository | A person or agent working in that repository | What they can read. The build is unchanged |
| **Data masking** | Records in a database: names, card numbers, addresses | Developers and testers using a copy of production data | The values, replaced with realistic stand-ins |
| **Code obfuscation** | A shipped program | Anyone who receives the binary or the script | The code itself, rewritten to be hard to read while it still runs |
| **Secret scanning and secret masking** | Passwords, keys and tokens that ended up in code or logs | Anyone with access to the repository or the log | Nothing in the source. It finds or blanks the secret |
| **Prompt masking** | Names and strings inside text sent to a language model | The model provider | The text in transit, swapped out and restored in the reply |
| **Path permissions in version control** | Files or folders in a repository | A user of the version control server | What lands on their disk. A build that needs the missing files fails |

Data masking is the closest relative. A masked database still has the right shape, so the application runs against it. Code masking makes the same promise one layer up: the codebase still has the right shape, so the build runs against it.

Obfuscation is the one people mix up most. Obfuscated code is handed over in full and made unpleasant to read. Masked code is not handed over at all.

## Why path permissions are not enough

Perforce, Subversion and a few other systems can deny one user the right to read one path. The file then never reaches that user's machine, which is the goal, and the compiler on that machine cannot read it either, which is the cost. Perforce's command reference states the effect of denying the read right directly:

> "If this right is denied, users cannot use p4 print, p4 diff, or p4 sync on files."

So the administrator picks one: the file is out of view and the build breaks, or the build works and the file is readable. Git does not offer the choice at all, because read access in Git is to the whole repository.

Code masking exists to remove that choice. It needs the person and the build to be treated as two different readers of the same files, which a version control server cannot do, because it only decides what is copied to a disk.

## What masked code looks like to the person

For someone working under code masking, a masked file behaves like a file that is not there. It is not in the tree, a search does not find it, and opening its path fails the way a wrong path fails. What they keep is what their own code needs in order to be written: the names and types of what they call, so the editor can still complete and check their work.

Occlude describes this with four states for every path: *Visible*, *Read-only*, *Occluded* and *Absent*. [The four states](https://occlude.dev/docs/states/) says what each one returns.

## When you need it, and when you do not

You probably need code masking when all three are true: outsiders or agents work in your codebase, some of that codebase must not be read by them, and the two parts depend on each other closely enough that splitting them would break the build or cost an integration step on every change.

You do not need it when your repositories already match who may see what. If the sensitive code sits behind a stable interface in its own repository, give outsiders the other repository and stop there. That is cheaper than any product, including ours.

## What code masking does not do

- It does not make anyone forget what they were allowed to see.
- It does not stop a person with full access from passing code to a person without it.
- It is not a replacement for a contract. It changes what the contract has to cover.

## Where Occlude fits

Occlude is a code masking product for contractors and AI agents. It runs in your cloud and holds the repository there, so the work happens next to the code and nothing is copied to the outsider's laptop. Occlude is new. [How a build runs](https://occlude.dev/docs/builds/) shows what the outsider can do, and [Where your code goes](https://occlude.dev/docs/data-flow/) what can leave. The comparison with what teams use today is in [How to give a contractor access to part of a repository](https://occlude.dev/blog/contractor-access-to-part-of-a-repository/).

## Sources

- [p4 protect, the Helix Core command reference](https://help.perforce.com/helix-core/server-apps/cmdref/current/Content/CmdRef/p4_protect.html), for the effect of denying the read right. Read on 28 November 2026.
- Our pages: [The four states](https://occlude.dev/docs/states/), [How it works](https://occlude.dev/how-it-works/).
