Skip to main content
skill CX Codex

credentials — Claude Code skill: safe API key handling

Checks whether a key exists in .env and asks the user to add it without pasting the value into chat.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add google-deepmind/science-skills --skill credentials -a claude-code
Open on GitHub

What credentials does

This skill sets the protocol for handling keys and tokens. The moment a task needs a credential, the agent first checks for the variable in ~/.env with grep -sq "^CREDENTIAL_NAME=" ~/.env. A non-zero exit code stops the work: no scripts run, and the agent does not try to work around the missing key.

Instead of asking for a paste, the agent hands over a ready command built on read -s, so typing stays hidden, and appends the value to the file. The CREDENTIAL_NAME and ENV_FILE placeholders get filled in before the command is shown. The registration link from the calling skill comes along too, so a user without a key knows where to get one.

Helper scripts load credentials themselves through dotenv. Exporting variables or passing them as CLI arguments is unnecessary. The catch: verification only looks at ~/.env in the home directory, so a key that lives in shell environment variables or another file will not be found and the agent will stall for no reason. Reading cat ~/.env, echo $VAR or printenv is explicitly off the table — that leaks the value into context.

What it helps with

  • check that a key exists without printing its value
  • add an API key to ~/.env without pasting it into the conversation
  • halt the agent before it runs scripts with a missing key
  • point the user to where the token is issued
  • let scripts pick up credentials without manual exports

Example prompts for the agent

  • check whether ALPHAGENOME_API_KEY is in ~/.env and give me the command to add it if not
  • this skill needs a key — generate the read -s command with the ~/.env path
  • run the script, it will pull the key from .env

How to install credentials

1Skills CLI (Vercel)

npx skills add google-deepmind/science-skills --skill credentials -a claude-code

2Manually: put the files in place

~/.claude/skills/credentials/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/credentials/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about credentials

How do I install credentials in Claude?

npx skills add google-deepmind/science-skills --skill credentials -a claude-code. The skill file lands at ~/.claude/skills/credentials/SKILL.md.

Why does the agent ignore my environment variable?

The protocol only checks ~/.env. A variable set in the shell or stored elsewhere fails the check and the agent stops, even though the key exists. Add the line to ~/.env.

Can I just paste the key into chat?

No. The value stays in the conversation history and the agent context. The skill prints a read -s command instead: typing is hidden and the key goes straight to the file.

Source text

SKILL.md · Apache-2.0
---
name: credentials
description: >-
  Instructions for handling API keys and credentials safely, verifying their
  presence, and prompting the user to add them if missing using a safe protocol.
---

# Safe Credentials Protocol

Many skills require API keys or other credentials to function or to access
higher rate limits. This skill defines the standard safe credentials protocol
for verifying and prompting for these credentials without leaking sensitive keys
into the agent context or the conversation history.

## Safe Verification (No Leaks)

As soon as a skill that requires a credential or API key looks relevant to the
user's request, you **MUST** immediately verify if the credential is present in
the `.env` file (typically located in your home directory `~/.env` or the
project root) — **before doing any other work** for that skill.

**CRITICAL**: You must verify the presence of the credential *without* printing
its value to the terminal or reading it into your context.

### How to verify:

Use `grep` in quiet and suppress-errors mode (`-sq`) to check if the variable is
defined in `~/.env`. The `-s` flag ensures the command works cleanly even if
`~/.env` does not exist yet.

```bash
grep -sq "^CREDENTIAL_NAME=" ~/.env
```

Replace `CREDENTIAL_NAME` with the actual credential name required by the
calling skill (e.g., `ALPHAGENOME_API_KEY` or `USER_EMAIL`).

-   If the command **succeeds** (exit code 0), the credential is present. You
    can proceed.
