Guides · Updated December 2, 2026

How agent skills handle API keys and secrets

By Tineessa Nelson, Use This Skill

An agent skill should get an API key from an environment variable that you set outside the conversation, in your shell or in your agent's settings, and read it only when a command runs. The key should never be written into SKILL.md or pasted into the chat. Of 1,975 public skills we read on December 2, 2026, 157 name a key, and none ship a real one.

A skill is a folder of instructions and scripts with no secret store of its own, so every skill that calls an outside service must say where its key comes from. The careful ones also tell the agent what not to do with it.

How do real skills get their keys?

On December 2, 2026 we cloned all 47 GitHub repositories in this directory's November 30 crawl and read every text file in every skill folder by script. A skill counts as naming a key when any of its files mentions a credential variable such as OPENAI_API_KEY, GITHUB_TOKEN or AWS_SECRET_ACCESS_KEY. Placeholder names such as YOUR_API_KEY were not counted.

What the skill's files do Skills Repositories
Name a credential variable 157 28
Read it from the environment (os.environ, process.env, $VAR, export) 115 21
Mention a .env file 49 18
Mention a keychain, 1Password, a vault or a secrets manager 26 11
Tell the agent not to print, log, commit or share the key 54 17
Tell the agent not to ask for a key in chat or paste one into a prompt 7 5
Name a key but say nothing about where it should come from 26 10
Ship a real-looking key 0 0
Name no credential variable at all 1,818 40

Source: Use This Skill directory (data/skills.json, crawl of November 30, 2026, 1,975 skills in 47 repositories), every skill folder read on December 2, 2026. The rows overlap: one skill can read the environment and also mention a .env file. Matches are text patterns, so a variable shown in example code counts. In a hand-read sample of 20 of the 157, 17 used the key in the skill's own work (calling a service, deploying, running a bundled script) and 3 showed it only in example application code.

Three repositories account for most of the 157: K-Dense-AI's scientific skills (58), OmniRoute (24) and wshobson/agents (23). The variables named most often are OMNIROUTE_TOKEN (21 skills), ANTHROPIC_API_KEY (14), GITHUB_TOKEN (14), OPENROUTER_API_KEY (12) and OPENAI_API_KEY (11). Three of Anthropic's own 20 skills name a key: claude-api, mcp-builder and skill-creator.

The search for real keys looked for the published formats of Anthropic, OpenAI, AWS, GitHub, Slack, Google and Stripe keys. It found one match in 1,975 skills: an example in trailofbits' firebase-apk-scanner references, AIzaSyA1B2C3D4E5..., which is a made-up placeholder in a guide to finding exposed keys. A pattern search only finds the formats it knows, so treat this as "none found", not as a guarantee.

What do the scan results say about these skills?

The weekly scan of November 30, 2026 found 125 of the 157 clear, 23 worth a review and 9 flagged. All nine flags are for a download piped straight into a shell (curl ... | bash), not for anything to do with keys. Across the whole directory the scan found 1,913 skills clear, 49 for review and 13 flagged.

The scan has one rule about secrets, and it is a review rule, not a flag: it matches lines that refer to ~/.ssh, ~/.aws/credentials, ~/.netrc or a keychain, or that print, read or upload a .env file. It matched 27 skills, 20 of them among the 157. Many of those matches are careful instructions rather than risky ones, which is why the rule asks for a human read. Three examples, quoted from the skills:

  • database-lookup: "Check only the named key in .env if needed — do not read or display the whole .env file."
  • omero-integration: "Never crawl for .env files or read unrelated environment variables."
  • pufferlib: "Do not print all environment variables or recursively discover .env files."

Should a skill ask you to paste your key into the chat?

The skills that address this directly say no. Anything you type becomes part of the conversation, which the agent may repeat in a file, a commit message or a tool call. Seven skills in five repositories tell the agent not to ask for it or paste it anywhere. Four of them:

  • Anthropic's claude-api: "When you need to call the API and ANTHROPIC_API_KEY is unset, don't ask the user for a key." It tells the agent to check the ant CLI's stored credentials first.
  • remotion-dev's remotion-best-practices: "Store credentials in .env using REMOTION_AWS_ACCESS_KEY_ID and REMOTION_AWS_SECRET_ACCESS_KEY; never ask the user to paste secrets into chat."
  • sandbase's similarweb-analytics uses its API only when "SANDBASE_API_KEY is already configured in its environment" and says never to ask for it in chat, a prompt, a report or a command argument.
  • wshobson's hermes-tweet: "Do not paste credentials into prompts, issues, PR comments, or tool inputs."

