Coding Prompts

AI prompts for code review, debugging, refactors and architecture across any stack.

45+
prompts
7
use cases
3
AI models
Coding prompts
45
AI models supported
3
Use cases
7
Total library
491+

Search within Coding only — titles, summaries, use cases, models and tags.

View all 45 prompts

Browse by AI Model

AI models that pair well with Coding

Open the model hub to see how each one handles this kind of work.

All Prompts

Browse all 45 coding prompts

Filter by use case, model or difficulty — every prompt in this category, on one page.

Showing 25–36 of 45 prompts

DevOps
ChatGPT

Kubernetes NetworkPolicy for Zero-Trust with Observability

This prompt guides platform and security engineers in generating Kubernetes NetworkPolicy manifests. It ensures a zero-trust security posture across multiple namespaces while explicitly preserving crucial observability traffic. The output includes K8s YAML, Helm/Kustomize guidance, and a deployment strategy.

View prompt →
DevOps
ChatGPT

Secure, Compact Multi-Stage Docker for Node.js APIs

Craft a secure, lightweight multi-stage Dockerfile for Node.js APIs, targeting sub-150MB images on a distroless base. This solution provides a Dockerfile, Docker Compose setup, and essential notes on build, runtime, security, and image size optimization, helping engineers ship production-ready services efficiently.

View prompt →
DevOps
ChatGPT

Optimize Docker Images: Reduce 1.2GB to under 150MB for CI/CD

This guide helps platform engineers optimize Docker images, shrinking them from 1.2GB to under 150MB. It provides a detailed process to achieve significant size reduction and enhance security, all while ensuring application runtime stability for efficient CI/CD pipelines.

View prompt →
DevOps
ChatGPT

Build a Docker Compose Local Development Stack

Generate a full Docker Compose configuration for a local development environment, integrating your application, PostgreSQL, Redis, and MailHog. It includes named volumes for data persistence, a `wait-for-db` entrypoint for service reliability, and provides essential guidance on image size and security for a robust setup.

View prompt →
DevOps
ChatGPT

Optimize Node.js 20 pnpm Dockerfiles for Production

Generate a multi-stage Dockerfile for Node.js 20 applications using pnpm, focusing on dependency caching and a compact runtime image. This ensures faster builds and smaller deployment artifacts, critical for production environments. Includes Docker Compose and build argument guidance.

View prompt →
Database
ChatGPT

Retrieve Top-3 Orders by Customer Revenue with Window Functions

Develop an optimized SQL query to identify the top three orders per customer based on revenue using window functions. This solution includes DDL, the query, expected plan notes, and index recommendations, ensuring efficient performance on large datasets.

View prompt →
Database
ChatGPT

SQL Duplicate Row Cleanup with Transactional Safety

Generate a comprehensive SQL solution for data engineers to identify and safely remove duplicate customer records. The output prioritizes transactional safety, preserving the earliest entry by `created_at`, and includes DDL, test data, cleanup query, execution plan notes, and

View prompt →
Database
ChatGPT

Postgres JSONB Query Patterns for Event Data

Generate PostgreSQL JSONB query patterns for DDL, filtering, GIN indexing, and nested field updates on event data. This workflow provides practical SQL solutions to common semi-structured data challenges, improving query performance and maintainability for database engineers.

View prompt →
Database
ChatGPT

SQL Pivot Monthly Revenue: Filter-Aggregate Approach

Generate a portable SQL solution to pivot monthly revenue data by product category. This approach uses standard SQL FILTER-aggregate syntax, eliminating the need for database-specific extensions. The output includes DDL, the pivot query, expected execution plan notes, index recommendations, and test data for immediate implementation.

View prompt →
Database
ChatGPT

Hourly Event Aggregation with Time Zone and Empty Buckets

This workflow guides data engineers through creating an hourly time-bucketed aggregation of event data using PostgreSQL's generate_series. It addresses time zone complexities and ensures all hours are represented, even those without events, for comprehensive analytics.

View prompt →
Database
ChatGPT

SQL Recursive CTE for Organizational Hierarchy Tree

Generate a comprehensive organizational hierarchy using a recursive CTE, deriving an employee tree from manager relationships. The solution provides DDL, an optimized query with depth and full path, index recommendations, and test data. This simplifies hierarchical data traversal and reporting for engineers.

View prompt →
Code Review
ChatGPT

Build a FastAPI CRUD Service with Pydantic V2 and SQLModel

Generate a complete FastAPI CRUD application for a Task resource. It uses Pydantic V2 for robust data schemas, SQLModel for database interaction, and incorporates dependency injection for session management, providing a production-minded Python solution with code, tests, and dependency setup.

View prompt →

Featured Prompts

Hand-picked for this category

The strongest prompts in this category — copy, tweak and ship.

⭐ Editor's Choice

The featured prompt on this page

One prompt we'd ship today. Read why it works, see a preview, and copy it in a click.

Editor's Choice · Tuned for Claude

Claude Senior Code Review

Why it works · It defines the runtime, behaviour and edge cases, then asks for tests — turning the AI from a code generator into a reliable engineering pair.

Best use case

Best for coding workflows where staff-engineer review of any diff with risks and nits.

Expected output

Working code in the runtime you specified, with edge cases handled and a small test you can run immediately.

Open full prompt

Staff-engineer review of any diff with risks and nits.

Coding prompts turn an AI into the senior engineer on your team — the one who catches the bug, names the abstraction, and writes the missing test.

Each prompt assigns a role, scopes the task, and asks for structured output you can act on. They work especially well with Claude and ChatGPT.

Use them in your IDE, your code review tool, or pasted into a chat. They're designed to be model-agnostic.

