30 Claude Prompts That Write JavaScript
Describe what you need and Claude returns runnable, commented JavaScript you can paste straight in: DOM and browser tricks, array and object utilities, fetch and async patterns, Node scripts, vanilla UI widgets, and regex. Not "explain a for loop."
In short: This page contains 30 copy-paste ready prompts, organized into 6 categories with a description and pro tip for each. The first 15 prompts are free instantly โ no signup needed. Hand-curated and tested by the AI Academy team.
DOM & Browser
5 promptsDebounced Live Search Filter
1/30You are a senior front-end JavaScript engineer who writes clean, dependency-free code. <context> I need a debounced live-search filter for a list on my page, returned as one self-contained, commented JavaScript snippet I can paste into a script tag and run immediately. </context> <inputs> - List markup: [E.G. UL WITH LI ITEMS, OR CARD DIVS] - Search input selector: [E.G. #search] - Attribute or text to match on: [ITEM TEXT / DATA-NAME] - Debounce delay in ms: [E.G. 200] - Case sensitivity: [CASE-INSENSITIVE / EXACT] </inputs> <task> Write a function that reads the input, debounces keystrokes, filters the matching items by toggling a hidden class or display, shows a "no results" state when nothing matches, and highlights the matched substring in each visible item. Wire it up with a single init call. </task> <constraints> - Vanilla JS only, no libraries; works with a variable number of items. - Comment each block; debounce implemented from scratch, not imported. - Do not mutate original text irreversibly; restore it when the query clears. </constraints> <format> Return the full JavaScript in one code block, then a two-line note on the HTML structure it expects and how to change the match field. </format>
Produces a from-scratch debounced list-search filter with highlighting and a no-results state, ready to use.
Pro tip: Tell Claude whether your items are static HTML or rendered from an array; it will filter the DOM or the source data accordingly.
Scroll-Spy Nav Highlighter
2/30You are a front-end engineer who specializes in accessible, performant scroll interactions. <context> I want a scroll-spy that highlights the current section link in my sticky nav as the user scrolls, returned as one self-contained, commented JavaScript snippet ready to run. </context> <inputs> - Nav link selector: [E.G. .nav a] - Section selector or id pattern: [E.G. section[id]] - Active class name: [E.G. is-active] - Offset for the sticky header in px: [E.G. 80] </inputs> <task> Write code that uses IntersectionObserver to detect which section is in view, adds the active class to the matching nav link and removes it from the others, handles the sticky-header offset, and updates on load and resize. Fall back gracefully if a section id is missing. </task> <constraints> - Vanilla JS, IntersectionObserver based (no scroll-event thrashing); no libraries. - Comment the observer options and the offset logic; guard against missing elements. </constraints> <format> Return the full JavaScript in one code block, then a short note on the nav-and-section HTML it assumes and how to tune the offset. </format>
Generates an IntersectionObserver scroll-spy that keeps the active nav link in sync while scrolling, ready to use.
Pro tip: Give Claude your exact sticky-header height so the active state flips at the right scroll position, not too early.
Copy-to-Clipboard Button + Toast
3/30You are a front-end engineer who builds small, reliable UX helpers. <context> I need copy-to-clipboard buttons with a confirmation toast, returned as one self-contained, commented JavaScript snippet I can drop in and run. </context> <inputs> - Button selector: [E.G. .copy-btn] - Source of the text to copy: [DATA-COPY ATTRIBUTE / SIBLING CODE BLOCK / INPUT VALUE] - Success message: [E.G. Copied!] - Toast position: [TOP-RIGHT / BOTTOM-CENTER] </inputs> <task> Write code that, on click, copies the resolved text using the async Clipboard API, shows a small auto-dismissing toast, temporarily swaps the button label to a confirmed state, and handles the failure path with a fallback (execCommand or a selectable prompt). Support multiple copy buttons on one page. </task> <constraints> - Vanilla JS, no libraries; event delegation so dynamically added buttons work. - Include the minimal CSS for the toast inline via injected style or comments; comment the fallback path. - Never leave the button stuck in the confirmed state. </constraints> <format> Return the full JavaScript in one code block, then note where the copied text comes from and how to restyle the toast. </format>
Builds multi-button copy-to-clipboard with a toast and a graceful fallback, ready to use.
Pro tip: Tell Claude if the source is a code block, an input, or a data attribute so it resolves the right text on each click.
Dark-Mode Toggle With Persistence
4/30You are a front-end engineer focused on theming and no-flash page loads. <context> I want a dark-mode toggle that remembers the user's choice, returned as one self-contained, commented JavaScript snippet ready to run. </context> <inputs> - Toggle button selector: [E.G. #theme-toggle] - Where the theme applies: [DATA-THEME ON HTML / A DARK CLASS ON BODY] - Default when no choice saved: [SYSTEM / LIGHT / DARK] - localStorage key: [E.G. theme] </inputs> <task> Write code that reads the saved preference (or the system setting via prefers-color-scheme when set to system), applies the theme, toggles it on button click, persists the new value, updates the button's aria-pressed and label, and listens for OS theme changes when in system mode. Include a tiny inline script hint to prevent the flash of the wrong theme on load. </task> <constraints> - Vanilla JS, no libraries; guards for private-mode localStorage failures. - Comment the persistence and system-preference logic; keep DOM writes minimal. </constraints> <format> Return the full JavaScript in one code block, then note the head snippet that avoids the theme flash and how to add a third theme. </format>
Creates a persistent dark-mode toggle with system-preference support and a no-flash hint, ready to use.
Pro tip: Ask Claude for the tiny head-level script too so the correct theme paints before your main bundle loads.
Infinite Scroll / Lazy Loader
5/30You are a front-end engineer who builds efficient content-loading patterns. <context> I need infinite scroll that loads more items as the user reaches the bottom, returned as one self-contained, commented JavaScript snippet ready to run. </context> <inputs> - Container selector: [E.G. #feed] - How items are fetched: [FETCH URL WITH PAGE PARAM / SLICE FROM A LOCAL ARRAY] - Page size: [E.G. 20] - Sentinel behavior: [LOAD NEAR BOTTOM / EXPLICIT LOAD-MORE BUTTON FALLBACK] </inputs> <task> Write code that appends a sentinel element, uses IntersectionObserver to load the next page when it comes into view, renders new items into the container, shows a loading indicator, stops when there are no more pages, and handles fetch errors with a retry option. Prevent duplicate concurrent loads. </task> <constraints> - Vanilla JS, no libraries; a single in-flight guard so pages never double-load. - Comment the observer, the pagination state, and the end-of-list condition. - Provide a small renderItem function I can swap for my own markup. </constraints> <format> Return the full JavaScript in one code block, then note how to point it at a real API and how to change the render template. </format>
Generates an IntersectionObserver infinite-scroll loader with a loading state and end-of-list handling, ready to use.
Pro tip: Tell Claude your API's exact response shape so the renderItem function maps the right fields with no guesswork.
XML tags are just the start. Learn the full Claude workflow.
A growing library of 300+ hands-on AI tutorials covering Claude, ChatGPT, and 50+ tools. New tutorials added every week.
Array & Object Utilities
5 promptsgroupBy + Aggregate Helper
6/30You are a JavaScript engineer who writes small, well-tested utility functions. <context> I need a groupBy helper that also aggregates, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Sample records (shape): [E.G. {category, amount, date}] - Group by: [FIELD NAME OR A KEY FUNCTION] - Aggregations I want: [COUNT / SUM OF FIELD / AVG / MIN-MAX] - Output shape: [OBJECT KEYED BY GROUP / ARRAY OF {key, items, stats}] </inputs> <task> Write a groupBy function that accepts a key or a key-function, plus an aggregate helper that computes count and the requested numeric rollups per group. Include a small demo array and a console.log showing the grouped, aggregated result. </task> <constraints> - Pure functions, no dependencies; do not mutate the input array. - Handle missing or null group keys with an explicit bucket; comment each step. - Use reduce cleanly, not nested loops that are hard to follow. </constraints> <format> Return the full JavaScript in one code block with the demo run, then note how to add a new aggregation. </format>
Produces a reusable groupBy plus aggregation module with a working demo run, ready to use.
Pro tip: Give Claude one real row of your data so the aggregations target your actual field names and types.
Deep Clone + Deep Merge
7/30You are a JavaScript engineer who cares about correctness with nested data. <context> I need reliable deepClone and deepMerge utilities, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Data types to support: [PLAIN OBJECTS, ARRAYS, DATES, MAPS/SETS?] - Merge rule for arrays: [REPLACE / CONCAT / MERGE BY INDEX] - Handle circular references: [YES / NO] </inputs> <task> Write deepClone (using structuredClone when available with a documented manual fallback) and deepMerge that recursively merges plain objects per the chosen array rule, leaving the sources untouched. Add a demo showing a nested merge and proving the originals are unchanged. </task> <constraints> - No dependencies; the manual clone fallback handles Date and the chosen collection types. - If circular refs are requested, track visited nodes; comment the recursion and edge cases. - Never mutate inputs; return new structures. </constraints> <format> Return the full JavaScript in one code block with the demo, then note the array-merge rule chosen and how to switch it. </format>
Generates immutable deepClone and deepMerge helpers with a demo proving inputs stay untouched, ready to use.
Pro tip: State your array-merge preference up front; replace vs concat changes behavior for config objects a lot.
Dedupe Array of Objects by Key
8/30You are a JavaScript engineer who writes precise data helpers. <context> I need to remove duplicate objects from an array by a key, returned as one self-contained, commented JavaScript function ready to run. </context> <inputs> - Object shape: [E.G. {id, email, name}] - Dedupe key(s): [SINGLE FIELD OR COMPOSITE OF SEVERAL] - On conflict keep: [FIRST SEEN / LAST SEEN / NEWEST BY A DATE FIELD] - Case-insensitive on strings: [YES / NO] </inputs> <task> Write a dedupeBy function that builds a composite key from the chosen fields, keeps the record per the conflict rule, and preserves original order. Include a demo array with duplicates and log the deduped result plus how many were removed. </task> <constraints> - Pure function, no dependencies; does not mutate the input. - Uses a Map for O(n) behavior; comment the key-building and conflict logic. - Normalizes case only when requested. </constraints> <format> Return the full JavaScript in one code block with the demo run, then note how to switch to composite keys. </format>
Builds an order-preserving dedupe-by-key function with a first/last/newest conflict rule and demo, ready to use.
Pro tip: Tell Claude which record wins on a tie (first, last, or newest by date) so duplicates collapse the way you expect.
Filter / Sort / Paginate Pipeline
9/30You are a JavaScript engineer who builds clean data-transformation pipelines. <context> I need a reusable filter-sort-paginate pipeline for a table or list, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Row shape: [E.G. {name, price, createdAt, active}] - Filters to support: [TEXT SEARCH FIELDS / BOOLEAN / RANGE ON A NUMBER] - Sortable fields: [WHICH FIELDS, DEFAULT SORT] - Page size: [E.G. 25] </inputs> <task> Write composable functions applyFilters, applySort, and paginate, plus a queryData wrapper that runs them in order and returns the page rows, total count, and total pages. Include a demo dataset and a sample query showing a text filter, a sort, and page 2. </task> <constraints> - Pure functions, no dependencies; never mutate the source rows. - Sorting is stable and handles strings, numbers, and dates; comment each stage. - queryData returns metadata (total, page, pages) not just the slice. </constraints> <format> Return the full JavaScript in one code block with the demo query, then note how to plug it into a UI's pagination controls. </format>
Generates composable filter, sort, and paginate functions plus a query wrapper with metadata, ready to use.
Pro tip: List exactly which columns should be sortable so Claude validates the sort field instead of trusting arbitrary input.
Everyday Array Toolkit
10/30You are a JavaScript engineer who writes a small, dependency-free lodash-style toolkit. <context> I want a compact array-utilities module I can reuse across projects, returned as one self-contained, commented JavaScript file ready to run. </context> <inputs> - Helpers I want: [CHUNK, FLATTEN-DEEP, UNIQUE, PARTITION, RANGE, ZIP, SUM-BY, KEY-BY] - Module style: [ES EXPORTS / A SINGLE OBJECT] - Node or browser: [WHICH ENVIRONMENT] </inputs> <task> Implement each requested helper as a small pure function with a one-line doc comment and one usage example. End with a short self-test block that calls each helper and console.logs the results so I can verify behavior instantly. </task> <constraints> - No dependencies; each function pure and non-mutating. - flattenDeep is recursive with a guard; chunk and range validate their inputs. - Comment the tricky ones (partition, zip, keyBy) with expected output. </constraints> <format> Return the full JavaScript in one code block including the self-test, then note how to import it in my chosen module style. </format>
Produces a dependency-free array-utilities module with doc comments and a self-test block, ready to use.
Pro tip: Only ask for the helpers you actually need; a tighter list keeps the module small and easy to audit.
Fetch & Async
5 promptsRobust Fetch Wrapper
11/30You are a JavaScript engineer who writes resilient network code. <context> I need a fetch wrapper with timeout, retries, and JSON handling, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Base URL (optional): [E.G. https://api.example.com] - Default headers: [E.G. AUTH BEARER, CONTENT-TYPE] - Timeout in ms: [E.G. 8000] - Retry count and which statuses retry: [E.G. 2 RETRIES ON 429/5XX] </inputs> <task> Write an apiFetch(path, options) that merges default headers, enforces a timeout via AbortController, parses JSON safely (handling empty bodies), retries idempotent requests on the chosen statuses with backoff, and throws a rich error object carrying status, url, and parsed body. Include get/post/put/del convenience methods and a demo call. </task> <constraints> - Vanilla JS using native fetch and AbortController; no libraries. - Never retry non-idempotent methods unless told; comment the timeout and retry logic. - Surface a typed error, do not silently return undefined. </constraints> <format> Return the full JavaScript in one code block with a demo call, then note how to add auth-token refresh. </format>
Generates an apiFetch wrapper with timeout, safe JSON parsing, retries, and rich errors, ready to use.
Pro tip: Tell Claude which HTTP statuses should retry; blindly retrying a 400 or 401 just wastes calls.
Concurrency-Limited Async Queue
12/30You are a JavaScript engineer who handles large batches of async work safely. <context> I need to run many async tasks with a concurrency cap, returned as one self-contained, commented JavaScript function ready to run. </context> <inputs> - Task type: [FETCH CALLS / FILE READS / ANY PROMISE-RETURNING FN] - Concurrency limit: [E.G. 5] - On task failure: [FAIL FAST / COLLECT ERRORS AND CONTINUE] - Need results in input order: [YES / NO] </inputs> <task> Write an asyncPool(limit, items, worker) that processes items with at most 'limit' running at once, returns results in the original order when requested, and follows the chosen failure policy. Include an onProgress callback and a demo that simulates variable-latency tasks. </task> <constraints> - Vanilla JS, promises only, no dependencies; no unbounded Promise.all over the whole list. - Comment the scheduling loop and how order is preserved. - Respect the failure policy exactly (fail-fast rejects; collect returns {value|error} per item). </constraints> <format> Return the full JavaScript in one code block with the simulated demo, then note how to plug in a real worker function. </format>
Builds an ordered, concurrency-limited async pool with progress and a failure policy, ready to use.
Pro tip: Match the concurrency limit to your API's rate limit so the pool throttles instead of triggering 429s.
Retry With Exponential Backoff
13/30You are a JavaScript engineer who writes reliable retry logic. <context> I need a generic retry helper with exponential backoff and jitter, returned as one self-contained, commented JavaScript function ready to run. </context> <inputs> - What it wraps: [ANY ASYNC FUNCTION] - Max attempts: [E.G. 5] - Base delay and factor: [E.G. 300MS, DOUBLE EACH TIME] - Retry-if rule: [PREDICATE ON THE ERROR, E.G. STATUS 429/5XX] </inputs> <task> Write retry(fn, options) that calls fn, and on a retryable error waits base * factor^attempt plus random jitter (capped at a max delay) before trying again, giving up after max attempts and rethrowing the last error. Support an AbortSignal to cancel pending waits. Include a demo that fails twice then succeeds. </task> <constraints> - Vanilla JS, no dependencies; jitter and a max-delay cap included. - Only retries when the retry-if predicate returns true; comment the backoff math. - Respects an abort signal so a canceled operation stops waiting. </constraints> <format> Return the full JavaScript in one code block with the demo, then note sensible defaults for API calls. </format>
Produces a configurable retry helper with jittered exponential backoff and abort support, ready to use.
Pro tip: Ask Claude to add jitter (it will by default) so parallel clients don't all retry on the same beat and stampede the server.
Autocomplete With Cancellation
14/30You are a front-end engineer who builds responsive type-ahead search. <context> I need an autocomplete that queries an API as the user types without race conditions, returned as one self-contained, commented JavaScript snippet ready to run. </context> <inputs> - Input selector and results container: [E.G. #q AND #results] - API endpoint (query param): [E.G. /search?q=] - Debounce delay in ms: [E.G. 250] - Minimum characters before searching: [E.G. 2] </inputs> <task> Write code that debounces input, aborts the previous request with AbortController when a new keystroke fires, ignores stale responses, renders results (with a loading and empty state), and supports keyboard up/down/enter selection. Guard against the min-character threshold and clear results when the field empties. </task> <constraints> - Vanilla JS, native fetch and AbortController, no libraries. - No race conditions: the latest query always wins; comment the abort and staleness guards. - Accessible: results are a listbox with aria attributes and keyboard navigation. </constraints> <format> Return the full JavaScript in one code block, then note the expected API response shape and how to change the result template. </format>
Generates a debounced autocomplete with request cancellation, keyboard nav, and no stale results, ready to use.
Pro tip: Give Claude the JSON shape your search endpoint returns so the result renderer maps title and id fields correctly.
Poll Until Condition Met
15/30You are a JavaScript engineer who writes clean polling utilities. <context> I need to poll an endpoint until a job finishes, returned as one self-contained, commented JavaScript function ready to run. </context> <inputs> - Endpoint to poll: [E.G. /jobs/{id}] - Done condition: [E.G. status === 'complete'] - Fail condition: [E.G. status === 'failed'] - Interval and overall timeout: [E.G. EVERY 2S, GIVE UP AFTER 2 MIN] </inputs> <task> Write pollUntil(fetchStatus, options) that repeatedly calls fetchStatus, resolves with the payload when the done predicate is true, rejects on the fail predicate or overall timeout, and waits the interval between attempts. Support an AbortSignal and an optional backoff so intervals can grow. Include a demo that resolves after a few simulated polls. </task> <constraints> - Vanilla JS, promises only, no dependencies; a hard overall-timeout guard. - No overlapping requests; wait for each poll to settle before scheduling the next. - Comment the done/fail/timeout branches clearly. </constraints> <format> Return the full JavaScript in one code block with the simulated demo, then note how to switch from fixed to growing intervals. </format>
Builds a pollUntil helper with done/fail predicates, timeout, and optional backoff, ready to use.
Pro tip: Always give it an overall timeout; without one a stuck job would poll forever and leak the loop.
Node Scripts
5 promptsFile Organizer CLI
16/30You are a Node.js engineer who writes practical command-line scripts. <context> I want a Node script that sorts files in a folder into subfolders by type, returned as one self-contained, commented script ready to run with node. </context> <inputs> - Target folder: [PATH OR PASS AS ARGV] - Grouping rule: [BY EXTENSION / BY DATE / BY CUSTOM MAP OF EXT TO FOLDER] - Dry-run first: [YES / NO] - On name collision: [SKIP / RENAME WITH SUFFIX] </inputs> <task> Write a script using node:fs and node:path that reads the folder, decides each file's destination subfolder by the chosen rule, creates folders as needed, and moves files, honoring the collision rule. Support a --dry-run flag that logs planned moves without touching anything and print a summary count at the end. </task> <constraints> - Node built-ins only, no npm packages; use async fs promises. - Never overwrite silently; the collision rule is respected and logged. - Comment argument parsing and the move logic; skip directories and hidden files unless told. </constraints> <format> Return the full script in one code block, then note the exact run command and what --dry-run prints. </format>
Generates a Node CLI that sorts files into subfolders with dry-run and collision handling, ready to run.
Pro tip: Always run it with --dry-run first; ask Claude to make that the default so a fat-finger never moves files unexpectedly.
CSV to JSON Converter
17/30You are a Node.js engineer who writes robust data-conversion scripts. <context> I need a Node script that converts a CSV file to JSON, returned as one self-contained, commented script ready to run with node. </context> <inputs> - Input CSV path and output JSON path: [PATHS OR ARGV] - Delimiter and quote char: [E.G. COMMA, DOUBLE-QUOTE] - Type coercion: [KEEP STRINGS / PARSE NUMBERS AND BOOLEANS] - Header row present: [YES / NO, OR SUPPLY COLUMN NAMES] </inputs> <task> Write a script that reads the CSV, correctly parses quoted fields containing commas and escaped quotes and newlines, maps rows to objects using the header (or provided names), optionally coerces numbers and booleans, and writes pretty-printed JSON. Print row and error counts. Do not pull in a CSV library. </task> <constraints> - Node built-ins only; the parser handles quoted fields and embedded delimiters, not a naive split(','). - Validate the file exists; report malformed rows instead of crashing. - Comment the parsing state machine and the coercion rules. </constraints> <format> Return the full script in one code block, then note the run command and how to switch delimiters (e.g. TSV). </format>
Produces a Node CSV-to-JSON converter with a real quoted-field parser and type coercion, ready to run.
Pro tip: Mention if your CSV has quoted commas or newlines inside fields so Claude writes a proper parser, not a split.
Directory Size & Large-File Scanner
18/30You are a Node.js engineer who writes filesystem tooling. <context> I need a script that scans a directory tree and reports sizes and the biggest files, returned as one self-contained, commented Node script ready to run. </context> <inputs> - Root path: [PATH OR ARGV] - Report: [TOTAL SIZE / TOP N LARGEST FILES / SIZE BY EXTENSION] - N for top-largest: [E.G. 20] - Ignore patterns: [E.G. node_modules, .git] </inputs> <task> Write a script that recursively walks the tree (skipping ignored folders), sums total size, tracks the top N largest files, and aggregates bytes by extension. Print a clean, human-readable report with sizes formatted (KB/MB/GB) and a sorted top-N table. Handle permission errors gracefully. </task> <constraints> - Node built-ins only; recursion or an explicit stack, not shelling out to du. - Skip symlink loops and unreadable paths without crashing; comment the walk and formatting. - Byte formatting is a small reusable helper. </constraints> <format> Return the full script in one code block, then note the run command and how to change the ignore list. </format>
Builds a recursive directory scanner reporting total size, top-N largest files, and size by extension, ready to run.
Pro tip: Add node_modules and .git to the ignore list up front or the scan drowns in dependency files.
Minimal JSON REST API Server
19/30You are a Node.js engineer who writes small servers with no framework. <context> I need a tiny REST API server backed by an in-memory store, returned as one self-contained, commented Node script ready to run. </context> <inputs> - Resource name: [E.G. tasks] - Fields on the resource: [E.G. id, title, done] - Port: [E.G. 3000] - Routes I need: [LIST, GET ONE, CREATE, UPDATE, DELETE] </inputs> <task> Write a server using node:http that implements CRUD for the resource with an in-memory array, parses JSON bodies safely, routes by method and path (including an id segment), returns correct status codes (200/201/204/400/404), sets JSON content-type and basic CORS, and generates ids. Seed two example records and log the routes on startup. </task> <constraints> - Node built-ins only, no Express or other packages; handle invalid JSON with a 400. - Comment the router, the body parser, and each handler's status codes. - Return proper 404 for unknown routes and 405 hints where useful. </constraints> <format> Return the full script in one code block, then note the run command plus example curl calls for each route. </format>
Generates a framework-free node:http CRUD API with an in-memory store and correct status codes, ready to run.
Pro tip: Ask Claude for the matching curl commands so you can smoke-test every route the moment the server boots.
Bulk Find-and-Replace Across Files
20/30You are a Node.js engineer who writes safe codebase-wide edit scripts. <context> I need a script that finds and replaces text across many files, returned as one self-contained, commented Node script ready to run. </context> <inputs> - Root folder and file glob: [E.G. ./src, ONLY .js AND .ts] - Find and replace: [LITERAL STRING OR REGEX, PLUS REPLACEMENT] - Dry-run first: [YES / NO] - Backups: [WRITE .bak FILES / NONE] </inputs> <task> Write a script that recursively finds matching files, counts and previews matches per file, and performs the replacement (literal or regex), honoring a --dry-run flag and an optional backup. Print a summary of files changed and total replacements. Skip binary files and the usual ignore folders. </task> <constraints> - Node built-ins only; regex mode escapes correctly and supports flags. - Never write when --dry-run is set; comment the file matching, the replace, and the backup logic. - Skip node_modules, .git, and non-text files by default. </constraints> <format> Return the full script in one code block, then note the run command and the difference between literal and regex mode. </format>
Produces a Node bulk find-and-replace script with dry-run, backups, and regex support, ready to run.
Pro tip: Run it in dry-run mode and read the per-file match preview before letting it write anything.
Small UI Components
5 promptsAccessible Modal Dialog
21/30You are a front-end engineer who builds accessible vanilla-JS components. <context> I need an accessible modal dialog, returned as one self-contained, commented JavaScript snippet (with the minimal CSS) ready to run. </context> <inputs> - Open trigger selector: [E.G. .open-modal] - Modal content: [INLINE HTML / REFERENCED BY DATA-TARGET] - Close options: [X BUTTON, BACKDROP CLICK, ESC KEY] - Return focus to: [THE TRIGGER] </inputs> <task> Write a modal controller that opens on the trigger, traps focus inside the dialog (Tab and Shift+Tab wrap), closes on the X, backdrop click, and Escape, restores focus to the trigger, sets aria-hidden and role=dialog with aria-modal, and locks background scroll while open. Support multiple modals via data-target. Include the minimal CSS. </task> <constraints> - Vanilla JS, no libraries; correct ARIA and a real focus trap. - Comment the focus-trap and keyboard handling; restore body scroll on close. - Works for more than one modal on the page. </constraints> <format> Return the full JavaScript plus minimal CSS in one code block, then note the HTML structure it expects. </format>
Generates an accessible modal with focus trap, Escape/backdrop close, and scroll lock, ready to use.
Pro tip: Ask Claude to return focus to the exact element that opened the modal; skipping this breaks keyboard users.
ARIA Tabs Component
22/30You are a front-end engineer who builds accessible interactive widgets. <context> I need a tabs component with proper keyboard support, returned as one self-contained, commented JavaScript snippet (with minimal CSS) ready to run. </context> <inputs> - Tabs container selector: [E.G. .tabs] - Number of tabs and labels: [DESCRIBE OR READ FROM MARKUP] - Default active tab: [FIRST / BY INDEX] - Activation: [AUTOMATIC ON FOCUS / MANUAL ON ENTER-SPACE] </inputs> <task> Write a tabs controller that wires role=tablist/tab/tabpanel and aria-selected, shows the active panel and hides the rest, supports Left/Right (and Home/End) arrow navigation with roving tabindex, and follows the chosen activation model. Enhance existing markup progressively so content is visible without JS. Include minimal CSS. </task> <constraints> - Vanilla JS, no libraries; full ARIA tab pattern and roving tabindex. - Comment the keyboard map and the aria wiring; support multiple tab groups per page. </constraints> <format> Return the full JavaScript plus minimal CSS in one code block, then note the tab/panel HTML structure it enhances. </format>
Builds an ARIA-compliant tabs widget with arrow-key navigation and roving tabindex, ready to use.
Pro tip: Tell Claude whether tabs activate on focus or on Enter; the manual model is safer when panels load data.
Accordion / FAQ Collapsible
23/30You are a front-end engineer who builds smooth, accessible disclosure widgets. <context> I need an accordion for an FAQ section, returned as one self-contained, commented JavaScript snippet (with minimal CSS) ready to run. </context> <inputs> - Accordion container selector: [E.G. .faq] - Behavior: [ONE OPEN AT A TIME / ALLOW MULTIPLE OPEN] - Start state: [ALL CLOSED / FIRST OPEN] - Animate height: [YES / NO] </inputs> <task> Write an accordion controller using button headers with aria-expanded toggling their panels, supporting the chosen single-vs-multiple open behavior, keyboard operation (Enter/Space), and an optional smooth height animation. Enhance existing markup so it degrades gracefully without JS. Include minimal CSS with a rotating chevron. </task> <constraints> - Vanilla JS, no libraries; each header is a real button with aria-expanded and aria-controls. - Comment the toggle and the single-open logic; animation uses max-height or the details element cleanly. </constraints> <format> Return the full JavaScript plus minimal CSS in one code block, then note the header/panel HTML it expects. </format>
Generates an accessible FAQ accordion with single-or-multi open behavior and smooth animation, ready to use.
Pro tip: For FAQs, pick allow-multiple-open so readers can compare two answers without one snapping shut.
Toast Notification System
24/30You are a front-end engineer who builds small reusable UI systems. <context> I need a toast notification system I can call from anywhere, returned as one self-contained, commented JavaScript module (with minimal CSS) ready to run. </context> <inputs> - Types: [SUCCESS, ERROR, INFO, WARNING] - Position: [TOP-RIGHT / BOTTOM-CENTER / ETC] - Auto-dismiss ms (0 = sticky): [E.G. 4000] - Max visible at once: [E.G. 3] </inputs> <task> Write a toast module exposing toast.success/error/info/warning(message, options) that creates a container if missing, stacks toasts up to the max (queueing extras), auto-dismisses with a pause-on-hover timer, supports a manual close button and an optional action link, and animates in and out. Include the minimal CSS per type. Add a demo firing one of each. </task> <constraints> - Vanilla JS, no libraries; timers pause on hover and resume on leave. - Accessible: container is an aria-live region; comment the queue and timer logic. - No memory leaks: remove elements and clear timers on dismiss. </constraints> <format> Return the full JavaScript plus minimal CSS in one code block with the demo, then note how to change the position. </format>
Builds a callable toast system with types, queueing, pause-on-hover, and aria-live, ready to use.
Pro tip: Set a max-visible cap so a burst of errors queues neatly instead of burying the whole screen in toasts.
Star Rating Input Widget
25/30You are a front-end engineer who builds accessible form widgets. <context> I need an interactive star-rating input, returned as one self-contained, commented JavaScript snippet (with minimal CSS) ready to run. </context> <inputs> - Container selector: [E.G. #rating] - Number of stars: [E.G. 5] - Allow half stars: [YES / NO] - Hidden input name for form submit: [E.G. score] </inputs> <task> Write a widget that renders the stars, fills them on hover and click, sets a value in a hidden input for form submission, supports keyboard (arrow keys to change, Enter to set), and exposes an onChange callback. If half stars are enabled, handle the half-position on hover. Build it as a radiogroup with proper ARIA so it is screen-reader usable. Include minimal CSS. </task> <constraints> - Vanilla JS, no libraries; keyboard and pointer both work; role=radiogroup with aria-checked. - Comment the hover/click math and the half-star handling; hidden input stays in sync. </constraints> <format> Return the full JavaScript plus minimal CSS in one code block, then note how to read the value on form submit. </format>
Generates an accessible star-rating input with keyboard support, half stars, and a hidden form value, ready to use.
Pro tip: Ask for the hidden input so the rating posts with a normal form submit and you get keyboard access for free.
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.
Regex & Text
5 promptsSlugify & Case Converter
26/30You are a JavaScript engineer who writes careful string utilities. <context> I need slugify plus case-conversion helpers, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Helpers I want: [SLUGIFY, CAMEL-CASE, KEBAB-CASE, SNAKE-CASE, TITLE-CASE] - Handle accents/diacritics: [YES, STRIP TO ASCII / NO] - Slug separator: [HYPHEN / UNDERSCORE] - Max slug length: [E.G. 60 OR NONE] </inputs> <task> Write slugify (lowercase, strip or transliterate accents, remove punctuation, collapse spaces to the separator, trim, optional length cap) and the requested case converters, each pure with a doc comment and an example. End with a self-test block running each on tricky inputs (accents, emoji, extra spaces) and logging results. </task> <constraints> - No dependencies; use Unicode normalization for accent stripping when requested. - Comment the regex in each helper; functions are pure and handle empty strings. </constraints> <format> Return the full JavaScript in one code block with the self-test, then note how to switch the separator or length cap. </format>
Produces a slugify plus case-conversion module with accent handling and a self-test, ready to use.
Pro tip: Ask Claude to transliterate accents (cafรฉ โ cafe) so slugs stay clean ASCII for URLs.
Input Validation Regex Module
27/30You are a JavaScript engineer who writes practical validation helpers. <context> I need a small validation module with well-commented regexes, returned as one self-contained JavaScript file ready to run. </context> <inputs> - Validators I need: [EMAIL, URL, PHONE, POSTAL CODE, STRONG PASSWORD] - Locale for phone/postal: [E.G. US / INTERNATIONAL] - Password rules: [MIN LENGTH, UPPER, NUMBER, SYMBOL] - Return style: [BOOLEAN / {valid, reason}] </inputs> <task> Write each requested validator as a function with a documented regex (explaining what each part matches), following the chosen return style, plus a password checker that reports which specific rule failed. End with a self-test block covering valid and invalid samples for each validator and logging pass/fail. </task> <constraints> - No dependencies; regexes are readable and commented, not opaque one-liners. - Be pragmatic on email (RFC-perfect is not the goal); explain the tradeoff in a comment. - Password checker returns actionable reasons, not just false. </constraints> <format> Return the full JavaScript in one code block with the self-test, then note the known limits of each regex. </format>
Builds a commented validation module (email, URL, phone, password) with reasons and a self-test, ready to use.
Pro tip: For passwords, ask for a reason on failure so your form can tell users exactly which rule they missed.
Extract Entities From Text
28/30You are a JavaScript engineer who writes text-parsing utilities. <context> I need to extract structured items from free text, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - What to extract: [EMAILS, URLS, @MENTIONS, #HASHTAGS, PHONE NUMBERS, DOLLAR AMOUNTS] - Dedupe results: [YES / NO] - Preserve order or sort: [ORDER OF APPEARANCE / SORTED] - Return: [ARRAYS PER TYPE / OBJECTS WITH INDEX POSITIONS] </inputs> <task> Write an extract(text) function that returns the requested entity types using well-commented regexes with the global flag, optionally deduping and ordering per the inputs. If index positions are requested, include start/end offsets for each match. End with a self-test on a messy sample paragraph and log the parsed result. </task> <constraints> - No dependencies; each regex is explained inline and tested against edge cases (trailing punctuation on URLs, etc.). - Do not double-count overlapping matches; comment the dedupe and ordering logic. </constraints> <format> Return the full JavaScript in one code block with the self-test, then note how to add a new entity type. </format>
Generates a text-entity extractor (emails, URLs, mentions, hashtags, amounts) with a self-test, ready to use.
Pro tip: Give Claude a real messy sample of your text so the regexes are tuned to your actual formatting quirks.
Template / Mail-Merge Interpolator
29/30You are a JavaScript engineer who writes safe string-templating helpers. <context> I need a small template interpolator for mail-merge style text, returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Placeholder syntax: [E.G. {{name}} OR ${name}] - Support nested keys: [YES, E.G. {{user.email}} / NO] - Missing-value behavior: [LEAVE BLANK / KEEP PLACEHOLDER / THROW] - Optional formatters/filters: [E.G. {{price | currency}} โ YES / NO] </inputs> <task> Write a render(template, data) that replaces placeholders using the chosen syntax, resolves nested keys safely, follows the missing-value policy, and (if enabled) applies simple named formatters like upper, currency, or date. Include a couple of default formatters and a demo merging a template with a sample data object. </task> <constraints> - No dependencies; no eval or new Function โ a regex/replace approach only, for safety. - Comment the placeholder regex, nested-key resolution, and formatter dispatch. - Missing values follow the policy exactly and never render 'undefined'. </constraints> <format> Return the full JavaScript in one code block with the demo, then note how to register a custom formatter. </format>
Builds a safe (no-eval) template interpolator with nested keys and formatters plus a demo, ready to use.
Pro tip: Insist on the no-eval approach; templating user text with new Function is a real injection risk.
Reading Time & Text Stats Utility
30/30You are a JavaScript engineer who writes content-analysis helpers. <context> I need a text-stats utility (reading time, word count, truncation), returned as one self-contained, commented JavaScript module ready to run. </context> <inputs> - Reading speed (WPM): [E.G. 225] - Count from: [PLAIN TEXT / STRIP HTML FIRST] - Truncate mode: [BY WORDS / BY CHARACTERS, WITH AN ELLIPSIS, NO MID-WORD CUT] - Also want: [SENTENCE COUNT / EST. READING GRADE / NONE] </inputs> <task> Write functions for wordCount, readingTime (returns minutes and a friendly label), and truncate (word- or char-based without cutting a word, appending an ellipsis), optionally stripping HTML first and computing the extra stats requested. Handle empty input and multiple spaces. End with a self-test on a sample paragraph logging every stat. </task> <constraints> - No dependencies; HTML stripping via a commented regex when enabled. - truncate never breaks a word mid-way and never adds an ellipsis when nothing was cut; comment the logic. </constraints> <format> Return the full JavaScript in one code block with the self-test, then note how to change the WPM or truncation mode. </format>
Produces a text-stats module (word count, reading time, smart truncate) with a self-test, ready to use.
Pro tip: Tell Claude if your input is HTML so it strips tags before counting; otherwise markup inflates the word count.
Frequently Asked Questions
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.