AI Prompts for Security: Free AI Prompt | SheCodes

Free AI prompt · The Optimize Book

AI Prompts for Security

A ready-to-use prompt from the chapter Security Basics. Paste it into Claude, ChatGPT, Lovable, Bolt or any AI coding tool.

The prompt

“Add rate limiting to my API routes: max 10 requests per minute per IP. Use Upstash Rate Limit. Return a 429 status with a friendly error message when the limit is exceeded.”

How to use it

  1. Copy the prompt and paste it into your AI coding tool.
  2. Check the result in the preview, then ask for changes one at a time: "make the buttons bigger", "use my brand colours".
  3. Read the chapter to understand why it works and what to do next.

More prompts like this

All prompts

AI Prompts for Security

“Add security headers to my Next.js app: Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, and Referrer-Policy. Configure them in next.config.js.”

AI Prompts for Security

“Audit my app for XSS vulnerabilities. Check all places where user input is rendered and make sure nothing uses dangerouslySetInnerHTML with unsanitized data. Add input validation to all forms.”

AI Prompts for Security

“Add CSRF protection to my form submissions. Generate a CSRF token on the server, include it as a hidden field in forms, and validate it on submission.”

AI Prompts for Security

“Set up environment variables properly. Move all API keys and secrets to .env.local, make sure nothing sensitive has the NEXT_PUBLIC_ prefix, and add .env.local to .gitignore.”

Pre-deploy checklist

“Review my project and tell me if it's ready to go live. Check for: any leftover test URLs that point to my computer instead of the real site, any missing API keys or settings, any large unoptimized images, any debug messages left behind, any missing error pages, and any missing SEO tags. List everything I need to fix before I publish.”

Improve my ai prompts

“I want to improve how I prompt AI coding tools. Review my project and suggest 5 specific things I could have described better in my prompts to get better results. Focus on: layout specifics, color choices, component behavior, responsive design, and edge cases.”