Skip to content

Last updated

Can you paste an API key or client data into Claude Code? Where secrets go instead

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers in a papasan chair
Where each kind of secret goes when you work with Claude Code, from the book's safety chapters
What it isNever put it inWhere it goes instead
API keys and tokensA prompt, CLAUDE.md, memory notes or a skillA sign-in through /mcp, an environment variable or a git-ignored .env file
Your own passwordsNotes files, spreadsheets or memory notesA password manager
Client records like tax files or bank detailsPrompts, unless the job truly needs it, or GitHubA folder outside Claude's working folders, with deny rules and an encrypted backup
The .env file itselfGit, or a folder Claude may readYour ignore list, plus Read(./.env) in the deny list
A key that already leakedYour to-do list for laterRevoked and replaced the same day

How to use the secrets table

Claude should know a secret's name, never its value. The table is that one idea, sorted by the kind of secret.

The left column is the thing. The middle column is every place people put it by accident. The right column is the safe home. Keys can be replaced in five minutes. A client's tax ID can't, because there is nothing to revoke. That is why client records get the strictest row.

The deny rules in the table are the lock. The permissions page shows the syntax, and the security page explains the guards Claude Code adds around them.

Know the gaps, too. A read deny rule covers Claude's own file tools and common commands that name a file. It doesn't cover a command that searches a whole folder. Deny rules stop accidents. They are not a vault. The stronger guard is keeping secrets out of the folders Claude works in at all.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers on a rug

The key on your clipboard

The new email tool won't connect. The setup page gave you a long string of letters and numbers and called it an API key. Claude Code is open in the other window.

You copy the key. Your cursor sits in the prompt box.

It's my own computer. What's the harm?

Think of a treehouse password said out loud in class. Everyone heard it. The kid taking notes wrote it down with the date. The only fix is to change the password. A pasted key works the same way. It isn't said once and gone. It gets written down in the session file.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers on a balcony at sunset

Already pasted a key? Do this today

Most people searching this have already done it. That is fixable. Work in this order, because the first step is the only one that actually closes the leak.

  1. Revoke the old key at the service and create a new one.
  2. Put the new one in the right place: an environment variable or a git-ignored file. Never back where the old one leaked.
  3. Confirm the old key is dead. Try it once, or check the service's key list.
  4. Clean up the copies. The pasted key sits in the session transcript under the projects folder in your home .claude folder. The sessions page says you can delete a project's transcripts sooner than the 30-day sweep with claude purge. If you said "remember this" near the key, ask Claude to list its memory notes and remove any line that holds it.
  5. Write down the date you did it.

Step 4 is tidying. Steps 1 to 3 are the fix. A deleted copy does not take the key back from anything that already read it.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers on a sofa

Check your plan's training setting

The other half of the question is what happens on Anthropic's side. The book's advice is to check this today, not later. On Free, Pro and Max plans, the data-usage page says your data, including Claude Code sessions, is used to train new models when the model-improvement setting is on. Team, Enterprise and API accounts are not used for training unless the customer opts in.

You can see and change the setting at claude.ai/settings/data-privacy-controls. If you handle client records, set it the way your clients would expect, and write down the date you checked. These terms change, so read the current page rather than trusting any summary, this one included.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers in a net hammock

The secrets I found in my own folders

In September 2026, an audit by my assistant found a real-looking access token in two of my website projects. It wasn't in a .env file. It was in a config file for a code editor's connector, the kind of file nobody thinks of as secret. In one project it had been there since the very first commit.

In July 2026, an audit of another site found a credentials file sitting in the public website folder, and a sign-in secret pasted into a documentation file.

Deleting the file and scrubbing the history feel like the fix. They aren't. Anyone who saw the secret can still use it. A rotation that waits on a to-do list is a leak that is still open.

So I decided once. On July 13, 2026, I wrote one ignore policy for every project instead of choosing project by project. Environment files never go in. Token files never go in. If you hold client records, that folder goes on the list on day one.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers on a white sofa

