Config Env Conventions
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Service configuration and environment variable conventions across all services: naming, validation, defaults, and secret handling for confident deployment across environments.
Why This Matters
- Portability: Same code, different configs per env
- Safety: Validate config at startup, fail fast
- Security: Clear separation of secrets
- Debugging: Know where config comes from
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
Quick Start
Assumptions
- Services follow 12-Factor App principles
- Secret management system available (Vault, AWS SM, GCP SM)
- Multiple environments (development, staging, production)
- Configuration validation at startup
- TypeScript or similar language with schema validation
Compatibility
- Node.js: 16+
- TypeScript: 4.5+
- Zod: 3.0+
- Vault: 1.10+
- AWS Secrets Manager: Latest API
Test Scenario Matrix
| Scenario |
Input |
Expected Output |
Verification |
| Load valid config |
Valid env vars |
Config object loaded |
No errors |
| Missing required var |
Missing required env |
Validation error |
Error message |
| Invalid type |
Invalid port string |
Validation error |
Type check |
| Secret loading |
Secret from manager |
Secret loaded securely |
No logs of value |
| Environment detection |
APP_ENV set |
Correct environment |
Env variable set |
Technical Guardrails
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done
Configuration is complete when:
Anti-patterns
- Hardcoded values: Config in code
- Secrets in .env: Committed to git
- No validation: Runtime failures
- Magic strings: Config keys scattered in code
- Implicit env: Behavior changes based on
NODE_ENV unpredictably
- Production defaults: Real production values as defaults
- Mixed secrets: Secrets and config in same place
- No documentation: Undocumented configuration options
Reference Links
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: config-env-conventions3description: Service configuration and environment variable conventions across all Use when this capability is needed.4---56# Config Env Conventions78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Service configuration and environment variable conventions across all services: naming, validation, defaults, and secret handling for confident deployment across environments.1819## Why This Matters20- **Portability**: Same code, different configs per env21- **Safety**: Validate config at startup, fail fast22- **Security**: Clear separation of secrets23- **Debugging**: Know where config comes from2425## Core Concepts & Rules2627### 1. Core Principles28- Follow established patterns and conventions29- Maintain consistency across codebase30- Document decisions and trade-offs3132### 2. Implementation Guidelines33- Start with the simplest viable solution34- Iterate based on feedback and requirements35- Test thoroughly before deployment363738## Inputs / Outputs / Contracts39* **Inputs**:40 - <e.g., env vars, request payload, file paths, schema>41* **Entry Conditions**:42 - <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>43* **Outputs**:44 - <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>45* **Artifacts Required (Deliverables)**:46 - <e.g., Code Diff, Unit Tests, Migration Script, API Docs>47* **Acceptance Evidence**:48 - <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>49* **Success Criteria**:50 - <e.g., p95 < 300ms, coverage ≥ 80%>5152## Skill Composition53* **Depends on**: [secrets-key-management](../71-infrastructure-patterns/secrets-key-management/SKILL.md), [config-distribution](../69-platform-engineering-lite/config-distribution/SKILL.md)54* **Compatible with**: [api-style-guide](./api-style-guide/SKILL.md), [service-standards-blueprint](./service-standards-blueprint/SKILL.md)55* **Conflicts with**: None56* **Related Skills**: [env-matrix-dev-stg-prod](../69-platform-engineering-lite/env-matrix-dev-stg-prod/SKILL.md), [logging-metrics-tracing-standard](./logging-metrics-tracing-standard/SKILL.md)5758## Quick Start59#6061## Assumptions62- Services follow 12-Factor App principles63- Secret management system available (Vault, AWS SM, GCP SM)64- Multiple environments (development, staging, production)65- Configuration validation at startup66- TypeScript or similar language with schema validation6768## Compatibility69- **Node.js**: 16+70- **TypeScript**: 4.5+71- **Zod**: 3.0+72- **Vault**: 1.10+73- **AWS Secrets Manager**: Latest API7475## Test Scenario Matrix76| Scenario | Input | Expected Output | Verification |77|----------|-------|-----------------|--------------|78| Load valid config | Valid env vars | Config object loaded | No errors |79| Missing required var | Missing required env | Validation error | Error message |80| Invalid type | Invalid port string | Validation error | Type check |81| Secret loading | Secret from manager | Secret loaded securely | No logs of value |82| Environment detection | APP_ENV set | Correct environment | Env variable set |8384## Technical Guardrails85#8687## Agent Directives & Error Recovery88*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*8990- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.91- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.92- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.93- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.949596## Definition of Done97Configuration is complete when:9899- [ ] All env vars follow naming convention100- [ ] Configuration schema defined and validated101- [ ] `.env.example` complete with all keys102- [ ] Required vs optional clearly marked103- [ ] Secrets not in `.env` files104- [ ] Defaults are safe (not production values)105- [ ] Environment detection implemented106- [ ] Config changes don't require code changes107- [ ] Documentation complete108- [ ] Startup validation tested109110## Anti-patterns1111. **Hardcoded values**: Config in code1122. **Secrets in .env**: Committed to git1133. **No validation**: Runtime failures1144. **Magic strings**: Config keys scattered in code1155. **Implicit env**: Behavior changes based on `NODE_ENV` unpredictably1166. **Production defaults**: Real production values as defaults1177. **Mixed secrets**: Secrets and config in same place1188. **No documentation**: Undocumented configuration options119120## Reference Links121- [12-Factor App: Config](https://12factor.net/config)122- [Node.js Config Best Practices](https://github.com/goldbergyoni/nodebestpractices#1-project-structure-practices)123- [Zod Documentation](https://zod.dev/)124- [AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/)125126## Versioning & Changelog127128* **Version**: 1.0.0129* **Changelog**:130 - 2026-02-22: Initial version with complete template structure131132---133> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.134<!-- tomevault:4.0:skill_md:2026-04-13 -->