Claude Prompt Library

30 Claude Prompts for Frontend Developers

30 copy-paste prompts

Paste these into Claude to get component APIs, accessibility fixes, performance diagnostics, CSS structure, state management plans, and code review notes you can act on the same day.

In short: This page contains 30 copy-paste ready prompts, organized into 6 categories with a description and pro tip for each. The first 5 prompts are free instantly, no signup needed. Hand-curated and tested by the AI Academy team.

Louis Corneloup
By Louis Corneloup · Founder, Techpresso
Last updated ·Hand-curated & tested by the AI Academy team

Component Design and Architecture

5 prompts

Design a Reusable Button Component API

1/30

✨ What it does

Produces a proposed prop API for a shared button component with reasoning and usage examples.

You are a senior frontend engineer specializing in design systems. <context> I am building a component library that several product teams will consume, and I want the button API to cover current and near future use cases without becoming bloated. </context> <inputs> - Framework: [REACT OR VUE OR SVELTE] - Existing variants: [LIST OF CURRENT BUTTON VARIANTS] - Upcoming needs: [LOADING STATE, ICON ONLY, SPLIT BUTTON] - Design reference: [FIGMA LINK OR SHORT DESCRIPTION] - Library name: [DESIGN SYSTEM NAME] </inputs> <task> Propose a prop API for a Button component, including variant, size, state, and icon props, with reasoning for each choice. </task> <constraints> Keep the prop list under 12 props, avoid boolean props that could conflict with each other, name props consistently with the rest of [DESIGN SYSTEM NAME], and flag any prop that duplicates native HTML button behavior. </constraints> <format> Return a table with columns prop name, type, default value, and purpose, followed by three short code examples showing common usages. </format>

💡

Pro tip: Paste your actual current Button.tsx file into the inputs so Claude proposes changes instead of a generic rewrite.

Plan a Component Composition Strategy

2/30

✨ What it does

Recommends a component composition pattern with a comparison table and a starting code skeleton.

You are a staff frontend engineer who has scaled component libraries at multiple companies. <context> I am deciding whether a new feature area should use compound components, render props, or simple prop driven components, and I want a clear recommendation before writing code. </context> <inputs> - Feature: [FEATURE NAME, E.G. DATA TABLE WITH FILTERS] - Framework: [REACT, VUE, ANGULAR] - Team size working on it: [NUMBER OF DEVELOPERS] - Flexibility needed: [DESCRIBE HOW MUCH CUSTOMIZATION CONSUMERS NEED] </inputs> <task> Recommend a composition pattern for this feature, explain the tradeoffs against the two next best alternatives, and sketch the top level component structure. </task> <constraints> Base the recommendation on the stated team size and flexibility needs, not on trends, and call out any pattern that would be hard to test or hard for a junior developer to extend. </constraints> <format> Return a short recommendation paragraph, a comparison table of the three patterns considered, and a code skeleton for the chosen approach. </format>

💡

Pro tip: Give Claude the actual number of consumers of this component, since compound components pay off differently at 2 call sites than at 40.

Extract a Shared Component from Duplicated Code

3/30

✨ What it does

Merges duplicated UI code into a single parameterized component and rewrites the call sites.

You are a senior frontend engineer doing a refactor pass across a codebase. <context> I have found near identical UI blocks repeated in several files and I want to extract them into one shared component without breaking any existing usage. </context> <inputs> - Code snippet A: [PASTE FIRST OCCURRENCE] - Code snippet B: [PASTE SECOND OCCURRENCE] - Code snippet C (optional): [PASTE THIRD OCCURRENCE] - Framework: [REACT, VUE, ANGULAR, SVELTE] </inputs> <task> Compare the snippets, identify what varies between them, and produce a single shared component with props for the parts that differ. </task> <constraints> Preserve all existing behavior exactly, do not introduce new dependencies, keep the new component under [MAX LINES OF CODE] lines, and list every call site that needs to be updated. </constraints> <format> Return the new shared component code, then a bullet list of each original call site rewritten to use it. </format>

💡

Pro tip: If the three snippets differ in more than styling, ask Claude first whether they should really share one component before it writes code.

Design a Design System Token Structure

4/30

✨ What it does

Produces a two tier design token structure in JSON with a naming convention explanation.

You are a design systems engineer who works closely with product designers. <context> Our styling is currently a mix of hardcoded values and a partial set of CSS variables, and I want to define a proper token structure before we grow the design system further. </context> <inputs> - Current styling approach: [CSS MODULES, TAILWIND, STYLED COMPONENTS, PLAIN CSS] - Existing tokens if any: [LIST WHAT ALREADY EXISTS] - Brand colors: [LIST HEX VALUES] - Platforms to support: [WEB, DARK MODE, MOBILE WEB] </inputs> <task> Design a two tier token structure with primitive tokens and semantic tokens, covering color, spacing, and typography. </task> <constraints> Semantic token names must describe purpose, not appearance, for example use a name tied to a surface role rather than a raw color name, and every semantic token must map to exactly one primitive token. </constraints> <format> Return a JSON structure for the tokens, followed by a short explanation of the naming convention so other engineers can add tokens consistently. </format>

