Skip to content

Guide · Agent skill

How to use the Extract Python Environment Variables agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The Extract Python Environment Variables skill is an agent skill for Python recipes. It finds every environment variable the code reads, including hidden defaults set with os.environ.setdefault, and then updates the recipe's .env.example, load_dotenv() bootstrap and pyproject.toml so the configuration is declared in one place. This guide covers what the skill does, how to install it, how to ask for it in plain language and what to check before you commit the changes.

Extract Python Environment Variablesgoogle/adk-recipes · Apache-2.0

Quick start

  1. 1Install the skill. Download the skill ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder, or upload it under Settings → Capabilities → Skills in the Claude apps.
  2. 2Check the prerequisites. Confirm Python is available, that scripts/extract_env_vars.py is in the skill folder, and that python-dotenv is listed in the recipe's pyproject.toml.
  3. 3Commit or stash your work. Start from a clean git state so you can review exactly what the skill changes.
  4. 4Ask for the task in plain language. Tell the agent which recipe to process, for example asking it to extract the env vars or update .env.example for that folder.
  5. 5Review the warnings and the diff. Read any [WARN] lines, check every changed line in .env.example and the Python files, and confirm no user-written line was altered.
  6. 6Fix remaining TODOs. Replace any <TODO: update-this-value> entries with real values and update the source where a stub string was found.

What is an agent skill?

An agent skill is a folder that gives an AI agent a set of instructions and, in some cases, scripts it can run for a specific task. This one is named extract-python-environment-variables and its main instructions are in a file called SKILL.md. When the agent judges that a request matches the skill, it follows those instructions.

What the skill makes the agent do

The skill runs scripts/extract_env_vars.py against a recipe directory. The script scans the .py files (skipping tests/ and common cache and virtual environment folders) for calls such as os.environ["VAR"], os.environ.get, os.getenv and os.environ.setdefault. It then appends missing variables to .env.example and upgrades stale TODO entries in place when the source can supply a real default.

The skill can also inject a load_dotenv() bootstrap into the package __init__.py, make sure python-dotenv is listed in pyproject.toml, and replace hardcoded model-name strings such as "gemini-3.5-flash" with an os.getenv(...) lookup.

  • Only UPPER_SNAKE_CASE names are captured. Lowercase names such as os.getenv("my_api_key") are skipped and listed in a [WARN] line.
  • Stub-looking values such as changeme, your-api-key or anything containing example.com are written as <TODO: update-this-value>, with the original source string kept in the comment.
  • Each new or upgraded line has the shape VAR=<value> # extracted-by:extract-env-vars; <provenance>.
VAR=<value> # extracted-by:extract-env-vars; <provenance>

How do you install the skill?

Download the skill ZIP from this page and unzip it. For a personal setup, place the folder in ~/.claude/skills/. For a single project, place it in that project's .claude/skills/ folder.

In the Claude apps you can instead upload the skill under Settings → Capabilities → Skills.

  • Personal install: ~/.claude/skills/
  • Project install: .claude/skills/ inside the project
~/.claude/skills/

What does the skill need before it runs?

You need Python. The skill depends on scripts/extract_env_vars.py, which is bundled with the skill but was not included in the files reviewed for this page, so confirm the script is present in the folder before you rely on it. The target recipe's pyproject.toml must list python-dotenv at the minimum version the skill sets.

The skill runs scripts and does not use the network, according to the review.

  • Python installed
  • scripts/extract_env_vars.py present in the skill folder
  • python-dotenv listed in the recipe's pyproject.toml
python-dotenv>=1.0.0

How do you trigger the skill with natural requests?

You do not need a special command. Describe the task in plain language and name the recipe. The skill is written to respond to requests such as the ones below, which come from its trigger description.

Good requests name the outcome you want, for example asking the agent to extract the env vars in a recipe folder, or to replace hardcoded model names in agent.py with environment variables.

  • "Extract env vars from this recipe."
  • "Update .env.example for this Python recipe."
  • "Add load_dotenv to this package."
  • "Surface the setdefault defaults in this project."
  • "Upgrade the stale TODOs in .env.example."
  • "Replace the hardcoded model names in this recipe."
  • "Fix the environment variables in this Python recipe."

