Practice Lab

Paste a Password Into Claude Code on Your Own Machine and It Lands in a Plaintext File, Kept 30 Days by Default. My Assistant Won't Touch One.

WorkflowNovember 19, 2026 · David J.S. Madgett · 15 min read

Sooner or later every lawyer who runs an AI assistant hits the same moment. A new API key shows up. A vendor rotates a password. Some integration wants a client secret before it’ll lift a finger. And the assistant’s sitting right there, perfectly able to store it for you.

So you paste it into the chat. “Put this in the keychain.” Done in four seconds.

Don’t. And don’t let your assistant ask you to.

The rule in this firm is short. The assistant never sees, types, echoes or stores a secret. When a credential has to land somewhere, the assistant writes a little script. The script prompts me silently, drops the value straight into the operating system’s credential store, and prints one line saying whether it worked. The refusal doesn’t bend. The friction’s the assistant’s problem. Not mine.

Here’s why, in the vendors’ own words. Then the script, and what it actually printed when I ran it.

(No real credential appears anywhere in this article. Every Keychain command below ran against throwaway items with a made-up service name and made-up values, and every one of them was deleted afterward.)


The chat window is a file

You think of the chat box as a conversation. Your vendor thinks of it as a record. And it says so, in writing.

Claude Code is the tool this firm’s system is built on. Here’s what Anthropic’s documentation for it says stays on your own machine:

Local caching: Claude Code clients store session transcripts locally in plaintext under ~/.claude/projects/ for 30 days by default to enable session resumption.

Plaintext. Thirty days, and that’s only the default: a setting changes the number, and Claude Code keeps transcripts of sessions run in Claude Desktop or Cowork at any age unless you set a separate limit. On every machine you run it on.

The same page covers what goes over the wire: “This data includes all user prompts and model outputs, encrypted in transit via TLS 1.2+.” Encrypted in transit, sure. Then it lands. For commercial accounts the page lists “Standard: 30-day retention period”. For consumer accounts, it’s a 30-day period if you don’t let Anthropic use your data for model improvement and a “5-year retention period” if you do. And if you ever send a bug report with the /feedback command, “Transcripts shared via /feedback, or via /bug and /share, which report through the same path, are retained for 5 years.”

There’s a redaction step on some of the upload paths. Read this one slowly. When you agree to share a session transcript through the post-session survey, the page says “Known API key and token patterns are redacted before upload. Source code, file contents, and other conversation content are uploaded as-is.”

Known patterns. A vendor API key with a recognizable prefix might get caught. The password to your bank portal doesn’t have a pattern. Neither does your e-filing password, or the one for your practice-management system. It’s just a string. As-is.

OpenAI tells the same story. Here’s its Codex configuration page:

By default, Codex saves local session transcripts under CODEX_HOME (for example, ~/.codex/history.jsonl).

And for the API generally, OpenAI’s data-controls page says that, by default, “abuse monitoring logs are generated for all API feature usage and retained for up to 30 days, unless longer retention is required by law, or is reasonably necessary to protect our services or any third party from harm.” Those logs, per the same page, “may contain certain customer content, such as prompts and responses”.

Now watch what the vendors do with their own credentials.

Claude Code’s security page: “API keys and tokens are stored in the macOS Keychain when available.” OpenAI’s authentication page for Codex offers a keyring setting that “stores credentials in your operating system credential store and fails if it is unavailable.” And when Codex’s login cache lives in a plain file instead, OpenAI’s own instruction is blunt:

Treat ~/.codex/auth.json like a password: it contains access tokens. Don’t commit it, paste it into tickets, or share it in chat.

Share it in chat. The vendor that built the chat is telling you not to put its own key in a chat.

Take the hint. Claude Code keeps its own keys in the macOS Keychain when it’s available, Codex will put its in the operating system’s credential store if you tell it to, and both keep transcripts in files. If they won’t mix the two, you shouldn’t either.

Four verbs: see, type, echo, store

The rule has four verbs because a secret leaks four different ways.

See. If the value passes through the assistant’s context, it’s in the transcript. Everything above applies.

Type. If the assistant types it into a command, a config file or a form, the value went through the model to get there. Same transcript. And if it typed it on a command line, it may also be sitting out where other processes can read it. More on that in a minute.

