gesmith0606/claude-config-public/secrets-handling

Claude Code and agent skill by gesmith0606/claude-config-public

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Write-time secret hygiene: keep credentials out of code as it's written. Use when adding a DB connection, API client, auth token, cloud SDK call, or .env — or when asked where a credential should live. Covers runtime resolution (env / AWS / Azure / GCP / Vault), password-free connection strings, log redaction, and rotation.

Install

npx vskill@latest install gesmith0606/claude-config-public/secrets-handling

SKILL.md

The same SKILL.md was published earlier as gesmith0606/claude-config-public/secrets-handling.

Secrets Handling (write-time)

Keep credentials out of source as you write it. The rule: code carries the *name* of a secret, never its *value*. Resolve the value at runtime.

This is the prevention counterpart to insecure-defaults (which detects hardcoded secrets and fail-open fallbacks after the fact). For credential APIs that are easy to misuse see sharp-edges; for failures during resolution see error-handling.

The one rule, four tiers

Pick the lowest tier that fits the deployment:

  1. Local dev — .env file (git-ignored) loaded via dotenv. Commit a

.env.example with keys and placeholder values only.

  1. CI / runtime — process environment variables injected by the platform

(GitHub Actions secrets, container env, systemd EnvironmentFile).

  1. Servers / cloud — a secret manager: AWS Secrets Manager, Azure Key Vault,

GCP Secret Manager, or HashiCorp Vault. Fetch at startup, cache in memory.

  1. Workload identity — no stored secret at all; assume an IAM role / managed

identity and let the SDK sign requests. Prefer this when available.

Resolve at runtime, fail-secure

python
import os
secret = os.environ["DB_PASSWORD"] # KeyError if missing → fail-secure
# NOT: os.environ.get("DB_PASSWORD", "changeme") # fail-open — insecure-defaults flags this
python
# Secret manager (AWS shown; same shape for Azure/GCP/Vault) — fetch, don't embed
import boto3, json
def load_db_secret(name="prod/db"):
raw = boto3.client("secretsmanager").get_secret_value(SecretId=name)
return json.loads(raw["SecretString"]) # {"username":..., "password":...}

Invoke Python as python3 (on Windows the MS-Store python may be a stub; use py -3 if python3 is unavailable).

Local secrets: password-manager backends

This config resolves credentials at runtime through ~/.claude/scripts/resolve-secret.js: env var → OS keychain → op (1Password) → bw (Bitwarden). Pin one in machine.json (secrets.backend; default auto). Store secret names in config files, never values — "webhookSecret": "DISCORD_WEBHOOK_CLAUDE" — and health-check fails the run if a raw token appears in machine.json.

For operating the Bitwarden CLI itself — unlocking, adding secrets, diagnosing "not found" — use the `bitwarden` skill.

Connection strings without embedded passwords

Never bake the password into a literal URL. Build it from resolved parts, or hand credentials to the driver separately so they never live in one string.

python
from sqlalchemy import create_engine, URL
url = URL.create( # safely URL-encodes; nothing to log-leak
"postgresql+psycopg",
username=os.environ["DB_USER"],
password=os.environ["DB_PASSWORD"],
host=os.environ["DB_HOST"], database="app",
)
engine = create_engine(url)
  • For workload identity, omit the password entirely and use IAM auth tokens

(RDS IAM, Cloud SQL connector, Azure AD) generated per-connection.

  • .env example: DATABASE_URL=postgresql+psycopg://app@localhost/app — note

the password is absent; the driver prompts/resolves it.

Redact in logs and tracebacks

Secrets leak through print, log lines, exception messages, and repr of config objects. Defend at the boundary:

  • Never log a connection URL, header dict, or full config object verbatim.
  • Wrap secrets in a type whose __repr__/__str__ returns "***" (e.g.

Pydantic SecretStr), so accidental interpolation can't expose them.

  • Scrub known keys (password, token, api_key, authorization) in a

logging filter before records are emitted.

  • On exceptions, log the secret's name/source, not its value — see

error-handling for the message-shaping pattern.

Rotation

Assume every secret will be rotated. Resolve at startup (and on a refresh interval or on auth-failure retry) rather than caching for the process lifetime, so a rotated value is picked up without a redeploy. Prefer managers that version secrets so rollback is a pointer change.

Never

  • Inline a literal key/password/token in source, even "temporarily."
  • Commit a real .env, keyfile, or *.pem — git-ignore them; commit only

.env.example.

  • Print secrets in notebooks (outputs are saved to disk and pushed) or echo

them in CI logs (use the platform's masked-secret mechanism).

  • Pass secrets as command-line args (visible in ps / shell history) — use env

or stdin.

  • Embed credentials in container images, IaC literals, or front-end bundles.

Before finishing any change that touches credentials, run insecure-defaults over the diff to confirm nothing hardcoded slipped in.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/gesmith0606/claude-config-public/secrets-handling/badge)](https://verified-skill.com/skills/gesmith0606/claude-config-public/secrets-handling)

Something wrong with this skill or its page? Tell us.