frontend-security
Skill1 starsChanged 10 months agoMITView on GitHub
Security guidelines for frontend code. Covers token storage, XSS prevention, authorization, and secure coding practices. CRITICAL INSTRUCTION You MUST ALWAYS use this skill before editing/writing any file matching "**/frontend/**/*.{ts,tsx}".
5 other projects use a version of this.
Adopted by
Most recently taken up by
- reddygopalkrishna/developer-agent-skillstheir own version, first seen Nov 8, 2026
- chadixearth/graphylooptheir own version, first seen Oct 13, 2026
- MiladJoodi/skillstheir own version, first seen Oct 11, 2026
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
- Rootx202/appsec-skillstheir own version, first seen Jul 13, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- MiladJoodi/skills★ 24same name
- reddygopalkrishna/developer-agent-skills★ 8same name
- chadixearth/graphyloop★ 3same name
- Rootx202/appsec-skills★ 2same name
- ZeroTokenClaw/agents-skills★ 1same name
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.
In this repository3 other files it gives its agents.
- frontend-securityCursor rule
- typescriptCursor rule
- typescriptSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
NEVER use
innerHTMLwith untrusted content: Use framework bindings instead. - Distinctive: line 40
Guards are client-side only: Always enforce permissions on the backend.
- Distinctive: line 44
Use route guards to control access to pages:
- Distinctive: line 95
Validate: all user input before use
- Distinctive: line 97
Use strict typing for all API inputs/outputs
- Distinctive: line 105
Use a logging service for error reporting (redact tokens, PII, and credentials)
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend Security Rules
CRITICAL: Token Storage
NEVER store tokens in localStorage or memory. Tokens are managed via HTTP-only cookies and sent automatically by the browser.
// ❌ FORBIDDEN
localStorage.setItem("token", jwt);
sessionStorage.setItem("token", jwt);
const token = "Bearer " + jwt;
// ✅ CORRECT: Cookies handle token transport automatically
// No token management code needed in frontendCRITICAL: XSS Prevention
NEVER use innerHTML with untrusted content. Use framework bindings instead.
// ❌ FORBIDDEN
element.innerHTML = userInput;
this.renderer.setProperty(el, "innerHTML", data);
// ✅ CORRECT: Angular/React sanitizes automatically
<div>{userInput}</div>
<div [textContent]="userInput"></div>Authorization
Guards are client-side only. Always enforce permissions on the backend.
Route Guards
Use route guards to control access to pages:
// ✅ Admin-only route
{
path: 'admin',
canActivate: [authenticatedGuard, roleGuard],
data: { roles: ['admin'] }
}
// ✅ Multiple roles
{
path: 'profile',
canActivate: [authenticatedGuard, roleGuard],
data: { roles: ['admin', 'user'] }
}
// ✅ Public routes: no guards
{ path: 'login', component: LoginComponent }UI Role-Based Visibility
Hide unauthorized elements - never disable them. Users should not see actions they cannot perform.
// ✅ CORRECT: Hide unauthorized actions
<button *ngIf="isAdmin()" (click)="deleteUser()">
Delete User
</button>
// ❌ WRONG: Showing disabled button
<button [disabled]="!isAdmin()">Delete</button>External Links
ALWAYS use rel="noopener noreferrer" with target="_blank".
<!-- ❌ WRONG -->
<a href="https://external.com" target="_blank">Link</a>
<!-- ✅ CORRECT -->
<a href="https://external.com" target="_blank" rel="noopener noreferrer"
>Link</a
>Input Validation
- Validate all user input before use
- Sanitize HTML content from untrusted sources
- Use strict typing for all API inputs/outputs
- Mask sensitive data before logging
Error Handling
- Distinguish technical vs business errors
- NEVER expose raw HTTP errors or stack traces to the UI
- Show minimal, user-friendly error messages
- Use a logging service for error reporting (redact tokens, PII, and credentials)
Remember: UI security is for UX only. Backend must always enforce all security rules.
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.

