claude-mpm 5.4.59__py3-none-any.whl → 5.4.64__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of claude-mpm might be problematic. Click here for more details.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/CLAUDE_MPM_TEACHER_OUTPUT_STYLE.md +5 -0
- claude_mpm/cli/startup.py +14 -9
- claude_mpm/scripts/start_activity_logging.py +0 -0
- claude_mpm/services/agents/deployment/agent_template_builder.py +8 -0
- claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +79 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +178 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/agent-prompts.md +577 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/coordination-patterns.md +467 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/examples.md +537 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/troubleshooting.md +730 -0
- claude_mpm/skills/bundled/collaboration/git-worktrees.md +317 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +112 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/references/code-reviewer-template.md +146 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/references/review-examples.md +412 -0
- claude_mpm/skills/bundled/collaboration/stacked-prs.md +251 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +81 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/references/best-practices.md +362 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/references/plan-structure-templates.md +312 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +152 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/advanced-techniques.md +668 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/examples.md +587 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/integration.md +438 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/tracing-techniques.md +391 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +131 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +325 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/integration-and-workflows.md +490 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/red-flags-and-failures.md +425 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +499 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/INTEGRATION.md +611 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/README.md +596 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/SKILL.md +260 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/examples/nextjs-env-structure.md +315 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/frameworks.md +436 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/security.md +433 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/synchronization.md +452 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/troubleshooting.md +404 -0
- claude_mpm/skills/bundled/infrastructure/env-manager/references/validation.md +420 -0
- claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +86 -0
- claude_mpm/skills/bundled/main/internal-comms/SKILL.md +43 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
- claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +160 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/design_principles.md +412 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/workflow.md +1237 -0
- claude_mpm/skills/bundled/main/skill-creator/SKILL.md +189 -0
- claude_mpm/skills/bundled/main/skill-creator/references/best-practices.md +500 -0
- claude_mpm/skills/bundled/main/skill-creator/references/creation-workflow.md +464 -0
- claude_mpm/skills/bundled/main/skill-creator/references/examples.md +619 -0
- claude_mpm/skills/bundled/main/skill-creator/references/progressive-disclosure.md +437 -0
- claude_mpm/skills/bundled/main/skill-creator/references/skill-structure.md +231 -0
- claude_mpm/skills/bundled/php/espocrm-development/SKILL.md +170 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/architecture.md +602 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/common-tasks.md +821 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/development-workflow.md +742 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/frontend-customization.md +726 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/hooks-and-services.md +764 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/testing-debugging.md +831 -0
- claude_mpm/skills/bundled/pm/pm-delegation-patterns/SKILL.md +167 -0
- claude_mpm/skills/bundled/pm/pm-git-file-tracking/SKILL.md +113 -0
- claude_mpm/skills/bundled/pm/pm-pr-workflow/SKILL.md +124 -0
- claude_mpm/skills/bundled/pm/pm-ticketing-integration/SKILL.md +154 -0
- claude_mpm/skills/bundled/pm/pm-verification-protocols/SKILL.md +198 -0
- claude_mpm/skills/bundled/react/flexlayout-react.md +742 -0
- claude_mpm/skills/bundled/rust/desktop-applications/SKILL.md +226 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/architecture-patterns.md +901 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/native-gui-frameworks.md +901 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/platform-integration.md +775 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/state-management.md +937 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/tauri-framework.md +770 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/testing-deployment.md +961 -0
- claude_mpm/skills/bundled/tauri/tauri-async-patterns.md +495 -0
- claude_mpm/skills/bundled/tauri/tauri-build-deploy.md +599 -0
- claude_mpm/skills/bundled/tauri/tauri-command-patterns.md +535 -0
- claude_mpm/skills/bundled/tauri/tauri-error-handling.md +613 -0
- claude_mpm/skills/bundled/tauri/tauri-event-system.md +648 -0
- claude_mpm/skills/bundled/tauri/tauri-file-system.md +673 -0
- claude_mpm/skills/bundled/tauri/tauri-frontend-integration.md +767 -0
- claude_mpm/skills/bundled/tauri/tauri-performance.md +669 -0
- claude_mpm/skills/bundled/tauri/tauri-state-management.md +573 -0
- claude_mpm/skills/bundled/tauri/tauri-testing.md +384 -0
- claude_mpm/skills/bundled/tauri/tauri-window-management.md +628 -0
- claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +119 -0
- claude_mpm/skills/bundled/testing/condition-based-waiting/references/patterns-and-implementation.md +253 -0
- claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/SKILL.md +458 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/examples/example-inspection-report.md +411 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/references/assertion-quality.md +317 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/references/inspection-checklist.md +270 -0
- claude_mpm/skills/bundled/testing/test-quality-inspector/references/red-flags.md +436 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +140 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md +572 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/core-anti-patterns.md +411 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/detection-guide.md +569 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/tdd-connection.md +695 -0
- claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +184 -0
- claude_mpm/skills/bundled/testing/webapp-testing/decision-tree.md +459 -0
- claude_mpm/skills/bundled/testing/webapp-testing/playwright-patterns.md +479 -0
- claude_mpm/skills/bundled/testing/webapp-testing/reconnaissance-pattern.md +687 -0
- claude_mpm/skills/bundled/testing/webapp-testing/server-management.md +758 -0
- claude_mpm/skills/bundled/testing/webapp-testing/troubleshooting.md +868 -0
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/METADATA +1 -1
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/RECORD +128 -11
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/WHEEL +0 -0
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/entry_points.txt +0 -0
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/licenses/LICENSE-FAQ.md +0 -0
- {claude_mpm-5.4.59.dist-info → claude_mpm-5.4.64.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: env-manager
|
|
3
|
+
description: Environment variable validation, synchronization, and management across local development, CI/CD, and deployment platforms
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
category: infrastructure
|
|
6
|
+
progressive_disclosure:
|
|
7
|
+
entry_point:
|
|
8
|
+
summary: "Validate, synchronize, and secure environment variables across local dev, CI/CD, and deployment platforms with framework-specific support"
|
|
9
|
+
when_to_use: "When managing .env files, deploying to Vercel/Railway/Heroku, syncing with secret managers, or troubleshooting env-related issues"
|
|
10
|
+
quick_start: "1. Validate local .env 2. Check security 3. Sync to platform 4. Verify deployment 5. Generate documentation"
|
|
11
|
+
references:
|
|
12
|
+
- validation.md
|
|
13
|
+
- security.md
|
|
14
|
+
- synchronization.md
|
|
15
|
+
- frameworks.md
|
|
16
|
+
- troubleshooting.md
|
|
17
|
+
author: Claude MPM Team
|
|
18
|
+
license: MIT
|
|
19
|
+
requires_tools:
|
|
20
|
+
- bash
|
|
21
|
+
- python
|
|
22
|
+
tags:
|
|
23
|
+
- environment-variables
|
|
24
|
+
- deployment
|
|
25
|
+
- security
|
|
26
|
+
- devops
|
|
27
|
+
- nextjs
|
|
28
|
+
- vercel
|
|
29
|
+
- railway
|
|
30
|
+
context_limit: 800
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# Environment Variable Manager
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
Manage environment variables systematically across local development, CI/CD pipelines, and deployment platforms. Prevent common issues like missing variables, exposed secrets, platform misconfigurations, and framework-specific gotchas.
|
|
38
|
+
|
|
39
|
+
**Core capabilities:**
|
|
40
|
+
- **Validation**: Check structure, completeness, naming conventions
|
|
41
|
+
- **Security**: Scan for exposed secrets, validate .gitignore coverage
|
|
42
|
+
- **Synchronization**: Sync with deployment platforms and secret managers
|
|
43
|
+
- **Framework Support**: Next.js, Express, Flask, Django patterns
|
|
44
|
+
- **Documentation**: Auto-generate .env.example and setup guides
|
|
45
|
+
|
|
46
|
+
## When to Use This Skill
|
|
47
|
+
|
|
48
|
+
Activate when:
|
|
49
|
+
- Setting up new project environment configuration
|
|
50
|
+
- Deploying to Vercel, Railway, Heroku, or other platforms
|
|
51
|
+
- Troubleshooting "works locally but not in production"
|
|
52
|
+
- Managing secrets across multiple environments
|
|
53
|
+
- Syncing variables with 1Password, AWS Secrets Manager
|
|
54
|
+
- Creating .env.example documentation
|
|
55
|
+
- Onboarding new developers (environment setup)
|
|
56
|
+
- Migrating between deployment platforms
|
|
57
|
+
- Framework-specific env configuration (Next.js NEXT_PUBLIC_ prefix)
|
|
58
|
+
|
|
59
|
+
## Core Principles
|
|
60
|
+
|
|
61
|
+
1. **Never Log Secrets**: All operations must NEVER display actual secret values
|
|
62
|
+
2. **Validate Before Deploy**: Catch env issues locally, not in production
|
|
63
|
+
3. **Framework-Aware**: Respect framework conventions (Next.js, Express, Flask)
|
|
64
|
+
4. **Platform-Specific**: Generate correct configs for each deployment platform
|
|
65
|
+
5. **Security First**: Scan for exposed secrets, validate .gitignore
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
### Validation Workflow
|
|
70
|
+
```bash
|
|
71
|
+
# 1. Check local .env structure
|
|
72
|
+
python scripts/validate_env.py .env
|
|
73
|
+
|
|
74
|
+
# 2. Check for missing variables
|
|
75
|
+
python scripts/validate_env.py .env --compare .env.example
|
|
76
|
+
|
|
77
|
+
# 3. Validate naming conventions
|
|
78
|
+
python scripts/validate_env.py .env --framework nextjs
|
|
79
|
+
|
|
80
|
+
# 4. Check for duplicates
|
|
81
|
+
python scripts/validate_env.py .env --check-duplicates
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Security Workflow
|
|
85
|
+
```bash
|
|
86
|
+
# 1. Scan for exposed secrets in code
|
|
87
|
+
python scripts/scan_exposed.py --scan-code
|
|
88
|
+
|
|
89
|
+
# 2. Check .gitignore coverage
|
|
90
|
+
python scripts/scan_exposed.py --check-gitignore
|
|
91
|
+
|
|
92
|
+
# 3. Validate secret formats
|
|
93
|
+
python scripts/scan_exposed.py --validate-formats .env
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Synchronization Workflow
|
|
97
|
+
```bash
|
|
98
|
+
# 1. Compare local vs platform
|
|
99
|
+
python scripts/sync_secrets.py --platform vercel --compare
|
|
100
|
+
|
|
101
|
+
# 2. Generate platform config
|
|
102
|
+
python scripts/sync_secrets.py --platform vercel --generate
|
|
103
|
+
|
|
104
|
+
# 3. Sync to platform (dry-run first)
|
|
105
|
+
python scripts/sync_secrets.py --platform vercel --sync --dry-run
|
|
106
|
+
|
|
107
|
+
# 4. Actual sync
|
|
108
|
+
python scripts/sync_secrets.py --platform vercel --sync
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Documentation Workflow
|
|
112
|
+
```bash
|
|
113
|
+
# Generate .env.example from .env
|
|
114
|
+
python scripts/validate_env.py .env --generate-example
|
|
115
|
+
|
|
116
|
+
# Generate setup documentation
|
|
117
|
+
python scripts/validate_env.py .env --generate-docs
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Navigation
|
|
121
|
+
|
|
122
|
+
For detailed workflows and patterns:
|
|
123
|
+
- **[Validation](references/validation.md)**: Complete validation workflows and checks
|
|
124
|
+
- **[Security](references/security.md)**: Secret scanning and security patterns
|
|
125
|
+
- **[Synchronization](references/synchronization.md)**: Platform sync and secret manager integration
|
|
126
|
+
- **[Frameworks](references/frameworks.md)**: Framework-specific patterns (Next.js, Express, Flask)
|
|
127
|
+
- **[Troubleshooting](references/troubleshooting.md)**: Common issues and solutions
|
|
128
|
+
|
|
129
|
+
## Framework-Specific Quick Reference
|
|
130
|
+
|
|
131
|
+
### Next.js
|
|
132
|
+
```bash
|
|
133
|
+
# Validate Next.js env structure
|
|
134
|
+
# - NEXT_PUBLIC_* for client-side vars
|
|
135
|
+
# - Check .env.local, .env.production precedence
|
|
136
|
+
python scripts/validate_env.py .env --framework nextjs
|
|
137
|
+
|
|
138
|
+
# Files to manage:
|
|
139
|
+
# - .env.local (local development, gitignored)
|
|
140
|
+
# - .env.production (production, usually from platform)
|
|
141
|
+
# - .env (shared defaults, committed)
|
|
142
|
+
# - .env.example (documentation, committed)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Express/Node.js
|
|
146
|
+
```bash
|
|
147
|
+
# Validate Node.js env structure
|
|
148
|
+
python scripts/validate_env.py .env --framework nodejs
|
|
149
|
+
|
|
150
|
+
# Standard structure:
|
|
151
|
+
# - process.env.NODE_ENV
|
|
152
|
+
# - process.env.PORT
|
|
153
|
+
# - process.env.DATABASE_URL
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Python/Flask
|
|
157
|
+
```bash
|
|
158
|
+
# Validate Python env structure
|
|
159
|
+
python scripts/validate_env.py .env --framework python
|
|
160
|
+
|
|
161
|
+
# Standard structure:
|
|
162
|
+
# - FLASK_APP
|
|
163
|
+
# - FLASK_ENV
|
|
164
|
+
# - DATABASE_URL (SQLAlchemy format)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Platform-Specific Quick Reference
|
|
168
|
+
|
|
169
|
+
### Vercel
|
|
170
|
+
```bash
|
|
171
|
+
# Generate vercel.json env config
|
|
172
|
+
python scripts/sync_secrets.py --platform vercel --generate
|
|
173
|
+
|
|
174
|
+
# Sync to Vercel project
|
|
175
|
+
python scripts/sync_secrets.py --platform vercel --sync
|
|
176
|
+
|
|
177
|
+
# Respects NEXT_PUBLIC_ prefix for client-side vars
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Railway
|
|
181
|
+
```bash
|
|
182
|
+
# Generate Railway config
|
|
183
|
+
python scripts/sync_secrets.py --platform railway --generate
|
|
184
|
+
|
|
185
|
+
# Sync to Railway project
|
|
186
|
+
python scripts/sync_secrets.py --platform railway --sync
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Heroku
|
|
190
|
+
```bash
|
|
191
|
+
# Generate Heroku config
|
|
192
|
+
python scripts/sync_secrets.py --platform heroku --generate
|
|
193
|
+
|
|
194
|
+
# Sync via Heroku CLI
|
|
195
|
+
python scripts/sync_secrets.py --platform heroku --sync
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Key Reminders
|
|
199
|
+
|
|
200
|
+
- **NEVER log actual secret values** - Always mask/redact in output
|
|
201
|
+
- **Validate before every deployment** - Catch issues locally
|
|
202
|
+
- **Use .env.example for documentation** - Keep it updated
|
|
203
|
+
- **Framework conventions matter** - Next.js NEXT_PUBLIC_, Django DJANGO_SETTINGS_MODULE
|
|
204
|
+
- **Platform-specific quirks exist** - Vercel auto-exposes NEXT_PUBLIC_*, Railway uses exact syntax
|
|
205
|
+
- **Secret managers are your friend** - 1Password, AWS Secrets Manager for team sync
|
|
206
|
+
- **.gitignore is critical** - NEVER commit .env files with secrets
|
|
207
|
+
- **Environment precedence can be tricky** - Know your framework's loading order
|
|
208
|
+
|
|
209
|
+
## Common Validation Checks
|
|
210
|
+
|
|
211
|
+
### Structure Validation
|
|
212
|
+
- [ ] No empty values (except explicitly allowed)
|
|
213
|
+
- [ ] No inline comments (some parsers don't support)
|
|
214
|
+
- [ ] Proper quoting for values with spaces
|
|
215
|
+
- [ ] No duplicate keys
|
|
216
|
+
- [ ] Valid key naming (UPPERCASE_WITH_UNDERSCORES)
|
|
217
|
+
|
|
218
|
+
### Security Validation
|
|
219
|
+
- [ ] No exposed secrets in code
|
|
220
|
+
- [ ] .env files in .gitignore
|
|
221
|
+
- [ ] No secrets in git history
|
|
222
|
+
- [ ] API keys match expected format
|
|
223
|
+
- [ ] No hardcoded URLs with credentials
|
|
224
|
+
|
|
225
|
+
### Framework Validation (Next.js)
|
|
226
|
+
- [ ] NEXT_PUBLIC_* for client-side vars only
|
|
227
|
+
- [ ] No secrets in NEXT_PUBLIC_* vars
|
|
228
|
+
- [ ] .env.local exists for local secrets
|
|
229
|
+
- [ ] .env.example documents all vars
|
|
230
|
+
|
|
231
|
+
### Platform Validation (Vercel)
|
|
232
|
+
- [ ] All required vars defined
|
|
233
|
+
- [ ] No conflicts between environments
|
|
234
|
+
- [ ] Correct variable names (Vercel conventions)
|
|
235
|
+
- [ ] Build-time vs runtime vars separated
|
|
236
|
+
|
|
237
|
+
## Integration with Other Skills
|
|
238
|
+
|
|
239
|
+
### Related Skills
|
|
240
|
+
- **docker-containerization** - Environment variables in containers
|
|
241
|
+
- **security-scanning** - Broader security checks including secrets
|
|
242
|
+
- **nextjs-local-dev** - Next.js specific development patterns
|
|
243
|
+
- **systematic-debugging** - Debug env-related issues
|
|
244
|
+
|
|
245
|
+
### Workflow Integration
|
|
246
|
+
```
|
|
247
|
+
1. Developer creates .env.local
|
|
248
|
+
2. env-manager validates structure
|
|
249
|
+
3. env-manager scans for security issues
|
|
250
|
+
4. Developer generates .env.example
|
|
251
|
+
5. Before deploy: env-manager compares local vs platform
|
|
252
|
+
6. env-manager generates platform config
|
|
253
|
+
7. Developer reviews and confirms sync
|
|
254
|
+
8. env-manager syncs to platform
|
|
255
|
+
9. Deployment proceeds with verified configuration
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
**Lines**: 197 (including frontmatter) ✓ <200
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# Next.js Environment Variable Structure
|
|
2
|
+
|
|
3
|
+
Complete guide to Next.js environment variable management.
|
|
4
|
+
|
|
5
|
+
## File Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
my-nextjs-app/
|
|
9
|
+
├── .env # Shared defaults (committed)
|
|
10
|
+
├── .env.local # Local secrets (gitignored)
|
|
11
|
+
├── .env.development # Development defaults (committed)
|
|
12
|
+
├── .env.development.local # Local dev overrides (gitignored)
|
|
13
|
+
├── .env.production # Production defaults (committed)
|
|
14
|
+
├── .env.production.local # Production secrets (gitignored)
|
|
15
|
+
├── .env.test # Test environment (committed)
|
|
16
|
+
└── .env.example # Documentation (committed)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## File Precedence
|
|
20
|
+
|
|
21
|
+
Next.js loads files in this order (higher = higher precedence):
|
|
22
|
+
|
|
23
|
+
1. `.env.$(NODE_ENV).local` (e.g., `.env.production.local`)
|
|
24
|
+
2. `.env.local` (not loaded in test environment)
|
|
25
|
+
3. `.env.$(NODE_ENV)` (e.g., `.env.production`)
|
|
26
|
+
4. `.env`
|
|
27
|
+
|
|
28
|
+
**Example**: In production, if `DATABASE_URL` is defined in both `.env` and `.env.production.local`, the value from `.env.production.local` wins.
|
|
29
|
+
|
|
30
|
+
## Variable Types
|
|
31
|
+
|
|
32
|
+
### Client-Side Variables (NEXT_PUBLIC_*)
|
|
33
|
+
|
|
34
|
+
Exposed to the browser. Must prefix with `NEXT_PUBLIC_`.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# .env.local
|
|
38
|
+
NEXT_PUBLIC_API_URL=https://api.example.com
|
|
39
|
+
NEXT_PUBLIC_ANALYTICS_ID=UA-123456789
|
|
40
|
+
NEXT_PUBLIC_SITE_NAME=My Awesome Site
|
|
41
|
+
NEXT_PUBLIC_ENABLE_FEATURE_X=true
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Access in code**:
|
|
45
|
+
```javascript
|
|
46
|
+
// Works in both client and server
|
|
47
|
+
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
|
|
48
|
+
|
|
49
|
+
// Usage in components
|
|
50
|
+
export default function MyComponent() {
|
|
51
|
+
return <div>API: {process.env.NEXT_PUBLIC_API_URL}</div>;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**⚠️ Security Warning**: NEVER put secrets in `NEXT_PUBLIC_*` variables!
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# ❌ WRONG - Secret exposed to browser
|
|
59
|
+
NEXT_PUBLIC_API_SECRET=sk_live_abc123
|
|
60
|
+
|
|
61
|
+
# ✅ CORRECT - Secret only on server
|
|
62
|
+
API_SECRET=sk_live_abc123
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Server-Side Variables
|
|
66
|
+
|
|
67
|
+
Only available in server-side code (API routes, getServerSideProps, etc.).
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# .env.local
|
|
71
|
+
DATABASE_URL=postgres://localhost:5432/mydb
|
|
72
|
+
JWT_SECRET=super-secret-jwt-key-do-not-expose
|
|
73
|
+
STRIPE_SECRET_KEY=sk_live_abc123
|
|
74
|
+
SMTP_PASSWORD=email-password-here
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Access in code**:
|
|
78
|
+
```javascript
|
|
79
|
+
// ✅ Works in API routes
|
|
80
|
+
export default async function handler(req, res) {
|
|
81
|
+
const dbUrl = process.env.DATABASE_URL;
|
|
82
|
+
// Use dbUrl...
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ✅ Works in getServerSideProps
|
|
86
|
+
export async function getServerSideProps() {
|
|
87
|
+
const secret = process.env.JWT_SECRET;
|
|
88
|
+
// Use secret...
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ❌ Does NOT work in components (browser)
|
|
92
|
+
export default function MyComponent() {
|
|
93
|
+
const dbUrl = process.env.DATABASE_URL; // undefined!
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Example Files
|
|
98
|
+
|
|
99
|
+
### .env (Committed - Shared Defaults)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Shared defaults for all environments
|
|
103
|
+
NEXT_PUBLIC_APP_NAME=My Next.js App
|
|
104
|
+
NEXT_PUBLIC_DEFAULT_LOCALE=en
|
|
105
|
+
|
|
106
|
+
# Database (overridden in .env.local)
|
|
107
|
+
DATABASE_URL=postgres://localhost:5432/dev
|
|
108
|
+
|
|
109
|
+
# External services (no secrets)
|
|
110
|
+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_abc123
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### .env.local (Gitignored - Local Secrets)
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Local development secrets
|
|
117
|
+
DATABASE_URL=postgres://localhost:5432/mylocal
|
|
118
|
+
JWT_SECRET=dev-jwt-secret-change-in-production
|
|
119
|
+
STRIPE_SECRET_KEY=sk_test_local_key
|
|
120
|
+
|
|
121
|
+
# Local overrides
|
|
122
|
+
NEXT_PUBLIC_API_URL=http://localhost:4000/api
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### .env.production (Committed - Production Defaults)
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Production environment defaults
|
|
129
|
+
NEXT_PUBLIC_API_URL=https://api.production.com
|
|
130
|
+
NEXT_PUBLIC_ANALYTICS_ID=UA-PROD-123456
|
|
131
|
+
|
|
132
|
+
# These will be overridden by platform env vars
|
|
133
|
+
DATABASE_URL=set-this-in-vercel
|
|
134
|
+
JWT_SECRET=set-this-in-vercel
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### .env.example (Committed - Documentation)
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Copy this to .env.local and fill in actual values
|
|
141
|
+
|
|
142
|
+
# Client-side (browser accessible)
|
|
143
|
+
NEXT_PUBLIC_API_URL=https://api.example.com
|
|
144
|
+
NEXT_PUBLIC_ANALYTICS_ID=your-analytics-id
|
|
145
|
+
NEXT_PUBLIC_SITE_NAME=Your Site Name
|
|
146
|
+
|
|
147
|
+
# Server-side (secrets)
|
|
148
|
+
DATABASE_URL=postgres://user:password@host:5432/database # pragma: allowlist secret
|
|
149
|
+
JWT_SECRET=your-jwt-secret-32-chars-minimum
|
|
150
|
+
STRIPE_SECRET_KEY=sk_live_your_stripe_key
|
|
151
|
+
SMTP_HOST=smtp.example.com
|
|
152
|
+
SMTP_PORT=587
|
|
153
|
+
SMTP_USER=your-email@example.com
|
|
154
|
+
SMTP_PASSWORD=your-smtp-password
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Common Patterns
|
|
158
|
+
|
|
159
|
+
### Database Configuration
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Development (.env.local)
|
|
163
|
+
DATABASE_URL=postgres://localhost:5432/myapp_dev
|
|
164
|
+
|
|
165
|
+
# Production (Vercel Environment Variables)
|
|
166
|
+
DATABASE_URL=postgres://user:pass@prod-host:5432/myapp_prod # pragma: allowlist secret
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### API Keys
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Public keys (client-side)
|
|
173
|
+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_abc123
|
|
174
|
+
|
|
175
|
+
# Secret keys (server-side only)
|
|
176
|
+
STRIPE_SECRET_KEY=sk_live_xyz789
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Feature Flags
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Toggle features
|
|
183
|
+
NEXT_PUBLIC_ENABLE_DARK_MODE=true
|
|
184
|
+
NEXT_PUBLIC_ENABLE_BETA_FEATURES=false
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Deployment to Vercel
|
|
188
|
+
|
|
189
|
+
### Step 1: Add Environment Variables in Vercel
|
|
190
|
+
|
|
191
|
+
1. Go to Project Settings → Environment Variables
|
|
192
|
+
2. Add each variable:
|
|
193
|
+
- **Key**: `DATABASE_URL`
|
|
194
|
+
- **Value**: `postgres://...`
|
|
195
|
+
- **Environments**: Production, Preview, Development
|
|
196
|
+
|
|
197
|
+
### Step 2: Separate Client vs Server Variables
|
|
198
|
+
|
|
199
|
+
Vercel automatically exposes `NEXT_PUBLIC_*` variables at build time.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Vercel automatically handles:
|
|
203
|
+
NEXT_PUBLIC_API_URL=https://api.example.com # ✅ Exposed to browser
|
|
204
|
+
|
|
205
|
+
# Server-only:
|
|
206
|
+
DATABASE_URL=postgres://... # ✅ Not exposed to browser
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Step 3: Rebuild After Changing NEXT_PUBLIC_ Variables
|
|
210
|
+
|
|
211
|
+
⚠️ Important: `NEXT_PUBLIC_*` variables are **baked into the build** at build time.
|
|
212
|
+
|
|
213
|
+
If you change them in Vercel, you must **redeploy**:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
vercel --prod
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Validation Workflow
|
|
220
|
+
|
|
221
|
+
### 1. Validate Local Environment
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Check structure
|
|
225
|
+
python scripts/validate_env.py .env.local --framework nextjs
|
|
226
|
+
|
|
227
|
+
# Compare with .env.example
|
|
228
|
+
python scripts/validate_env.py .env.local --compare-with .env.example
|
|
229
|
+
|
|
230
|
+
# Check for security issues
|
|
231
|
+
python scripts/scan_exposed.py --check-gitignore
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 2. Check File Precedence
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# List all .env files
|
|
238
|
+
ls -la .env*
|
|
239
|
+
|
|
240
|
+
# Validate each
|
|
241
|
+
for file in .env*; do
|
|
242
|
+
echo "=== $file ==="
|
|
243
|
+
python scripts/validate_env.py $file --framework nextjs
|
|
244
|
+
done
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### 3. Sync to Vercel
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Compare local vs Vercel
|
|
251
|
+
python scripts/sync_secrets.py --platform vercel --compare
|
|
252
|
+
|
|
253
|
+
# Sync (dry-run first)
|
|
254
|
+
python scripts/sync_secrets.py --platform vercel --sync --dry-run
|
|
255
|
+
|
|
256
|
+
# Actually sync
|
|
257
|
+
python scripts/sync_secrets.py --platform vercel --sync --confirm
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Common Issues
|
|
261
|
+
|
|
262
|
+
### Issue: Variable Undefined in Browser
|
|
263
|
+
|
|
264
|
+
**Symptom**: `process.env.MY_VAR` is `undefined` in component.
|
|
265
|
+
|
|
266
|
+
**Solution**: Add `NEXT_PUBLIC_` prefix:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# ❌ Wrong
|
|
270
|
+
API_URL=https://api.example.com
|
|
271
|
+
|
|
272
|
+
# ✅ Correct
|
|
273
|
+
NEXT_PUBLIC_API_URL=https://api.example.com
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Issue: Changed Variable Not Reflected
|
|
277
|
+
|
|
278
|
+
**Symptom**: Changed `NEXT_PUBLIC_*` variable in Vercel, but app still uses old value.
|
|
279
|
+
|
|
280
|
+
**Solution**: Redeploy (variables are baked into build):
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
vercel --prod
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Issue: Works Locally, Not in Production
|
|
287
|
+
|
|
288
|
+
**Symptom**: App works with `.env.local`, fails in production.
|
|
289
|
+
|
|
290
|
+
**Solution**: Ensure all variables from `.env.local` are set in Vercel:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Compare
|
|
294
|
+
python scripts/sync_secrets.py --platform vercel --compare
|
|
295
|
+
|
|
296
|
+
# Find missing vars and add them in Vercel UI
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Security Checklist
|
|
300
|
+
|
|
301
|
+
- [ ] `.env.local` in `.gitignore`
|
|
302
|
+
- [ ] `.env.*.local` in `.gitignore`
|
|
303
|
+
- [ ] No secrets in `NEXT_PUBLIC_*` variables
|
|
304
|
+
- [ ] No `.env` files committed with real secrets
|
|
305
|
+
- [ ] `.env.example` has structure, not actual values
|
|
306
|
+
- [ ] Secrets set directly in Vercel (not in committed files)
|
|
307
|
+
|
|
308
|
+
## References
|
|
309
|
+
|
|
310
|
+
- [Next.js Environment Variables Documentation](https://nextjs.org/docs/basic-features/environment-variables)
|
|
311
|
+
- [Vercel Environment Variables](https://vercel.com/docs/environment-variables)
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
**Related**: [validation.md](../references/validation.md) | [security.md](../references/security.md) | [frameworks.md](../references/frameworks.md)
|