💡

Pro tip: Paste a screenshot description of your current UI states so the semantic tokens map to real surfaces like card or banner, not guesses.

Write Component Prop Type Documentation

5/30

✨ What it does

Generates markdown documentation for a component's props, variants, and common mistakes.

You are a frontend engineer responsible for developer experience on an internal component library. <context> Other engineers keep asking basic questions about how to use our components because the prop documentation is thin, and I want to fix that for a high traffic component. </context> <inputs> - Component source code: [PASTE COMPONENT FILE] - Component name: [COMPONENT NAME] - Common misuse seen so far: [DESCRIBE A RECENT BUG CAUSED BY MISUSE] </inputs> <task> Write documentation for this component covering each prop, when to use each variant, and at least one common mistake to avoid. </task> <constraints> Write for a mid level engineer who has never seen this component, keep each prop description to one or two sentences, and include a working code example for every variant, not just the default one. </constraints> <format> Return markdown with a short overview, a prop table, one code example per variant, and a final section titled Common Mistakes. </format>

💡

Pro tip: Feed Claude the actual bug report or Slack thread about the misuse so the Common Mistakes section addresses a real incident.

Accessibility Audits and Fixes

5 prompts

Audit a Component for Screen Reader Support

6/30

✨ What it does

Reviews a component's markup for screen reader issues and returns a prioritized fix table plus corrected code.

You are an accessibility specialist who tests components with real screen readers before signing off on them. <context> I built a component and I am not confident it announces correctly to screen reader users, and I want a review before it ships. </context> <inputs> - Component code: [PASTE COMPONENT MARKUP AND JS] - Screen readers used in QA: [VOICEOVER, NVDA, JAWS] - Component purpose: [SHORT DESCRIPTION, E.G. DROPDOWN MENU] </inputs> <task> Review the markup for missing or incorrect semantics, and describe exactly what a screen reader user would hear at each interaction step. </task> <constraints> Base findings only on standard accessibility APIs, not assumptions about a specific screen reader's quirks, cite the relevant WAI-ARIA pattern if one exists for this component type, and separate blocking issues from minor improvements. </constraints> <format> Return a table with columns issue, why it matters, and fix, ordered from blocking to minor, followed by the corrected markup. </format>

💡

Pro tip: Ask a follow up question naming the specific interaction, like opening the menu with the keyboard, if the first answer stays too general.

Fix Keyboard Navigation Issues

7/30

✨ What it does

Diagnoses and fixes keyboard navigation problems in a widget, matching the standard ARIA interaction pattern.

You are a frontend accessibility engineer who specializes in keyboard interaction patterns. <context> Users who navigate by keyboard have reported that they get stuck or cannot reach certain controls in a widget I own, and I need to fix the tab order and key handling. </context> <inputs> - Widget code: [PASTE COMPONENT CODE] - Reported problem: [DESCRIBE WHAT THE USER COULD NOT DO] - Expected keys: [TAB, ARROW KEYS, ESCAPE, ENTER] </inputs> <task> Identify every place the tab order or key handling breaks expected behavior, and rewrite the code so keyboard users can complete the same actions mouse users can. </task> <constraints> Follow the standard keyboard pattern for this widget type from the WAI-ARIA Authoring Practices, do not trap focus unless the widget is a modal, and preserve all existing mouse behavior. </constraints> <format> Return a short list of what was broken, then the corrected code with comments marking each keyboard handling change. </format>

💡

Pro tip: Name the exact widget type such as combobox or tabs so Claude applies the correct APG pattern instead of a generic one.

Write ARIA Labels for a Complex Widget

8/30

✨ What it does

Adds correct ARIA roles and states to a custom widget with explanations of what each attribute communicates.

You are an accessibility engineer who writes ARIA attributes for complex interactive widgets. <context> I have a custom widget that has no native HTML equivalent, and I need correct ARIA roles, states, and labels so assistive technology understands it. </context> <inputs> - Widget markup: [PASTE HTML STRUCTURE] - Widget behavior: [DESCRIBE WHAT IT DOES, E.G. MULTI SELECT COMBOBOX] - Dynamic states: [LIST STATES THAT CHANGE, E.G. EXPANDED, SELECTED, LOADING] </inputs> <task> Add the correct ARIA roles, states, and properties to the markup, and explain what each one communicates to assistive technology. </task> <constraints> Use native HTML elements and attributes wherever possible instead of ARIA, only add ARIA where no native equivalent exists, and keep all dynamic states updated through actual attribute changes, not just visual styling. </constraints> <format> Return the updated markup with inline comments explaining each ARIA attribute, followed by a short note on which JavaScript events must update which attributes. </format>

