Prompt Library

ChatGPT Prompts for Software Engineers

30 copy-paste prompts

Thirty battle-tested prompts that turn ChatGPT into a pair programmer — generate code, hunt down bugs, review pull requests, write tests and docs, and design systems. Swap in your language and codebase, then ship.

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.

By Louis Corneloup · Founder, Techpresso
Last updated ·Hand-curated & tested by the AI Academy team

Code Generation

5 prompts

Implement a feature from a spec

1/30

<context> You are a senior [LANGUAGE] engineer working in [CODEBASE]. We follow the existing conventions, error-handling patterns, and folder structure already present in the repo. I will give you a feature spec for [FEATURE]. </context> <task> 1. Restate the feature in one sentence and list any assumptions you are making. 2. Propose the file(s) to create or modify and a one-line reason for each. 3. Write production-ready [LANGUAGE] code implementing [FEATURE], with input validation, error handling, and inline comments only where logic is non-obvious. 4. List edge cases you handled and any you deliberately deferred. 5. End with a short checklist of what I should verify before merging. </task>

A complete, convention-aware implementation of a feature plus a pre-merge checklist.

💡

Pro tip: Paste the actual spec or ticket text into the context block so ChatGPT anchors to real requirements instead of inventing them.

Generate a typed API client

2/30

<context> You are building a typed client in [LANGUAGE] for an HTTP API used by [CODEBASE]. I will paste the endpoint list or an OpenAPI snippet for [FEATURE]. </context> <task> 1. Define request and response types/models for each endpoint. 2. Implement a small client class/module with one method per endpoint. 3. Centralize base URL, auth headers, timeouts, and retry-on-5xx logic. 4. Surface errors as typed results rather than throwing raw network errors. 5. Show one usage example per method and note any pagination or rate-limit handling. </task>

A reusable, strongly typed API client with auth, retries, and usage examples.

💡

Pro tip: Attach the OpenAPI/Swagger file directly so ChatGPT derives exact field names and types rather than guessing.

Scaffold a new module

3/30

<context> You are scaffolding a new module in [CODEBASE] using [LANGUAGE]. The module implements [FEATURE] and must match the existing project layout and dependency-injection style. </context> <task> 1. Outline the module boundary: public interface vs internal helpers. 2. Generate the file structure with stubbed functions and clear TODOs. 3. Wire the module into the app entry point or DI container. 4. Add the minimal config or env keys the module needs, with safe defaults. 5. Provide a one-paragraph README block describing how to use the module. </task>

A ready-to-fill module skeleton wired into the app with a usage README.

💡

Pro tip: Describe your DI or registration pattern in the context so the wiring step matches how your app actually bootstraps.

Convert pseudocode to working code

4/30

<context> You are a [LANGUAGE] engineer in [CODEBASE]. I will paste pseudocode or a rough algorithm for [FEATURE] and need it turned into idiomatic, tested code. </context> <task> 1. Translate the pseudocode into idiomatic [LANGUAGE], preserving intent. 2. Replace any hand-waved steps with concrete, correct logic and call out where you did so. 3. Add guard clauses for invalid input and explain the time/space complexity. 4. Suggest a more efficient approach if one exists, with the tradeoff. 5. Include a tiny runnable example demonstrating expected output. </task>

Idiomatic, complexity-annotated code translated faithfully from pseudocode.

💡

Pro tip: Ask ChatGPT to flag every spot where it had to guess intent so you can confirm the algorithm before trusting it.

Write a CLI command

5/30

<context> You are extending the command-line tool in [CODEBASE], written in [LANGUAGE]. I want a new command that implements [FEATURE]. </context> <task> 1. Define the command name, arguments, and flags with defaults and help text. 2. Implement argument parsing and validation following the existing CLI framework. 3. Implement the command logic, separating I/O from pure business logic. 4. Handle non-zero exit codes and write errors to stderr. 5. Show example invocations and their expected output. </task>

A new CLI command with parsing, validation, exit codes, and usage examples.