Echo. A script that prints the value back to “confirm” it got stored just put it on your screen. And in your terminal’s scrollback. And in the transcript of any agent watching that terminal. Some confirmation.

Store. An assistant that “helpfully” writes the key into a .env file or a settings file just made a plaintext copy you’ll forget exists. I wrote in May about the keychain wrapper at the center of my Clio integration: every credential lives in the operating system keychain and nowhere else. That only works if nothing ever writes one anywhere else.

So the assistant does none of the four. Not when it’s convenient. Not when I tell it to.

That last part is where people trip. An assistant that’ll type a password because the lawyer told it to doesn’t have a rule. It has a default. And an assistant that just refuses, explains itself, and stops has handed the lawyer a new chore: figure out what to do instead. That’s how you train a person to route around the rule. Next time the key goes on a sticky note, or into a text file on the desktop, or into some other tool that doesn’t refuse.

The refusal is fixed. The friction is the assistant’s to remove. Here’s how that works in this firm’s standing instructions. The moment a credential needs storing or testing, the assistant writes the prompting script. It tells me the one command to run. It states the no-typing rule in a single sentence, right alongside. No second explanation. No lecture. And if I paste a secret into the chat anyway, the assistant tells me once that it’s in the transcript now and should be rotated. Then it moves on.

One sentence, one command. That’s the whole interaction, and it’s over in less than a minute.

Here’s the script

Here’s a version I wrote and ran for this article. It’s macOS, it’s built on Apple’s own security command, and it runs 26 lines counting comments:

#!/bin/sh
# store-secret.sh SERVICE ACCOUNT
# The human types the secret once, into Apple's own prompt. Nothing echoes.
# The value never sits in a shell variable or on a command line.
# Prints one verdict: "stored: ok" or "stored: FAILED (...)".
set -u
svc="${1:?usage: store-secret.sh SERVICE ACCOUNT}"
acct="${2:?usage: store-secret.sh SERVICE ACCOUNT}"

# Prompting needs a terminal. No terminal means no human, so stop.
if [ ! -t 0 ]; then
  echo "stored: FAILED (no terminal; run this yourself)"; exit 2
fi

# -w LAST, with no value after it: security prompts for the value itself.
# -U updates the item if it already exists.
if ! security add-generic-password -U -s "$svc" -a "$acct" -w; then
  echo "stored: FAILED (security exited non-zero)"; exit 1
fi

# Check it landed and isn't empty. Count bytes; never print the value.
n=$(security find-generic-password -s "$svc" -a "$acct" -w 2>/dev/null | wc -c)
if [ "$n" -le 1 ]; then
  echo "stored: FAILED (item missing or empty)"; exit 1
fi
echo "stored: ok"

Here’s a real run. I can’t very well type into a prompt from inside an article, so I drove both prompts with expect, a standard Unix tool that types into a terminal the way a person does. It typed a throwaway value at both:

$ ./store-secret.sh zz-throwaway-practice-lab-demo demo
password data for new item: 
retype password for new item: 
stored: ok

Look at the screen. Two prompts with nothing after them, because security doesn’t echo what you type. Then one verdict. Afterward I searched the captured terminal output for the throwaway value. Zero hits.

Now here’s what the assistant gets if it tries to run the script from its own shell instead of handing it to me. An agent’s shell has no terminal. I simulated that here with < /dev/null:

$ ./store-secret.sh zz-throwaway-practice-lab-demo demo < /dev/null
stored: FAILED (no terminal; run this yourself)
exit=2

That guard catches an agent that runs the script by mistake. It doesn’t stop one that’s trying: a tool like expect hands it a terminal, which is exactly how I drove the demo above. That part is the rule’s job, not the script’s.

And the cleanup, so nothing from this article is left in my Keychain:

$ security delete-generic-password -s zz-throwaway-practice-lab-demo -a demo >/dev/null && echo "deleted: ok"
password has been deleted.
deleted: ok
$ security find-generic-password -s zz-throwaway-practice-lab-demo -a demo >/dev/null 2>&1; echo "exit=$?"
exit=44

That exit=44 is security saying it couldn’t find the item. The man page doesn’t document that number, so don’t build anything on it. Treat any non-zero as “not found or not readable” and move on.

Apple’s own help screen says don’t put it on the command line

