Guide

ChatGPT for Coding in 2026: 10 Real Use Cases (With Prompts)

10 real ChatGPT prompts for developers: debugging, tests, SQL, regex, and code review, plus verified pricing and honest limits versus Claude Code and Cursor.

Most developers already have ChatGPT open in a tab. The question is what it's actually good for versus what wastes time or ships a bug you didn't catch. This is a working list, not a hype piece: ten prompts engineers run daily, where they hold up, and where the model quietly makes something up. (Devshot covers AI and dev tools daily.)

ChatGPT is strong at explaining, translating, and drafting: a stack trace into a diagnosis, a vague spec into a first-pass function, a half-remembered regex into a working pattern. It's weak at anything needing your actual codebase, dependency versions, or what happens when the code runs. Treat it like a well-read colleague who has never seen your repo and can't run your test suite. Useful constantly. Trusted blindly, never.

Which Plan (and When a Coding Agent Beats ChatGPT)

Here's what OpenAI currently charges, verified directly from chat.openai.com's pricing page:

  • Free ($0/month): GPT-5.5 Instant, 27K context window, tight message caps. Fine for a one-off question, not a working session.
  • Go ($8/month): more messages, a bigger 54K window, still built for casual chat, not dev workloads.
  • Plus ($20/month): GPT-5.6, 256K reasoning context, expanded Codex access, custom GPTs, projects. The tier most developers should buy.
  • Pro (from $100/month): 5x-20x usage, 400K context, maximum Codex tasks. Worth it only if you hit Plus's limits weekly.
  • Business (custom, 2-seat minimum): admin console, SSO, data excluded from training by default. Buy it for compliance, not coding power.

The part that matters more than price: "ChatGPT" means the chat interface, desktop app, or browser extension, a place you paste code and ask questions. It doesn't read your repository and can't run anything unless you paste the output back in.

OpenAI's own answer to that gap is Codex, a separate agentic tool with a CLI and IDE extension, bundled into Plus and up. Codex, Claude Code, Cursor's agent mode, and Copilot's agent mode compete in the same category: they index your repo, edit multiple files, and run build and test commands in a loop. Claude Code ships inside Claude Pro ($20) and Max (from $100). Cursor is $16 Individual, $32 Teams. Copilot is $10 Pro, $39 Pro+.

If your work is "explain this, write this function, debug this trace," ChatGPT on Plus is good and cheap. If it's "implement this across twelve files and make the tests pass," you want a coding agent with repo context instead. Most engineers run both.

10 Ways Developers Actually Use ChatGPT

1. Explain code you didn't write

The most common use case, and one of the safest. Good for onboarding onto a legacy module or a dependency's internals before you patch around it.

Explain what this function does, line by line where it's not obvious.
Then tell me: what are the edge cases it handles, what happens if
`items` is empty or None, and is there anything here that looks like
a bug rather than intentional behavior?

def reconcile(items, ledger):
    seen = {}
    for i in items:
        key = (i.account_id, i.posted_at.date())
        seen.setdefault(key, []).append(i)
    ...

Paste the whole function, not a snippet. Half a function with no context is how you get a plausible-sounding explanation of the wrong thing.

2. Write a function from a spec

Give it the exact signature, types, and one concrete example. A vague description gets a vague function back.

Write a Python function `chunk_by_weight(items: list[dict], max_weight: float) -> list[list[dict]]`
that splits a list of items (each with a "weight" key) into sublists
where no sublist's total weight exceeds max_weight. Preserve original
order. If a single item's weight exceeds max_weight on its own, put it
alone in its own sublist rather than raising. Include a docstring and
one usage example in the docstring.

Name the edge case you actually care about (here, the oversized single item) or you get a naive implementation that breaks on real data.

3. Debug a stack trace

Paste the full trace, not just the last line. It needs the call chain to reason about where the bug actually lives versus where it just surfaced.