💡

Pro tip: Remind Claude of the first rule of ARIA if the widget could instead use a native element, since native controls usually need less code and fewer bugs.

Check Color Contrast Compliance

9/30

✨ What it does

Calculates WCAG contrast ratios for given color pairs and suggests compliant adjustments.

You are an accessibility auditor who reviews visual designs against WCAG contrast requirements. <context> I am about to ship a new UI and I want to confirm the text and interactive elements meet contrast requirements before a designer signs off. </context> <inputs> - Color pairs to check: [LIST FOREGROUND AND BACKGROUND HEX PAIRS] - Text sizes involved: [LIST FONT SIZES AND WEIGHTS] - Target conformance level: [WCAG AA OR AAA] </inputs> <task> Calculate the contrast ratio for each color pair, state whether it passes the target conformance level for its text size, and suggest an adjusted color for any pair that fails. </task> <constraints> Use the WCAG contrast ratio formula, treat large text and normal text thresholds separately, and keep suggested color adjustments close to the original brand color rather than replacing it entirely. </constraints> <format> Return a table with columns color pair, ratio, pass or fail, and suggested fix if needed. </format>

💡

Pro tip: List every state of a component, including hover, disabled, and placeholder text, since those are the pairs most often missed in a first design pass.

Build an Accessible Form Validation Flow

10/30

✨ What it does

Redesigns a form's validation flow so errors are announced and associated correctly for screen reader users.

You are a frontend engineer who specializes in accessible form design. <context> Our current form only shows validation errors as red text near the field, and screen reader users are not being told an error happened at all, so I need to redesign the validation flow. </context> <inputs> - Form fields: [LIST FIELD NAMES AND TYPES] - Current validation code: [PASTE EXISTING VALIDATION LOGIC] - Framework: [REACT, VUE, PLAIN HTML AND JS] </inputs> <task> Design an accessible validation flow that announces errors to screen readers, associates error text with its field, and moves focus appropriately on submit. </task> <constraints> Do not rely on color alone to indicate an error, use aria-live regions or aria-describedby correctly rather than both in conflicting ways, and keep the error messages specific enough that a user knows how to fix the field. </constraints> <format> Return the updated form code, then a short list explaining which accessibility technique solves which part of the original problem. </format>

💡

Pro tip: Test the resulting flow with a real screen reader after Claude's fix, since aria-live timing behaves differently across browsers.

Performance Budgets and Optimization

5 prompts

Set a Performance Budget for a New Page

11/30

✨ What it does

Defines a performance budget with specific thresholds and reasoning for a new page.

You are a frontend performance engineer who sets and enforces performance budgets. <context> We are building a new page and I want to define a performance budget up front so the team has a target instead of fixing problems after launch. </context> <inputs> - Page type: [LANDING PAGE, DASHBOARD, CHECKOUT] - Target device profile: [LOW END MOBILE, TYPICAL LAPTOP] - Business goal for the page: [DESCRIBE, E.G. SIGNUP CONVERSION] - Current similar page metrics if any: [LCP, TBT, BUNDLE SIZE NUMBERS] </inputs> <task> Propose a performance budget for this page covering load time metrics and asset size limits, and explain why each threshold was chosen. </task> <constraints> Base thresholds on the stated device profile, not a generic best case, tie each metric to a user facing consequence rather than an abstract score, and keep the total number of tracked metrics to five or fewer so the team can actually monitor them. </constraints> <format> Return a table with columns metric, budget, and reason, followed by a short paragraph on how to monitor these in CI. </format>

💡

Pro tip: Give Claude your actual analytics device breakdown so the budget reflects your real users' hardware, not a generic laptop assumption.

Diagnose a Slow First Contentful Paint

12/30

✨ What it does

Analyzes performance trace data to rank likely causes of a slow first contentful paint.

You are a web performance engineer who diagnoses rendering bottlenecks. <context> A page I own has a slow first contentful paint according to real user monitoring, and I need to find the likely cause before I start changing code. </context> <inputs> - Waterfall or trace summary: [PASTE KEY REQUEST TIMINGS OR DESCRIBE THEM] - Current FCP value: [NUMBER IN SECONDS] - Rendering approach: [SERVER RENDERED, CLIENT RENDERED, STATIC] - Known render blocking resources: [LIST SCRIPTS OR STYLESHEETS IN HEAD] </inputs> <task> Analyze the likely causes of the slow first contentful paint based on the given data, and rank them by probable impact. </task> <constraints> Do not suggest a fix that is not supported by the data provided, distinguish between server response time issues and render blocking resource issues, and note if more data would be needed to confirm a suspected cause. </constraints> <format> Return a ranked list of likely causes with the supporting evidence for each, followed by the single highest impact fix to try first. </format>

