Sub topic 15
Writing a Team Policy for AI Tool Use
This chapter assumes you have read the earlier chapters on secret types, data flow, provider policies, scanning, and incident response. It also assumes you can use Git and a command line. The earlier chapters covered personal habits. This one turns them into a written policy that a whole team can follow and check.
Why individual habits are not enough
One careful developer cannot protect a repository if a teammate pastes a production token into a chat tool. A policy gives everyone the same answers to the same questions:
- Which tools may we use, and on which plans?
- Which data may go into them?
- What may an agent do without asking?
- How do we know the rules are followed?
- What happens when someone breaks them, or when a secret leaks?
A good policy is short enough to read and specific enough to check. A policy that says "be careful with secrets" cannot be audited. A policy that says "agents may not read files matching .env.*" can be.
Step 1: Classify your data
Start with data classes. Everything else in the policy refers to them. Keep the number small. Three or four classes are easier to remember than eight.
| Class | Examples | Rule for AI tools |
|---|---|---|
| Secret | API keys, passwords, private keys, Terraform state, session tokens | Never enters a prompt, file context, or tool output sent to a provider |
| Restricted | Customer data, unreleased security fixes, proprietary algorithms, contracts | Only approved tools on plans with no training on your data and defined retention |
| Internal | Most application source code, internal docs, architecture notes | Approved tools only |
| Public | Open source code, published docs | Any tool |
The "Secret" class has no exceptions, because secrets have no legitimate reason to be in a prompt. For the other classes, the rule depends on the tool and the plan, which is why the next step matters.
Step 2: Approve tools by plan, not by name
The same product can have different terms on different plans. In the provider policy chapter you compared retention, training use, and human review. A policy should record the result of that comparison. List the exact plan, not just the product.
An approved-tools register can be a small table kept in the repository:
| Tool | Plan | Approved data classes | Notes |
|---|---|---|---|
| Assistant A | Business | Internal, Public | Training on our data disabled by contract. Reviewed 2026-09 |
| Assistant A | Free | Public | Provider may retain prompts |
| Local model server | Self-hosted | Restricted, Internal, Public | Runs inside our network |
| Any other tool | Any | Public | Needs review before wider use |
Two details make the register useful:
- A review date. Provider terms change. A register entry older than your review interval, for example six months, counts as unapproved until someone rechecks it.
- A default for unlisted tools. Treat any tool not in the register as public-data only. This stops "shadow" use of tools nobody vetted.
If you handle data that cannot leave your network, the register is where you name the self-hosted option from the previous chapter and say which classes it may handle.
Step 3: Set agent permissions as policy
Agents that read files, run commands, and call network services need rules too. Write them as defaults that the team applies in each tool's configuration.
Good baseline rules:
- Agents run with the developer's least-privilege credentials, never with production or administrator credentials.
- File reads outside the project directory require approval.
- Shell commands that delete, deploy, change permissions, or send data over the network require approval each time.
- Auto-approve is allowed only for read-only commands in a sandbox or disposable environment.
- Third-party extensions and tool servers need the review described below before anyone installs them.
The reason for rule 3 is prompt injection. Text inside a web page, an issue, or a dependency can tell an agent to send data elsewhere. An approval prompt on network and destructive actions is the control that still works when the model is fooled.
Step 4: Require technical controls in every repository
Policy text that nobody enforces drifts. Pair each rule with a control that lives in the repository, so a new clone is protected by default.
The following table links rules to controls.
| Rule | Control in the repository |
|---|---|
| Secret files stay out of AI context and Git | Ignore file with secret patterns |
| Secrets come from the environment | Code reads from environment variables |
| No secrets in commits | Pre-commit scanner plus the same scan in CI |
| Leaks are found in history | Scheduled full scan |
A baseline ignore file that every repository copies:
.env
.env.*
!.env.example
*.pem
*.key
terraform.tfstate
terraform.tfstate.*Many AI tools can read a similar ignore file, but the file name and syntax differ between tools. Record in the policy which file each approved tool uses, and check that it works. Do not assume a gitignore rule also hides a file from an assistant.
Application code reads secrets at runtime and fails loudly when one is missing:
import os
api_key = os.environ["PAYMENTS_API_KEY"]The scanner runs before each commit through a shared configuration:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.4
hooks:
- id: gitleaksPin rev to a current release. Each developer then installs the hook and scans the existing files once:
pip install pre-commit
pre-commit install
pre-commit run --all-filesA local hook can be skipped, so the policy must also require the same scan in CI. The CI check is the one that cannot be bypassed by a single developer.
Step 5: Define prompt hygiene rules
Tell people what to do before they paste anything. Keep the rule simple: paste the smallest amount of text that reproduces the problem, and redact it first. A shared helper reduces the effort. This one replaces a few well-known credential shapes:
import re
PATTERNS = [
(re.compile(r"AKIA[0-9A-Z]{16}"), "[REDACTED_AWS_KEY_ID]"),
(re.compile(r"(?i)(authorization:\s*bearer\s+)[^\s]+"), r"\1[REDACTED]"),
(re.compile(r"(?i)((?:password|secret|token|api[_-]?key)\s*[=:]\s*)\S+"), r"\1[REDACTED]"),
]
def redact(text: str) -> str:
for pattern, replacement in PATTERNS:
text = pattern.sub(replacement, text)
return text
print(redact("password=hunter2 Authorization: Bearer abc123"))Step 6: Review extensions and tool servers
Third-party extensions and tool servers run with the access you give them. The policy should require a short review before first use. The reviewer checks:
- Who maintains it, and how active the project is.
- What files, commands, and network destinations it can reach.
- What credentials it needs, and whether a scoped credential is enough.
- Whether it sends data to a service outside your approved list.
Approved items go into the same register as tools. Pin versions so an update cannot change behavior without a new review.
Step 7: Connect the policy to incident response
The policy must state what to do when a secret reaches an AI tool or a repository. Use the rotate-first order from the incident chapter:
- Revoke or rotate the secret immediately.
- Check logs for use of the old secret.
- Remove it from code and history, and clear it from tool context where possible.
- Record what happened and fix the control that failed.
Add one cultural rule: reporting a leak quickly must never be punished. If people fear blame, they hide leaks, and the delay costs far more than the mistake.
Step 8: Assign owners and audit
Every rule needs an owner and a check. Without them, the document goes stale.
| Item | Owner | Check |
|---|---|---|
| Tool and plan register | Security lead | Review every six months |
| Repository baseline files | Each repository maintainer | CI fails when files are missing |
| Scanner configuration | Platform team | CI scan on every pull request |
| Extension reviews | Security lead | Register entry required before install |
| Leak reports | On-call engineer | Postmortem within a set time |
Where tools offer audit logs, turn them on for approved business plans and decide who reads them. Logs nobody reads give false comfort, so name a person and an interval.
Step 9: Keep the policy usable
Policies fail when they are too long or too strict to follow. A few practical rules help:
- Keep the main document to one or two pages and link to details.
- Explain the reason for each rule in a sentence. People follow rules they understand.
- Provide an approved path. If the approved tool is slow or missing features, people will use an unapproved one.
- Test the policy with a new team member. Where they get stuck, the text is unclear.
- Review after every incident and every major change in provider terms.
Common errors
- Listing products without plans. The free and business tiers of one product can differ on training and retention.
- Relying on the local hook alone. Developers can bypass hooks, so CI must repeat the scan.
- Assuming ignore files are universal. Each tool has its own file name and syntax support.
- No default for unlisted tools. New tools appear weekly, and silence reads as permission.
- No owner. Rules without owners are never reviewed.
Exercise
Your team uses one AI assistant on a free plan for personal experiments and on a business plan for work. A colleague asks whether they can paste a customer export into the free one to "just test a prompt." Using the register and data classes from this chapter, what is the answer, and which two parts of the policy support it?
Show answer
No. A customer export is Restricted data, and the free plan is approved only for Public data in the register because the provider may retain prompts. The data classification table sets the rule for Restricted data (approved tools on plans with no training and defined retention), and the tool register ties approval to a plan, not a product name. The colleague should use an approved plan or a self-hosted option, or use synthetic data.
Exercise
A developer's pre-commit hook was never installed, and a commit containing an API key reaches the remote repository. Which control should catch it, and what is the first action after it is found?
Show answer
The CI scan, which the policy requires in addition to the local hook, should catch it. The first action is to revoke or rotate the key, before cleaning up history, because anyone who has seen the key can use it until it is invalid.