Implement [infinite scroll / cursor pagination] for a list of [items] in [framework] calling [API]. Handle loading and error states, avoid duplicate requests, preserve scroll position, and include the backend query for cursor pagination.
Coding & Development prompts
Code generation, debugging and documentation
127 prompts
Build a file upload feature in [stack]. Show a progress bar, validate file type and size on client and server, store files in [storage], generate safe file names, and return a URL. Explain security considerations.
File upload with progress
Secure file uploads with progress bars and validation.
Implement a real-time [feature, e.g. chat / live notifications] using WebSockets in [stack]. Include server setup, client connection with reconnect logic, message format, authentication, and how to scale beyond one server.
WebSocket real-time feature
Adds real-time updates like chat or live notifications.
Add a dark mode toggle to my site built with [stack]. Use CSS variables, respect prefers-color-scheme by default, remember the user's choice, avoid a flash of the wrong theme on load, and keep it accessible.
Write a Node.js script that [task, e.g. reads a CSV and calls an API for each row]. Use async/await, limit concurrency to [n], retry failed requests with backoff, log progress, and handle errors without crashing. Include package.json dependencies.
Node.js script with async/await
A clean Node.js script with proper async error handling.
Build a [component, e.g. pricing table / navbar / testimonial slider] with Tailwind CSS. Make it responsive, accessible (keyboard and screen reader friendly), support dark mode, and use a [color] accent. Return the HTML and explain the key classes.
Tailwind CSS component
A polished, responsive UI component built with Tailwind classes.
Review this PostgreSQL schema. Check normalisation, data types, constraints, foreign keys, indexes for likely queries ([queries]), naming consistency, and future scaling issues. Suggest improvements with migration SQL. Schema: [paste schema]
PostgreSQL schema review
Reviews a database schema for performance and integrity issues.
Design a GraphQL schema for [domain, e.g. a blog with posts, authors and comments]. Include types, queries with pagination, mutations, input types, and example resolvers in [language/framework]. Note how to avoid N+1 queries.
Write a GraphQL schema and resolvers
A GraphQL schema with queries, mutations and resolvers.
Refactor this callback-based code to use async/await. Keep the behaviour identical, add proper try/catch error handling, and explain any changes in execution order. Code: [paste code]
Convert callbacks to async/await
Modernises callback-based code to promises and async/await.
Write a Python class for [purpose, e.g. a shopping cart]. Include type hints, docstrings, validation, a clean public API, and pytest unit tests covering normal use and edge cases.
Write a Python class with tests
A well-designed Python class with type hints and unit tests.
My web page has these performance metrics and details: [Lighthouse results / stack / page description]. Identify the biggest causes of slow loading and poor Core Web Vitals, and give prioritised fixes with code examples (images, fonts, JS bundles, caching, rendering).
Web app performance audit
Finds and fixes slow page loads and poor Core Web Vitals.
Write Jest unit tests for this function/module. Cover normal cases, edge cases, error handling, and mock [dependencies]. Use descriptive test names and arrange-act-assert structure. Code: [paste code]