💡

Pro tip: Paste the actual waterfall from Chrome DevTools or WebPageTest rather than a summary, since the exact request order changes the diagnosis.

Plan a Code Splitting Strategy

13/30

✨ What it does

Proposes a code splitting plan grouping app features into chunks based on real usage patterns.

You are a frontend architect who plans bundle splitting for large single page applications. <context> Our main JavaScript bundle has grown too large and users on slow connections wait too long before the app is interactive, so I need a code splitting plan. </context> <inputs> - Framework and bundler: [REACT WITH WEBPACK, VUE WITH VITE, ETC] - Current bundle size: [SIZE IN KB] - Route or feature list: [LIST MAIN ROUTES OR FEATURES] - Which features are used by most users vs rarely: [DESCRIBE USAGE PATTERNS] </inputs> <task> Propose a code splitting plan that separates rarely used features from the main bundle, including which routes should lazy load and which shared code should stay in the main chunk. </task> <constraints> Do not split so aggressively that common navigation triggers many small network requests, account for the given usage patterns rather than splitting purely by route, and flag any shared dependency that would end up duplicated across chunks. </constraints> <format> Return a proposed chunk structure as a list, with each chunk's contents and the reason it was grouped that way. </format>

💡

Pro tip: Share your actual bundle analyzer output if you have one, since guessed chunk contents miss shared dependency duplication.

Reduce Bundle Size for a Feature

14/30

✨ What it does

Identifies heavy dependencies in a feature and suggests lighter alternatives with estimated savings.

You are a frontend engineer focused on JavaScript bundle size reduction. <context> A specific feature in our app is adding more to the bundle than expected, and I want to find what can be trimmed without removing functionality. </context> <inputs> - Feature code or import list: [PASTE IMPORTS OR KEY CODE] - Bundle analyzer output: [PASTE RELEVANT SIZE NUMBERS] - Dependencies used: [LIST LIBRARY NAMES AND VERSIONS] </inputs> <task> Identify which imports or dependencies contribute the most to this feature's size, and suggest lighter alternatives or partial import strategies for each. </task> <constraints> Only suggest a replacement library if it covers the same functionality currently used, note any dependency that could be replaced with a small amount of custom code instead, and flag any import that is pulling in the whole library instead of a single function. </constraints> <format> Return a table with columns dependency, current size impact, suggested fix, and estimated savings. </format>

💡

Pro tip: Run source-map-explorer or a bundle analyzer first and paste the real numbers, since estimated savings without data are just guesses.

Optimize Image Loading Strategy

15/30

✨ What it does

Produces an image loading strategy with format, sizing, and lazy loading rules tailored to the page.

You are a frontend performance engineer who specializes in image delivery. <context> Images are a large share of our page weight and I want a loading strategy that improves perceived speed without hurting image quality. </context> <inputs> - Page type: [PRODUCT GALLERY, BLOG POST, DASHBOARD] - Current image setup: [FORMAT, SIZES, WHETHER LAZY LOADED] - Hosting or CDN: [NAME OF IMAGE CDN OR HOSTING SETUP] - Largest contentful paint element: [DESCRIBE IF IT IS AN IMAGE] </inputs> <task> Propose an image loading strategy covering format choice, responsive sizing, and lazy loading, tailored to this page type. </task> <constraints> If the largest contentful paint element is an image, it must not be lazy loaded, specify concrete width and format targets rather than general advice, and account for the stated CDN's actual capabilities rather than assuming features it may not support. </constraints> <format> Return a short strategy summary, then a table of image types on the page with format, sizing, and loading attribute recommendations for each. </format>

💡

Pro tip: Confirm which image is the LCP element before applying this, since lazy loading that specific image will make performance worse, not better.

These prompts give you the what. Tutorials give you the why.

Learn when to use extended thinking, how to build Claude Projects, and workflows that compound. 300+ tutorials and growing.

Try AI Academy Free

CSS Architecture and Styling Systems

5 prompts

Choose a CSS Architecture for a New Project

16/30

✨ What it does

Recommends a CSS architecture for a new project with a comparison table and starter file structure.

You are a frontend architect who has shipped and maintained several large scale CSS systems. <context> We are starting a new project and I need to decide between CSS modules, a utility framework, and CSS in JS before the team writes the first component. </context> <inputs> - Team size: [NUMBER OF DEVELOPERS] - Team CSS experience level: [BEGINNER, MIXED, EXPERT] - Framework: [REACT, VUE, ANGULAR, SVELTE] - Project type: [MARKETING SITE, INTERNAL TOOL, CONSUMER APP] </inputs> <task> Recommend a CSS architecture for this project, and explain the tradeoffs against the two next best options given the team's size and experience. </task> <constraints> Weigh long term maintenance cost as much as initial setup speed, name specific risks for a team with the stated experience level, and avoid recommending a solution just because it is currently popular. </constraints> <format> Return a short recommendation paragraph, a comparison table of the three options, and a minimal starter file structure for the chosen approach. </format>