💡

Pro tip: Name the CLI framework you use (Cobra, Click, Commander, etc.) so the generated parsing code drops straight in.

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

5 prompts

Diagnose a stack trace

6/30

<context> You are debugging [CODEBASE], written in [LANGUAGE]. I will paste a stack trace and the relevant code for [FEATURE]. The error happens at runtime in production. </context> <task> 1. Read the stack trace top-down and identify the most likely root cause. 2. Explain the failure in plain language and what conditions trigger it. 3. Propose the smallest correct fix, with the exact code change. 4. List two other plausible causes and how to rule each one out. 5. Suggest a guard or assertion that would have surfaced this earlier. </task>

A ranked root-cause diagnosis plus a minimal fix and a prevention guard.

💡

Pro tip: Paste both the trace and the surrounding source — ChatGPT reasons far better with the actual frames than with the error message alone.

Find a logic bug

7/30

<context> You are reviewing [LANGUAGE] code from [CODEBASE] that produces wrong output for [FEATURE] but does not crash. I will paste the function and a failing input/expected-output pair. </context> <task> 1. Trace the code line by line for the failing input and show intermediate values. 2. Pinpoint the exact line where actual diverges from expected. 3. Explain why the bug occurs, not just where. 4. Provide the corrected code and re-trace it for the same input. 5. Add one more test input that would catch a regression of this bug. </task>

A line-by-line trace that isolates a silent logic bug, plus a fix and regression test.

💡

Pro tip: Give a concrete failing input and the expected output so ChatGPT can execute the trace deterministically instead of speculating.

Debug a flaky test

8/30

<context> You are investigating a flaky test in [CODEBASE] ([LANGUAGE]) that covers [FEATURE]. It passes locally but fails intermittently in CI. </context> <task> 1. List the usual sources of flakiness (timing, shared state, ordering, randomness, network) and rank which are most likely here. 2. Read the pasted test and implementation and point to specific lines that introduce nondeterminism. 3. Propose a deterministic rewrite of the risky parts. 4. Suggest how to reproduce the flake locally (seeds, parallelism, ordering). 5. Recommend a CI change to catch this class of flake going forward. </task>

A prioritized flakiness diagnosis with a deterministic test rewrite and CI advice.

💡

Pro tip: Mention your test runner and whether tests run in parallel — both heavily change which flakiness causes are likely.

Explain unexpected behavior

9/30

<context> You are helping me understand why [FEATURE] in [CODEBASE] behaves differently than I expect. The language is [LANGUAGE]. I will describe expected vs actual behavior and paste the code. </context> <task> 1. Restate my expected behavior and the observed behavior in your own words. 2. Identify the language feature, library quirk, or async/ordering issue causing the gap. 3. Demonstrate the cause with a minimal reproducible snippet. 4. Give the corrected version and explain the mental model I was missing. 5. Point to the relevant docs or spec section for further reading. </task>

A clear explanation of a surprising behavior with a minimal repro and the right mental model.

💡

Pro tip: Be explicit about your runtime/version — behavior around async, floats, and equality often differs across language versions.

Triage a performance regression

10/30

<context> You are investigating a performance regression in [FEATURE] within [CODEBASE], written in [LANGUAGE]. I will paste the hot code path and any profiler output I have. </context> <task> 1. Identify the most expensive operations in the pasted path (allocations, N+1 queries, repeated work, blocking I/O). 2. Rank suspected bottlenecks by likely impact. 3. Propose targeted optimizations with the rewritten code for the top one. 4. Estimate the complexity/cost change and any correctness risk of each fix. 5. Suggest a benchmark or metric to confirm the improvement. </task>

A ranked bottleneck analysis with a concrete optimization and a way to measure the win.

💡

Pro tip: Paste real profiler or query-log output if you have it — ChatGPT prioritizes far more accurately with measured hotspots than guesses.

Code Review

5 prompts

Review a pull request diff

11/30