I'm getting this error and I don't understand why, since the function
above it checks for None. Walk me through what's likely happening,
and give me two hypotheses ranked by likelihood.

Traceback (most recent call last):
  File "worker.py", line 88, in process_batch
    result = handler(item)
  File "worker.py", line 41, in handler
    return item.metadata["source"]["id"]
TypeError: 'NoneType' object is not subscriptable

# handler():
def handler(item):
    if item is None:
        return None
    return item.metadata["source"]["id"]

The trap here: the check guards item, not item.metadata["source"]. ChatGPT is good at spotting that mismatch. It can't tell you why source is None in production, since it has no access to your data. That part's on you.

4. Write tests

Name the framework and the cases that matter. Left unguided, it writes happy-path tests and calls it done.

Write pytest unit tests for this function. I want cases for: normal
input, an empty list, a single item over max_weight, all items exactly
at max_weight, and negative weights (should raise ValueError). Use
parametrize where it reduces duplication. Don't test implementation
details, test behavior.

def chunk_by_weight(items, max_weight):
    ...

"Write tests for this" alone gets you three trivial tests that miss the edge case that actually breaks in production.

5. Refactor without changing behavior

State the constraint: same inputs, same outputs, different internals. Otherwise you get a rewrite that "improves" behavior you were relying on.

Refactor this function to reduce nesting and improve readability.
Do not change any behavior, including error messages and the order
operations happen in. Explain each change in one line so I can verify
nothing shifted.

def validate_order(order):
    if order:
        if order.get("items"):
            if len(order["items"]) > 0:
                for item in order["items"]:
                    if not item.get("sku"):
                        return False, "missing sku"
    return True, None

Diff the output yourself. A "cleaned up" early return can silently change which error message a caller sees first.

6. Build a regex you don't want to write by hand

A genuinely strong use case: regex is pure pattern matching, and the model doesn't need to know anything about your system to get it right.

Write a regex that matches valid semantic version strings (e.g. 1.2.3,
2.0.0-beta.1, 1.4.10+build.5) and captures major, minor, patch, and an
optional prerelease/build suffix as named groups. Show the pattern,
name each group, and give me 5 example strings it should match and 3
it should reject.

Always ask for rejection examples too. A regex that matches everything you want but also matches garbage you didn't test for is the usual failure.

7. Write a SQL query

Give it the schema, not a description of the tables. Guessed column names produce queries that look right and fail on your actual database.

Given this schema, write a PostgreSQL query that returns each customer's
total spend in the last 90 days, only for customers with at least 3
orders in that window, sorted by spend descending.

orders(id, customer_id, total_cents, created_at)
customers(id, email, created_at)

Use created_at for the date filter, total_cents for spend (convert to
dollars in the output), and explain the query plan implications of the
HAVING clause you use.

Run it against staging first, and check the query plan yourself on large tables. It won't know your indexes exist.

8. Get a second opinion on a PR

Paste the actual diff, not a description. Ask for specific categories of feedback so you get more than "looks good to me."

Review this diff as if you were a strict senior engineer. Flag:
1) anything that could break in production but isn't covered by a test,
2) unclear naming, 3) any place error handling swallows a real failure,
4) anything that duplicates logic that probably exists elsewhere in a
codebase like this. Be specific about line numbers, don't just summarize.

[paste the diff]

A pre-review pass, not a replacement for one. It can't know whether the change matches a decision made in last week's design review.

9. Generate boilerplate

The highest-use, lowest-risk use case. A Dockerfile, a CI workflow, a CRUD router skeleton: pattern-heavy and cheap to verify.

Write a multi-stage Dockerfile for a Node 20 TypeScript app: install
deps and build in a builder stage, copy only the compiled dist and
production node_modules into a slim runtime stage, run as a non-root
user, and expose port 3000. Add a HEALTHCHECK that curls /health.

Boilerplate is where ChatGPT earns its subscription cost back fastest, and where it's safest to accept almost as-is: a wrong Dockerfile fails loudly in CI instead of shipping a silent bug.

