Prompt Library

36 ChatGPT Prompts That Make You a Faster, Better Developer

36 copy-paste prompts

Copy-paste prompts for generating code, fixing bugs, reviewing pull requests, learning frameworks, writing SQL, and designing APIs. Works with any language or stack.

In short: This page contains 36 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

Code Generation & Boilerplate

6 prompts

Generate a Complete Function from Requirements

1/36

✨ What it does

ChatGPT writes a [language] function that [describe what it should do], with typed inputs, edge cases, a docstring, and 3 unit tests, not just the happy path. Fill language and behavior, then run the tests and edit names to match your codebase.

Write a [language] function that [describe what it should do]. Requirements: Input: [describe input types and formats]. Output: [describe expected output]. Edge cases to handle: [list them]. Performance constraint: [if any]. Include: type annotations/hints, JSDoc/docstring with parameters and return type, and 3 unit test cases covering normal input, edge case, and error case. Follow [style guide: PEP 8/Airbnb/Google] conventions.

💡

Pro tip: Always specify the language, style guide, and edge cases. The more constraints you give, the less you have to fix afterward.

Scaffold a New Project Structure

2/36

✨ What it does

ChatGPT scaffolds a new [project type: REST API/web app/CLI tool/library] in [language/framework], with folder structure, boilerplate, and explanations for each directory. List [list 3-5 core features], then create only the folders you will actually use.

I'm starting a new [project type: REST API/web app/CLI tool/library] using [language/framework]. The project needs to: [list 3-5 core features]. Generate: the recommended folder structure with explanations for each directory, boilerplate files I need (config, entry point, package manifest, gitignore), a basic [Docker/CI/testing] setup, and initial dependency list with versions. Follow [monorepo/standard] conventions for [framework]. Don't include any features I didn't list — keep it minimal.

💡

Pro tip: Compare the suggested structure against the official docs for your framework. ChatGPT sometimes suggests outdated conventions, especially for fast-moving frameworks like Next.js or SvelteKit.

Generate CRUD Operations for a Data Model

3/36

✨ What it does

ChatGPT generates Create, Read, Update, and Delete operations from your [language/ORM] model in [paste model/schema definition], including validation, pagination, PATCH updates, and soft delete. Paste the schema, then wire the handlers into your existing routes.

I have this data model in [language/ORM]: [paste model/schema definition] Generate complete CRUD operations: - Create: with input validation and duplicate checking - Read: single by ID + list with pagination, sorting, and filtering - Update: partial update (PATCH semantics), validate changes - Delete: soft delete with [column name] flag Use [framework: Express/FastAPI/Spring/etc.] patterns. Include error handling that returns appropriate HTTP status codes. Add request/response type definitions.

💡

Pro tip: Review the validation logic carefully. ChatGPT tends to be either too permissive or too strict — adjust validation to match your actual business rules.

Convert Code Between Languages

4/36

✨ What it does

ChatGPT converts [source language] code in [paste code] into idiomatic [target language], swapping libraries and warning you where behavior will differ. Paste the source, then review the warnings before you trust the port.

Convert this [source language] code to [target language]: ```[source language] [paste code] ``` Requirements: use idiomatic [target language] patterns (not a line-by-line translation), replace [source language]-specific libraries with [target language] equivalents, maintain the same functionality and error handling, add type annotations appropriate for [target language], and note any behavior differences between the languages that could cause bugs (e.g., integer overflow, null handling, async patterns).

💡

Pro tip: Pay special attention to the behavior difference warnings. A "working" translation that handles null, errors, or concurrency differently can introduce subtle bugs.

Generate Regex with Explanation

5/36

✨ What it does

ChatGPT writes a [language] regex for your match and non-match examples, plus a line-by-line breakdown and test cases. Fill [example 1] and [example 2] for both sides, then run the tests on strings from your real data.