<context> You are a staff engineer reviewing a pull request in [CODEBASE], written in [LANGUAGE]. The PR implements [FEATURE]. I will paste the diff. Be direct but constructive. </context> <task> 1. Summarize what the diff does in two sentences. 2. Flag correctness bugs, race conditions, and unhandled errors first, citing exact lines. 3. Note security and input-validation concerns. 4. Call out readability, naming, and duplication issues, ranked by severity. 5. End with a clear verdict: approve, approve-with-nits, or request-changes, and the top three must-fix items. </task>

A severity-ranked PR review with line-level comments and a clear merge verdict.

💡

Pro tip: Paste the unified diff (git diff format) rather than full files so ChatGPT focuses only on what changed.

Spot security vulnerabilities

12/30

<context> You are performing a security-focused review of [LANGUAGE] code from [CODEBASE] that handles [FEATURE]. Assume input is untrusted. </context> <task> 1. Check for injection (SQL, command, template), XSS, SSRF, and path traversal in the pasted code. 2. Review auth, authorization, and secrets handling for gaps. 3. Flag unsafe deserialization, insecure defaults, and missing rate limits. 4. For each finding, give severity, the vulnerable line, and a concrete fix. 5. List anything you could NOT verify from the code alone and what to check next. </task>

A vulnerability report with severity, exact lines, fixes, and verification gaps.

💡

Pro tip: Tell ChatGPT what trust boundary the code sits on (public endpoint, internal job, admin-only) so it weights severity correctly.

Suggest a cleaner refactor

13/30

<context> You are reviewing [LANGUAGE] code in [CODEBASE] that works but is hard to maintain. It implements [FEATURE]. I want refactoring suggestions, not a rewrite. </context> <task> 1. Identify the biggest maintainability smells (long functions, deep nesting, primitive obsession, duplication). 2. For the top three, show the before snippet and a refactored after snippet. 3. Keep behavior identical — note any behavior you might be changing. 4. Explain the principle each refactor applies and why it helps. 5. Order the refactors by payoff-to-risk ratio. </task>

Targeted, behavior-preserving refactors with before/after snippets ranked by payoff.

💡

Pro tip: Ask it to preserve behavior explicitly and call out risky changes, so you can refactor incrementally without surprise regressions.

Enforce coding standards

14/30

<context> You are reviewing [LANGUAGE] code from [CODEBASE] against our team conventions for [FEATURE]. I will paste our style rules followed by the code. </context> <task> 1. List each violation of the pasted conventions with the offending line. 2. Provide the corrected line or block for each violation. 3. Distinguish hard rule violations from stylistic preferences. 4. Suggest a lint rule or formatter config that would auto-enforce each fixable item. 5. Summarize how many issues are auto-fixable vs need human judgment. </task>

A convention-compliance report with fixes and lint rules to automate enforcement.

💡

Pro tip: Paste your actual style guide or linter config first so feedback maps to your real standards, not generic best practice.

Assess test coverage of a change

15/30

<context> You are reviewing whether a change to [FEATURE] in [CODEBASE] ([LANGUAGE]) is adequately tested. I will paste the changed code and its existing tests. </context> <task> 1. List the behaviors and branches in the changed code. 2. Map each existing test to the behavior it covers. 3. Identify untested branches, edge cases, and error paths. 4. Write the missing test cases as code, named for the behavior they verify. 5. Give a one-line coverage verdict: sufficient or insufficient to merge. </task>

A behavior-to-test coverage map with the missing tests written out as code.

💡

Pro tip: Include both the diff and the current test file so ChatGPT can tell which branches are genuinely uncovered versus already tested.

Testing

5 prompts

Generate unit tests

16/30

<context> You are writing unit tests in [LANGUAGE] for [FEATURE] in [CODEBASE]. We use the repo's existing test framework and naming style. I will paste the function under test. </context> <task> 1. Enumerate the function's inputs, outputs, and side effects. 2. Derive test cases: happy path, boundary values, invalid input, and error conditions. 3. Write the tests using the existing framework, with descriptive names and arrange-act-assert structure. 4. Mock or stub external dependencies cleanly. 5. Note any behavior that is ambiguous and should be clarified before locking it in tests. </task>