💡

Pro tip: Mention any existing internal libraries the team already relies on, since a mismatch there often outweighs the architecture choice itself.

Refactor Legacy CSS into a Scalable System

17/30

✨ What it does

Creates a phased migration plan to move legacy CSS toward a scalable architecture without a full rewrite.

You are a senior frontend engineer who specializes in incremental CSS refactors. <context> Our stylesheet has grown into a tangle of overrides and duplicate rules over several years, and I need a plan to migrate it to a cleaner system without a full rewrite. </context> <inputs> - Current stylesheet sample: [PASTE A REPRESENTATIVE SECTION OF CSS] - Target architecture: [CSS MODULES, UTILITY CLASSES, BEM] - Constraints on rewrite time: [DESCRIBE HOW MUCH TIME IS AVAILABLE] - Pages that cannot break: [LIST HIGH TRAFFIC OR REVENUE PAGES] </inputs> <task> Propose a phased migration plan from the current CSS to the target architecture, prioritizing low risk sections first and isolating the pages that cannot break. </task> <constraints> Do not propose a big bang rewrite, keep each phase small enough to ship and verify independently, and call out any global selector in the sample that will be risky to touch. </constraints> <format> Return a numbered list of migration phases, each with scope, risk level, and a rollback approach if something breaks. </format>

💡

Pro tip: Paste your messiest file, not your cleanest one, since that is where Claude finds the global selectors actually causing the pain.

Design a Responsive Grid Layout Strategy

18/30

✨ What it does

Designs a consistent responsive grid strategy with breakpoints and per-section reflow behavior.

You are a frontend engineer who specializes in responsive layout systems. <context> I am building a page layout that needs to work across phone, tablet, and desktop widths, and I want a consistent grid approach rather than one off breakpoints per component. </context> <inputs> - Page sections: [LIST MAIN SECTIONS, E.G. HEADER, SIDEBAR, CARD GRID] - Breakpoints currently used: [LIST PIXEL VALUES IF ANY EXIST] - CSS approach: [CSS GRID, FLEXBOX, UTILITY FRAMEWORK] - Content that must reflow: [DESCRIBE ANY TRICKY CONTENT, E.G. LONG TABLES] </inputs> <task> Design a grid layout strategy for this page that defines consistent breakpoints and explains how each section reflows at each width. </task> <constraints> Use a small, consistent set of breakpoints rather than one per component, prefer intrinsic sizing techniques over fixed pixel breakpoints where possible, and address how the tricky content will reflow specifically. </constraints> <format> Return a breakpoint table, then a short description of the layout behavior for each page section at each breakpoint, then example CSS for the grid container. </format>

💡

Pro tip: Describe the tricky content, like a wide data table, in detail since that is usually where a generic grid strategy breaks down.

Build a Dark Mode Theming Plan

19/30

✨ What it does

Produces a theming plan for adding dark mode with semantic variables and a component migration order.

You are a frontend engineer who has implemented theming systems for production products. <context> We need to add a dark mode to our product and our current styles use hardcoded colors throughout, so I need a plan to introduce theming without rewriting every component at once. </context> <inputs> - CSS approach: [CSS VARIABLES, CSS IN JS, UTILITY FRAMEWORK] - Current color usage: [DESCRIBE HOW COLORS ARE DEFINED TODAY] - Components with the most hardcoded colors: [LIST COMPONENT NAMES] - Theme switching requirement: [SYSTEM PREFERENCE, MANUAL TOGGLE, BOTH] </inputs> <task> Propose a theming plan that introduces semantic color variables, supports the stated switching requirement, and prioritizes which components to migrate first. </task> <constraints> Do not require a full rewrite before dark mode can ship for any component, ensure the switching mechanism does not cause a flash of the wrong theme on load, and keep semantic variable names tied to purpose rather than to light or dark specifically. </constraints> <format> Return the proposed variable structure, the switching mechanism explained in a short paragraph, and a prioritized migration order for components. </format>

💡

Pro tip: Ask Claude specifically about avoiding a flash of unstyled theme on load, since that detail is easy to skip in a first pass plan.

Audit CSS for Specificity Conflicts

20/30

✨ What it does

Diagnoses a CSS specificity conflict with a specificity calculation and a minimal, non-hacky fix.

