AGENTS.md
AGENTS.mdAGENTS.mdroot
Quality
63/100
Scores the file, not the repository.Length
677 words
13 headings · 0 code blocksRepository
91
— · pushed 25 days agoLast changed
2 days ago
First indexed 2 days ago.1# Security Rules23These rules apply to all code generated in this project. They are non-negotiable.45## Secrets67- NEVER put API keys, database credentials, or tokens in frontend code (anything under src/, app/, pages/, components/, public/)8- NEVER put secret keys in environment variables prefixed with NEXT_PUBLIC_, VITE_, or REACT_APP_ (these are bundled into the client)9- NEVER hardcode credentials in source files. Use environment variables loaded server-side only10- The .env file MUST be in .gitignore before the first commit. Verify this before creating any .env file11- Use .env.example with placeholder values only, never real credentials1213## Database1415- Enable Row Level Security on EVERY Supabase table before deployment. Default policy: deny all. Write explicit policies scoped to auth.uid()16- NEVER set a Supabase RLS policy to `USING (true)` or `FOR ALL` without a WHERE condition17- Firebase Security Rules MUST require `request.auth != null` and scope access to `request.auth.uid`18- NEVER use `pickle.loads`, `pickle.load`, or any deserialization on user-supplied data. Use JSON for all network data exchange1920## Authentication and Authorization2122- EVERY API route that returns or modifies user data MUST have authentication middleware that runs BEFORE the handler, not inside it23- Unauthenticated requests to protected endpoints MUST return 40124- EVERY route that takes a resource ID MUST verify the authenticated user owns that resource: `current_user.id == resource.owner_id`. This is a SEPARATE check from authentication25- Admin endpoints MUST verify admin role and return 403 for non-admin users26- Session cookies MUST set `httpOnly: true`, `secure: true`, and `sameSite: 'lax'`2728## Input and Output2930- NEVER concatenate user input into SQL queries. ALWAYS use parameterized queries or ORM methods31- NEVER use `dangerouslySetInnerHTML`, `v-html`, or `innerHTML` with user-supplied content unless it is first sanitized with DOMPurify32- ALL user input MUST be validated server-side. Client-side validation is for UX only33- File uploads MUST validate file type by reading magic bytes, not by checking the filename extension. Rename all uploads to UUIDs server-side. Store on a separate domain (S3, R2, GCS), never on the app origin3435## URL Fetching (SSRF Prevention)3637- If the application fetches URLs provided by users (link previews, image proxies, URL validators), it MUST:38 - Block all private/internal IP ranges: 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, ::139 - Allow only http and https schemes40 - Resolve the hostname and check the IP BEFORE making the request4142## Security Headers4344- Set these headers on ALL responses via a single global middleware:45 - `Content-Security-Policy: default-src 'self'` (adjust as needed for your app)46 - `Strict-Transport-Security: max-age=31536000; includeSubDomains`47 - `X-Frame-Options: DENY`48 - `X-Content-Type-Options: nosniff`49 - `Referrer-Policy: strict-origin-when-cross-origin`50- In Express, use the `helmet` package. In Next.js, set headers in next.config.js5152## CORS5354- NEVER set CORS origin to `*` (wildcard). Use an explicit allowlist of your actual domains55- NEVER combine `origin: '*'` with `credentials: true`5657## Rate Limiting5859- Login, registration, and password reset endpoints MUST have rate limiting (block after N failed attempts per IP within a time window)60- Do NOT trust X-Forwarded-For for rate limiting unless behind a trusted reverse proxy6162## Payments6364- Stripe webhook endpoints MUST verify the signature using `stripe.Webhook.construct_event` (or equivalent) on every request. Reject any request with an invalid or missing signature65- Webhook handlers MUST track processed event IDs and skip duplicates (idempotency)66- Handle the full event lifecycle: payment_intent.succeeded, invoice.payment_failed, customer.subscription.deleted, customer.subscription.past_due6768## Error Handling6970- NEVER expose stack traces, SQL errors, file paths, or library names in API responses71- Production error responses MUST return only generic messages: `{"error": "Something went wrong"}`72- Full error details go to server-side logs only73- Debug mode / development error pages MUST be disabled in production7475## Password Hashing7677- ALWAYS use bcrypt, Argon2, or scrypt for password hashing78- NEVER use MD5, SHA-1, or plain SHA-256 for passwords7980## Dependencies8182- Before installing any package, verify it exists on the official registry with a reasonable download count and history83- Pin exact versions in package.json / requirements.txt (no ^ or ~ in production)84- Commit lock files (package-lock.json, poetry.lock, yarn.lock)85
