Why it matters more now
In the AI era, a repository holds the prompts, agent instructions, model settings, evaluation data and business rules that make a product valuable, next to the code itself. That is intellectual property worth protecting carefully, and every person or agent with repository access can read all of it. Least privilege is how you make sure each of them sees only their part.
Why repository permissions cannot get you there
- Access is per repository. GitHub's repository roles (Read, Triage, Write, Maintain, Admin) all apply to the whole repository. There is no role that shows one folder.
- History comes with it. Anyone who can read the repository can read every past version of every file.
- Code owner rules control approvals, not reading. A
CODEOWNERSfile decides who must approve changes to a path. It does not stop anyone from reading it. - Splitting into many repositories is costly. Shared code, builds and tests get harder, and the pieces still reference each other.
The four limits of least privilege for code
| Limit | Question it answers | Per-task answer |
|---|---|---|
| What | Which code can they see? | Only the folders the task touches, from one exact version, with no history |
| How long | When does access end? | When the task ends, at a time set in advance |
| Where to | What can they connect to? | Only the sites the task needs, such as package sites for reading |
| What leaves | How does work reach the repository? | Only as a reviewed pull request, after someone approves it |
Most teams handle "what leaves" well with protected branches and reviews. The other three are where access quietly grows.
Putting it in place, step by step
- Map your code by sensitivity. Mark the folders that hold the most valuable or dangerous parts: billing, sign-in, prompts and model settings, anything touching customer data.
- Start everyone at no access. Outside developers, new hires on trial, and AI agents begin with nothing and get access per task.
- Grant per task, with an end time. Each task names its folders and its duration. When it ends, access ends without anyone having to remember.
- Keep keys out of reach. No real keys, passwords or
.envfiles in what you share. If a task needs a service, use test credentials. - Close the internet by default. Allow only the sites the work needs, and never your Git host from inside the workspace.
- Review everything that comes back. Pay extra attention to new libraries and files that run automatically.
- Keep a record you can show. Who had which folders, when, what they changed and what they connected to.
Common mistakes
- "Read only, so it's safe." Read access is the access that lets code be copied.
- Permanent access for temporary work. A three-week contract becomes a year of access because nobody removed it.
- Organization-wide tokens for tools and agents. One token that can read every repository, handed to a script that needs one.
- Keys committed to the repository. Everyone with the repository has them, including in history.
- Trusting removal to undo access. Removing someone does not delete the copies they already made.
How the Sealed Room applies least privilege
- What: each room holds only the folders you pick for the task, copied from one exact commit with no history. Hidden files and package folders never go in.
- How long: you set the time when you open the room, up to 8 hours, and the room and everything in it are deleted when it ends.
- Where to: only the sites you allow, package sites for reading by default. GitHub, GitLab and Bitbucket are never reachable.
- What leaves: you review every changed line, files that could run automatically are flagged, and your approval opens a pull request.
- The record: every change and every connection, in a record that cannot be edited.
See how the Sealed Room works.
Questions teams ask
Is this the same as zero trust?
Zero trust is the wider idea of trusting nothing by default and checking every request. Per-task access to code is one practical piece of it, applied to the asset most companies forget to include.
Does least privilege slow developers down?
It does when every request goes through a ticket. It does not when opening a room for a task takes a minute and the developer gets a full editor, a terminal and the packages they need.
What about our own employees?
The same pattern works for anyone who does not need the whole repository: new hires on trial, people moving between teams, and anyone working on a sensitive part of the code.