← Index31 entries · By Vocation
Section II · For the Software Engineer

Prompts for the Software Engineer

AI prompts to help software engineers ship faster: code review, debugging, explaining code, writing tests, refactoring, and documentation.

§ Overview

Most of an engineer's day isn't typing code — it's reading unfamiliar code, chasing a stack trace, and explaining decisions to people who weren't in the room. That's exactly where a model like ChatGPT or Claude earns its keep. Paste in a confusing function and ask for a junior-friendly walkthrough; drop an error message and get ranked root causes with tests to confirm each one.

The prompts in this collection map to that real workflow. You'll find senior-style pull request reviews, behavior-preserving refactors, unit test generation that hits edge cases and failure modes, and a security pass aligned to OWASP categories. There are also the chores nobody loves — Conventional Commits messages, a hardened multi-stage Dockerfile, REST schemas with proper status codes and idempotency notes.

Good prompting matters here because the model only knows what you tell it. Vague input gives plausible-but-wrong code; a sharp prompt with the actual constraints gives something you can ship after review.

§ Field Notes

What makes a good prompt for a software engineer

A strong engineering prompt carries the constraints the code actually lives under: language and version, the framework, what the function is allowed to assume about its inputs, and whether behavior must stay identical (refactors) or can change (optimizations). Paste the real code and the real error, not a paraphrase — line numbers and exact messages are signal the model uses.

State the output format you want too. Ask for a diff, a test file in your framework, or a review grouped by severity with file references. And always tell it to flag assumptions and edge cases rather than silently guessing, so you catch the gaps during review instead of in production.

§ Pro Tips

Get sharper results

  • 01When debugging, paste the full error including the stack trace and the surrounding code, then ask for root causes ranked by likelihood with a quick test to confirm or rule out each one.
  • 02For refactors, explicitly require that behavior stay identical and ask the model to list every behavioral assumption it made so you can verify them against your test suite.
  • 03When generating unit tests, name the framework and ask specifically for happy-path, boundary, and failure-mode cases — generic 'write tests' prompts skew toward the happy path only.
  • 04Give the model your real schema or type definitions when asking for SQL or API design, so it returns queries and shapes that compile against your actual data instead of invented columns.
§ FAQ

Common questions

Can I trust AI-generated code without reviewing it?

No — treat it like a draft from a fast but context-blind colleague. The model can produce code that looks correct and compiles but misses an edge case or makes a wrong assumption about your data. Run it through tests and read it the way you'd review any pull request.

How do I keep proprietary code from leaking when I paste it into a chatbot?

Check your company's policy first, and prefer an enterprise tier where your inputs aren't used for training. When you can, strip secrets, anonymize identifiers, and share only the minimal snippet needed to reproduce the problem rather than entire files.

Which is better for coding, ChatGPT or Claude?

Both handle these prompts well, and the gap is smaller than the quality of your prompt. Many engineers keep both open and compare on hard problems. The bigger lever is giving either model enough context — versions, constraints, the real code — rather than picking the 'right' tool.

§ The Prompts · 31
№ 002coding

Perform a Thorough Code Review on a Pull Request

Get a senior-engineer-style code review with categorized, file-referenced feedback.

For
claude·chatgpt
№ 006coding

Explain Complex Code in Simple Terms

Turn confusing code into a clear, junior-friendly explanation with edge-case notes.

For
claude·chatgpt
№ 012coding

Debug an Error Message Step-by-Step

Get a structured debugging plan: error explanation, ranked root causes, tests, and fixes.

For
claude·chatgpt
№ 019data

Write a SQL Query From a Business Question

Translate a business question into a clean, commented SQL query against your schema.

For
chatgpt·claude
№ 020productivity

Write a Concise Weekly Status Update

Convert messy weekly notes into a manager-ready 200-word status update.

For
chatgpt·claude
№ 021coding

Refactor Code for Readability and Maintainability

Refactor any code for readability and maintainability without changing its behavior.

For
claude·chatgpt
№ 022coding

Generate Unit Tests for a Function

Generate comprehensive unit tests with happy path, edge cases, and failure modes.

