Build safely: secrets, data and honest AI use
The habits that keep your users, your accounts and your reputation safe when you build with AI.
Secrets stay secret
A secret is anything that grants access: passwords, API keys, database service keys, payment keys. If a secret is in your front-end code, anyone can open the browser's developer tools and copy it. Researchers have found exactly this in many vibe-coded apps, including AI and payment keys sitting in plain sight.
- Keep secrets in environment variables on the server or host, in a .env file locally, and list .env in .gitignore.
- Call paid APIs (AI, payments, email) from server code or an edge function, never straight from the browser.
- If a secret leaks (pushed to GitHub, pasted in a chat), rotate it: create a new one and revoke the old one. Deleting the commit isn't enough.
- Turn on two-factor authentication for GitHub, your host, your database and your email.
Lock the data by default
Assume anyone can call your API directly. The database or server must decide who sees what: row level security on every table, deny by default, smallest possible policies. Test it by trying to read another user's data while signed in as someone else.
Collect only the data you need, and be extra careful with children's and students' data, health information and anything financial.
Check what AI writes
- Ask the AI to review its own code for security issues, then ask a second tool too.
- Read every change that touches sign-in, payments, permissions or deleting data.
- Don't install packages you can't find on the official registry, and check they're real and maintained. AI can invent package names.
- Back up your database before big changes; keep code in Git.
Honest and fair AI use
Follow your school's or employer's AI rules and say when AI helped. Don't pass off AI writing or art as entirely yours where that matters.
Respect copyright: don't ask AI to reproduce other people's books, songs, logos or characters, and check you have rights to images you use.
AI can reflect bias in its training data. Look at who an AI-powered feature might treat unfairly, and test with a range of people.
Make it accessible: real text on buttons and images, good colour contrast, keyboard navigation. AI tools can check this if you ask.
Key terms
- Secret
- Anything that grants access: passwords, API keys, service keys.
- API key
- A secret code that identifies your app to a service and is often tied to billing.
- .env file
- A local file holding environment variables and secrets; never committed to Git.
- .gitignore
- A list of files Git must never save, such as .env secrets.
- Rotate (a key)
- Replace a secret with a new one and revoke the old one.
- Two-factor authentication (2FA)
- A second check at sign-in, like a code from an app, on top of your password.
- Row level security (RLS)
- Database rules that decide which rows each user may read or change.
- Least privilege
- Give each person, app or AI only the access its job needs.
- Supply-chain risk
- Danger from the packages and tools your project depends on, including fake look-alike packages.
- Accessibility (a11y)
- Making apps usable by everyone, including people using screen readers or keyboards.
- Bias (in AI)
- Unfair patterns an AI picks up from its training data.
Try it
Run a 10-minute safety check
- In your project, search the code for 'key', 'secret' and 'password'. Anything that looks real?
- Confirm .env is listed in .gitignore.
- Ask your AI tool: 'Review this project for exposed secrets, missing access checks and unsafe database rules. List findings by severity.'
- Fix the top finding and turn on two-factor for your GitHub account.
Ask an AI tutor about this guide
Copy a prompt into ChatGPT, Claude or Gemini to go deeper. Check what it tells you against the guide.
- Explain it like I'm 12
- Quiz me (5 questions, one at a time)
- Show me a real example for my situation
- What do beginners get wrong?
Knowledge check
Five questions. Get 4 right to earn the Safe Builder badge. You can retake it as often as you like.
Question 1 of 5
Finished the Build safely guides? Take the Build safely track test for ten mixed questions.
My notes
Write what clicked, what confused you, and what you want to try. Saved in this browser only.
Learn it live
Digital Builders University runs small live workshops where you build something real with an instructor beside you, starting with Vibe Coding 101.
See workshopsPractise it
- Build Challenge: Club sign-up list with admin view (Builder, 2 to 3 hours)
- Build Challenge: Inbox triage automation (Builder, 2 hours)
- Build Challenge: AI FAQ helper on a website (Pro, 4 hours)
- Template: AI build safety review
- Game: Error Detective (read real error messages and pick the fix)
- Cheat sheet: Build safely checklist
- Game: Bug Hunt (read short code snippets and find the bug)
- Game: Prompt Fixer (pick the prompt that gets the best result)
Official sites
- OWASP Top 10 (opens in a new tab)
- GitHub Docs: Secret scanning (opens in a new tab)
- W3C: Introduction to web accessibility (opens in a new tab)
Last reviewed November 25, 2026. AI tools change fast; check each tool’s own site for current features, plans and prices.
