Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/langchain-multi-env-setup

@0d57af8
Run it yourself

Build reliable dev / staging / prod isolation for LangChain 1.0 services — Pydantic Settings + SecretStr, cloud Secret Manager in prod, per-env prompt and model version pinning, env-specific checkpointer and observability. Use when graduating from .env-in-dev to real prod infra, or debugging a config that loaded the wrong values in the wrong env. Trigger with "langchain multi-env", "langchain pydantic settings", "langchain secret manager", "langchain env config", "langchain prod setup".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/langchain-multi-env-setup

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesone-pager.md

≈801 tokens on demand. Your agent reads this file only when SKILL.md points to it.

langchain-multi-env-setup — One-Pager

Build reliable dev / staging / prod isolation for LangChain 1.0 services — Pydantic Settings with SecretStr, GCP/AWS Secret Manager in prod, per-env prompt and model pinning, startup smoke tests that fail fast.

The Problem

A team deploys a LangChain 1.0 service to staging with python-dotenv reading .env.staging into os.environ. Security runs docker exec <pod> env during a routine audit and sees ANTHROPIC_API_KEY=sk-ant-api03-... in plain text — sev-1 incident (pain P37). The same week, staging starts answering with prod-tuned prompts and hitting a model that was only rolled out to prod, because the config loader picked LANGCHAIN_ENV=production from a stale shell profile. Three failures chain together: secrets in process env, no env-aware config gate, and no startup validation that would have caught the wrong model id before the first request landed.

The Solution

One Settings class built on pydantic-settings, SecretStr for every key, Literal["dev","staging","prod"] typed env switch, and fail-fast validation on import. Secret Manager (GCP / AWS / Vault) pulls values into the in-memory Settings object only — never back into os.environ — so docker exec env returns nothing sensitive. Per-env pins for model_id, prompt_commit_hash, vector_index_name, checkpointer_url, and rate-limit budgets live in the Settings class so dev / staging / prod diverge by data, not by conditional code. A startup smoke test under 10 seconds verifies every integration is reachable before the health check goes green.

Who / What / When

Aspect Details
Who Python engineers graduating a LangChain 1.0 service from .env-in-dev to real prod infra, or debugging a wrong-env config that shipped
What Settings skeleton + Secret Manager integration + per-env model/prompt pinning + startup smoke test + env matrix
When Before the first staging or prod deploy, or immediately after any incident where a prod secret leaked or a staging request hit the wrong model

Key Features

  1. Pydantic Settings with SecretStr and Literal env — Fail-fast validation on startup, one class as the source of truth, SecretStr prevents accidental print(settings) leaks, HttpUrl validates checkpointer and observability endpoints
  2. Secret Manager pull into memory only — GCP Secret Manager / AWS Secrets Manager / Vault client pulls keys at startup into the Settings object; never writes to os.environ, so docker exec env and /proc/<pid>/environ stay clean (fixes P37)
  3. Per-env pinning matrix — model_id, prompt_commit_hash, vector_index_name, checkpointer_url, max_cost_usd_per_day all diverge per env inside Settings, not in if env == "prod": branches sprinkled through business logic
  4. Startup smoke test under 10 seconds — One validate_integrations() call hits the model (1-token health ping), the vector store (describe_index), the checkpointer (SELECT 1), and the observability endpoint before the HTTP server accepts traffic

Quick Start

See SKILL.md for full instructions.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill implements security best practices for configuration management in LangChain applications, focusing on preventing credential leakage and ensuring environment isolation using Pydantic and cloud secret managers.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
What it can do
Reads files Edits files Runs commands
version
2.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
compatibility
Designed for Claude Code
All 5 allowed tools
ReadWriteEditBash(python:*)Bash(gcloud:*)
Other metadata
tags
[
  "saas",
  "langchain",
  "langgraph",
  "python",
  "langchain-1.0",
  "config",
  "pydantic",
  "multi-env",
  "secrets"
]

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/langchain-multi-env-setup