Editorial

The coding prompt library, explained

Welcome to the Coding hub. You'll find 45 coding prompts organised by use case, ranked by quality and tagged with the AI models that handle each task best. The collection is curated, not generated — every prompt has been written by humans, tested against real workflows and refined based on what actually ships.

These prompts are built for software engineers, ML engineers and indie devs who want code, tests and architecture suggestions they can ship. They work across the major AI models — ChatGPT, Claude, Gemini and the leading image and video generators — and they hold up whether you're prompting in a chat window, an editor extension or a workflow tool. Pull these in during scoping, scaffolding, refactors and code reviews — anywhere a teammate would help.

Why these prompts work: each one starts with a clear role, names the audience or scene, defines the output format and adds 2–3 hard constraints. That structure is what separates a vague AI answer from a usable one. The library is curated so you don't have to test 30 versions of the same prompt to find the one that actually performs — that work is already done.

Expect production-style code, types, edge-case handling and at least a smoke test — written in the style you specify. You'll occasionally want to regenerate or refine, especially the first time you use a prompt with your own context. Treat each prompt as a starting structure: the variables and constraints stay, the topic and tone become yours.

Read each prompt before you copy it. Swap the placeholders for your real audience, product and constraints, and add one or two engineering-specific details from your own brief. The prompts here are designed to be edited — the more context you bring, the stronger the output.

If you're new to AI prompting in coding, start with the featured prompts at the top of this page — they're the highest-leverage, lowest-friction picks. From there, drop into the use-case hubs below to find the exact workflow you need.

Prompt Writing Guide

How to write better Coding prompts

Six habits that consistently produce stronger AI output. Apply them to any prompt on this page.

  1. 1

    State the runtime and stack

    Language, version, framework, target platform. "Node 20 on Cloudflare Workers" produces very different code than "any JavaScript".

  2. 2

    Write the requirements first

    Functional behaviour, inputs, outputs, error handling. The AI is excellent at following a spec and mediocre at guessing intent.

  3. 3

    List the edge cases

    Empty arrays, null, network failures, race conditions, oversize payloads. Naming them up front prevents the "happy path only" trap.

  4. 4

    Ask for tests

    Request a small test suite alongside the implementation. Tests force the model to reason about boundaries — and you get verification for free.

  5. 5

    Pin code style

    TypeScript strict, no `any`, named exports, early returns. Pin style and you'll spend zero time on lint cleanup.

  6. 6

    Demand explanations on tricky parts

    Ask the model to comment any non-obvious step. Comments expose flawed reasoning before you ship the code.

Best Practices

Coding best practices

Apply these in every prompt on this page. Small habits, outsized improvements in output quality.

Pin the runtime and version

Language + framework + version. Skip and you'll get half-deprecated APIs.

Write the spec first

Inputs, outputs, errors, edge cases. The AI is a great spec follower.

Ask for tests alongside code

Tests catch flawed reasoning before you ship.

Forbid `any` in TypeScript

One rule removes 80% of weak AI-generated TS code.

Avoid These

Common Coding prompt mistakes

The same handful of mistakes are responsible for most weak AI output. Catch them before you hit send.

  • Missing the runtime

    Different runtimes have different APIs. Without it, the AI guesses — usually wrongly.

  • Glossing over edge cases

    If the prompt only describes the happy path, the code will only handle the happy path.

  • Asking for "clean code"

    "Clean" is subjective. Specify naming, style and lint rules instead.

  • Skipping tests

    Without tests you have no way to verify the AI's reasoning. Always ask for at least a smoke test.

  • Pasting too much code

    Dump only the relevant functions and types. Long context dilutes attention.

Pro Tips

Advanced prompt patterns

Side-by-side rewrites that show what separates a weak prompt from a great one.

Instead of

“Write a function to debounce.”

Use

“Write a TypeScript `debounce<T>` higher-order function targeting Node 20. Cancel in-flight calls, return a `.cancel()` method, preserve `this`, type the return as `(...args: Parameters<T>) => void`. Include 4 Vitest tests covering rapid calls, cancel, late call, and `this` binding.”

Why it works: Stack, behaviour, types and tests are all defined.

Instead of

“Make this API.”

Use

“Implement a REST endpoint POST /api/invoices in Hono on Cloudflare Workers. Validate body with Zod. Return 400 on invalid input, 409 on duplicate, 201 with the new invoice on success. Include a small handler test and a sample curl.”

Why it works: Framework, runtime, errors and verification are pinned.

Instead of

“Fix this bug.”

Use

“Here's the error: `TypeError: cannot read 'map' of undefined`. The function receives `items` from the API. Add a guard, log a warning when it's missing, and update the test to cover the empty case. Don't change the public API.”

Why it works: Symptom, expected fix and scope are explicit.

Instead of

“Optimise this query.”

Use

“This Postgres query takes 1.4s on a 12M-row `events` table. The filter is `user_id = ? AND created_at > ?`. Propose 2 index strategies, explain the trade-offs, and rewrite the query if helpful.”

Why it works: Volume, filter and trade-off framing produce useful answers.

Instead of

“Refactor this code.”

Use

“Refactor this React component to extract the data fetching into a TanStack Query hook. Keep the rendering identical. Add types, no `any`, and update tests if they reference the old API.”

Why it works: Boundary and constraints prevent over-refactoring.

FAQ

Coding prompts, answered

Common questions about using this category of prompts.

Related searches

People also search for coding prompts

Popular searches related to this page. Each one links to the closest matching prompt library.

Explore Coding Prompts

Browse dozens of curated prompts optimized for modern AI models.

View All Coding Prompts