/bulletproof-react-skills:securityfrom bulletproof-react-skills
Security conventions from bulletproof-react: token storage and authentication for SPAs, authorization patterns, and other client-side hardening practices. Use when implementing auth, authorization checks, or handling sensitive data in a React app. Reach for this whenever a task involves deciding where to store a JWT after login, wiring up route/component guards so only certain roles can see a feature, restricting an action (like deleting a comment) to its owner, or reviewing a PR that touches authentication/authorization code — for example "where should I store the auth token", "how do I hide this button from non-admins", "only the comment author should be able to delete it", or "is this login flow XSS-safe".
Ships in bulletproof-react-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Adapted from bulletproof-react @
9506629, MIT licensed. See ../../NOTICE.md for provenance and the re-pin workflow.
Client-side authentication improves UX, but it is not a substitute for server-side enforcement — always assume the server independently protects its resources, and treat anything you do here as a complement to that, not a replacement.
Protecting resources comprises two key components:
Authentication verifies who the user is. In single-page applications (SPAs), authenticate users with a JSON Web Token (JWT): issue it on login/registration, store it in the app, and send it with every authenticated request (header or cookie) so the server can validate identity and permissions.
Prefer storing the token in application state — that's the most secure option. But know the tradeoff: a page refresh resets that state, which drops the user's authentication status.
That's why you'll typically still need to persist the token in a cookie or localStorage/sessionStorage.
localStorage vs cookie for storing tokensAvoid localStorage for tokens when you can: it's readable by any script on the page, so a Cross-Site Scripting (XSS) vulnerability elsewhere in the app can be used to steal the token directly.
Prefer a cookie configured with HttpOnly instead — client-side JavaScript can't read it at all, which closes off that theft vector. In the sample app, js-cookie is used for cookie management, on the assumption that the real API enforces HttpOnly so the client never actually has cookie access.
Storing the token safely isn't sufficient on its own — also sanitize every user input before rendering it, since that's what keeps XSS vulnerabilities from being introduced in the first place, token storage aside.
HTML Sanitization Example Code
For a full list of security risks, check OWASP.
Treat user info as global state, available from anywhere in the app. If the project already uses react-query, use react-query-auth — it handles the user-state wiring once you give it configuration. Otherwise, fall back to React context + hooks or a third-party state management library.
Auth Configuration Example Code
Treat the presence of a user object as the signal that the user is authenticated.
Authorization verifies whether the authenticated user has permission to access a specific resource in the app.
Authorization Configuration Example Code
Use role-based authorization when access maps cleanly onto a small set of roles: define roles (e.g. USER, ADMIN) and associate each with its permissions, then gate functionality by the user's role — for instance, restrict certain features to regular users while letting admins reach everything.
Reach for PBAC instead of RBAC when access needs to be more granular than a role can express — for example, when only the owner of a specific resource should be allowed to act on it. For a user's comment, PBAC lets you restrict deletion to the comment's author specifically, rather than to a whole role.
Use the RBAC component (passing it the allowed roles) when role-based protection is enough. When you need stricter, per-resource protection, pass it a policy check instead.
What SKILL.md sets; muted values are Claude Code's defaults
7 skills in this plugin
/components-and-stylingComponent and styling conventions from bulletproof-react: colocation,
avoiding nested render functions, container/presentation separation, and
composition-over-config for component APIs. Covers when to reach for a
fully-styled vs. headless component library, which styling solution fits
a given setup (including React Server Components constraints), and using
Storybook for isolated component development. Use this when designing a
new component's API, reviewing a component for prop bloat or nested
render functions, choosing a component library or styling approach for a
project, or when a request looks like "this component is taking too many
props, how should I split it up," "what component library should I use
for this dashboard," or "where should I put this piece of state/style so
it doesn't cause unnecessary re-renders."
/performancePerformance conventions from bulletproof-react: code splitting,
component/state update optimization, list virtualization, image
optimization, and bundle analysis. Use when a React app feels slow or before
shipping a feature that renders large lists or heavy assets. Reach for this
whenever you're about to add a route, decide where a piece of state should
live, render a list of unknown or large size, or add images — and whenever
a request mentions phrasing like "this page feels slow", "why is this
component re-rendering so much", or "how should I load these images".
/project-standardsProject standards from bulletproof-react: ESLint/Prettier/TypeScript config,
absolute imports, pre-commit hooks, and CI conventions. Use when setting up
tooling for a React project or reviewing its lint/format/type configuration.
Reach for this whenever asked to "set up linting for a new React project,"
"configure absolute imports so I stop seeing ../../../," "add a pre-commit
hook to run lint and type-check," or "review this project's ESLint/Prettier/
tsconfig setup" — or when enforcing consistent file/folder naming conventions
across a codebase.
/project-structureProject structure conventions from bulletproof-react: what lives in src/,
the app/assets/components/features/hooks/lib/stores/testing/types/utils
layout, and how features are organized to stay unidirectional. Use when
scaffolding a new React project, deciding where a new file belongs, reviewing
a PR that imports across feature boundaries, or setting up ESLint import
restrictions — for example "where should this component/hook/API call live",
"should this be shared or feature-scoped", or "is this cross-feature import
okay".
/state-and-dataState management and data-fetching conventions from bulletproof-react:
component vs. application vs. server vs. form vs. URL state, a single shared
API client instance, colocated request declarations paired with React Query
hooks, and API/in-app error handling. Use when adding state, wiring up an
API call, or handling request/render errors in a React app. Reach for this
whenever you're about to decide "should this be useState or global state?",
add a new fetch/mutation to a React app, wire up form validation, or figure
out where a caught error should surface — e.g. "where should I put this
modal's open/closed state?", "how do I fetch and cache this list from the
API?", "the app crashed on one bad component and took the whole page down
with it."
/testingTesting strategy conventions from bulletproof-react: when to reach for a
unit vs. integration vs. e2e test, and the recommended tooling (Vitest,
Testing Library, Playwright, MSW) for each. Use this whenever adding tests
to a React app, deciding what kind of test a piece of code actually needs,
or reviewing a PR's test coverage — especially when the default has been
"add a unit test" without considering whether an integration test would
give more real confidence. Reach for this when the user asks things like
"what kind of test should this component have", "should I mock the API
for this test", or "how do I set up e2e tests for this app".
npx claudepluginhub dfadler/bulletproof-react-skills --plugin bulletproof-react-skills