10. Learn a new API or library

Paste the actual docs or a sample from the library's current README, don't ask it to recall usage from memory. See "Where It Fails" for why that distinction matters.

Here's the README section for a library I haven't used before. Based
only on what's in this text, show me a minimal working example that
does [specific thing], and tell me if anything I'm asking for isn't
covered by what you can see here.

[paste the README section or docs page]

This turns ChatGPT into a fast reading assistant instead of an unreliable narrator. "Explain this from what I pasted" beats "explain how this library works" every time.

Where It Fails

Hallucinated APIs. Ask it to write against a library from memory and it can invent a plausible method that doesn't exist, or misremember an argument order. Worse for smaller, faster-moving libraries. Paste real docs whenever the API surface matters.

Outdated library versions. No live changelog view means it can confidently suggest an API deprecated two versions back. Check current docs for anything version-sensitive.

No repo context. It has never seen your codebase unless you paste the relevant parts in. It doesn't know you already have a chunk_by_weight helper three files over, or that the function it just "fixed" is called from six other places.

No live data, no execution. It can't run your code in your environment, see your database, or tell you why a test is flaky on your CI runner. Anything depending on runtime state is a guess dressed up as an answer.

Confidently wrong, not vaguely wrong. The costliest failure isn't obviously broken code, it's code that looks correct, compiles, and fails on a case you didn't test. Treat unfamiliar-library code and anything touching auth, payments, or data deletion as needing real verification.

FAQ

Is ChatGPT good for coding?

Yes, for explanation, drafting, and translation: understanding unfamiliar code, a first-pass function or test suite, a plain-English request turned into SQL or regex. Not reliable for anything depending on your codebase, current library versions, or live execution. Never the last check before something ships.

ChatGPT vs Claude Code vs Cursor vs GitHub Copilot: what's the difference?

ChatGPT (the chat interface) is a general-purpose assistant you paste code into. Claude Code, Cursor's agent mode, Copilot's agent mode, and OpenAI's own Codex are different: they index your repo, edit multiple files, and run build and test commands in a loop, no copy-pasting required. Conversation-sized task, ChatGPT is fine and cheaper. Multi-file in-repo change, an agent gets there faster.

Does ChatGPT write insecure or hallucinated code?

Both. Hallucination shows up as invented API methods, more often with smaller or newer libraries. Insecurity shows up when you ask for something generic ("write a login function") and get a simple pattern instead of a hardened one. Ask explicitly for parameterized queries and secure defaults, and treat auth or payment code as needing a real review.

Is it safe to paste proprietary code into ChatGPT?

Check your plan's data policy first. Free and Plus may train on conversations by default, a setting you can turn off under Data Controls. Business and Enterprise exclude your data by default. Clear NDA-covered code with your company's policy before pasting, and redact API keys and customer names regardless of plan.

Which ChatGPT plan is best for developers?

Plus, for almost everyone. At $20/month it gives you the current model, a large enough context window for real functions and files, and expanded Codex access. Pro's $100+/month only pays off if you hit Plus's limits regularly.

Can ChatGPT run and test my code?

Not your code, in your environment. It can run Python in a sandboxed session for data analysis, but has no access to your repo, dependencies, or CI. It can write tests for you to run; it can't run your actual suite.

Does ChatGPT know the latest library versions?

No, not reliably. It has a training cutoff and won't know about last week's release. For anything version-sensitive, paste the current docs rather than asking it to recall the API from memory.

Can ChatGPT replace a code review from a human teammate?

No. It's a solid pre-review pass, catching obvious issues before a human looks at the diff. It has no context on your team's prior decisions, no accountability for what merges, and no way to know if a change matches a design doc it never saw. Use it to tighten a PR, not to skip review.

Devshot — the daily dev & AI brief

Free daily newsletter, read in 5 minutes.

Subscribe free