The chapters that lock the drawer

This is the problem Claude Code for Non-Programmers was written for. The book is independent and is not affiliated with Anthropic.

Safety and Failure opens with secrets: a search that finds them without printing them, the deny rules, a starter ignore file, a pre-share checklist and a separate checklist for client data. It also covers prompt injection, when a page Claude reads tries to give it orders.

Permissions and Modes explains why a deny rule wins in every mode.

Connecting the World shows how to connect other apps with a sign-in instead of a pasted key.

Claude Code for Non-Programmers by İsmail Günaydın, book cover

The book for this problem

Claude Code for Non-Programmers

A Business Owner's Guide to Building Your Own AI Operating System (2027 Edition). By İsmail Günaydın, 355 pages.

Where this problem is in the book:

  • Safety and Failure
  • Permissions and Modes
  • Connecting the World

Links go to Amazon. I wrote this book and earn a royalty on every sale. Amazon sets the price and handles delivery and returns.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers on an outdoor sofa

Is Claude Code for Non-Programmers the right book for you?

Yes, if

  • A setup page just handed you an API key and Claude Code is open in the other window
  • You keep client records like tax files, ID numbers or bank details
  • You think you might already have pasted a key somewhere

Skip it if

  • You want legal advice on your profession's data rules; check those first
  • You need a security audit of a large company

Fair doubts before you buy

It's my own computer and my own assistant. What's the harm?

That pause is the right instinct. The transcript is a plain text file anyone or anything that can open it can read. Memory folders get synced and backed up. And on Free, Pro and Max plans, your data may be used for training when that setting is on. A key you never pasted is a key you never worry about.

Won't a .claudeignore file keep Claude out of my secrets?

No. You may see it recommended online, but the documentation says it has no effect. Use deny rules in your settings file. They are enforced by Claude Code itself, and they block in every mode.

Get Claude Code for Non-Programmers

A business owner who has never opened a terminal can give Claude real jobs on real files, safely, using one working system including the parts that broke.

Links go to Amazon. I wrote this book and earn a royalty on every sale. Amazon sets the price and handles delivery and returns.

This book is independent and is not affiliated with or endorsed by Anthropic.

Kaia Vance, the AI-generated ToolGenX brand character, reading Claude Code for Non-Programmers in a kitchen

Questions people ask about this

Does Claude Code save what I type?
Yes. Every session is saved as a plain text file in the projects folder inside your home .claude folder. Transcripts older than the cleanupPeriodDays setting are deleted, 30 days by default. That is a tidy-up, not a security feature.
How do I stop Claude Code from reading my .env file?
Add a deny rule. Put Read(./.env) and Read(./secrets/**) in the deny list in ~/.claude/settings.json, then start a fresh session and ask it to read your .env file. It should refuse.
How can Claude use an API key without seeing it?
Tell it the name, not the value. Say the key is in an environment variable called YOUR_API_KEY, and ask it to write the script so it reads the key from there, never prints it, never writes it to a file and never asks you to paste it.
Does Anthropic train on my Claude Code sessions?
It depends on your plan and setting. The data-usage page says Free, Pro and Max data, including Claude Code sessions, is used for training when the model-improvement setting is on, with five-year retention, or 30 days with it off. Team, Enterprise and API plans are not trained on unless the customer opts in. These terms change, so check the page.
What do I do if I leaked an API key?
Change it the same day. Revoke the old key at the service, make a new one, put it in an environment variable or a git-ignored file, check that the old one is dead, and write down the date. Deleting the file is not the fix, because anyone who saw the key can still use it.
Where do I change whether Anthropic trains on my Claude Code sessions?
On a Free, Pro or Max plan, open claude.ai/settings/data-privacy-controls and look at the model-improvement setting. The book says data, including Claude Code sessions, is used for training when it is on. Team, Enterprise and API accounts are not trained on unless the customer opts in. Check the current page, since terms change.

Related problems