Safe Use of AI Coding Assistants (Secrets, Licences, Data)
AI coding tools are useful. They can also leak secrets, suggest code you cannot use, or run a dangerous command. This lesson shows the simple rules that keep you and your company safe.
In short: never paste secrets or .env files, check the licence of suggested code, know what leaves your machine (cloud vs local), follow company policy, and never auto-approve dangerous shell commands.
Why safe use matters
One pasted API key in a cloud chat can bill your cloud account overnight. One copy-pasted snippet under a strict open-source licence can create a legal problem for your company. One agent command like rm -rf can wipe a folder. Safety is part of the skill, not an extra.
What the risks are
- Secrets: API keys, passwords, .env files, private keys, customer data, production connection strings.
- Licences: code the AI suggests may match open-source projects. Some licences force you to open your whole product (copyleft). Others are fine for commercial use (MIT, Apache-2.0).
- Data leaving your PC: cloud assistants send prompts and often parts of your files to a company server. Local tools like Ollama keep the model on your machine.
- Dangerous actions: agent mode can run shell commands, edit many files, install packages, or push to git if you allow it.
- Company policy: many Indian IT companies ban pasting client code into public AI tools, or allow only approved tools.
How a safe session flows
Rule 1 — do not paste secrets
- Never put
.env,credentials.json, PEM keys, or database passwords in a prompt. - In Claude Code, deny those paths in
.claude/settings.json(example below). - In Copilot / Cursor / Continue, keep secrets out of the workspace the tool indexes, or add them to ignore lists.
- If you pasted a key by mistake: rotate it now (create a new key, delete the old one) in AWS, GitHub, Stripe, etc.
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(**/*.pem)",
"Bash(rm -rf:*)",
"Bash(git push --force:*)"
]
}
}Rule 2 — check licences of suggested code
- If the AI pastes a large block that looks copied from a library, ask: “Is this from an open-source project? Which licence?”
- Search a unique line on GitHub. If it matches a GPL or AGPL file and your product is closed-source, do not use it as-is.
- Prefer asking the AI to write a small function from a clear spec, not “copy how library X does it”.
- When you use a real library, add it through your package manager (pip, npm, Maven) so the licence is tracked.
Rule 3 — know what leaves your machine
| Setup | Where code/prompts go | Good for |
|---|---|---|
| Cloud chat (ChatGPT, Claude web, Gemini) | provider servers | learning, public practice code |
| IDE cloud assistants (Copilot, Claude Code, Cursor cloud models) | provider servers + your project context | day-to-day coding under company rules |
| Local Ollama + Continue | stays on your PC (no cloud model call) | client code, personal data, offline work |
| Company private model / VPC | your company's servers | enterprise policy |
Rule 4 — company policy first
- Ask your lead: which AI tools are allowed? Is client code allowed in any cloud tool?
- Use only the approved account (often a company Copilot or Claude seat), not your personal free account for office work.
- Do not paste customer names, phone numbers, Aadhaar, PAN, bank data, or medical records into any AI.
- If policy is unclear, use a local model or write the code yourself until someone confirms.
Rule 5 — never auto-approve dangerous shell
- Keep permission prompts on in Claude Code, Copilot Agent, Cursor Agent, Devin Local, Kiro.
- Read every command before Yes. Refuse:
rm -rf,mkfs,dd, force-push to main, curl-piped-to-bash from unknown URLs, disabling firewalls. - Prefer Plan mode first for big tasks: the tool lists steps; you approve; then it runs.
- On a production server or a shared machine, do not run agent mode at all unless your team has a written process.
A one-page safe checklist
- Before: approved tool? secrets out of the folder? policy OK?
- During: no .env in prompts; Plan mode for big jobs; read every diff and shell line.
- After: run tests yourself; rotate any key you may have exposed; commit only what you understand.
Quick quiz
1. Should you paste a .env file into ChatGPT to “debug the config”?
No. Redact secrets or describe the keys without values. Rotate any key you already pasted.
2. Cloud vs local Ollama — what is the privacy difference?
Cloud sends prompts/context to a provider. Ollama runs the model on your PC.
3. What should you do before allowing an agent to run a shell command?
Read the full command. Refuse deletes, force-pushes and unknown install scripts.
4. Why check the licence of a big pasted snippet?
It may come from a copyleft project you cannot ship inside closed-source software.
Save tokens and money
Safety also saves money: smaller prompts without secrets and logs mean fewer tokens. Put standing deny rules in one short settings file instead of repeating “do not read .env” in every chat.