agent-skills / accelint-security-best-practices
AGENTS.md25 starsChanged 54 days agoApache-2.0View on GitHub
Comprehensive security guide for JavaScript and TypeScript applications following OWASP Top 10, designed for AI agents and LLMs. Each rule includes one-line summaries here, with links to detailed examples in the references/ folder. Load reference files only when you need detailed implementation guidance for a specific rule. This structure minimizes context usage while providing complete security guidance when needed. NEVER do these - they appear in codebases frequently but create severe vulnerabilities: See individual reference files for detailed alternatives and…
We split this AGENTS.md into the rules it gives an agent
12 rules. About 3 are common, 6 are distinctive, and 3 are very specific to this project.
≈3
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
NEVER: do these - they appear in codebases frequently but create severe vulnerabilities:
- Common: line 31
NEVER: use default configurations in production - default secrets, disabled security headers, permissive CORS create known vulnerabilities
- Distinctive: line 32
NEVER: use Array.includes() for permission checks - O(n) lookup and type safety issues.
- Common: line 48
Never hardcode secrets; use environment variables.
- Very specific: line 66
Use parameterized queries for SQL.
- Distinctive: line 84
Check ownership/permissions before every operation.
- Distinctive: line 98
Use CSRF tokens on state-changing operations.
- Common: line 112
Never log passwords, tokens, credit cards, or PII.
- Very specific: line 119
Run npm audit regularly; update dependencies with npm update.
- Very specific: line 126
Use helmet.js for security headers.
- Distinctive: line 165
Fail securely: - When validation fails, deny access.
- Distinctive: line 167
Security testing: - Test with malicious inputs and edge cases.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Security Best Practices
Abstract
Comprehensive security guide for JavaScript and TypeScript applications following OWASP Top 10, designed for AI agents and LLMs. Each rule includes one-line summaries here, with links to detailed examples in the references/ folder. Load reference files only when you need detailed implementation guidance for a specific rule.
How to Use This Guide
- Start here: Scan the rule summaries to identify relevant security patterns
- Load references as needed: Click through to detailed examples only when implementing
- Progressive loading: Each reference file is self-contained with ❌/✅ examples
This structure minimizes context usage while providing complete security guidance when needed.
Critical Security Anti-Patterns
NEVER do these - they appear in codebases frequently but create severe vulnerabilities:
- NEVER hardcode secrets - API keys, passwords, tokens in source code are immediately compromised via version control; use environment variables exclusively
- NEVER concatenate user input into queries - creates SQL/NoSQL injection; use parameterized queries and ORMs (10-1000x safer)
- NEVER store tokens in localStorage - vulnerable to XSS attacks; use httpOnly cookies for authentication tokens
- NEVER skip authorization checks - authentication verifies identity, authorization verifies permission; check both on every protected operation
- NEVER trust user input - all input from users, APIs, files is potentially malicious; validate type, format, size with schemas (Zod, Joi)
- NEVER expose detailed errors to users - stack traces and database errors leak architecture; log server-side, return generic messages
- NEVER skip rate limiting - enables brute force (1000 password attempts/sec), DoS, data scraping; apply to all endpoints
- NEVER log sensitive data - passwords, tokens, PII in logs persist in aggregation systems accessible to many; redact before logging
- NEVER use default configurations in production - default secrets, disabled security headers, permissive CORS create known vulnerabilities
- NEVER use Array.includes() for permission checks - O(n) lookup and type safety issues; use Set.has() (O(1)) or proper RBAC
See individual reference files for detailed alternatives and ✅ correct patterns.
Security Categories (OWASP Top 10)
Before implementing security: Identify attack surface and worst-case scenarios. Layer defenses so single vulnerability doesn't compromise entire system.
Defense in depth: authentication + authorization + input validation + rate limiting + logging
1. Secrets Management (OWASP A02)
Never hardcode secrets; use environment variables; validate secrets exist at startup; rotate secrets regularly; use secret management services. View detailed examples
2. Input Validation (OWASP A04)
Validate all user input with schemas (Zod, Joi); whitelist validation (not blacklist); check type, format, size, content; sanitize before processing. View detailed examples
2.1 File Upload Validation
Validate file size, type (MIME type), extension; store outside webroot; use CDN/object storage; scan for malware; generate unique filenames. View detailed examples
3. Injection Prevention (OWASP A03)
Use parameterized queries for SQL; type-check NoSQL inputs; use execFile (not exec) for commands; validate and sanitize all dynamic content.
View detailed examples
4. Authentication (OWASP A07)
Store tokens in httpOnly cookies (not localStorage); use bcrypt with cost ≥12 for passwords; implement secure session management; short-lived access tokens with refresh tokens. View detailed examples
4.1 Multi-Factor Authentication
Implement TOTP (time-based one-time passwords); verify MFA on sensitive operations; provide backup codes; secure QR code generation. View detailed examples
5. Authorization (OWASP A01)
Check ownership/permissions before every operation; implement RBAC (role-based access control); prevent IDOR (insecure direct object reference); use UUIDs instead of sequential IDs. View detailed examples
6. XSS Prevention (OWASP A03)
React auto-escapes by default (safe); sanitize HTML with DOMPurify if using dangerouslySetInnerHTML; implement Content Security Policy (CSP); avoid inline scripts.
View detailed examples
7. CSRF Protection (OWASP A08)
Use CSRF tokens on state-changing operations; set SameSite=Strict on cookies; implement double-submit cookie pattern; verify origin headers. View detailed examples
8. Rate Limiting (OWASP A04)
Apply rate limits to all API endpoints; stricter limits on authentication (5/hour) and expensive operations (10/min); IP-based and user-based limiting; return 429 status code. View detailed examples
9. Sensitive Data Protection (OWASP A09)
Never log passwords, tokens, credit cards, or PII; redact sensitive fields before logging; return generic error messages to users; log detailed errors server-side only. View detailed examples
10. Dependency Security (OWASP A06)
Run npm audit regularly; update dependencies with npm update; use exact versions or controlled ranges; enable Dependabot; monitor for CVEs; use npm ci in CI/CD.
View detailed examples
11. Security Headers (OWASP A05)
Use helmet.js for security headers; implement CSP (Content Security Policy); enable HSTS (HTTP Strict Transport Security); set X-Frame-Options, X-Content-Type-Options; disable X-Powered-By. View detailed examples
12. SSRF Prevention (OWASP A10)
Validate URLs against allowlist; block private IPs (localhost, 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16); prevent redirect chains; use URL parsing to extract hostname. View detailed examples
Quick Reference for Vulnerability Mapping
For systematic vulnerability identification and categorization, load references/quick-reference.md which provides:
- Vulnerability symptom → OWASP category mapping
- Code pattern → Security risk lookup
- Anti-pattern detection with concrete code examples
- Decision matrix for severity assessment
Severity Impact Summary
| Severity | Impact | When to Fix | Examples |
| Critical | Data breach, RCE, complete compromise | Immediately (emergency deploy) | SQL injection, hardcoded production secrets, no auth on admin endpoints |
| High | Unauthorized access, data theft, service disruption | Next release (days) | Missing authorization, XSS, insecure session management |
| Medium | Exploitable with conditions or when chained | Scheduled release | Missing rate limiting, weak CORS, insufficient logging |
| Low | Defense-in-depth, best practices | When convenient | Missing security headers, detailed error messages |
Priority order: Fix Critical vulnerabilities first (emergency), then High (planned), then Medium/Low (scheduled).
Important Notes
- Audit everything philosophy - Audit ALL code for security vulnerabilities. Internal utilities and helpers are frequently exposed through APIs or user interactions.
- Defense in depth - Layer security controls so single vulnerability doesn't compromise entire system. Never rely on single protection.
- Fail securely - When validation fails, deny access. Default to most secure option when uncertain.
- Principle of least privilege - Grant minimum permissions necessary. Verify every operation.
- Security testing - Test with malicious inputs and edge cases. Add tests for attack scenarios.
- Incident response - Log security events with sufficient detail for investigation and response.
Other versions1 project uses a version of this.
Word for word · 1
- davidanthonyn/claude-skills★ 0100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/accelint-design-foundation/AGENTS.mdAGENTS.md
- skills/accelint-eval-architect/AGENTS.mdAGENTS.md
- skills/accelint-nextjs-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-prompt-manager/AGENTS.mdAGENTS.md
- skills/accelint-react-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-react-testing/AGENTS.mdAGENTS.md
- skills/accelint-readme-writer/AGENTS.mdAGENTS.md
- skills/accelint-skill-manager/AGENTS.mdAGENTS.md
- skills/accelint-skill-manager/references/agents.mdAGENTS.md
- skills/accelint-ts-best-practices/AGENTS.mdAGENTS.md
- skills/accelint-ts-documentation/AGENTS.mdAGENTS.md
- skills/accelint-ts-performance/AGENTS.mdAGENTS.md
- skills/accelint-ts-testing/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- accelint-ac-to-playwrightSkill
- accelint-architecture-docSkill
- accelint-archive-synthesisSkill
- accelint-design-foundationSkill
- accelint-english-managerSkill
- accelint-eval-architectSkill
- accelint-nextjs-best-practicesSkill
- accelint-onboard-agentsSkill
- accelint-onboard-openspecSkill
- accelint-persona-reviewSkill
- accelint-prompt-managerSkill
- accelint-qrspi-applySkill
- accelint-qrspi-archiveSkill
- accelint-qrspi-proposeSkill
- accelint-react-best-practicesSkill
- accelint-react-testingSkill
- accelint-readme-writerSkill
- accelint-security-best-practicesSkill
- referencesSkill
- accelint-skill-managerSkill
- accelint-skill-proseSkill
- accelint-tanstack-query-best-practicesSkill
- accelint-ts-audit-allSkill
- accelint-ts-best-practicesSkill
- accelint-ts-documentationSkill
- accelint-ts-performanceSkill
- accelint-ts-testingSkill
- constraints-extractorSkill
- context-driftSkill
- epistemic-mapperSkill
- generate-docsSkill
- jargon-extractorSkill
- pr-descriptionSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