What changes will you see after a run?

When the bootstrap is injected, the package __init__.py receives the import and call shown below, with a comment explaining that a missing .env is expected in production because the platform supplies the environment.

Trailing relative imports that would trigger Ruff E402 after the injection are marked with # noqa: E402 -- must come after load_dotenv(). Relative imports at the top of the file are left alone, and a line already carrying the marker is skipped.

  • Pre-existing os.environ.setdefault and os.getenv calls written by the author are left untouched.
  • The skill does not write new os.environ.setdefault lines into Python files.
from dotenv import load_dotenv # Load variables from .env if present. In production the environment is # already populated by the platform (Cloud Run, GKE, etc.), so a missing # .env is expected and not an error. load_dotenv()

What safety rules does the skill follow?

The skill has two rules it is designed never to break. First, any .env.example line it cannot prove it wrote is treated as user-owned and is never modified. When the file has quoted values, backslash continuations or duplicate declarations, the rewriter stops rather than guess. A stale TODO left in place is considered cheap; an overwritten edit is not.

Second, outside the three listed Python edits (the load_dotenv bootstrap, the noqa suffix and model-literal replacement), the skill does not write to Python files.

The script does write values and rewrites some Python lines, so review the diff before you commit. The skill manages declarations and defaults only. It does not store credentials, so production secrets need a separate process.

  • Review the git diff before committing.
  • Keep real secrets out of .env.example; the skill manages declarations and defaults, not credential storage.
  • Projects that are not Python are out of scope because the scanner targets Python source files.

Tips for better results

Run the skill on a clean working tree so the diff shows only what the agent changed. Fix any [WARN] lines by renaming lowercase variables to uppercase in source or adding them to .env.example by hand. Where the output leaves a <TODO: update-this-value> entry, decide the real value yourself and update the source as well.

If you want to control every config value by hand, skip this skill for that recipe.

  • Work on a clean git state so the diff is easy to review.
  • Read every [WARN] line in the output.
  • Treat remaining TODO entries as a checklist.

What people use it for

  • Standardising .env.example across several agent recipes so each one declares its variables the same way.
  • Converting hardcoded model names such as a Gemini model string in agent.py into a configurable environment variable.
  • Surfacing hidden defaults set with os.environ.setdefault so a person editing .env.example can see them.
  • Cleaning up an older recipe whose .env.example still has placeholder TODO entries.

Frequently asked questions

How do I install the extract python environment variables agent skill?

Download the skill ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder for one project. In the Claude apps you can instead upload it under Settings → Capabilities → Skills.

Is the extract-python-environment-variables skill free?

The skill is licensed under Apache-2.0, as listed on this page. Check the license file in the skill folder for the full terms.

What do I need to run this skill?

You need Python, the scripts/extract_env_vars.py script that ships with the skill, and python-dotenv listed in the recipe's pyproject.toml. The review found that the skill runs scripts but does not use the network.

Does the skill overwrite my .env.example edits?

No, by design. Any line the skill cannot prove it wrote is treated as user-owned and is never modified. When the file is ambiguous, such as with quoted values or duplicate declarations, the skill stops rather than rewrite it.

Does it work on projects that are not Python?

No. The scanner targets Python source files, so it is not suitable for other languages.

What is a good alternative if I want to set every config value by hand?

Skip the skill for that recipe and edit .env.example and the source yourself. This skill suits maintainers who want a consistent .env.example, not those who need full manual control of every value.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

This skill suits maintainers of Python agent recipes who want a consistent .env.example, developers moving hardcoded model names into environment variables, and teams tidying up older recipes with placeholder TODOs. Skip it for non-Python projects, for recipes where you want to hand-control every config value, or for anything that needs real secrets storage; always review the diff before committing.

Download the skill