A few skills do ask for a secret in one step. Vercel's vercel-cli-with-tokens, for example, tells the agent to "Ask the user for a fresh token" when the one it has stops working. If a skill asks you for a key, you can set the variable yourself instead and tell the agent it is set.

Where do I set a key for a skill in Claude Code?

Claude Code reads keys from two places, according to its environment variables documentation, checked December 2, 2026:

Where Applies to Good for keys?
Your shell (export NAME=value) That terminal session Yes; restart claude after a change
~/.claude/settings.json, env key "You, in every project" Yes
.claude/settings.local.json, env key "You, in this project only" Yes; Claude Code gitignores it when it saves a setting there, and the docs say to add it to your gitignore if you create it by hand
.claude/settings.json, env key "Everyone working in the project, checked into source control" No; this file is shared

The documentation says Claude Code "reads them directly from the file, so they take effect no matter how claude was launched", and that when a variable is set in both places, "the settings file value applies in most sessions." Values are copied as written: "No shell processes them, so shorthand such as ~ or $HOME stays as typed."

The commands a skill runs are subprocesses of Claude Code (the documentation lists the Bash and PowerShell tools, hooks and stdio MCP servers among them), which is how a script in a skill folder sees a variable you set. One public skill, taylorwilsdon's managing-google-workspace, shows the settings approach and says to "Direct the user to edit" the file "themselves" and "not ask the user to paste secrets into the conversation". Its example path is ~/.claude/settings.local.json; the files listed in Claude Code's documentation are the four in the table above, so check that the file you edit is one of them.

We did not check how Codex, Cursor or Gemini CLI pass environment variables to skills for this page. In any agent, a variable exported in the shell you start the agent from is the most portable choice.

What should you check before giving a skill a key?

  1. Read which variable it wants and what it does with it. Search the folder for the variable name and follow it into any scripts/. A key should go to the service the skill is for, and nowhere else.
  2. Paste the skill's GitHub link into the live skill check. It lists lines that read credential files, print .env files, pipe downloads into a shell or send data to webhook and tunnel addresses, each with the file and line.
  3. Give it the narrowest key you can. A read-only or project-scoped token limits the damage if a step goes wrong.
  4. Keep the key out of shared files. Not in SKILL.md, not in .claude/settings.json, not in a committed .env. If you share skills with your team, share the variable name, not the value.
  5. Remember the key outlives the skill. Uninstalling a skill deletes the folder, not the variable or the token. Revoke the token if you stop using the service.

If you write skills, copy the careful ones: name the variable, read it at run time, say what to do when it is missing, and tell the agent not to print it or ask for it in chat. See also what a malicious skill can do.

How we got these numbers

We cloned the 47 repositories at depth 1 on December 2, 2026 and walked every text file under 1 MB in each of the 1,975 skill folders, skipping .git and node_modules. A credential variable is an upper-case name ending in API_KEY, TOKEN, SECRET, SECRET_KEY, ACCESS_KEY, ACCESS_TOKEN, AUTH_TOKEN, PAT, PASSWORD or CREDENTIALS; names beginning YOUR_, EXAMPLE_ or REQUIRE_ were set aside as placeholders or switches (four skills named only those). The other rows are fixed text patterns, and the quoted lines were read by hand. Scan statuses and the credentials rule come from data/scan.json (scan of November 30, 2026) and lib/scan-rules.json. We did not install these skills or give any of them a key for this page.

Questions

Can I put my API key in SKILL.md?

You should not. SKILL.md is read into the agent's context every time the skill runs, and skill folders are usually copied, committed and shared. In our December 2, 2026 read of all 1,975 public skills in this directory, none shipped a real-looking key; skills that need one name an environment variable, such as OPENAI_API_KEY, and read it when a command runs.

Where do I set an environment variable for a skill in Claude Code?

Either export it in the shell you start claude from, or add it under the env key of a Claude Code settings file. Claude Code's documentation lists ~/.claude/settings.json for you in every project, .claude/settings.json for everyone in a project (checked into source control), and .claude/settings.local.json for you in one project only. Keys belong in the first or the last, not in the shared project file.

Should a skill ask me to paste my key into the chat?

It is better if it does not. Anything you paste becomes part of the conversation. Seven public skills in five repositories say so outright, including Anthropic's own claude-api skill, which tells the agent not to ask the user for a key when ANTHROPIC_API_KEY is unset and to check the ant CLI's stored credentials first.

Does the Use This Skill scan check for leaked keys?

The weekly scan marks skills that read credential files such as ~/.ssh or ~/.aws/credentials, or that print or upload a .env file, for review. Searching for key formats is a separate check we ran for this page. You can run the same rules on any public skill by pasting its GitHub link into usethisskill.com/scan.