You are a frontend engineer who debugs CSS specificity and cascade issues. <context> A style is not applying the way I expect on a page and I suspect a specificity or cascade order conflict rather than a typo, and I want a clear diagnosis before changing anything. </context> <inputs> - Relevant CSS rules: [PASTE THE COMPETING CSS RULES] - HTML structure affected: [PASTE THE RELEVANT MARKUP] - Expected style: [DESCRIBE WHAT SHOULD APPEAR] - Actual style: [DESCRIBE WHAT ACTUALLY APPEARS] </inputs> <task> Calculate the specificity of each competing rule, explain which one wins and why, and propose the smallest possible fix. </task> <constraints> Do not suggest adding an id selector or important as the fix unless there is truly no other option, prefer restructuring selectors or source order over increasing specificity, and explain the cascade order clearly enough that the same bug will not recur. </constraints> <format> Return a short explanation of the specificity calculation for each rule, then the recommended fix as a code diff. </format>

💡

Pro tip: Include the full selector chain, not just the class name, since specificity conflicts often hide in a parent selector you forgot about.

State Management

5 prompts

Choose a State Management Approach for a Feature

21/30

✨ What it does

Recommends a state management approach for a specific feature with a comparison table and code sketch.

You are a senior frontend engineer who evaluates state management tradeoffs regularly. <context> I am building a new feature and need to decide between local component state, a shared context, or a dedicated state library before writing the data layer. </context> <inputs> - Feature description: [DESCRIBE THE FEATURE] - Data shared across components: [DESCRIBE WHAT DATA MULTIPLE COMPONENTS NEED] - Update frequency: [HOW OFTEN THE DATA CHANGES] - Existing state tools in the app: [REDUX, ZUSTAND, CONTEXT, NONE] </inputs> <task> Recommend a state management approach for this feature specifically, and explain why it fits better than the two next best options given the data sharing and update frequency described. </task> <constraints> Do not recommend introducing a new state library if the existing tools in the app can handle this cleanly, weigh re-render cost for the stated update frequency, and be explicit about when this choice should be revisited as the feature grows. </constraints> <format> Return a short recommendation paragraph, a comparison table of the three options considered, and a minimal code sketch of the chosen approach. </format>

💡

Pro tip: State the actual re-render concern, like a field that updates on every keystroke, since that changes the recommendation more than app size does.

Design a Global Store Shape

22/30

✨ What it does

Redesigns a global state store shape to fix known pain points and support a new feature.

You are a frontend architect who designs application level state stores. <context> Our global store has grown organically and is now hard to reason about, and I want to redesign its shape before adding the next major feature. </context> <inputs> - Current store shape: [PASTE OR DESCRIBE THE CURRENT STATE TREE] - State library: [REDUX, ZUSTAND, PINIA, MOBX] - New feature needing state: [DESCRIBE THE NEW FEATURE] - Known pain points: [DESCRIBE CURRENT ISSUES, E.G. DEEPLY NESTED UPDATES] </inputs> <task> Propose a redesigned store shape that fixes the stated pain points and accommodates the new feature, and explain how updates and selectors change under the new shape. </task> <constraints> Keep normalized data separate from UI only state, avoid deeply nested objects that require multiple spread operations to update, and describe a migration path rather than requiring a rewrite of every reducer or store slice at once. </constraints> <format> Return the proposed store shape as a JSON like structure, then a short migration plan as a numbered list. </format>

💡

Pro tip: Paste an actual buggy update function from the current store, since Claude can point to exactly which nesting caused it.

Debug a State Synchronization Bug

23/30

✨ What it does

Traces a state synchronization bug through the actual data flow to find the root cause and produce a fix.

You are a frontend engineer who specializes in debugging state synchronization issues. <context> Two parts of my UI show different values for what should be the same piece of state, and I need to find where the state gets out of sync. </context> <inputs> - Relevant state code: [PASTE THE STATE DEFINITION AND UPDATE LOGIC] - Components involved: [LIST THE COMPONENTS SHOWING DIFFERENT VALUES] - Steps to reproduce: [DESCRIBE THE USER ACTIONS THAT CAUSE THE MISMATCH] - State library: [REDUX, CONTEXT, ZUSTAND, LOCAL STATE COPIES] </inputs> <task> Trace through the reproduction steps against the given code, and identify the specific point where the two components stop reflecting the same value. </task> <constraints> Do not guess at a fix without tracing the actual data flow described, distinguish between a stale closure, a missed subscription, and a duplicated local copy of state as possible causes, and confirm which one matches the evidence given. </constraints> <format> Return a step by step trace of the data flow during the reproduction steps, then the identified root cause, then the fix as a code diff. </format>

💡

Pro tip: Include the exact click and navigation sequence that reproduces the bug, since the order of events often reveals a missed subscription.

Plan a Migration from Prop Drilling to Context

24/30

✨ What it does

Plans a migration from prop drilling to context while preserving intermediate component behavior.

