This is the page where a blanket ban would be wrong — and pretending otherwise is exactly why developers stop listening to security guidance. Most of the code you write isn't the secret. The framework is public, the pattern is on Stack Overflow, the algorithm is in a textbook.
The genuine risk is narrower and more specific than "don't paste code". Get that part right and you can use AI on code all day without a problem.
Four distinct problems hide under the phrase "pasting code", and only some of them apply to any given paste.
Trade secret protection is conditional. Code qualifies as a trade secret only while you're taking reasonable steps to keep it secret. Disclosing it to a third-party vendor with no confidentiality agreement is a decent argument that you weren't. That's a legal position you can weaken by accident, in one paste, permanently.
Client code usually isn't yours to disclose. If you're an agency, a consultancy, or anyone working under an MSA, there's likely a clause naming who may process that code. An AI vendor is a subprocessor. Nobody added them to the list.
Code carries passengers. Hardcoded keys, internal hostnames, database names, private endpoints, a comment with someone's phone number. You pasted a function; you also pasted everything around it.
Architecture is intelligence. Internal service names, queue topology, which system talks to which — that's a map. Useful to you, and useful to anyone planning to attack you.
Reduce before you paste. The minimal reproducible example is a discipline developers already know from bug reports — it applies here unchanged, and it usually gets you a better answer anyway.
// 400 lines of
// PricingEngine.java
client = Client(
host="pricing-prod.acme.internal",
key="sk_live_9f2XkQ")
def acme_margin_ladder(tier):
# our actual pricing logic
...
// 12 lines that reproduce it
client = Client(
host="[HOST]",
key="[KEY]")
def calculate_rate(tier):
return rates[tier] * 1.2
// TypeError: unhashable type
// on line 3 when tier is None
Rename the domain concepts, fake the data, keep the structure that causes the bug. You've removed the confidential part and lost nothing the model needed.
If yes, paste it. If you hesitated, that hesitation is the answer — and it's the same instinct that made you reduce the snippet before posting it publicly. Nothing new to learn.
Approved enterprise coding assistants are a genuinely different position. Enterprise tiers of GitHub Copilot, Claude, ChatGPT and similar carry contractual no-training terms and, in some cases, run inside your own cloud tenancy. If your employer has assessed one and put it on the approved list, the calculus changes — that's what the assessment was for.
Two caveats that survive even then: client code under an NDA is still governed by the NDA, not by your tooling choice. And the secrets rule doesn't move — strip those regardless of which tool you're in.