A pattern worth naming, because it is common and nobody reports it as an incident: an administrator builds automation with an AI coding assistant over several weeks. Tokens get pasted into the chat as the work goes along, because that is the fastest way to hand a value to the tool. Weeks later the transcript directory holds hundreds of megabytes of plain-text logs, and inside them sit every API key, access token and app secret that was ever pasted.
Nothing was breached. No attacker was involved. The credentials are simply sitting unencrypted on a workstation, often inside a folder that a backup or sync agent copies to cloud storage on a schedule nobody reviews.
This article covers how to audit that directory, how to rotate what you find without breaking production, and how to stop the same thing accumulating again.
Why this happens
AI assistants keep conversation history so they can rebuild context between sessions. That history is written to disk as plain JSON or JSONL, usually one file per session, and it records the conversation verbatim. There is no filter looking for credential-shaped strings on the way in.
Three properties make this worse than a single stray file.
Sessions fork and duplicate. Resuming or branching a conversation can copy the earlier history into a new file. One token pasted once can end up in a dozen session files, each a separate copy on disk. This is the detail that surprises people most during an audit: the same value appearing again and again with different timestamps.
The directory grows quietly. Transcript folders are rarely on anyone's backup exclusion list, and they are not where administrators think to look for secrets. A folder that reaches a few hundred megabytes does so without ever asking for attention.
Logs outlive the credential's purpose. A token pasted for a one-off test stays in the transcript long after the task is finished and the token is forgotten. The transcript has no concept of a value being temporary.
Audit: find what is actually there
Work on a copy where you can, and treat the output of this process as sensitive in its own right. A list of where your credentials are is itself worth protecting.
Step 1: locate the transcript directory
Check your assistant's documentation for where it stores session history. On Windows this is typically under the user profile; on macOS and Linux, under the home directory. Note the total size before you start, because it tells you how much history you are about to search and how long this has been accumulating.
Step 2: scan for token patterns
Most providers use a recognisable prefix, which makes a regular expression sweep effective without any specialist tooling.
| Provider type | Pattern to search |
|---|---|
| Git hosting tokens | ghp_, gho_, github_pat_, glpat- |
| Cloud API tokens | AKIA for AWS, provider-specific prefixes elsewhere |
| AI and LLM keys | sk-, AIza |
| Email and messaging | re_, SG., xoxb- |
| Private keys | -----BEGIN blocks |
| Generic | 32 or 40 character hexadecimal strings |
Run each pattern across every file in the directory and record three things per hit: which credential it is, the date it first appears, and how many separate files contain it. That third number is the one people skip, and it is the one that tells you the real size of the problem.
Expect false positives from the generic patterns. Session identifiers, request IDs and internal pipe names are often 32 hex characters, and they are not secrets. Plan to triage rather than treat every match as an incident.
Step 3: classify, do not just count
Sort the results into three groups, because the response differs for each.
Live and powerful. Git hosting tokens, cloud API tokens, anything that can reach other secrets. A Git token that can read repository secrets is the highest priority in the whole exercise, because one leaked token exposes everything stored behind it. Treat this group as the reason you are doing the audit.
Live but narrow. Publishing keys, email API keys, analytics tokens. Real exposure with a limited blast radius. These need rotating, but they do not need rotating tonight.
Not actually secret. Site verification tags, publisher identifiers, OAuth client IDs and DNS verification records are public by design. They look alarming in a scan because they are long and random, and they need no action at all. Marking them explicitly keeps the rotation list short enough that somebody will actually work through it.
Rotate in the right order
The order matters more than the speed. Revoking first breaks running automation and converts a risk you were managing into an incident you are now firefighting.
- Create the replacement at the provider.
- Update every consumer. Repository secrets, CI variables, local environment files, and any platform-specific environment store. Check whether the same value is used in more than one place, because shared credentials are routinely updated in one location and missed in another.
- Verify. Run a job that uses the credential and confirm it succeeds. Do not skip this because the change looked simple.
- Revoke the old value at the provider.
- Record it, so the next audit knows the old value is already dead and nobody re-investigates it.
For tokens with an expiry date, write the date somewhere you will actually see it. Automation that stops on a Tuesday because a token quietly expired is a slow and frustrating problem to diagnose, particularly when the failure surfaces as an unrelated-looking error in a scheduled job.
A note on shared credentials
The single most common rotation failure is a credential used by three systems where only two get updated. Before you rotate anything, write down every consumer. If you cannot produce that list with confidence, that gap is a finding in itself and worth fixing before the rotation rather than after.
Stop the next one
Set secrets directly, never through the conversation. Platform CLI tools read a value from a prompt or a file and send it straight to the encrypted store. The value never enters the chat context, so it never enters the transcript. This single habit prevents nearly all of what an audit finds.
Reference secrets by name. Tell the assistant the variable name, not the value. Well-configured automation reads the name from its environment at run time and never needs the literal in a conversation.
Put the transcript directory on your sensitive list. Exclude it from cloud sync and general-purpose backups, or accept that your chat history travels wherever those backups go. Both are defensible choices; the problem is making the choice by accident.
Prune old sessions. Transcripts from finished work have little ongoing value, and every retained session is another copy of whatever was pasted into it. Pruning also makes the next audit faster.
Scan on a schedule. The same regular expression sweep, run quarterly, takes minutes once the patterns are written down, and catches drift before it accumulates into a long afternoon.
The part people get wrong
The instinct on finding credentials in a log file is to delete the file. That feels like remediation. It is not.
Deleting removes one copy while the credential stays valid, and copies survive in backups, sync folders and duplicated session files. Anyone who already had access to the original still has whatever they took from it.
Rotation is the fix. Deletion is the housekeeping you do afterwards, once the old values are already dead and removing them changes nothing. Doing it in the other order produces a tidy directory and an unchanged risk, which is the worst of both outcomes because it also produces the feeling of having dealt with it.
What we checked
- Audited a real developer workstation on 2026-11-25: enumerated an AI assistant's local transcript directory, counted session files and total size, and swept every file with the regular expression patterns listed above. Details of the system and its owner are deliberately omitted.
- Confirmed from that audit that a single pasted credential appeared in multiple separate session files, because resumed and forked sessions duplicate earlier history. The highest duplication observed for one value was in double figures.
- Confirmed that the transcript files were plain text, readable without any decryption step, and protected only by file system permissions.
- Confirmed that generic patterns such as 32 character hexadecimal strings produce substantial false positives, including internal session and pipe identifiers, which is why the classification step above exists.
- Not verified: we did not test whether any specific vendor redacts credential-shaped strings before writing transcripts. Behaviour differs between tools and versions, so check your own tool rather than assuming either way.
- Not verified: file locations given here are described in general terms because vendors change them between versions. Treat your tool's current documentation as authoritative.
Last tested: 2026-11-25
References
- Vendor documentation for your AI assistant, for the current transcript directory location and any retention settings it exposes.
- Your cloud and Git platform documentation, for the correct rotation procedure and token expiry options for each credential type.
Comments
Questions and tips are welcome. Comments are checked by the EpiFive team before they appear; please do not share passwords, phone numbers or other private details.