For
claude·chatgpt
№ 023coding

Write a Clear Git Commit Message

Generate a Conventional Commits-compliant git commit message with context and rationale.

For
claude·chatgpt
№ 024coding

Design a RESTful API Endpoint Schema

Design a complete REST API schema with request/response bodies, status codes, and error cases.

For
claude·chatgpt
№ 025coding

Build and Explain a Regular Expression

Get a working regex with a plain-English breakdown and a set of passing/failing test cases.

For
claude·chatgpt
№ 026coding

Translate Code From One Language to Another

Convert code between programming languages while using idiomatic patterns in the target language.

For
claude·chatgpt
№ 027coding

Audit Code for Performance Bottlenecks

Identify performance bottlenecks in code and get ranked, impact-focused optimization suggestions.

For
claude·chatgpt
№ 028coding

Run a Security Review on Code

Get an OWASP-aligned security review with severity ratings and remediation snippets.

For
claude·chatgpt
№ 029coding

Design a Normalized Database Schema

Design a fully normalized relational database schema with DDL, indexes, and design rationale.

For
claude·chatgpt
№ 030coding

Write Clear Technical Documentation

Generate complete Markdown technical docs with params, examples, and error handling.

For
claude·chatgpt
№ 084career

Write a Self-Review for Your Performance Review

Turn your wins into a polished, metrics-backed self-review with an explicit ask.

For
chatgpt·claude
№ 096coding

Generate a Production-Ready Dockerfile and Explain Each Line

Generate a hardened, multi-stage Dockerfile with line-by-line comments and matching .dockerignore.

For
claude·chatgpt
№ 097coding

Explain and Write a Regex From Plain English

Translate a plain-English matching requirement into a regex with line-by-line breakdown and edge cases.

For
claude·chatgpt
№ 098coding

Design a Clean REST API for a New Resource

Get a complete REST endpoint design with shapes, errors, and idempotency notes.

For
claude·chatgpt
№ 099coding

Write Unit Tests for an Existing Function

Generate a thorough unit test suite covering happy path, branches, edges, and errors.

For
claude·chatgpt
№ 100coding

Optimize a Slow Function With Specific Tradeoffs

Get a ranked list of optimizations with complexity analysis and explicit tradeoffs.

For
claude·chatgpt
№ 176coding

Refactor a long, tangled function into smaller, testable units

Breaks an overgrown function into smaller, single-responsibility units while preserving behavior and the public signature.

For
chatgpt·claude
№ 177coding

Generate table-driven unit tests for a function with edge cases

Produces a table-driven unit test suite covering happy paths, boundaries, and error conditions for a given function.

For
chatgpt·claude
№ 178coding

Explain a cryptic regex and rewrite it to be readable

Decodes a confusing regex token by token, surfaces edge cases and backtracking risk, then rewrites it readably.

For
chatgpt·claude
№ 179coding

Write clear API reference docs straight from source code

Generates accurate API reference documentation from source code without inventing behavior, flagging ambiguities.

For
chatgpt·claude
№ 180coding

Port a code snippet to another language idiomatically

Translates a snippet into idiomatic code in a target language and flags cross-language correctness pitfalls.

For
chatgpt·claude
№ 181coding

Turn a diff into a clear, reviewer-friendly PR description

Converts a diff and context into a structured, reviewer-friendly pull request description and title.

For
chatgpt·claude
№ 182coding

Design a normalized database schema from plain requirements

Turns plain-language requirements into a normalized relational schema with DDL, relationships, and trade-offs.

For
chatgpt·claude
№ 183coding

Diagnose and rewrite a slow SQL query using its plan

Reads a query plan to explain why a SQL statement is slow, then rewrites it and recommends indexes.

For
chatgpt·claude
№ 184coding

Decode a stack trace and pinpoint the likely root cause

Reads a stack trace frame by frame to explain the failure and pinpoint the most likely root cause with next steps.

For
chatgpt·claude
№ 185coding

Brainstorm edge-case test scenarios before you write tests

Enumerates grouped edge-case and adversarial test scenarios for a feature so nothing gets shipped untested.

For
chatgpt·claude