agentleFS
maleus-aimaleus-ai/claude-code-setup/.claude/skills/frontend-security/SKILL.md

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

  • Other versions5 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 5

    1. MiladJoodi/skills★ 24same name
    2. reddygopalkrishna/developer-agent-skills★ 8same name
    3. chadixearth/graphyloop★ 3same name
    4. Rootx202/appsec-skills★ 2same name
    5. 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.

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
  1. Very specific:

    NEVER use innerHTML with untrusted content: Use framework bindings instead.

    line 26
  2. Distinctive:

    Guards are client-side only: Always enforce permissions on the backend.

    line 40
  3. Distinctive:

    Use route guards to control access to pages:

    line 44
  4. Distinctive:

    Validate: all user input before use

    line 95
  5. Distinctive:

    Use strict typing for all API inputs/outputs

    line 97
  6. Distinctive:

    Use a logging service for error reporting (redact tokens, PII, and credentials)

    line 105

“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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 frontend

CRITICAL: 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.