You are a senior frontend engineer who has cleaned up prop drilling in production codebases. <context> A piece of data is being passed through five or more component layers just to reach one deeply nested component, and I want to remove the prop drilling without breaking the components in between. </context> <inputs> - Component tree involved: [DESCRIBE OR PASTE THE NESTED COMPONENT STRUCTURE] - Data being drilled: [DESCRIBE WHAT DATA IS PASSED DOWN] - Framework: [REACT, VUE, SVELTE] - Components that also use the intermediate props for their own logic: [LIST ANY, IF NONE SAY NONE] </inputs> <task> Propose a plan to introduce context or a similar mechanism that removes the prop drilling, while keeping any intermediate components that use the data for their own logic working correctly. </task> <constraints> Do not wrap the entire application in a new context provider if a narrower scope will do, preserve the existing prop interface for any component that is also used elsewhere with different data, and avoid introducing unnecessary re-renders across the whole tree. </constraints> <format> Return the proposed context structure, a list of which components change and how, and one before and after code example for the deepest component. </format>

💡

Pro tip: Mention if any component in the chain is reused elsewhere with different data, since that changes whether context can wrap it safely.

Write Tests for State Transitions

25/30

✨ What it does

Writes a test suite covering valid state transitions, known edge cases, and invalid transitions.

You are a frontend engineer who writes tests for state logic before it ships. <context> I have state logic with several transitions and edge cases, and I want thorough tests written before I trust it in production. </context> <inputs> - State logic code: [PASTE THE REDUCER, STORE, OR HOOK CODE] - Testing library: [JEST, VITEST, TESTING LIBRARY] - Known edge cases: [LIST ANY EDGE CASES ALREADY KNOWN] - States possible: [LIST THE POSSIBLE STATE VALUES, E.G. IDLE, LOADING, ERROR, SUCCESS] </inputs> <task> Write tests covering every valid state transition, the listed edge cases, and at least one invalid transition that should be rejected or ignored. </task> <constraints> Test behavior through the public interface rather than internal implementation details, cover the invalid transition case explicitly rather than assuming it cannot happen, and keep each test focused on one transition or edge case. </constraints> <format> Return the test file using [TESTING LIBRARY], with a short comment above each test naming the transition or edge case it covers. </format>

💡

Pro tip: List the invalid transitions you are worried about explicitly, since Claude will only test the ones it is told to distrust.

Most people use 10% of Claude. Tutorials unlock the rest.

AI Academy: 300+ hands-on tutorials on Claude, ChatGPT, Midjourney, and 50+ AI tools. New tutorials added every week.

Start Your Free Trial

Code Review for Frontend

5 prompts

Review a Pull Request for a New Component

26/30

✨ What it does

Reviews a pull request for correctness, API design, accessibility, and test coverage, split into blocking and non-blocking notes.

You are a senior frontend engineer doing a thorough code review before approving a pull request. <context> A teammate opened a pull request adding a new component and I want a careful review before I approve it, covering more than just style nitpicks. </context> <inputs> - Diff or component code: [PASTE THE PULL REQUEST DIFF OR FILE] - Component purpose: [DESCRIBE WHAT THE COMPONENT DOES] - Team conventions: [DESCRIBE ANY NAMING OR STRUCTURE CONVENTIONS TO FOLLOW] </inputs> <task> Review the code for correctness, prop API design, accessibility, and test coverage, and separate blocking issues from suggestions. </task> <constraints> Do not comment on formatting that a linter would already catch, back every blocking issue with a specific line or snippet reference, and note if a test is missing for a case the code clearly needs to handle. </constraints> <format> Return two sections, Blocking and Suggestions, each as a bullet list referencing the specific code involved. </format>

💡

Pro tip: Paste the actual diff rather than the whole file, since Claude then focuses the review on what changed instead of relitigating old code.

Write Code Review Comments on a React Hook

27/30

✨ What it does

Reviews a custom React hook for stale closures, dependency issues, and missing cleanup, with concrete fixes.

You are a senior React engineer reviewing custom hooks for correctness and reuse. <context> A teammate wrote a custom hook and I want to check it for common hook mistakes like stale closures, missing dependencies, and unnecessary re-renders before approving it. </context> <inputs> - Hook code: [PASTE THE CUSTOM HOOK] - Where it is used: [LIST COMPONENTS OR FEATURES USING IT] - React version: [REACT VERSION NUMBER] </inputs> <task> Review the hook for stale closures, incorrect or missing dependency arrays, unnecessary re-renders, and cleanup handling, and explain the impact of each issue found. </task> <constraints> Explain the specific scenario that triggers each bug rather than stating a rule in the abstract, do not flag a missing dependency if omitting it is actually intentional and safe, and note any effect that is missing a cleanup function it needs. </constraints> <format> Return a numbered list of issues, each with the line involved, the triggering scenario, and the suggested fix as a code snippet. </format>

💡

Pro tip: Tell Claude your React version, since automatic batching and strict mode double invocation change what counts as a real bug.

Review a CSS Change for Regressions

28/30

✨ What it does

