20 of the best prompts for using environment variables correctly, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for using environment variables correctly, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Getting Using Environment Variables Correctly right takes more than a single prompt. This 4-stage guide covers Diagnose the Wall, Isolate and Fix, Verify the Resolution, and more, breaking the whole process into focused steps where each prompt builds on the last. Claude Code sometimes hardcodes values or secrets directly into the code, which can lead to security vulnerabilities and maintenance issues. This can cause sensitive information to be exposed and make updates cumbersome. These prompts guide developers in ensuring values are read from environment variables, enhancing security and flexibility. Every prompt is optimized and runs in ChatGPT, Claude, and Gemini.
Check if Claude Code is hardcoding values instead of using environment variables.
Identify Hardcoded Values
Please review the recent changes made to the codebase and identify any hardcoded values or secrets that may pose a security risk. Provide a detailed list of these hardcoded values, including their locations within the code and any relevant context about their usage. Additionally, suggest best practices for handling these values securely, such as using environment variables or configuration files. Format your response in a clear, organized manner for easy reference.
Check CLAUDE.md Compliance
Please review the following CLAUDE.md file content: [PASTE CONTENT]. Analyze the rules outlined in the document and confirm your understanding of each one. Specifically, identify which rule pertains to the use of environment variables and explain how it applies in this context. Provide a summary of any compliance issues you find along with suggestions for improvement.
Locate Environment Variable Usage
Please scan the codebase and identify all instances where environment variables should be utilized but are currently not being used. For each instance, provide the corresponding file names and line numbers where these omissions occur. Additionally, explain the potential impact of not using environment variables in these cases, and suggest best practices for incorporating them effectively. Format the output as a detailed report that highlights the findings clearly.
Analyze Recent Commits
Please analyze the recent commits in the code repository. Identify any instances of hardcoded values that may have been introduced in the last few changes. For each hardcoded value, provide the specific line of code, the context in which it was added, and suggest alternatives or best practices for handling such values. Additionally, summarize the potential impact of these hardcoded values on the overall codebase and any related environment configurations.
Review Configuration Files
Please review the configuration files provided and identify any values that should be read from environment variables instead of being hardcoded. For each value, explain why it is important to use an environment variable in this context, and provide recommendations on how to implement this change. Additionally, create a summary of the potential risks associated with leaving these values hardcoded and how using environment variables can mitigate those risks.
Focus on replacing hardcoded values with environment variables.
Replace Hardcoded Secrets
Identify all hardcoded secrets in the provided code. For each secret, replace it with an appropriate environment variable, ensuring to follow best practices for security and maintainability. Document the exact changes made, including the original hardcoded value and the new environment variable name. Additionally, provide a brief explanation of how to set up these environment variables in the development and production environments.
Modify Configuration Files
Please modify the configuration files to ensure they read values from environment variables instead of using hardcoded values. Specify which environment variables should be used for each configuration setting. Provide the updated content for each configuration file, clearly indicating the changes made and the corresponding environment variable names. Ensure that the format remains consistent with the original files and include comments where necessary to explain the changes.
Refactor Code for Environment Variables
Refactor the following code to utilize environment variables for sensitive information and configuration settings. Ensure that all hardcoded values are replaced with appropriate environment variable calls. For each change made, provide a detailed explanation of why the modification is necessary, including the benefits of using environment variables for security and flexibility. The final output should be a well-commented version of the code that clearly indicates where and how environment variables are implemented.
Correct CLAUDE.md Instructions
Please revise the content of the CLAUDE.md file to provide clear and detailed instructions on how to properly use environment variables. Include specific examples of common environment variables that should be set, explain their purpose, and outline the steps for configuring them in different environments (e.g., local development, production). Ensure the instructions are easy to follow and formatted for clarity, with headings and bullet points where appropriate. Provide a complete draft of the updated document.
Ensure Secure Defaults
Review the code and identify any default values that need to be set securely. For each default value, ensure that it can be overridden by an environment variable. Provide a summary of the changes made, including specific examples of how the defaults were modified and the corresponding environment variable configurations. Additionally, explain the importance of securing these defaults and how it enhances the overall security of the application.
Confirm that the changes correctly use environment variables and no hardcoded values remain.
Run Environment Variable Tests
Please execute a series of tests to verify that all values are being correctly read from the environment variables in my application. Provide a detailed report of the test results, including any discrepancies found, the expected values versus the actual values, and any recommendations for resolving issues. Additionally, summarize the overall status of the environment variable configuration and highlight any critical errors that need immediate attention.
Review Code Changes
Please review the code changes made to replace hardcoded values in the project. Provide a detailed summary that includes the names of all files modified and the specific lines where changes occurred. Additionally, explain the reasoning behind each modification and how it improves the code's maintainability and flexibility. Format the response in a clear, structured manner, highlighting any potential impacts on the overall functionality of the application.
Simulate Production Environment
Simulate a production environment for the application where all necessary environment variables are properly set. Ensure that the application runs correctly and efficiently without relying on any hardcoded values. Provide a detailed report of any issues encountered during the simulation, including specific error messages and potential solutions. Additionally, outline the steps taken to verify that the application behaves as expected in this environment, and suggest any improvements that could enhance its performance or security.
Check for Remaining Hardcoded Values
Please re-scan the codebase for any remaining hardcoded values. Identify and list all instances where hardcoded values are found, specifying their locations within the code. Additionally, provide a summary of your findings, including the total number of hardcoded values detected and any recommendations for replacing them with environment variables or configuration settings. Format the summary in a clear and organized manner, highlighting any critical issues that need immediate attention.
Confirm CLAUDE.md Compliance
Please review the current implementation of the CLAUDE.md instructions related to environment variables. Assess whether all guidelines are being adhered to and identify any areas of non-compliance. Provide a detailed report that includes specific examples of compliance or deviations, along with recommendations for ensuring full adherence to the instructions. Format your findings in a clear, structured manner with sections for compliance status, examples, and recommendations.
Establish guardrails to ensure environment variables are used consistently.
Create CLAUDE.md Rule
Create a new rule for the CLAUDE.md file that mandates the use of environment variables for all sensitive data. The rule should clearly state that any sensitive information, such as API keys, database credentials, and personal information, must be stored in environment variables instead of hard-coded in the codebase. Include examples of how to properly reference these environment variables in code and explain the importance of this practice for security and maintainability. Format the rule in a clear and concise manner, suitable for inclusion in the documentation.
Add Code Comment Warnings
Please provide a code snippet that includes multiple functions utilizing environment variables. I want you to insert a comment above each function that warns against hardcoding values. The comment should clearly state the potential risks of hardcoding and encourage the use of environment variables instead. Format the output as a list of functions with the appropriate comments included, ensuring that the comments are concise yet informative.
Develop a Session Checklist
Create a comprehensive session checklist to ensure best practices are followed at the beginning of each session. The checklist should include steps such as verifying that all necessary environment variables are set correctly, confirming that no hardcoded values are present in the code, and ensuring that any sensitive information is securely managed. Additionally, include reminders to review the session's objectives and any dependencies that need to be addressed. Format the checklist in a clear, easy-to-follow list format with bullet points.
Establish Project Conventions
Create a comprehensive project convention document that details the guidelines for using environment variables in software development. Include sections that cover the purpose of environment variables, best practices for naming conventions, how to securely manage sensitive information, and examples of common use cases. Additionally, provide recommendations for how to document environment variables within the project and any tools or methods for testing their implementation. Format the document in a clear and organized manner, suitable for team reference.
Implement Automated Checks
Please help me design an automated check that scans for hardcoded values in a codebase. The check should analyze the code for any instances where sensitive information, such as API keys, passwords, or configuration settings, are directly embedded in the source code. Outline the steps involved in implementing this check, including the programming language or framework to be used, how the check will be triggered (e.g., during code commits or builds), and how the results will be reported to the development team. Additionally, suggest best practices for addressing any hardcoded values that are found.
Claude Code may hardcode values if the CLAUDE.md file lacks clear instructions on using environment variables. Ensure your CLAUDE.md file specifies this requirement to prevent such issues.
Use environment variables for all secrets and sensitive data. Update your CLAUDE.md file to enforce this practice and regularly scan your codebase for hardcoded values.
Review the CLAUDE.md file for clarity and completeness. If rules are ignored, explicitly instruct Claude Code to follow them by pasting the relevant section during your session.
Add a rule that mandates the use of environment variables for all configurable values. Provide examples and ensure the file is easily accessible to Claude Code.
Claude Code can be instructed to scan for hardcoded values if you set up automated checks or explicitly request it during a session. Ensure your CLAUDE.md file supports this process.
AI Prompts for Environment Variable Enforcement Check
Hardcoding values or secrets can lead to security vulnerabilities and unexpected behavior in your application.
See promptsAI Prompts for Prevent Hardcoding of Secrets
Hardcoding values or secrets can lead to security vulnerabilities and make your application less flexible.
See promptsAI Prompts for Ensuring CLAUDE.md Compliance
Claude Code fails to read or apply project rules from the CLAUDE.md file, leading to incorrect task execution.
See prompts