I need a regex pattern in [language] to match: [describe what you want to match, with examples of strings that should and shouldn't match]. Should match: - [example 1] - [example 2] Should NOT match: - [example 1] - [example 2] Provide: the regex pattern, a line-by-line breakdown of what each part does, test cases covering all examples above plus edge cases, any known limitations or false positives, and the compiled/optimized version if applicable.

💡

Pro tip: Test the regex against your real data, not just the examples. Edge cases in regex are infinite — ChatGPT can't anticipate all of your data's quirks.

Create a Type-Safe Configuration Schema

6/36

✨ What it does

ChatGPT builds a type-safe config schema for your [language/framework] project from [List config values: database URL, API keys, feature flags, ports, etc.], with env loading and required versus optional checks. List the real vars, then fail startup on a missing required value.

I need a configuration system for my [language/framework] project. The config includes: [List config values: database URL, API keys, feature flags, ports, etc.] Generate: a type-safe config schema with validation, environment variable loading with sensible defaults, separate handling for required vs optional values, a validation function that fails fast with clear error messages on startup, type definitions so the rest of the codebase gets autocomplete, and an example .env file. Use [Zod/Pydantic/joi/whatever is standard for the language].

💡

Pro tip: Add the .env.example to your repo and add .env to .gitignore. Every developer who clones your project will thank you.

Prompts get you started. Tutorials level you up.

A growing library of 300+ hands-on AI tutorials. New tutorials added every week.

Start 7-Day Free Trial

Debugging & Error Fixing

6 prompts

Diagnose an Error Message

7/36

✨ What it does

ChatGPT explains an error in your [language/framework] project from [paste full error message and stack trace] and [paste the code around the error], including root cause, not just a patch. Paste both, then apply the fix and add the guard that prevents the same class of bug.

I'm getting this error in my [language/framework] project: ``` [paste full error message and stack trace] ``` Relevant code: ```[language] [paste the code around the error] ``` Context: [what you were doing when it happened]. Don't just fix the symptom. Explain: what this error means in plain English, the root cause (not just the line that threw), why this specific input or state triggers it, the fix with explanation of why it works, and how to prevent this class of error in the future.

💡

Pro tip: Always include the full stack trace, not just the error message. The trace tells ChatGPT where the error originated vs where it surfaced — which are often different.

Fix a Bug Without Breaking Other Things

8/36

✨ What it does

ChatGPT diagnoses a bug from [describe the unexpected behavior], expected [what should happen], actual [what happens instead], and [paste code], checking side effects before it suggests a fix. Fill all four, then apply only the change that leaves your other paths intact.

I have a bug: [describe the unexpected behavior]. Expected behavior: [what should happen]. Actual behavior: [what happens instead]. Here's the relevant code: ```[language] [paste code] ``` Before suggesting a fix: identify all code paths affected, check if the fix could break any existing functionality, look for other places in the code with the same pattern (they might have the same bug). Then provide: the minimal fix (smallest change that solves the problem), explanation of why it works, a test case that proves the bug is fixed, and a test case that proves existing functionality still works.

💡

Pro tip: Write the test case BEFORE applying the fix. Run it to confirm it fails, apply the fix, confirm it passes. This is the essence of test-driven bugfixing.

Debug a Performance Problem

9/36

✨ What it does

ChatGPT analyzes why [specific operation or endpoint] is slow in your [language/framework] app, given [current latency/time], [target performance], and [paste the slow code]. Paste the numbers and code, then fix the highest-ranked bottleneck first.

My [language/framework] application is slow. Here's what I know: What's slow: [specific operation or endpoint] How slow: [current latency/time] Expected: [target performance] Scale: [data size, concurrent users, etc.] Relevant code: ```[language] [paste the slow code] ``` Analyze: what's the time complexity of this code? Where are the likely bottlenecks (N+1 queries, unnecessary loops, blocking calls, memory allocation)? Suggest fixes ranked by impact: highest-impact/lowest-effort first. For each fix, estimate the expected improvement and explain why.

💡

Pro tip: Profile before optimizing. If you have actual profiling data (flame graphs, slow query logs), paste that too — it gives ChatGPT concrete data instead of guessing.

Explain Why Code Works (When You Don't Understand It)

10/36

✨ What it does

ChatGPT explains inherited [language] code from [paste mysterious code]: what it does, why it was written that way, and which edge cases it hides. Paste the mystery, then change nothing until you can explain it back in your own words.

I inherited this code and I don't understand what it does or why it works: ```[language] [paste mysterious code] ``` Explain: what does this code do, step by step in plain English? Why was it written this way instead of the obvious/simple way? What edge cases or problems is it handling that aren't obvious? Are there any bugs or issues hiding in it? If I needed to modify this code, what would I need to be careful about? Add inline comments that explain the non-obvious parts.

💡

Pro tip: Check git blame for the commit message that introduced the code. Often the original developer left context about why it's written that way.

Fix a Flaky Test

11/36

✨ What it does

ChatGPT diagnoses a flaky [language] test from [paste test] and [paste the code being tested], looking for races, shared state, and order dependence. Paste both, then stabilize the cause you actually have instead of adding a sleep.

I have a flaky test that passes sometimes and fails sometimes: Test code: ```[language] [paste test] ``` Code under test: ```[language] [paste the code being tested] ``` Failure pattern: [describe when it fails — randomly, on CI only, after other tests, etc.] Diagnose the likely cause: timing/race condition, shared mutable state, external dependency, order-dependent setup, floating point comparison, or timezone issue? Suggest a fix that makes the test deterministic. If the test is testing the wrong thing, suggest what it should test instead.

💡

Pro tip: If a test is flaky because the underlying code has a race condition, don't fix the test — fix the code. A flaky test is sometimes the messenger.

Trace a Data Flow Through Multiple Functions

12/36

✨ What it does

ChatGPT traces data from [entry point/function call] through [paste all relevant functions/files], showing transforms, side effects, and an ASCII flow. Paste the path, then mark the hop where the value becomes wrong in your run.

I need to understand how data flows through this code. Starting from [entry point/function call], trace the data transformation step by step: ```[language] [paste all relevant functions/files] ``` For each step: what function is called and with what arguments, how the data is transformed, what side effects occur (database writes, API calls, state changes), where errors could occur and how they propagate, and what the final output looks like. Draw an ASCII diagram showing the flow.

💡

Pro tip: Add logging at each step of the flow and run the actual code. Compare real output against ChatGPT's trace to catch any discrepancies.

Code Review & Optimization

6 prompts

Review Code for Production Readiness

13/36

✨ What it does

ChatGPT reviews [paste code] for production: security, error handling, crashes, and debuggability of this [describe what the code does] in a [type of application]. Paste the code, then fix the security and failure gaps before your cosmetics.

Review this code for production readiness: ```[language] [paste code] ``` Context: this is [describe what the code does] in a [type of application]. Check for: security vulnerabilities (injection, XSS, auth bypass, data exposure), error handling gaps (what happens when things fail?), edge cases that could cause crashes or data corruption, performance issues at scale, logging and observability (can we debug this in production?), and code maintainability (will someone understand this in 6 months?). Rate each issue as critical/warning/suggestion. Don't flag style preferences — only things that could cause real problems.

💡

Pro tip: Run this on your code BEFORE opening a PR. Fixing issues before review is faster than fixing them after review comments.

Refactor for Readability Without Changing Behavior

14/36

✨ What it does

ChatGPT refactors [paste code] in [language] for readability without changing behavior: names, smaller functions, guard clauses, and less nesting. Paste the function, then run your tests after each small extract.

Refactor this code to be more readable without changing its behavior: ```[language] [paste code] ``` Apply these specific improvements only: extract meaningful variable names, break long functions into smaller ones with clear names, reduce nesting depth (guard clauses, early returns), simplify conditional logic, remove dead code or unnecessary complexity. Show the refactored version and explain each change. Confirm that the refactored code handles the same edge cases as the original. Do NOT add features, change the API, or "improve" the architecture.

💡

Pro tip: Make sure you have tests before refactoring. If you don't, write tests for the current behavior first, then refactor, then verify tests still pass.

Optimize a Slow Database Query

15/36

✨ What it does

ChatGPT optimizes a slow query in [database: PostgreSQL/MySQL/MongoDB/etc.] from [paste query] and [paste relevant CREATE TABLE statements or describe structure], including indexes you can create. Paste query and schema, then EXPLAIN the new plan before you ship it.

This query is slow in [database: PostgreSQL/MySQL/MongoDB/etc.]: ```sql [paste query] ``` Table schema: ```sql [paste relevant CREATE TABLE statements or describe structure] ``` Table sizes: [approximate row counts]. Current execution time: [time]. The query plan shows: [paste EXPLAIN output if available]. Suggest optimizations: query rewriting (joins, subqueries, CTEs), index recommendations with CREATE INDEX statements, schema changes if needed, and caching strategy if the query runs frequently. For each suggestion, explain the expected improvement and any trade-offs (write performance, storage, maintenance).

💡

Pro tip: Always run EXPLAIN (or EXPLAIN ANALYZE in PostgreSQL) before and after optimization. Without the query plan, you're guessing.

Reduce Code Duplication Across Files

16/36

✨ What it does

ChatGPT compares similar [language] snippets in [paste code] and [paste similar code], naming what is truly duplicated versus what should stay separate. Paste both files, then extract only the shared pattern you are sure about.

I have similar code repeated across multiple files: File 1: ```[language] [paste code] ``` File 2: ```[language] [paste similar code] ``` [Add more files if applicable] Identify: what's actually duplicated vs what just looks similar, a shared abstraction that captures the common pattern, the right level of abstraction (don't over-abstract), and how each callsite should use the shared code. Show the extracted shared code AND the updated callsites. Make sure the abstraction handles all the variations between the originals.

💡

Pro tip: The Rule of Three: don't abstract until you see the pattern three times. Two similar pieces of code might diverge later. Three confirms the pattern.

Add Error Handling to Happy-Path Code

17/36

✨ What it does

ChatGPT finds every failure point in happy-path [language] code from [paste code] (network, I/O, parse, nulls) and what should happen in each catch. Paste the function, then give every catch a real retry, fallback, or error your user can see.

This code only handles the happy path: ```[language] [paste code] ``` Identify every point where something can fail: network calls, file I/O, parsing, user input, null/undefined values, database operations, type mismatches. For each failure point: what error could occur, what should happen when it does (retry, fallback, propagate, log), the appropriate error type/class, and user-facing vs internal error messaging. Add comprehensive error handling. Don't catch and swallow errors — every catch block should do something meaningful.

💡

Pro tip: Errors at system boundaries (user input, API calls, file system) need handling. Errors in internal code usually mean a bug and should be thrown, not caught.

Write Missing Tests for Existing Code

18/36

✨ What it does

ChatGPT writes a [testing framework: Jest/pytest/JUnit/etc.] suite for [paste code] covering public methods, edges, and error cases. Paste the code and pick the framework, then run the suite and add the case that failed on you.

I need tests for this existing code: ```[language] [paste code] ``` Generate a test suite using [testing framework: Jest/pytest/JUnit/etc.] that covers: every public function/method, normal inputs with expected outputs, edge cases (empty inputs, max values, null, special characters), error conditions (what should throw/reject/return errors), and integration between functions if applicable. For each test, explain what it's verifying and why that case matters. Organize tests by function with describe/context blocks. Aim for 90%+ code coverage.

💡

Pro tip: Run the tests after generating them. ChatGPT sometimes writes tests that pass for the wrong reason or reference APIs incorrectly. Green tests aren't automatically correct tests.

Like these prompts? There are full tutorials behind them.

Learn the workflows, not just the prompts. 300+ easy-to-follow tutorials inside AI Academy — and growing every week.

Try AI Academy Free

Learning New Languages & Frameworks

6 prompts

Learn a New Language by Comparing to One You Know

19/36

✨ What it does

ChatGPT teaches [new language] by pairing each concept with the [known language] version you already know, plus the gotchas that trip switchers. Fill both languages, then write a tiny program in the new one using only those pairs.

I'm an experienced [known language] developer learning [new language]. Teach me [new language] by comparison: for each core concept (variables, functions, control flow, data structures, error handling, async, types, modules), show the [known language] way I already know, then the [new language] equivalent with idiomatic patterns. Highlight the "gotchas" — things that look the same but behave differently. What are the biggest mindset shifts I need to make? What [known language] habits will hurt me in [new language]? Give me a learning roadmap: what to learn in what order for a developer at my level.

💡

Pro tip: Build something small (a CLI tool or API) in the new language within the first week. Reading without building creates false confidence.

Understand a Framework's Architecture and Conventions

20/36

✨ What it does

ChatGPT explains [framework] architecture: the problem it solves, routing and state, automatic magic, and folder conventions. Name the framework, then start a sample app and notice the magic instead of fighting your defaults.

I'm new to [framework]. Explain its architecture and key conventions: what problem does it solve and what's its philosophy? Core concepts (routing, state management, data fetching, etc.) — explain each in 2-3 sentences. The "magic" — things that happen automatically that I should know about. File and folder conventions (what goes where and why). The request/response lifecycle (or component lifecycle). Common antipatterns — things beginners do wrong. Show me a minimal but complete example that demonstrates the core patterns working together.

💡

Pro tip: After reading this, follow the official tutorial. You'll understand it 3x faster because you already have the mental model.

Explain a Design Pattern with a Real-World Example

21/36

✨ What it does

ChatGPT explains the [pattern name: Observer/Strategy/Factory/etc.] pattern for a [language] developer, with a real example, when it is overkill, and the trade-offs. Name the pattern, then apply it only if your current code has the problem it solves.

Explain the [pattern name: Observer/Strategy/Factory/etc.] design pattern for a [language] developer. Include: the problem it solves (when would I need this?), a simple real-world analogy, a code example that's realistic (not just Dog extends Animal), when to use it vs when it's overkill, the trade-offs (what do you give up?), and how [language]'s specific features make this pattern easier or unnecessary. If [language] has a built-in feature that replaces this pattern, show that instead.

💡

Pro tip: Don't learn patterns in isolation. Wait until you hit a real problem in your code, then look up the pattern that solves it. Patterns learned from real pain stick better.

Build a Feature Using an Unfamiliar Library

22/36

✨ What it does

ChatGPT walks you through [feature description] using [library/package name] in [language], covering setup, full code, and first-time pitfalls. Fill all three, then implement the feature and check the pitfalls against your install.

I need to implement [feature description] using [library/package name] in [language]. I've never used this library before. Walk me through: what this library does and its core API, installation and setup, a step-by-step implementation of my feature with complete code, what each part of the code does and why, configuration options I should know about, common pitfalls with this library, and how to test that it's working correctly. Use version [X] of the library. Don't use deprecated APIs.

💡

Pro tip: Specify the library version. Library APIs change frequently, and ChatGPT might show you patterns from an older version. Check the docs for breaking changes.

Understand the Difference Between Similar Technologies

23/36

✨ What it does

ChatGPT compares [technology A] and [technology B] (and [C] if you have a third) for [use case], covering strengths, performance, learning curve for [your background], and ops. Fill the blanks, then pick the one your team can operate.

I'm choosing between [technology A] and [technology B] (and [C] if applicable) for [use case]. Compare them on: what each is best at (core strength), performance characteristics and benchmarks, learning curve for a developer with [your background], ecosystem maturity (docs, community, packages), deployment and operational complexity, long-term viability (funding, adoption trends, corporate backing), and specific advantages for my use case: [describe project]. Give me a clear recommendation with your reasoning. Don't say "it depends" without then actually telling me what it depends on.

💡

Pro tip: Weight "ecosystem and community" heavily. The technically best tool with poor documentation and few Stack Overflow answers will slow you down more than a slightly worse tool with great community support.

Create a Learning Project That Covers Key Concepts

24/36

✨ What it does

ChatGPT designs a learning project in [language/framework] you can finish in [timeframe], with milestones that cover the concepts you listed. Set the timeframe, then build milestone one before you add extra features.

I'm learning [language/framework] and want a project that teaches me the fundamentals through building. My experience level: [beginner/intermediate/advanced in programming, beginner in this specific technology]. Design a project that: is completable in [timeframe], covers these core concepts: [list concepts you want to learn], has clear milestones I can build incrementally, is interesting enough to actually finish (not another todo app), and teaches concepts in the right order (foundations before advanced). For each milestone: describe what to build, what concept it teaches, provide starter code or pseudocode, and suggest what to Google when I get stuck.

💡

Pro tip: Commit after each milestone. If you get stuck on milestone 4, you still have a working project from milestone 3 to show for your effort.

Database & SQL Queries

5 prompts

Write a Complex SQL Query from Plain English

25/36

✨ What it does

ChatGPT writes a [database: PostgreSQL/MySQL/SQLite/etc.] query from [describe what data you need and any conditions], using your schema in [paste CREATE TABLE statements or describe schema], with JOIN reasons. Paste the schema and the English ask, then run EXPLAIN on a copy of prod-sized data.

I need a SQL query for [database: PostgreSQL/MySQL/SQLite/etc.]. In plain English, I want to: [describe what data you need and any conditions]. My relevant tables: ```sql [paste CREATE TABLE statements or describe schema] ``` Write the query with: proper JOIN types with explanation of why each is used, WHERE clauses with parameterized inputs (not hardcoded values), appropriate GROUP BY and aggregate functions if needed, ORDER BY and LIMIT for usability, and aliases that make the output readable. Also provide: a line-by-line explanation of the query, the expected output format with sample data, and performance notes (will this be slow on large tables?).

💡

Pro tip: Always test with LIMIT 10 first to verify the output looks right before running the full query. A wrong query on a million rows wastes time and resources.

Design a Database Schema for a Feature

26/36

✨ What it does

ChatGPT designs a schema for [describe feature/application] from [List data requirements and relationships], with types, keys, and indexes for the queries you expect. List the real relationships, then create the tables and try your common query.

I'm building [describe feature/application] and need a database schema. Requirements: [List data requirements and relationships] Design a schema with: table definitions including column types, constraints, and defaults, primary keys and foreign key relationships, indexes for expected query patterns: [describe common queries], consideration of: data integrity, normalization (or deliberate denormalization), soft deletes if appropriate, and audit fields (created_at, updated_at). Use [database] syntax. Explain each design decision. Flag any areas where I'll need to choose between normalization and query performance.

💡

Pro tip: Schema changes are expensive in production. Spend time getting the schema right before writing application code. It's much easier to change code than to migrate data.

Write a Database Migration

27/36

✨ What it does

ChatGPT writes UP and DOWN migrations for [database] given [Describe the change: add column, create table, modify constraint, etc.] and [paste current relevant tables], including backfill for existing rows. Paste the current tables, then run DOWN on your staging copy before UP in prod.

I need to make this change to my [database] schema: [Describe the change: add column, create table, modify constraint, etc.] Current schema: ```sql [paste current relevant tables] ``` Generate: an UP migration that makes the change, a DOWN migration that reverses it, handling for existing data (defaults, backfills, data transformation), consideration of zero-downtime deployment (can this run while the app is live?), and the ORM migration if I'm using [Prisma/Sequelize/Django/Rails/etc.]. Flag any destructive changes that can't be undone.

💡

Pro tip: Always test migrations against a copy of production data, not an empty database. Migrations that work on empty tables can fail on tables with millions of rows.

Optimize a Report Query

28/36

✨ What it does

ChatGPT plans how to get a dashboard query under [target time] given [paste query], [row counts for each table], current [time], and [frequency: on every page load, hourly, daily]. Paste those facts, then try the cheapest fix (index or cache) before your new table.

I have a reporting query that's too slow for a dashboard: ```sql [paste query] ``` Table sizes: [row counts for each table]. Current execution time: [time]. This runs [frequency: on every page load, hourly, daily]. I need it under [target time]. Suggest a strategy: can the query itself be optimized? Would a materialized view or summary table help? Should I pre-compute results on a schedule? What indexes would help? Can I trade some accuracy for speed (approximate counts, etc.)? Provide the optimized solution with implementation steps.

💡

Pro tip: For dashboards, pre-computed materialized views updated on a schedule are almost always faster than optimizing the live query. Users rarely need real-time data in reports.

Debug a Query That Returns Wrong Results

29/36

✨ What it does

ChatGPT debugs a SQL result mismatch from [paste query], expected [describe what you expect to see], actual [describe what you're actually getting], and [paste relevant tables]. Paste query and a sample, then fix the JOIN or filter that invented or dropped rows.

My SQL query returns unexpected results: ```sql [paste query] ``` Expected: [describe what you expect to see] Actual: [describe what you're actually getting] Schema: ```sql [paste relevant tables] ``` Sample data that demonstrates the problem: ```sql [paste or describe sample data] ``` Diagnose: is it a JOIN issue (wrong type, missing condition, cartesian product)? A GROUP BY issue (aggregating incorrectly)? A WHERE clause issue (filtering too much or too little)? A NULL handling issue? Show me the corrected query and explain exactly where the logic went wrong.

💡

Pro tip: Break complex queries into CTEs and check the output of each CTE independently. The bug is usually in one specific step, not the whole query.

Go from copy-pasting to actually mastering AI.

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

Start Your Free Trial

API Design & Documentation

7 prompts

Design a RESTful API for a Feature

30/36

✨ What it does

ChatGPT designs a REST API for [describe feature/resource] that supports [list operations] for [describe who calls this API and their auth level], with paths, JSON schemas, auth, and errors. Name the resource and callers, then implement one endpoint and match your error shape.

Design a REST API for [describe feature/resource]. The API needs to support: [list operations]. Users: [describe who calls this API and their auth level]. Provide: endpoint list with HTTP methods, paths, and descriptions, request/response schemas for each endpoint (JSON), authentication and authorization requirements, pagination strategy for list endpoints, error response format with specific error codes, rate limiting recommendations, and versioning strategy. Follow REST best practices. Use [camelCase/snake_case] for field names.

💡

Pro tip: Get API design reviewed by the team that will consume it before building it. An API that makes sense to the builder might confuse the consumer.

Write API Documentation from Code

31/36

✨ What it does

ChatGPT writes API docs from [paste route handlers/controllers] in [language]: method, path, auth, params, and example JSON plus curl. Paste the handlers, then hit each curl against your local server and correct what drifted.

Generate API documentation for these endpoints: ```[language] [paste route handlers/controllers] ``` For each endpoint, document: HTTP method and path, description of what it does, authentication requirements, request parameters (path, query, body) with types and validation rules, response format with example JSON for success and each error case, and curl examples that work out of the box. Format as [OpenAPI/Markdown/JSDoc]. Include a "Getting Started" section showing how to authenticate and make the first API call.

💡

Pro tip: Keep documentation next to the code it describes (in comments or co-located files). Documentation in a separate wiki always goes stale.

Design Error Handling for an API

32/36

✨ What it does

ChatGPT designs a consistent error format for your [language/framework] API: JSON shape, error codes, HTTP mapping, and a single handler. Name the stack, then route every exception through that handler before you add endpoints.

Design a consistent error handling strategy for my [language/framework] API. Current endpoints handle errors inconsistently. I need: a standard error response format (JSON structure), error code taxonomy (categories and specific codes), mapping from exceptions/errors to HTTP status codes, a middleware/handler that catches errors and formats responses, client-friendly error messages vs internal error details, logging strategy (what to log at each level), and examples of handling: validation errors, not found, auth failures, rate limits, server errors. Show implementation code.

💡

Pro tip: Never expose internal error details (stack traces, SQL queries, file paths) in API responses. Log them server-side, return a reference ID the client can share with support.

Generate TypeScript Types from an API Response

33/36

✨ What it does

ChatGPT infers TypeScript types from [paste JSON response], with specific types, optional nulls, nested interfaces, and JSDoc. Paste a real payload, then import the types and fix any field your API sometimes omits.

Generate TypeScript types from this API response: ```json [paste JSON response] ``` Requirements: infer the most specific types (not just `string` for everything), mark nullable fields as optional, create separate interfaces for nested objects, add JSDoc comments describing each field, export everything, handle array items with proper typing, and create a union type for any enum-like string values. Also generate a type guard function for runtime validation.

💡

Pro tip: If the API has documentation or an OpenAPI spec, use a code generator instead. Types generated from examples may miss optional fields that weren't in your sample.

Write Integration Tests for API Endpoints

34/36

✨ What it does

ChatGPT writes integration tests in [testing framework/tool: Supertest/requests/RestAssured/etc.] for [paste route definitions or OpenAPI spec], covering 200, 400, 401, and 404. Paste the routes, then run the suite against a test database you control.

Write integration tests for these API endpoints using [testing framework/tool: Supertest/requests/RestAssured/etc.]: ```[language] [paste route definitions or OpenAPI spec] ``` For each endpoint, test: successful operation (200/201), validation failures (400), authentication requirements (401/403), resource not found (404), and any business logic edge cases. Include: test setup/teardown (database seeding, auth tokens), helper functions for common operations, assertions on response body, status code, and headers, and tests for race conditions if applicable. Organize with clear test names that describe the scenario.

💡

Pro tip: Run integration tests against a separate test database that gets reset before each test suite. Never test against production data.

Design a Webhook System

35/36

✨ What it does

ChatGPT designs webhooks for [language/framework] that fire on [describe events that should trigger webhooks], covering subscribe API, payloads, async delivery, retries, and signatures. Fill both blanks, then send one signed event to a test URL you own.

I need to add webhooks to my [language/framework] application. When [describe events that should trigger webhooks], I need to notify external systems. Design: the webhook registration API (how clients subscribe), payload format for each event type, delivery mechanism (sync vs async, queue-based), retry strategy with exponential backoff, signature verification for security (HMAC), a dashboard/API for clients to see delivery history and failures, and rate limiting to protect both our system and the receiver. Show implementation code for the core delivery mechanism.

💡

Pro tip: Make webhook delivery async (use a job queue). Synchronous webhook delivery means a slow or down receiver slows down your entire application.

Convert Between API Styles

36/36

✨ What it does

ChatGPT converts a [REST/GraphQL/gRPC] API in [paste API definition] to [target style: REST/GraphQL/gRPC], keeping auth, errors, and pagination, plus a mapping of old to new. Paste the current spec, then update your clients using the mapping, not guesswork.

I have this [REST/GraphQL/gRPC] API: [paste API definition] Convert it to [target style: REST/GraphQL/gRPC]. Maintain: the same data access patterns, authentication/authorization, error handling, and pagination. Show: the new API definition, any schema/type definitions needed, a mapping document showing old → new endpoints, migration notes for clients transitioning, and what features of the new style we should take advantage of. Highlight anything that doesn't translate cleanly between styles.

💡

Pro tip: Don't convert just because a technology is trending. Each API style has genuine trade-offs. REST for simplicity, GraphQL for flexible queries, gRPC for performance.

Free tool

Prompt Optimizer

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

Try it free →

Frequently Asked Questions

No. ChatGPT accelerates developers — it doesn't replace them. It generates boilerplate quickly, explains unfamiliar code, and suggests solutions. But it can't understand your business requirements, make architectural decisions, debug complex system interactions, or take responsibility for production code. The developers who use AI tools effectively will outperform those who don't, but the core skill remains: understanding what to build and why. These prompts make you faster at the "how" so you can spend more time on the "what" and "why."
It varies by complexity. For straightforward tasks (CRUD operations, boilerplate, simple functions), it's highly reliable — maybe 90%+ correct. For complex logic, edge cases, and system integration, reliability drops significantly. Always: read and understand every line before using it, test the output (especially edge cases and error handling), verify security-sensitive code against OWASP guidelines, and check that it uses current APIs and patterns (not deprecated ones). Treat AI-generated code like code from a junior developer — helpful, but needs review.
ChatGPT performs best with languages that have the most training data: Python, JavaScript/TypeScript, Java, C#, Go, and Ruby. It's also strong with SQL, HTML/CSS, and Bash. Performance is moderate for Rust, Kotlin, Swift, and PHP. It's weakest with niche or newer languages (Zig, V, Gleam), domain-specific languages, and proprietary frameworks. For any language, it handles standard library code better than obscure third-party packages. Always verify that generated code uses the correct API for your specific library version.
Use both for different purposes. Copilot excels at inline code completion — it's faster for writing code line by line within your editor. ChatGPT (via these prompts) excels at higher-level tasks: designing architecture, debugging complex issues, code review, explaining unfamiliar codebases, and learning new technologies. Copilot is your pair programmer for typing. ChatGPT is your senior developer for thinking. Many developers use Copilot for autocomplete while coding and ChatGPT for planning, debugging, and learning.
Three rules improve every coding prompt: be specific about language, framework, and version (don't say "write a web app" — say "write a Next.js 14 App Router page using TypeScript and Tailwind"). Include context (paste your actual code, schemas, error messages, and constraints). State what you don't want (no deprecated APIs, no unnecessary dependencies, no over-engineering). The prompts in this library follow these patterns — adapt them to your specific stack and use case.

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.