Assesses the regression risk of a CSS change on shared selectors and recommends scoping fixes when needed.

You are a frontend engineer reviewing a CSS change for unintended side effects. <context> A pull request changes shared CSS and I am worried it could affect other pages that use the same classes, so I want a careful review before approving. </context> <inputs> - CSS diff: [PASTE THE CSS CHANGES] - Class names or selectors touched: [LIST THEM] - Pages or components known to use these selectors: [LIST IF KNOWN, OR SAY UNKNOWN] </inputs> <task> Review the diff for changes to shared selectors, identify which other components or pages are likely affected, and flag any change that widens a selector's scope beyond its original use. </task> <constraints> Assume any class name not clearly scoped to one component could be reused elsewhere, recommend scoping the change to a new class if the risk of a shared selector regression is high, and note if visual regression testing should be run before merging. </constraints> <format> Return a risk assessment as high, medium, or low with reasoning, followed by a recommended change if the risk is medium or high. </format>

💡

Pro tip: If you are unsure which pages use a shared class, search the codebase for that class name first and paste the results in as the usage list.

Check a PR for Accessibility Regressions

29/30

✨ What it does

Checks a pull request diff for accessibility regressions and gives a clear merge verdict with reasoning.

You are a frontend engineer who checks pull requests for accessibility regressions before they merge. <context> A pull request changes markup or interaction behavior and I want to confirm it has not introduced an accessibility regression before it ships. </context> <inputs> - Diff or changed markup: [PASTE THE RELEVANT MARKUP CHANGES] - What changed functionally: [DESCRIBE WHAT THE PR CHANGES] - Interactive elements affected: [LIST BUTTONS, LINKS, FORM FIELDS INVOLVED] </inputs> <task> Review the changes for lost semantics, removed keyboard support, or broken focus management compared to the likely previous behavior, and state whether the change is safe to merge. </task> <constraints> Compare against the accessibility behavior a reasonable prior version would have had, not an ideal rewrite, be explicit if you cannot tell from the diff alone whether something regressed, and prioritize keyboard and focus issues over minor semantic nitpicks. </constraints> <format> Return a clear verdict of safe to merge, needs changes, or needs manual testing, followed by the specific reasoning. </format>

💡

Pro tip: If the diff alone cannot confirm safety, ask Claude what specific manual test to run rather than accepting an uncertain approval.

Review a Performance-Sensitive Change

30/30

✨ What it does

Reviews a hot path code change for performance regressions and estimates impact at the stated scale.

You are a senior frontend engineer reviewing a change to code that runs on a hot path. <context> A pull request touches code that runs frequently, such as a list render or a scroll handler, and I want to check for performance regressions before approving it. </context> <inputs> - Code diff: [PASTE THE CHANGED CODE] - Where this code runs: [DESCRIBE THE HOT PATH, E.G. RENDERED PER LIST ITEM] - Approximate frequency or scale: [NUMBER OF ITEMS OR CALLS PER SECOND] </inputs> <task> Review the change for new allocations, unnecessary re-renders, or expensive operations introduced on this hot path, and estimate the likely performance impact at the stated scale. </task> <constraints> Base the estimate on the stated frequency or scale rather than a generic statement that something is slow, distinguish between a one time cost and a cost that repeats per item or per call, and suggest a specific alternative for any expensive operation found. </constraints> <format> Return a short impact estimate, then a list of specific lines with the issue and suggested fix for each. </format>

💡

Pro tip: Give Claude the real item count or call frequency, since a cheap operation at 10 items is a real problem at 10,000.

Free tool

Prompt Optimizer

Turn a rough idea into a structured, professional AI prompt.

Try it free →

Frequently Asked Questions

A useful prompt gives Claude the actual code, the framework, and the specific symptom or goal, not a generic request like fix my component. Frontend problems are usually about a specific piece of markup, state shape, or CSS rule, so pasting that in gets a real answer instead of general advice.
Yes. Paste the diff directly into the prompt along with what the change is supposed to do. Claude reviews the actual lines changed, which produces more useful feedback than describing the change in your own words.
Give Claude the actual markup and name the specific widget type, like combobox or modal, so it can compare your code against the correct ARIA pattern instead of listing generic accessibility tips that may not apply.
No. Paste actual trace or waterfall data from DevTools, Lighthouse, or your real user monitoring tool. Claude can reason well about that data, but a diagnosis based only on a vague description of slowness is a guess, not an analysis.
Most of these prompts work across frameworks since the underlying problems, like accessibility, CSS architecture, and performance, are not React specific. Just fill in your actual framework in the inputs so the code examples and state management advice match your stack.

Prompts are the starting line. Tutorials are the finish.

A growing library of 300+ hands-on tutorials on ChatGPT, Claude, Midjourney, and 50+ AI tools. New tutorials added every week.

7-day free trial. Cancel anytime.