A full unit-test suite covering happy, boundary, and error cases in your framework.

💡

Pro tip: Name the exact test framework and assertion library so the output runs without you rewriting imports or matchers.

Design edge-case test inputs

17/30

<context> You are hardening tests for [FEATURE] in [CODEBASE] ([LANGUAGE]). The happy path already passes. I want a thorough list of edge cases. I will paste the function or spec. </context> <task> 1. Brainstorm edge cases across categories: empty, null, boundary, very large, malformed, concurrent, and locale/encoding inputs. 2. For each, state the input and the expected behavior. 3. Flag cases where the correct behavior is undefined and needs a product decision. 4. Turn the well-defined cases into test code. 5. Prioritize which edge cases are most likely to occur in production. </task>

A categorized edge-case catalog turned into prioritized, runnable tests.

💡

Pro tip: Ask ChatGPT to separate cases with defined behavior from cases needing a product decision so you don't encode guesses as tests.

Write integration tests

18/30

<context> You are writing integration tests for [FEATURE] in [CODEBASE], using [LANGUAGE]. The feature spans multiple components (e.g. handler, service, database). I will describe the flow. </context> <task> 1. Identify the components involved and the boundaries worth testing together. 2. Define the test scenarios end-to-end, including setup and teardown. 3. Write the integration tests with realistic fixtures and a clean database/state per run. 4. Assert on observable outcomes, not internal implementation details. 5. Note which external services should be faked vs hit for real and why. </task>

End-to-end integration tests with proper setup/teardown and outcome-based assertions.

💡

Pro tip: Describe your test infrastructure (containers, in-memory DB, test doubles) so the setup/teardown code matches your environment.

Add property-based tests

19/30

<context> You are adding property-based tests for [FEATURE] in [CODEBASE] ([LANGUAGE]). I want to test invariants rather than fixed examples. I will paste the function. </context> <task> 1. Identify invariants the function must always satisfy (round-trips, idempotence, ordering, bounds). 2. Define generators for valid and adversarial inputs. 3. Write property-based tests using a suitable library for [LANGUAGE]. 4. Add shrinking-friendly assertions so failures minimize cleanly. 5. Explain what each property protects against and a known false-friend to avoid asserting. </task>

Invariant-based property tests with input generators and clear failure semantics.

💡

Pro tip: Tell ChatGPT which property-testing library you use (Hypothesis, fast-check, QuickCheck) so generator syntax is correct out of the box.

Reduce a bug to a failing test

20/30

<context> You are converting a reported bug in [FEATURE] ([CODEBASE], [LANGUAGE]) into a minimal failing test before I fix it. I will paste the bug report and relevant code. </context> <task> 1. Restate the bug as a precise expected-vs-actual statement. 2. Identify the smallest input that reproduces it. 3. Write a single failing test that asserts the correct (desired) behavior. 4. Confirm the test fails for the current code and would pass once fixed. 5. Suggest where the fix likely belongs, without writing the fix. </task>

A minimal red test that pins down a reported bug before you implement the fix.

💡

Pro tip: Use this red-test-first habit: have ChatGPT write the failing test, you confirm it fails, then ask for the fix in a separate turn.

Documentation

5 prompts

Document a function or module

21/30

<context> You are documenting [FEATURE] in [CODEBASE], written in [LANGUAGE]. Match the repo's existing docstring style. I will paste the code. </context> <task> 1. Write a one-line summary of what the code does. 2. Document each parameter, return value, and thrown error/exception. 3. Note side effects, preconditions, and thread-safety where relevant. 4. Add a short, copy-pasteable usage example. 5. Keep it accurate to the code — do not document behavior the code does not have. </task>

Accurate, style-matched docstrings with parameters, returns, errors, and an example.

💡

