Cursor + Claude: stop shipping broken env vars
The author describes a systematic approach to managing environment variables in Next.js applications to prevent deployment issues caused by missing or incorrect values. By using Zod for schema validation, generating .env.example files from code, and running validation at startup and in CI, they reduced debugging time and improved reliability. The solution was developed after repeated issues in production, preview, and CI environments despite using tools like Cursor and Claude.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3705649) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Sathish Posted on Apr 30 Cursor + Claude: stop shipping broken env vars #nextjs #typescript #webdev #tutorial I stopped guessing why builds break. I lint env vars. I generate .env.example from code. Not docs. I validate at runtime with Zod. One error message. I run a tiny Node script in CI. Fails fast. Context I ship small SaaS apps. Usually solo. Usually fast. And I kept losing time to env vars. The worst kind of bug. Works on my machine. Fails in CI. Or only fails after deploy.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).