AI Prompts for Security
“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.”
Free AI prompt · The Optimize Book
A ready-to-use prompt from the chapter Security Basics. Paste it into Claude, ChatGPT, Lovable, Bolt or any AI coding tool.
“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.”
“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.”
“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.”
“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.”
“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.”
“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.”
“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.”