The version of this script you’ll find all over the internet looks like this:

read -rs value
security add-generic-password -U -s "$svc" -a "$acct" -w "$value"

read -s keeps the value off the screen while you type it. Good. Then the very next line hands it to security as a command-line argument. Not good.

Command-line arguments aren’t private on a Unix system. Here’s a stand-in program, run in the background with a throwaway value as its argument, and ps looking at it half a second later (my username swapped for USER):

USER /bin/sh ./fake-tool -w throwaway-value-0006

There it is, right in the process table. Anything that runs ps at the wrong moment can see it, including an AI agent with shell access that’s been asked what’s running. And ps doesn’t stop at your own processes. Its man page describes -A as “Display information about other users’ processes, including those without controlling terminals.”

Apple knows. Run security add-generic-password -h and the help text says it outright:

Use of the -p or -w options is insecure. Specify -w as the last option to be prompted.

The man page says the same thing in its option table: -w password means “Specify password to be added. Put at end of command to be prompted (recommended)”. So that’s what the script does. -w is the last thing on the line with nothing after it, security prompts for the value itself, and the value never touches a shell variable or anybody’s argument list. No read -s needed.

There’s one catch, and I found it by running it. Because -w has to be the very last argument, there’s no room after it for the optional keychain path. Put the keychain path before -w and security prints its usage screen and exits 2. So prompt mode writes to your default keychain. That’s where I’d want it anyway. Need a different keychain? You’ll need another approach, and I didn’t test one for this piece.

A check that stores nothing and says it worked

Here’s why the script refuses to run without a terminal.

Run Apple’s prompt mode with no terminal attached and nothing on its input:

$ security add-generic-password -s zz-throwaway-practice-lab-demo -a notty -w < /dev/null; echo "exit=$?"
password data for new item: retype password for new item: exit=0
$ security find-generic-password -s zz-throwaway-practice-lab-demo -a notty -w | wc -c
       1

Exit 0. Item created. And the stored value is one byte long, which is just the newline find-generic-password adds on output. The password is empty.

That’s a check that can’t fail, and it ships with the operating system. Nobody typed a thing. The prompt read end-of-file. security stored nothing and called it a success. If your setup script does this inside a scheduled job, you’ll find out the first time the integration tries to authenticate with an empty string, and the error you get probably won’t say “your setup stored nothing.” I wrote about this whole family of bugs in July. Same lesson. Exit 0 told me nothing.

So the script has two guards. It won’t start without a terminal, because no terminal means no human. And after storing, it reads the value back through a pipe into wc -c, so it counts bytes without ever printing them, and calls anything one byte or shorter a failure.

Here’s that second guard catching a person who just hits Enter at both prompts:

password data for new item: 
retype password for new item: 
stored: FAILED (item missing or empty)

Exit status 1. But -U means the item gets updated if it already exists, so an empty Enter on an existing item doesn’t just fail to help. It hurts. I tested that on another throwaway item: stored a value, ran the script again, hit Enter twice. The byte count went from 21 to 1. The good value was gone. The script said FAILED, which is your cue to run it again with the real one.

Apple handles typos. Type two different values at the two prompts and security says passwords don't match and asks again. On the third mismatch it quits, and the script reports:

stored: FAILED (security exited non-zero)

Three outcomes a human can tell apart: ok, failed with a reason, and “you ran this in the wrong place.” That’s the whole point of the failure that says nothing. Say clear and silent differently.

What the Keychain doesn’t do

Now the limit.

Look at the script’s own check. It reads the value back with security find-generic-password -w. No password dialog popped up. That’s because of this line in the man page:

By default, the application which creates an item is trusted to access its data without warning.

The application that created the item is security. So anything that can run security as you can read it back. That includes any AI agent you’ve given a shell on your machine.

So here’s exactly what the script buys you. It keeps the secret out of the transcript, out of the vendor’s logs, off the screen, out of scrollback, and out of the process table. What it doesn’t do is put the secret beyond the reach of an agent that can run commands as you.

The man page does offer a knob. It says you “can remove this default access by explicitly specifying an empty app pathname”, which it writes as -T "". I didn’t use it here because the script’s own read-back check depends on that access, and a dialog that pops up during an unattended job is its own kind of failure. Weigh it for your own setup.