Pro tip: Specify your docstring convention (JSDoc, Google-style, reStructuredText) so the output renders correctly in your doc tooling.

Write a README for a project

22/30

<context> You are writing the README for [CODEBASE], a [LANGUAGE] project that does [FEATURE]. The audience is a developer seeing it for the first time. I will paste package metadata and key entry points. </context> <task> 1. Open with a one-paragraph description of what it does and who it is for. 2. Add Installation, Quick Start, and Configuration sections with runnable commands. 3. Document the main commands or API surface with examples. 4. Include Contributing and License placeholders matching the repo. 5. Keep claims grounded in the provided code — mark anything you inferred as TODO. </task>

A complete, first-impression README with install, quick start, and usage sections.

💡

Pro tip: Feed in your package.json/pyproject and a couple of entry-point files so commands and examples reflect the real project, not a template.

Generate API reference docs

23/30

<context> You are generating reference documentation for the public API of [FEATURE] in [CODEBASE] ([LANGUAGE]). I will paste the endpoint or function signatures. </context> <task> 1. For each endpoint/method, document the signature, parameters, and return shape. 2. Provide a request and response example for each. 3. List error codes/exceptions and when they occur. 4. Note authentication, rate limits, and idempotency where applicable. 5. Organize entries consistently and flag any signature you could not fully interpret. </task>

Consistent API reference entries with examples, errors, and auth notes.

💡

Pro tip: Give the actual type definitions or schema so response shapes are exact rather than approximated.

Write an architecture decision record

24/30

<context> You are writing an Architecture Decision Record (ADR) for a choice we made about [FEATURE] in [CODEBASE] ([LANGUAGE]). I will describe the context, the options we considered, and what we picked. </context> <task> 1. Title the ADR and set status (proposed/accepted) and date. 2. Write the Context section: the problem and constraints driving the decision. 3. Write the Decision section in one clear statement. 4. Document the Alternatives considered with their tradeoffs. 5. Write Consequences: what gets easier, what gets harder, and follow-ups. </task>

A structured ADR capturing context, decision, alternatives, and consequences.

💡

Pro tip: Tell ChatGPT the real constraints (deadlines, team skills, existing stack) so the consequences section reflects your actual tradeoffs.

Explain legacy code

25/30

<context> You are onboarding onto unfamiliar [LANGUAGE] code in [CODEBASE] that implements [FEATURE]. I will paste a chunk of legacy code with little documentation. </context> <task> 1. Give a high-level summary of what the code accomplishes. 2. Walk through the control flow and key data structures step by step. 3. Call out non-obvious behavior, hidden side effects, and likely intent of cryptic parts. 4. Flag risky or suspicious sections that may hide bugs. 5. Produce a concise comment block I can paste above the code to help the next reader. </task>

A plain-language walkthrough of legacy code with a paste-ready summary comment.

💡

Pro tip: Paste the surrounding callers too — legacy code is often only understandable in the context of who calls it and with what.

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

Architecture & Design

5 prompts

Design a system component

26/30

<context> You are a principal engineer designing a new component for [FEATURE] that will live in [CODEBASE], implemented in [LANGUAGE]. I will describe the requirements and current architecture. </context> <task> 1. Restate functional and non-functional requirements (latency, scale, consistency). 2. Propose two viable designs with a short pros/cons list each. 3. Recommend one and justify it against the requirements. 4. Define the component's interface, data model, and key failure modes. 5. List risks, open questions, and a phased rollout plan. </task>

Two candidate designs, a justified recommendation, and a phased rollout plan.

💡

Pro tip: State your real non-functional requirements (QPS, latency target, consistency needs) — they are what separate a good design from a generic one.

Choose between technical approaches

27/30

<context> You are advising on a technical choice for [FEATURE] in [CODEBASE] ([LANGUAGE]). I will list the options under consideration and our constraints. </context> <task> 1. Summarize each option in one sentence. 2. Build a comparison across the dimensions that matter (performance, complexity, cost, team familiarity, lock-in). 3. Identify the decisive factors given our constraints. 4. Make a clear recommendation and name the conditions under which you would change it. 5. List what to prototype to de-risk the choice cheaply. </task>

