Websites, apps & code / Coding & debugging
Keeping keys and passwords safe
Your code needs an API key and you fear leaking it.
1Fill in your details
Leave blank to use the example. Names are remembered for other prompts too (stored only on your device).
3Copy the prompt
Teach me to keep passwords and API keys in the right place. Project: A web page using a weather service API key. Public or not: It will be put on GitHub Requirements: - start with a checklist to follow before writing code - teach .env and .gitignore step by step, with examples I can copy (using fake keys) - explain what to do right away if a key leaks - remind me never to paste real keys to an AI or a chat group - fit where I work - Teach me .env and .gitignore. - Use only the details I give you. Do not invent anything. If something is missing, leave it as [ ] or ask me. Output format: A checklist, steps and a leak response. [Make it sound human] - Explain in plain words; no pleasantry openers or empty summaries. - Only necessary, short, practical code comments; the simplest working approach, no over-engineering. - Interface text (buttons, hints, error messages) should sound like a person wrote it; no "seamless", "empower", "unlock". [Quality] Code must run as is and handle common errors; tell me how to test it and confirm it works; ask first if a requirement is unclear; never put passwords or API keys in the code.
Paste it into ChatGPT, Gemini, Claude or Meta AI.
Test result
What we noticed
It gave the checklist, .env and .gitignore steps, and stressed that keys in web page code are visible, so use a backend or keyless service. Leak handling puts replacing the key first.
See what the AI actually wrote
Checklist: do these before you write any code
- [ ] 1. Make a new folder and create .gitignore first.
- [ ] 2. Put .env in .gitignore and save.
- [ ] 3. Create .env and put the real key in it.
- [ ] 4. The code reads the key from an environment variable; no key is written in code.
- [ ] 5. Before uploading to GitHub, run git status and confirm .env is not in the list.
- [ ] 6. Prepare a .env.example with fake values so others know what to fill in.
Only after these six, write code.
Important: anything inside a web page (HTML plus JavaScript) is visible to the browser. Even if the key sits in .env, if the page reads it directly, it ends up in the browser, and anyone can right-click, View source. So for a weather service there are two ways:
- Use a weather service that needs no key (simplest).
- Use a small backend or function you control (Vercel function, Cloudflare Workers): the page calls it, it uses the key to call the weather service, and the key lives only in that service's environment variables.
Step by step (Node backend as an example; fake key):
- Create .gitignore (do this first):
.env
node_modules/ - Create .env:
WEATHER_API_KEY=fake-key-do-not-use-123 - Create .env.example (safe to upload to GitHub):
WEATHER_API_KEY=put your key here - In code: const key = process.env.WEATHER_API_KEY;
- Check before uploading: run git status. .env should not appear. If it does, do not commit; recheck .gitignore.
- If .env was committed before: remove it from tracking (git rm --cached .env), then commit. Also treat the key as leaked and replace it.
If it leaks, do this right away:
- Go to the weather service's site and delete that key or generate a new one (the old one stops working). This is the most important step, more than deleting the file on GitHub.
- Check the service's usage log for anything you do not recognise.
- Put the new key in .env and never commit it.
- If it was already pushed to GitHub: deleting the file does not delete history; old versions still hold it. So step 1 is a must.
- If the key is used elsewhere, replace it there as well.
Reminder: never paste a real key to an AI, a chat group, a screenshot or a forum. When asking anyone to review code, replace keys with fake ones.
I was given no real key; the fake-key above is only a demo.
AI tools that suit this
- ChatGPT Suggested tool Free plan
The most widely used AI chat, for writing, questions and images
- Claude Suggested tool Free plan
Strong at long documents, editing and code
- Claude Code Suggested tool Free plan
AI that writes code directly on your computer
Recommendations only, not sponsored. Check each site for what the free plan includes.
This site is made by FullMark Tech
Want your own website, or your shop spreadsheets automated? FullMark Tech builds business websites and custom Excel tools.