answers.delivery

How-to · 3 min read

How to keep an AI coding agent out of sensitive files

You want an AI coding agent to help on a real codebase, but some parts, like payment code, infrastructure and database migrations, must stay off limits. A prompt that says "please do not touch the payments folder" is a request, not a rule, and models forget or reinterpret requests. You also want changes that break the test suite to be stopped before they reach you. And on a team, you need those limits to apply the same way for everyone who runs the agent, not just for the person who wrote the careful prompt.

Published
17 Nov 2026
Delivery
No. 12
Topic
AI and agents
Evidence
8 claims quoted from albertcode.dev

01
Why it's hard

Most coding agents decide what to edit from the conversation, so the only boundary is whatever you remembered to type that day. Instructions in a system prompt or a notes file can be ignored when the model thinks a wider change is needed, and you often only notice once the diff is already in your working tree. Reviewing every diff line by line catches problems, but it is slow and depends on the reviewer spotting the one file that should never have changed. What is missing is a limit written down in the repository and checked by the tool itself before anything is accepted. It should live next to the code, go through review like any other file and change only when someone commits a new version.

This part describes the usual way. It makes no claims about AlbertCode SWE, so nothing is quoted here.

02
How AlbertCode SWE does it

AlbertCode SWE Agent reads an optional contract file, albertcode.contract.toml, that you commit to your repository. In it you list forbidden paths, cap how many files a change may touch, name the test commands that must pass and decide which risk levels need an administrator. The agent refuses plans that touch forbidden paths and blocks acceptance of changes that fail the required tests. Because the contract is read from your repository and not from the isolated copy where the agent works, a task cannot loosen its own limits.

that bounds what AlbertCode may do there.Quoted from albertcode.dev
It is read from your repository, never from the isolated copy, so a task cannot widen its own limits.Quoted from albertcode.dev
Committed, this refuses any plan touching src/payments, blocks acceptance of a change that fails npm test, and makes high-risk plans wait for an administrator.Quoted from albertcode.dev

03
Step by step

  1. 1Add albertcode.contract.toml to the root of your repository.
  2. 2List the folders the agent must never touch under forbidden_paths, such as payments or migrations.
  3. 3Set max_files_changed so one task cannot quietly rewrite half the project.
  4. 4Name the test commands that must pass under verification, for example npm test.
  5. 5Commit the file, then use /contract in the terminal to check what the agent will enforce.

04
Tips

Start with a short forbidden list and grow it. Put in the folders where a wrong edit costs real money or downtime, like payments, infrastructure and migrations, and leave the rest open so the agent can still do useful work.

General advice. Not a claim about the product.

Make high-risk plans wait for an administrator. Even if a teammate is happy to approve their own low-risk fixes, anything the plan marks as high risk then needs a second person.

require_admin_for_risk = ["high"]Quoted from albertcode.dev

Keep the required tests honest. The contract can block a change that fails your test command, but it cannot judge code your tests never cover, and the agent's own reviews are made by the model you connect.

Results depend on the model, the request and the quality of the repository's own tests.Quoted from albertcode.dev

Do not worry about failed experiments piling up. When you reject or discard a change, its isolated copy is deleted and your working tree is never touched.

Rejecting or discarding a change deletes its isolated copy: your working tree never saw it.Quoted from albertcode.dev

05
Questions

Where does the agent read its limits from?

From albertcode.contract.toml in your repository, never from the isolated copy where it builds the change.

It is read from your repository, never from the isolated copy, so a task cannot widen its own limits.Quoted from albertcode.dev

Can I require tests to pass before a change is accepted?

Yes. The contract can list commands that must pass, and a change that fails them cannot be accepted.

must_pass = [["npm", "test"]]Quoted from albertcode.dev

Do the built-in security reviews replace human review?

No. They are made by the model you connect and only record that a review happened, so a person still has to review.

Human review remains required.Quoted from albertcode.dev

More from AlbertCode SWE

All 2 answers