A constraint-weighted comparison with a clear, conditional recommendation.

💡

Pro tip: Be explicit about constraints like team size and deadline — without them ChatGPT defaults to the theoretically best option, not the right one for you.

Model a database schema

28/30

<context> You are designing a database schema for [FEATURE] in [CODEBASE]. The app is written in [LANGUAGE]. I will describe the entities and access patterns. </context> <task> 1. List the entities, their attributes, and relationships. 2. Propose normalized tables with keys, types, and constraints. 3. Recommend indexes based on the stated query patterns. 4. Call out where denormalization or caching may be justified and the tradeoff. 5. Provide the DDL and note any migration concerns for existing data. </task>

A normalized schema with keys, indexes, DDL, and migration notes.

💡

Pro tip: Describe your top read queries — schema and index quality depend far more on access patterns than on the entities alone.

Plan a refactor or migration

29/30

<context> You are planning a large refactor/migration of [FEATURE] in [CODEBASE] ([LANGUAGE]) that must ship without downtime. I will describe the current state and target state. </context> <task> 1. Define the end state and the smallest safe increments to reach it. 2. Sequence the steps so the system stays releasable after each one. 3. Identify backward-compatibility shims and feature flags needed. 4. Call out data migration, rollback, and verification steps per phase. 5. Flag the riskiest step and how to de-risk it. </task>

A phased, always-releasable migration plan with rollback and risk mitigation.

💡

Pro tip: Emphasize the no-downtime constraint so ChatGPT produces an incremental strangler-style plan instead of a risky big-bang cutover.

Review a design for scalability

30/30

<context> You are reviewing an architecture for [FEATURE] in [CODEBASE] ([LANGUAGE]) for scalability and reliability. I will paste or describe the proposed design and expected load. </context> <task> 1. Identify the components most likely to become bottlenecks under the stated load. 2. Check for single points of failure and missing backpressure or rate limiting. 3. Evaluate data consistency, caching, and statefulness concerns. 4. Recommend concrete changes ranked by impact. 5. Suggest metrics and load tests to validate the design before launch. </task>

A scalability and reliability critique with ranked fixes and validation metrics.

💡

Pro tip: Give projected traffic and growth numbers — a design that is fine at 100 RPS and broken at 10k RPS only reveals itself with real targets.

Frequently Asked Questions

Copy a prompt, then replace the [LANGUAGE], [CODEBASE], and [FEATURE] placeholders with your real stack, repository context, and the task at hand. Paste in the actual code, diff, spec, or stack trace where the prompt asks for it. The structured <context> and <task> format tells ChatGPT exactly what to assume and what to produce, so you get deployable output instead of vague suggestions.
Use the most capable reasoning model available to you for debugging, architecture, and code review, where correctness and multi-step reasoning matter most. Lighter, faster models are fine for boilerplate generation and documentation. Whichever model you pick, always paste the real code rather than describing it — model quality matters far less than the quality of the context you provide.
Treat ChatGPT output as a strong first draft from a fast pair programmer, not as merge-ready code. Always read it, run it, and test it. These prompts deliberately ask for edge cases, error handling, and pre-merge checklists so you catch gaps before shipping. The biggest risks are subtle logic bugs and outdated API usage, both of which your tests and review process should catch.
Give it the full stack trace, the surrounding source, and a concrete failing input with the expected output. ChatGPT reasons dramatically better when it can trace real values than when it only sees an error message. Also state your language version and runtime, since behavior around async, equality, and numeric types varies between versions.
ChatGPT only sees what you paste into the chat. Never paste secrets, credentials, or customer data, and check your organization's policy on sharing proprietary code with third-party AI tools. For sensitive work, redact identifiers and share only the minimal snippet needed. Many teams use enterprise plans with data-retention controls specifically for this reason.

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.