agentleFS
hellobrophyhellobrophy/claude-skills/nextjs-frontend/SKILL.md

nextjs-frontend

Skill0 starsChanged 7 months agoMITView on GitHub

Use this skill whenever building, editing, or reviewing frontend code in a Next.js project. Triggers on: creating or refactoring React components, working with Figma MCP to extract designs or tokens, writing PostCSS/BEM styles, setting up component file structure, writing accessible HTML, working with TypeScript interfaces and props, or any task involving Next.js App Router patterns. Use this skill even for partial tasks like "add a new component", "extract tokens from this Figma frame", or "fix the accessibility on this form" — not just for full page builds.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. thesaifalitai/claude-setup★ 9same name
    2. suleyman/fullstack-agent-skills★ 2same name
    3. blackbenjamin/etps★ 1same name
    4. yiweiwan/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 repository5 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

24 rules. 0 are common, 9 are distinctive, and 15 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 15

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use type for unions/aliases, interface for object shapes.

    line 68
  2. Very specific:

    Server Components by default: Add 'use client' only when genuinely needed:

    line 101
  3. Very specific:

    Keep 'use client' as deep in the tree as possible — don't bubble it up unnecessarily.

    line 105
  4. Distinctive:

    If a component needs both server-fetched data and client interactivity, split it: fetch in a Server Component, pass data as props to a …

    line 106
  5. Distinctive:

    When unsure of level, default one level lower (simpler).

    line 113
  6. Very specific:

    Use semantic HTML by default.

    line 119
  7. Very specific:

    Use <button> for actions, <a> for navigation.

    line 122
  8. Distinctive:

    All interactive elements must be keyboard-focusable and have a visible focus state.

    line 123
  9. Very specific:

    Images: always provide alt. Decorative images use alt="" and role="presentation".

    line 124
  10. Distinctive:

    ARIA: use only when native semantics aren't sufficient.

    line 125
  11. Very specific:

    Don't suppress outlines with outline: none unless replacing with a custom focus style.

    line 131
  12. Very specific:

    Read references/css-conventions.md for the full guide.

    line 137
  13. Distinctive:

    Never hardcode hex values, spacing units, or font sizes in component CSS.

    line 142
  14. Very specific:

    PostCSS: use nesting (&) to keep related rules together.

    line 143
  15. Very specific:

    No global class leakage: all component styles are scoped to their CSS Module.

    line 144
  16. Very specific:

    Only global.css and tokens.css write to :root or bare element selectors.

    line 145
  17. Distinctive:

    When Figma Variables are available (via MCP or synced export):

    line 151
  18. Very specific:

    When a Figma token uses modes (e.g.

    line 161
  19. Distinctive:

    When working on a prototype without a token system: use clearly named temporary custom properties rather than hardcoded values.

    line 163
  20. Distinctive:

    When Figma MCP is connected, use it actively.

    line 170
  21. Very specific:

    Use get_variable_defs on the relevant Figma node to retrieve variables.

    line 174
  22. Very specific:

    Use get_design_context on the target frame or component node.

    line 180
  23. Very specific:

    Use get_screenshot to visually verify the design before coding.

    line 181
  24. Distinctive:

    Write semantic HTML first, then layer CSS via BEM + CSS Modules.

    line 184

“Common” is measured: kept by at least 6 in 10 of the 3 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

Next.js Frontend Skill

This skill defines coding conventions, file structure, and workflow patterns for a Next.js frontend codebase. Follow these rules consistently — even for small edits — to keep the codebase coherent.

Stack Overview

ConcernChoice
FrameworkNext.js (App Router)
LanguageTypeScript — strict mode always
StylingPostCSS + BEM + CSS Modules
Design sourceFigma via MCP (when available)
TokensFigma Variables → CSS custom properties
ComponentsBespoke, atomic/compound pattern
AnimationSee ux-motion skill (separate)

File & Folder Structure

src/
├── app/                        # Next.js App Router pages
│   └── [route]/
│       └── page.tsx            # Default export
├── components/
│   ├── atoms/                  # Smallest reusable units (Button, Icon, Label)
│   ├── molecules/              # Composed atoms (FormField, Card, NavItem)
│   └── organisms/              # Full sections (Header, ProductGrid, Footer)
├── styles/
│   ├── tokens.css              # CSS custom properties from Figma Variables
│   ├── global.css              # Resets, base type, body
│   └── utils.css               # Shared PostCSS utilities / mixins
└── types/
    └── *.types.ts              # Shared prop interfaces used by 2+ components

Components live alongside their own CSS Module:

components/atoms/Button/
├── Button.tsx
├── Button.module.css
└── index.ts                    # Re-exports named export

TypeScript Rules

  • Always use strict mode. No any. No non-null assertions unless unavoidable with a comment.
  • Props for a single component: define a interface directly above the component in the same file.
  • Props shared by 2+ components: define in src/types/ as a named export.
  • Use type for unions/aliases, interface for object shapes.
// Single-component props — same file, above the component
interface ButtonProps {
  label: string;
  onClick: () => void;
  variant?: "primary" | "secondary" | "ghost";
  disabled?: boolean;
}

export function Button({ label, onClick, variant = "primary", disabled = false }: ButtonProps) {
  // ...
}

Component Conventions

Export pattern

  • Named exports for all components.
  • Default exports for Next.js pages only (app/**/page.tsx).
  • Each component folder has an index.ts that re-exports the named export.
// components/atoms/Button/index.ts
export { Button } from "./Button";

Server vs Client Components

  • Server Components by default. Add 'use client' only when genuinely needed:
    • Browser APIs (window, document, localStorage)
    • Event handlers that require state or refs
    • React hooks (useState, useEffect, etc.)
  • Keep 'use client' as deep in the tree as possible — don't bubble it up unnecessarily.
  • If a component needs both server-fetched data and client interactivity, split it: fetch in a Server Component, pass data as props to a small Client Component leaf.

Atomic pattern

  • Atoms: single-purpose, no children of their own (Button, Icon, Tag, Avatar)
  • Molecules: compose 2–4 atoms with local logic (SearchField = Input + Button + Icon)
  • Organisms: full sections composing molecules (SiteHeader, ProductCard, FilterPanel)
  • When unsure of level, default one level lower (simpler). Promote only when reuse demands it.

HTML & Accessibility

  • Use semantic HTML by default. Reach for <article>, <section>, <nav>, <main>, <aside>, <header>, <footer>, <figure>, <time>, <address> appropriately.
  • No <div> or <span> where a semantic element fits.
  • Use <button> for actions, <a> for navigation. Never use a <div> as a button.
  • All interactive elements must be keyboard-focusable and have a visible focus state.
  • Images: always provide alt. Decorative images use alt="" and role="presentation".
  • ARIA: use only when native semantics aren't sufficient. Prefer native HTML first. Common correct uses: aria-label, aria-labelledby, aria-describedby, aria-expanded, aria-controls, aria-live for dynamic regions, role="status" for polite updates.
  • Heading hierarchy must be logical (h1 → h2 → h3), never skip levels.
  • Forms: every <input> has an associated <label> (via htmlFor / id, not just proximity).
  • Colour contrast: meet WCAG AA minimum (4.5:1 for body text, 3:1 for large/UI text).
  • Don't suppress outlines with outline: none unless replacing with a custom focus style.

CSS / PostCSS / BEM

Read references/css-conventions.md for the full guide. Summary:

  • BEM naming: .block__element--modifier
  • CSS Modules: one .module.css per component. Import as styles object.
  • Tokens: reference design tokens as CSS custom properties (var(--color-primary)). Never hardcode hex values, spacing units, or font sizes in component CSS.
  • PostCSS: use nesting (&) to keep related rules together. Avoid deep nesting (max 3 levels).
  • No global class leakage: all component styles are scoped to their CSS Module. Only global.css and tokens.css write to :root or bare element selectors.

Design Token Conventions

When Figma Variables are available (via MCP or synced export):

  • Map Figma variable collections to CSS custom property groups:
    • Color/* → --color-*
    • Spacing/* → --space-*
    • Typography/Size/* → --text-size-*
    • Typography/Weight/* → --font-weight-*
    • Radius/* → --radius-*
    • Shadow/* → --shadow-*
  • Define all tokens in src/styles/tokens.css on :root.
  • When a Figma token uses modes (e.g. light/dark), map to [data-theme="dark"] selector.

When working on a prototype without a token system: use clearly named temporary custom properties rather than hardcoded values. This makes it easy to wire up tokens later.


Figma MCP Workflow

When Figma MCP is connected, use it actively. Don't guess at design values.

Extracting tokens

  1. Use get_variable_defs on the relevant Figma node to retrieve variables.
  2. Map to CSS custom properties using the token naming conventions above.
  3. Write to src/styles/tokens.css.

Generating components from a design

  1. Use get_design_context on the target frame or component node.
  2. Use get_screenshot to visually verify the design before coding.
  3. Extract spacing, colour, and type values — map to tokens, not raw values.
  4. Structure the component following the atomic level appropriate to its complexity.
  5. Write semantic HTML first, then layer CSS via BEM + CSS Modules.

When Figma MCP is unavailable

Note it, then proceed with clearly named placeholder custom properties and a comment flagging where real tokens should be wired in once available.


Reference Files

  • references/css-conventions.md — Full PostCSS/BEM/CSS Modules guide with examples
  • references/a11y-patterns.md — Accessible component patterns (modals, menus, forms, etc.)

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.