The real fence for an agent is a different layer: what commands it’s allowed to run and what credentials it’s allowed to hold. I wrote about that in the audit of what my own AI could reach, so I’ll skip it here. The script solves the transcript problem. The permission rules and narrow scopes solve the reach problem. You need both.

The rule counts the friction too

Here’s where it stops being a shell trick and becomes a professional duty.

Minn. R. Prof. Conduct 1.6(c):

A lawyer shall make reasonable efforts to prevent the inadvertent or unauthorized disclosure of, or unauthorized access to, information relating to the representation of a client.

(Emphasis added.)

A password usually isn’t “information relating to the representation”. It’s the thing that opens it. A credential for your practice-management system, your mailbox or your document store is access to every client file behind it. Leak the fact and you’ve leaked a fact. Leak the key and you’ve handed over everything it opens until somebody rotates it.

Comment [17] lists the reasonableness factors. Read the last one slowly:

Factors to be considered in determining the reasonableness of the lawyer’s efforts include, but are not limited to, the sensitivity of the information, the likelihood of disclosure if additional safeguards are not employed, the cost of employing additional safeguards, the difficulty of implementing the safeguards, and the extent to which the safeguards adversely affect the lawyer’s ability to represent clients (e.g., by making a device or important piece of software excessively difficult to use).

(Emphasis added.)

The comment itself counts usability as a factor. A safeguard that makes the tool “excessively difficult to use” weighs against itself. That’s the legal version of “the friction is the assistant’s to remove.” An assistant that refuses and stops made the safeguard harder to use than it had to be. An assistant that hands you a one-line command made it nearly free. Run the other factors on the script and they all point the same way. The cost is zero. The difficulty is one command. The effect on representing clients is none.

Comment [18] covers transmission: “When transmitting a communication that includes information relating to the representation of a client, the lawyer must take reasonable precautions to prevent the information from coming into the hands of unintended recipients.” Pasting a credential into a vendor’s chat is a transmission, and in a session doing client work it travels with client information. The recipients are the vendor’s servers and a plaintext file on your disk. Nobody intended either one. The comment adds that special security measures aren’t required where the method of communication “affords a reasonable expectation of privacy.” A vendor that documents keeping a plaintext copy on your disk by default has told you how much privacy to expect.

Rule 1.1’s Comment [8] is the one everybody quotes, and here it actually earns its keep: a lawyer “should keep abreast of changes in the law and its practice, including the benefits and risks associated with relevant technology”. A transcript file is a risk associated with relevant technology. It’s right there in the vendor’s documentation, in plain English, for anyone who reads it.

The ABA’s cybersecurity opinion, Formal Opinion 477R, describes “reasonable efforts” as a “process” to “assess risks, identify and implement appropriate security measures responsive to those risks, verify that they are effectively implemented, and ensure that they are continually updated in response to new developments.” The script is that process in miniature. It implements the measure, and the byte count verifies it. 477R also says “Every access point is a potential entry point for a data loss or disclosure.” A transcript holding a password is an access point you created by accident. And it warns that in the electronic world, “‘delete’ usually does not mean information is permanently deleted”. Deleting the chat afterward isn’t a plan.

Formal Opinion 498, on virtual practice, says lawyers “should ensure that they have carefully reviewed the terms of service applicable to their hardware devices and software systems to assess whether confidentiality is protected.” The retention numbers above came from exactly that kind of reading. 498 also says, in its discussion of videoconferencing platforms, that “any recordings or transcripts should be secured.” It was talking about meeting transcripts, not AI sessions. I don’t see a principled difference.

And Rule 5.3. Whether a rule written for “a nonlawyer employed or retained by or associated with a lawyer” reaches software is an open question, and I said so in the drafts-only essay. But Comment [3] lists “using an Internet-based service to store client information” as an example of using nonlawyers outside the firm, and says the extent of the lawyer’s obligation depends on, among other things, “the terms of any arrangements concerning the protection of client information”. An AI vendor’s retention terms are exactly that kind of arrangement. They’re short. Read them.

Fine, but the vendor already has your client’s facts

Here’s the best argument against all this, and part of it is right.

If you’re using one of these tools on client work, the transcript is already full of client information. Names, facts, draft arguments. The vendor’s retention window already covers all of it. Why make a fuss over a password when the much bigger pile is sitting in the same file?