-   If the command **fails** (any non-zero exit code — whether the credential is
    missing or the `.env` file does not exist yet), the credential is missing.
    You **MUST IMMEDIATELY** stop and prompt the user to add it using the
    instructions in
    [Prompting the User to Add Credentials](#prompting-the-user-to-add-credentials)
    before attempting to run any scripts or tools. Do not conclude the turn by
    simply stating that the key is missing.

> [!CRITICAL] If verification fails (any non-zero exit code), you **MUST NOT**
> attempt to execute any tools or scripts from the calling skill, nor should you
> conclude the turn by simply reporting the missing key. You **MUST
> IMMEDIATELY** generate the appropriate terminal command from the templates
> below and prompt the user to run it. The template command will create the
> `.env` file if it does not already exist.

**NEVER** run `cat ~/.env`, `grep "VAR" ~/.env` (without `-q`), `echo $VAR`, or
`printenv` to check for credentials.

## Prompting the User to Add Credentials

If a credential is missing, do **NOT** ask the user to paste it into the chat.
This would leak the value into the agent's context and the conversation history.

Instead, you **MUST** generate a specific command for the user to run in their
terminal by replacing the placeholders in one of the templates below.

**CRITICAL**: Before presenting the command to the user, you **MUST** replace:

-   `CREDENTIAL_NAME` with the actual variable name needed (e.g.,
    `ALPHAGENOME_API_KEY`, `USER_EMAIL`).
-   `ENV_FILE` with the resolved literal path to the `.env` file (usually
    `~/.env`).

### Template

All credentials are treated as sensitive. The `read -s` flag hides the user's
typing. You **MUST** inform the user that their typing will be hidden.

**CRITICAL**: When requesting a credential, you **MUST** also provide the user
with the appropriate registration link or instructions provided by the calling
skill so they know how to obtain the value if they do not have one.

```bash
printf "Enter CREDENTIAL_NAME (typing hidden): " && read -s val && echo && echo "CREDENTIAL_NAME=$val" >> "ENV_FILE" && echo "Saved."
```

## Running scripts requiring credentials

All helper scripts inside the calling skills load these credentials
automatically from the `.env` file using `dotenv`.

**You do NOT need to** manually read the keys, export them to the shell
environment, or pass them as CLI arguments, when calling the helper scripts that
require them. As long as you have verified the key is present in `.env` using
the safe protocol above, simply run the script directly — the script will load
the credential automatically.

© google-deepmind · Apache-2.0 · google-deepmind/science-skills

Similar skills

All skills for Security →

From the same set39

embl-ebi-ols This skill queries the EMBL-EBI Ontology Lookup Service for terms, definitions and hierarchies. Useful when an agent works with diseases, phenotypes or gene functions. CX Codex +1 2,100installs reactome-database Connects Reactome services for gene list enrichment, identifier mapping, and pathway exports. Useful for running biological data queries inside coding agents. CX Codex +1 2,200installs dbsnp-database A skill for NCBI dbSNP: resolves rsIDs from coordinates or HGVS, returns variant type, gene associations, clinical significance and allele frequencies. CX Codex +1 2,200installs protein-sequence-similarity-search Runs a homology search on a protein sequence with MMseqs2 or BLAST, interprets the alignment metrics and writes a Markdown table of top hits. CX Codex +1 2,100installs protein-sequence-msa Runs multiple sequence alignment for protein sequences via EBI Clustal Omega. Helps evaluate sequence similarity, domain conservation, and key residue preservation. CX Codex +1 2,100installs predictingthepast Restores damaged Latin and Ancient Greek texts, estimates their origin, and retrieves parallel inscriptions. Use it when analysing an inscription or epigraphic document. CX Codex +1 1,200installs alphagenome-atlas-website-links Builds deep-links to the AlphaGenome Atlas for variants, loci, candidate tables and ref-vs-alt prediction views. CX Codex +1 522installs alphagenome-variant-impact-score Scores genetic variants with AlphaGenome Variant Impact values through the AlphaGenome Atlas API. Useful when you need to annotate a VCF or scan a window for every substitution. CX Codex +1 521installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor