The single most common mistake in a student's first AI project is a hardcoded API key, committed to a public GitHub repo, found by an automated scanner within hours.
The fix, once, at the start
- All keys and secrets live in a .env file, never committed — add it to .gitignore before you write a single line that uses a key.
- Load secrets via a library (python-dotenv or your framework's built-in config) rather than reading files manually.
- In production, use the hosting platform's environment-variable settings, not a .env file shipped with the deployment.
- If a key does leak, rotate it immediately — assume it's compromised the moment it's public, don't wait to see if it's misused.
One habit that prevents most of this
Write the .gitignore entry before you create the .env file, in the same sitting, so there is never a window where the key exists unprotected in your working directory.
See secrets management for student projects for the deeper version of this.





