AI pair programmer for coding assistance
Get AI-powered code suggestions, entire functions, and explanations directly in your editor as you code.
10 ready-to-use prompts — click any card to copy, or paste into the writer above.
// TypeScript. Write a function that takes an array of objects with name and score properties, removes duplicates keeping the highest score, sorts descending, and returns the top N results. Include JSDoc comments and handle null inputs gracefully.
// Write comprehensive Jest unit tests for the function below. Include: happy path, edge cases for empty arrays, null inputs, duplicate values, boundary conditions, and a test for performance with 10,000 items: [paste your function]
// Refactor this function to follow clean code principles. Remove duplication, improve naming, add error handling, reduce complexity, and add JSDoc. Explain each change you made and why: [paste your messy code]
// React + TypeScript. Write a custom hook useApiData that fetches from a URL, handles loading/error/success states, caches results for N minutes using useRef, cancels requests on unmount with AbortController, and auto-refetches when dependencies change.
// Node.js + Express + TypeScript. Write a POST /api/users/:id/settings endpoint that validates the request body against a Zod schema, updates the user settings in a PostgreSQL database using Prisma, logs the change with the user ID and timestamp, and returns appropriate HTTP status codes with error details.
// SQL (PostgreSQL). The following query takes 8 seconds on a table with 5 million rows. Analyze it, explain why it is slow, rewrite it for performance, and suggest the indexes I should add: [paste your slow query]
// TypeScript. Implement the Observer pattern for a real-time notification system. Multiple components should be able to subscribe to events like user.login, order.placed, payment.failed. Show the full implementation with a working example.
// JavaScript. Convert this callback-based function to use async/await. Add proper error handling with try/catch, handle all edge cases, and make sure it handles Promise.allSettled for parallel operations where appropriate: [paste your callback code]
// Generate JSDoc documentation and a README section for this module. Include: what it does, all parameters with types and descriptions, return values, thrown errors, usage examples for the 3 most common use cases, and known limitations: [paste your module]
// Perform a security audit on this code. Check for: SQL injection, XSS vulnerabilities, insecure direct object references, missing input validation, exposed secrets, unsafe dependencies, and improper error handling. For each issue, show the fix: [paste your code]