Fair. And if you haven’t made your peace with what’s in those transcripts, a password script won’t save you. That’s a separate decision about which tool, which account type and which retention terms, and it’s its own essay.

But a credential is a different animal. A client fact in a transcript is one fact. A credential in a transcript is every fact behind that login, plus the power to act: send, delete, file, pay. And it keeps working until somebody rotates it. Comment [17]’s first factor is “the sensitivity of the information”. Nothing in the file is more sensitive than the key to the file.

Second argument: the agent can read the Keychain anyway, so what’s the point? I already gave you that one. It can, if you let it run security. The script doesn’t claim to fence off the agent. It keeps the secret out of the places that outlive the session: the transcript, the vendor’s logs, the scrollback, the process table. Those are copies. The Keychain item is the one copy you meant to make.

One thing before you weigh my take on any of this: the firm publishes software for lawyers who run their own AI tools. I’ve got a horse in this race.

How I’d know I blew this one

My claim: an AI assistant should never handle a secret, and a short prompting script costs so little there’s no reasonable excuse to skip it. Here’s what would change my mind.

If the vendors start documenting that every transcript and log is scanned for credentials of any shape, not just “[k]nown API key and token patterns”, and that hits are removed before anything is written to disk or kept on their servers, then the transcript stops being the problem and this becomes belt-and-suspenders. I’d still use the script. I’d stop calling it a duty.

If the operating systems change so that items stored from the command line can’t be read back by the same tool without a human approving it, then the limit I described goes away and the case for the script only gets stronger. I’d have to rewrite the section on what the Keychain doesn’t do.

And if a year from now I find myself, or anyone else in this firm, pasting keys into the chat because running one command was too much trouble, then I got the friction wrong, and Comment [17]’s last factor is pointing right at my own safeguard. That’s the one I watch.

Until then: one sentence, one command, one line back. The assistant writes it. I type the secret once. It never lands in the transcript.


Sources

General commentary on law firm security and legal technology. The opinions, including the stated conditions under which the author would change his mind, are the author’s. Not legal advice and not ethics advice; what counts as “reasonable efforts” for a particular firm is a question for that lawyer’s own analysis. No client information appears in this article, and no real credential was used to write it. Everything in this section is free, and the only ask is that you use it to serve people who could not otherwise afford a lawyer. Questions about anything here: Send us a message.

words
4,143
sections
10
code_blocks
9
sources
11
distinctive_terms
keychain · transcripts · password · script · transcript
Pass it onLinkedInX

Get new articles as they land

One email when something new is published here. No course, no upsell — the Practice Lab stays free either way.

Used only to send Practice Lab posts. Unsubscribe from any email. Subscribing does not create an attorney–client relationship.

The only thing we ask

If something here saves you time, spend some of it on people who could not otherwise afford you.

Everything in the Practice Lab is free. No signup, no subscription, no donations — just take a case you would otherwise have to turn down on economics. More from the Practice Lab →

Keep Reading

21% vocabulary overlap

I Audited What My Own AI Could Reach. The Worst Finding Was 593 Public Links Already Sitting in Our File Share.

Lawyers keep asking whether the AI vendor trains on their data. Wrong first question. A small firm's exposure is what its own automations can reach and the sharing already sitting on its accounts. My audit's two worst findings weren't model problems at all: 593 public file-share links already sitting on the account, and unattended agents holding a mail key that could send and delete.

Essay · 15 min read

18% vocabulary overlap

Fifty Claude Accounts, Four Computers, Two AI Vendors. One Rulebook.

Small firms are about to repeat the practice-management lock-in mistake, this time with AI, by letting the firm's working knowledge pile up in one vendor's chat history and memory feature. Mine lives in plain files any model can read. Every record says who wrote it. A script checks the two tools' rule files for drift, with one hole I'll show you. The model is the part you replace.

Essay · 15 min read

16% vocabulary overlap

Connecting Claude to Clio — and Why I Had to Build It Myself

There's an open standard for exactly this problem. My practice management vendor doesn't implement it. So the connector is four hundred lines of my own Python, and the interesting part isn't the code. It's why every firm is writing it separately.

Tool · 15 min read

← All Practice Lab articles