Sub topic 4
What data may be shared with AI tools
This chapter assumes you know the basic Git and pull request workflow, you have used an AI coding assistant or chat tool, and you have seen a CI pipeline run. By the end, you should be able to write a data-sharing rule your team can follow and check.
Why data is its own policy topic
The previous chapters covered the risks of AI-assisted code and how to sort uses into allowed, restricted, and prohibited. Data sharing is where those categories meet a concrete question: what exactly may a developer paste, attach, or expose to a tool?
An AI tool can only leak what it receives. Anything you put in a prompt, attach as a file, or let an agent read leaves your machine. Depending on the vendor and plan, it may be:
- logged for abuse monitoring or debugging,
- stored for some retention period,
- visible to vendor staff under certain conditions,
- used to train future models.
Which of these happens depends on the vendor's contract and your plan, not on how the tool looks. A free consumer chat window and an enterprise API plan from the same vendor can have very different terms. A data rule therefore has two parts: a classification of your data, and a list of which tools are cleared for which classes.
Classify data into tiers
Most teams do not invent a new scheme. They reuse the company's existing data classification and map it onto AI use. If none exists, a four-tier model is a workable start.
| Tier | Examples | Default rule for AI tools |
|---|---|---|
| Public | Open-source code you publish, public documentation, generic questions | Allowed in any approved tool |
| Internal | Non-sensitive proprietary source code, internal design docs, architecture notes | Allowed only in tools approved for internal code |
| Confidential | Security-critical code, unreleased product plans, customer-identifying logs, contract terms | Restricted. Only in tools with contractual no-training and retention terms, and only with the minimum needed |
| Restricted | Credentials and secrets, personal data (names, emails, health or payment data), regulated data, production database contents | Prohibited in every AI tool, whatever the plan |
The tiers matter less than two properties. Every tier has a clear default, and a developer can decide in seconds which tier a piece of data belongs to. If the classification needs a meeting to apply, people will skip it.
Secrets are always prohibited
Secrets deserve their own rule because the damage is immediate and mechanical. A secret is any value that grants access: API keys, passwords, tokens, private keys, connection strings, and session cookies.
Secrets reach AI tools in ways that are easy to miss:
- Pasting a stack trace or config file that contains a token.
- Pasting a
.envfile to ask why the app will not start. - An agentic tool reading
.envor~/.aws/credentialswhile exploring a project. - Pasting a
curlcommand copied from browser dev tools, which often includes anAuthorizationheader.
State the rule in one sentence: never share credentials with an AI tool, including "temporary" or "test" ones. Then add the recovery step: if a secret was shared, treat it as compromised and rotate it. Deleting the chat does not undo the disclosure, because you cannot verify what the vendor already logged.
Personal and customer data
Personal data in a prompt is a legal issue as well as a policy issue. Sending customer records to a third-party tool can count as a transfer to a processor, and many privacy regimes require a contract and a stated purpose for that.
The practical rule for developers: use synthetic or anonymized data for prompts. When you need to debug a failing record, replace real values before pasting.
import re
EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.-]+")
CARD = re.compile(r"\b(?:\d[ -]?){13,16}\b")
def scrub(text: str) -> str:
"""Replace obvious emails and card-like numbers before sharing a log."""
text = EMAIL.sub("<email>", text)
text = CARD.sub("<card>", text)
return text
if __name__ == "__main__":
line = "payment failed for [email protected] card 4111 1111 1111 1111"
print(scrub(line))Running this prints payment failed for <email> card <card>. A scrubber like this is a safety net, not a guarantee. Regular expressions miss names, addresses, and free-text fields. The policy should still say that production data is not pasted, and treat the scrubber as a second line of defense.
Source code: the gray zone
Source code is the hardest category, because developers need to share it to get value from the tool. A blanket ban makes the tool useless and pushes people to unapproved tools. A blanket permission ignores the real differences between code.
Useful distinctions:
- Where the code lives. Open-source code you already publish is low risk. Private repositories are internal at minimum.
- What the code reveals. Authentication logic, cryptography, fraud rules, and exploit-relevant details are confidential even though they are "just code."
- How much is shared. A 20-line function with identifiers renamed is different from uploading a whole repository.
- Third-party material. Code under a customer's NDA, or code licensed to you with restrictions, may be barred from sharing by contract. The licensing chapter covers the output side of this question. Here the concern is what goes in.
A policy can encode these as a short default: internal code goes only into approved tools, confidential code only into tools with stronger terms and only the minimum needed, and anything under a customer NDA needs the customer's agreement.
Tool terms decide what is allowed
The tier table is only half the rule. The other half is a list of which tools are cleared for which tiers. Check these terms when you review a tool, and record the answers in your approved-tools list:
| Question | Why it matters |
|---|---|
| Is customer content used to train models? | Training use can make your code influence outputs given to others |
| How long are prompts and outputs retained? | Longer retention means a longer exposure window |
| Who at the vendor can read the data? | Staff access for support or abuse review is a disclosure |
| Where is data processed and stored? | Some contracts or laws restrict cross-border transfer |
| Is there an audit log or admin control? | You need evidence if an incident occurs |
| Does the plan differ from the free tier? | Individual and free accounts often have weaker terms |
The last row causes many violations. A developer with an approved enterprise tool at work may also have a personal account with the same product. The policy should say that only the company-managed account is cleared, and that personal accounts are treated as unapproved tools.
Context sharing by agentic tools
Chat tools receive what you paste. Agentic tools and editor integrations decide for themselves what to read. They may send open files, neighboring files, repository search results, terminal output, or directory listings as context.
This changes the rule from "do not paste X" to "make sure X is not reachable." Practical controls:
- Keep secrets out of the working directory. Use a secret manager or environment variables injected at run time instead of committed or local
.envfiles. - Use the tool's ignore mechanism (many tools support an ignore file or exclusion setting) to exclude
.env, key files, and data dumps. - Do not run agent sessions in a directory that holds production dumps or customer exports.
- Review what terminal output the tool can see. A command that prints environment variables puts them into context.
A later chapter on agent permissions covers command and file limits in depth. For data, the key point is that exclusion lists are a second layer. The first layer is not having sensitive files in the place the tool works.
Enforce what you can
A rule that depends only on memory will fail. Add checks that catch mistakes before they spread.
Secret scanning at commit time is the clearest example. This stops secrets from landing in the repository, which also keeps them out of any tool that later reads the repository.
# .github/workflows/secrets.yml
name: secret-scan
on:
pull_request:
push:
branches: [main]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Pair this with a local pre-commit hook so developers see the problem before they push. Also add the following to .gitignore so local secret files are never staged by accident:
.env
.env.*
*.pem
*.keyNone of these controls can see what a developer pastes into a browser chat window. That gap is why the written rule, training, and a no-blame reporting path still matter.
Writing the rule
Put the data rule in a form people can scan. A short example:
## Data sharing with AI tools
1. Use only company-approved tools, signed in with your company account.
2. Never share secrets, credentials, or personal or customer data.
3. Internal code: approved tools only.
4. Confidential code (auth, payments, security logic): only tools listed
as cleared for confidential data, and only the minimum needed.
5. Code under a customer NDA: ask the account owner first.
6. If you shared something you should not have, report it within one
working day. Reporting is not punished. Rotate any exposed secret.The last item matters. If people fear punishment, they hide mistakes, and the team loses the chance to rotate a key or notify a customer in time.
Common errors
- Classifying by file type instead of content. A
.mdfile can hold a production password. Classify by what the content reveals. - Trusting "we do not train on your data" alone. Retention, staff access, and logging can still be a problem.
- Forgetting side channels. Screenshots, error reports, and shared chat links carry data too.
- Treating anonymization as one step. Removing names but leaving unique IDs, timestamps, and rare values can still identify a person.
- No path for exceptions. If a legitimate task needs a tool that is not cleared, people will use it anyway unless there is a fast approval route.
Summary of decisions
| Decision | Recommended default |
|---|---|
| Classification | Reuse company tiers, map each to a tool rule |
| Secrets | Never shared, rotate if exposed |
| Personal data | Synthetic or anonymized only |
| Tool accounts | Company-managed only |
| Agent context | Keep sensitive files out of the working directory, add ignore rules |
| Enforcement | Secret scanning in CI plus pre-commit hook |
| Mistakes | Report within one working day, no blame |
Exercise
A developer is debugging a failing checkout. They want to paste a production log excerpt into an approved AI chat tool. The excerpt contains a customer's email address and an Authorization: Bearer ... header. Which parts of the policy apply, and what should the developer do before and after?
Show answer
Both items fall under the prohibited tier: the email is personal data and the bearer token is a secret. Before pasting, the developer should replace the email with a placeholder and remove the token, or build a synthetic log that reproduces the failure. Approval of the tool does not change this, because the rule is about the data, not the tool. If the token was already pasted, they should report it within one working day and rotate the token, since deleting the chat does not guarantee removal. The team should also check why a live token appears in logs, because that is a separate logging bug.
Exercise
Your team has an enterprise AI assistant cleared for internal code. A teammate uses their personal account for the same product because it is faster to sign in. Explain why this breaks the data rule even though the product is the same, and name one control that reduces the chance of it happening.
Show answer
The clearance applies to the company-managed account and its contract terms, which include retention and no-training commitments. A personal account usually has different terms, so it counts as an unapproved tool. Controls include requiring single sign-on for the approved tool, documenting that only company accounts are cleared, and offering a quick approval path so people do not work around the process.