Code Generation & Software Engineering Prompts
Prompts tailored for refactoring, bug fixing, unit test generation, and architectural design. This category has 15 ready-made Code Generation & Software Engineering prompts for ChatGPT, Claude and Gemini. Each one comes with a copy-ready template, a worked example, best practices and the mistakes to avoid. Open a prompt to fill in its blanks, or paste it straight into your AI chat.
Want one tailored to you? Fill in a prompt template and copy it.
AI Prompt to Write a GitHub Actions CI/CD Workflow from Plain English
This is a prompt for turning a plain English description of your build, test, and deploy process into a working GitHub Actions workflow YAML…
Role: You are a DevOps engineer writing a GitHub Actions workflow file. Context: Project type: [LANGUAGE/FRAMEWORK, e.g. Node.js with npm, Python with Poetry] Repository structure notes: [e.g. monorepo with /api and /web folders, single app at root] Runner: [e.g. ubuntu-latest] Task: Write a GitHub Actions workflow (.github/workflows/[FILENAME].yml) that does the following, in this order: 1. Trigger on: [TRIGGER EVENTS, e.g. pull_request to main, push of tags matching v*] 2. Job 1 - [JOB NAME, e.g. lint]: [WHAT IT DOES] 3. Job 2 - [JOB NAME, e.g. test]: [WHAT IT DOES], must run only after Job 1 succeeds 4. Job 3 - [JOB NAME, e.g. deploy]: [WHAT IT DOES], must run only after Job 2 succeeds and only on [CONDITION, e.g. tag pushes to main] Secrets/environment variables needed (reference by name only, do not invent values): [SECRET NAMES, e.g. DEPLOY_TOKEN, AWS_ACCESS_KEY_ID] Constraints: - Pin third-party actions to a specific major version (e.g. actions/checkout@v4) - Use caching for dependencies where the ecosystem supports it - Keep job names and step names descriptive enough to read clearly in the Actions UI Output format: Return the complete YAML file in a fenced code block, followed by a short bullet list explaining what each job does and when it runs.
AI Prompt to Debug a Failed Vercel Deployment Using Vercel's MCP Server
This Vercel MCP prompt helps developers and DevOps engineers figure out why a deployment failed without manually scrolling through build log…
ROLE: You are a deployment troubleshooting assistant with access to Vercel's MCP server. CONTEXT: - Project: [PROJECT_NAME] - Framework: [FRAMEWORK, e.g. Next.js 14] - Deployment ID or URL: [DEPLOYMENT_ID_OR_URL] - Last known good deployment: [PREVIOUS_DEPLOYMENT_ID_OR_URL, or 'none'] - What changed since the last successful deploy: [RECENT_CHANGES_SUMMARY] TASK: 1. Retrieve the build and runtime logs for the failing deployment. 2. Identify the failure category: build error, runtime error, environment/configuration issue, or dependency issue. 3. Quote the specific log lines that show the root cause. 4. If a last known good deployment is provided, compare configuration and environment variables between the two. 5. Propose a ranked list of likely fixes, most probable first. CONSTRAINTS: - Do not guess at a cause without quoting supporting log evidence. - Flag if critical information (e.g. an environment variable value) is missing rather than assuming it. OUTPUT FORMAT: - Failure category - Root cause (with quoted log evidence) - Ranked fix recommendations - Any missing information needed to confirm the diagnosis
ChatGPT Prompt to Generate a Production-Ready Dockerfile for Your App
This Dockerfile generator prompt gives ChatGPT, Claude, or Gemini everything needed to write a secure, production ready Dockerfile for your…
You are an expert DevOps engineer who writes secure, production-ready Dockerfiles. Context: - Application language and version: [LANGUAGE AND VERSION, e.g., Node.js 20] - Framework: [FRAMEWORK, e.g., Express, Django, Spring Boot] - Package manager: [PACKAGE MANAGER, e.g., npm, pip, Maven] - Target deployment platform: [PLATFORM, e.g., AWS ECS, Kubernetes, linux/amd64] - Special requirements: [e.g., private package registry, native dependencies, health checks] Task: Write a production-ready Dockerfile for this application. Use a multi-stage build that separates the build/dependency-install stage from the final runtime stage. The final image should: 1. Use the smallest reasonable base image for the runtime. 2. Run as a non-root user. 3. Only copy the files needed to run the application, not build tools or source maps. 4. Include a HEALTHCHECK instruction appropriate for this type of service. 5. Set any necessary environment variables and expose the correct port. Constraints: - Do not use the "latest" tag for any base image; pin a specific version. - Keep the final image size as small as possible. - Explain, in a short comment above each non-obvious instruction, why it's there. Output format: 1. The complete Dockerfile in a single code block. 2. A short bullet list explaining the base image choice and any trade-offs. 3. One suggested .dockerignore entry list for this stack.
AI Prompt to Debug a Failing API Test Using Postman's MCP Server
This prompt helps developers and QA engineers debug a failing API test by having an AI assistant like Claude or ChatGPT pull live request an…
ROLE: You are a senior API test engineer helping debug a failing test in a Postman collection accessed through an MCP connection. CONTEXT: - Collection name: [COLLECTION_NAME] - Failing request/folder: [REQUEST_OR_FOLDER_NAME] - Environment: [ENVIRONMENT_NAME] - Last known good run (if available): [RUN_ID_OR_DATE] TASK: 1. Retrieve the failing request's details (method, URL, headers, body) and its actual response (status code, headers, body) from the connected Postman MCP server. 2. Identify the exact assertion or test script line that failed, quoting it directly. 3. Compare the failing response against the expected response or the last known good run, and list every meaningful difference. 4. Classify the likely root cause as one of: schema change, authentication/authorization failure, timeout/network issue, environment misconfiguration, or application bug. 5. Propose a specific fix or next diagnostic step for that category. CONSTRAINTS: - Do not guess at response data you have not actually retrieved; if the MCP call fails, say so explicitly. - Keep the explanation under 200 words before listing the fix. OUTPUT FORMAT: - Summary: [one-sentence description of the failure] - Evidence: [key request/response fields and the failing assertion] - Root cause category: [one of the five categories above] - Recommended fix: [specific, actionable step]
AI Prompt to Generate an OpenAPI Spec From Existing API Code
This OpenAPI spec generator prompt tells ChatGPT, Claude, or Gemini how to read your existing API route handlers, controllers, or endpoint f…
ROLE You are an API documentation specialist who writes precise OpenAPI 3.x specifications strictly from the code provided. CONTEXT Language/framework: [LANGUAGE_AND_FRAMEWORK] Source code for this route group: [PASTE_ROUTE_OR_CONTROLLER_CODE] Existing spec file to extend, if any: [EXISTING_OPENAPI_FILE_OR_NONE] TASK For each endpoint in the provided code: 1. Identify the HTTP method, path, and path/query parameters with their types 2. Infer the request body schema from validation logic, type annotations, or serializers 3. Infer every possible response, including success and all error status codes the handler can return 4. Mark any field you cannot determine with confidence as [NEEDS REVIEW] in a comment rather than guessing CONSTRAINTS - Do not invent fields, parameters, or response codes that are not implied by the code - Use OpenAPI 3.1 syntax unless [OPENAPI_VERSION] specifies otherwise - Reuse and reference shared schemas with $ref instead of duplicating object definitions - Keep descriptions factual and based only on what the code does, not assumed business intent OUTPUT FORMAT Return a single valid YAML OpenAPI document, followed by a short bullet list titled 'Needs Human Review' for anything flagged uncertain.
AI Prompt to Generate a Regular Expression From a Plain-English Description
This regex generator prompt is for developers who know exactly what pattern they need to match but don't want to hand write and debug regex…
ROLE: You are a regular expression expert who writes precise, well-documented patterns. CONTEXT: I need a regular expression for this matching rule: [DESCRIBE WHAT THE PATTERN SHOULD MATCH IN PLAIN ENGLISH]. Target regex flavor/language: [E.G., JAVASCRIPT, PYTHON RE, PCRE, POSIX]. Strings that SHOULD match: [LIST 3-5 EXAMPLE STRINGS] Strings that should NOT match: [LIST 3-5 EXAMPLE STRINGS] TASK: 1. Write a regular expression that matches all the "should match" strings and rejects all the "should not match" strings. 2. Break down the pattern piece by piece, explaining what each group, anchor, and character class does. 3. Test the pattern mentally against every example I gave and confirm the result for each. 4. List any realistic edge cases my examples didn't cover that could still break this pattern, and note how the pattern handles them. OUTPUT FORMAT: - The regex pattern in a code block - A numbered breakdown of each part of the pattern - A table confirming match/no-match for each example string - A short "Edge cases to watch for" list
AI Prompt to Turn a Linear Ticket Into an Implementation Plan Using Linear's MCP Server
This prompt turns a raw Linear ticket into a concrete implementation plan before any code gets written. It's built for developers and tech l…
ROLE You are a senior software engineer producing an implementation plan from a project management ticket before any code is written. CONTEXT - Ticket source: Linear, accessed via the connected MCP server - Ticket ID or URL: [TICKET_ID_OR_URL] - Target repository or service: [REPO_OR_SERVICE_NAME] - Relevant tech stack: [LANGUAGE_FRAMEWORK_STACK] TASK 1. Read the ticket's title, description, comments, labels, and any linked parent or sub-issues from the connected Linear MCP server. 2. Summarize the current requirements in 3-5 sentences, noting anything that changed from the original description. 3. Propose an implementation approach: the files or modules likely affected, in order of change. 4. List edge cases and error conditions the implementation must handle. 5. List open questions that should be posted back to the ticket before work starts. CONSTRAINTS - Do not invent requirements that are not stated in the ticket or its comments. - If acceptance criteria are missing or ambiguous, say so explicitly instead of assuming an answer. - Keep the file/module list specific to what the ticket's labels and linked repo indicate; do not list unrelated parts of the codebase. - Flag any blocking dependency on another open ticket. OUTPUT FORMAT ## Ticket Summary [3-5 sentence summary] ## Implementation Approach - [Ordered list of files/modules and what changes in each] ## Edge Cases - [List] ## Open Questions - [List, or "None" if genuinely none]
AI Prompt to Triage Production Errors Using Sentry's MCP Server
This AI prompt is for developers and on call engineers who connect an AI assistant to Sentry's MCP server and want a fast, consistent first…
ROLE: You are a software engineer triaging production error reports retrieved through Sentry's MCP integration. CONTEXT: - Project: [PROJECT NAME] - Time window: [E.G. LAST 24 HOURS] - Current release/deploy: [VERSION, DEPLOY TIME] - Known pre-existing low-priority issues to exclude: [LIST OR 'NONE'] TASK: 1. Retrieve open issues for the specified project and time window via the MCP connection, including stack trace, event count, affected users, and first-seen timestamp. 2. Group issues that share the same root exception type and call path as a single item. 3. For each grouped issue, state what the stack trace shows is happening, which file/function is implicated, and your confidence level in that read (high/medium/low). 4. Rank issues by severity using event count, affected user count, and whether first-seen falls after the stated deploy time. 5. Exclude any issue listed as a known pre-existing low-priority issue, but note it was excluded. CONSTRAINTS: - Do not propose a specific code fix; describe what the trace indicates and flag it for the responsible engineer. - Do not rank an issue as high severity solely because of the error message tone; use the stated metrics. - If stack trace data is incomplete or truncated, say so instead of inferring the missing frames. OUTPUT FORMAT: - Triage Summary (total issues reviewed, number flagged as new since deploy) - Ranked Issue List (issue title, severity, event count, affected users, confidence in root cause read) - Excluded Known Issues (if any) - Issues Needing Manual Trace Review (low-confidence reads)
AI Prompt to Review Pull Requests for Bugs and Security Using GitHub's MCP Server
This prompt gives developers and engineering leads a repeatable way to review pull requests for bugs, security issues, and style problems by…
Role: You are a senior code reviewer with access to a GitHub MCP connection. Context: - Repository: [REPO_NAME] - Pull request: [PR_NUMBER] - Primary language/framework: [LANGUAGE_OR_FRAMEWORK] - Team coding standards: [LIST_KEY_STANDARDS_OR_LINT_RULES] Task: 1. Pull the current diff, changed file list, and CI status for the specified pull request. 2. Review the changes for: functional bugs, security issues (e.g. unvalidated input, hardcoded secrets, injection risks), and violations of the team's coding standards. 3. Note any missing or inadequate test coverage for the changed code. Constraints: - Base feedback only on the actual diff and files pulled from the repository, not assumptions about unseen code. - Separate findings into "Blocking" and "Suggestion" categories. - Reference the specific file and line number for each finding. - Do not approve, merge, or close the pull request; this review is advisory only. Output format: - Summary: one paragraph on overall PR readiness - Blocking issues: bulleted list with file:line and explanation - Suggestions: bulleted list with file:line and explanation - Test coverage notes: bulleted list
AI Prompt to Generate API Documentation From Source Code
This AI prompt for API documentation turns a block of source code (a function, a class, a set of REST route handlers) into clear, structured…
ROLE: You are a technical writer who specializes in developer-facing API documentation. CONTEXT: Language/framework: [PROGRAMMING LANGUAGE AND FRAMEWORK, e.g., Python/FastAPI] Code to document: [PASTE THE FULL FUNCTION, CLASS, OR ROUTE HANDLER HERE] Audience: [e.g., external API consumers / internal engineering team / open-source contributors] TASK: Document the code above. Base every statement only on what the code actually does — do not assume standard behavior that isn't present in the code itself. For each function or endpoint, produce: 1. SUMMARY: one sentence describing its purpose 2. PARAMETERS: name, type, whether required or optional, and what it's used for 3. RETURNS: the type and shape of the return value or response 4. ERRORS: every distinct error condition present in the code (exceptions raised, non-success status codes, validation failures), with the exact trigger condition 5. EXAMPLE: a realistic call or request with sample input and the resulting output CONSTRAINTS: - If a parameter's type or default value is ambiguous in the code, flag it as [NEEDS CLARIFICATION] rather than guessing - Do not add a 'notes' or 'best practices' section unless explicitly asked - Keep the summary to one sentence OUTPUT FORMAT: Return the documentation in [MARKDOWN / JSON / OPENAPI YAML] using this exact section order: Summary, Parameters, Returns, Errors, Example.
ChatGPT Prompt to Review Code for Bugs, Style, and Security Issues
This code review prompt turns ChatGPT, Claude, or Gemini into a thorough reviewer that checks a diff or file for bugs, style problems, and s…
You are an experienced software engineer performing a code review. Review the following code change for issues a careful human reviewer would catch before approving a pull request. Context: - Language/framework: [LANGUAGE AND FRAMEWORK] - Style guide or conventions to follow: [STYLE GUIDE, e.g. PEP 8, Airbnb JS, or "none specified"] - Purpose of this change: [ONE-SENTENCE DESCRIPTION OF WHAT THE CHANGE DOES] Code to review: [PASTE DIFF OR FULL FILE CONTENTS HERE] Review the code across these categories, in this order: 1. Correctness — logic errors, edge cases, off-by-one errors, null/undefined handling 2. Security — injection risks, unvalidated input, broken access control, exposed secrets 3. Readability — unclear naming, missing comments where logic is non-obvious, overly complex functions 4. Performance — unnecessary loops, redundant computation, inefficient queries 5. Test coverage — missing tests for new logic or edge cases Constraints: - Cite the specific line number or exact code snippet for every finding - Label each finding as Blocking, Should-fix, or Nitpick - Do not rewrite the code — describe the issue and suggest a fix in words - If a category has no issues, state that explicitly rather than skipping it Output format: For each category, list findings as: [Severity] Line/snippet: [code reference] Issue: [what's wrong] Suggested fix: [brief description] End with a one-line overall verdict: Approve, Approve with comments, or Request changes.
ChatGPT Prompt to Debug an Error From a Stack Trace
A debug stack trace prompt gives ChatGPT, Claude, or Gemini the exact error message, the stack trace, and the relevant code so it can find t…
ROLE: You are an experienced [PROGRAMMING LANGUAGE] developer helping debug a runtime error. CONTEXT: - Language/runtime: [LANGUAGE AND VERSION, e.g. Python 3.11, Node 20] - Framework/libraries involved: [FRAMEWORK NAMES AND VERSIONS] - What the code is supposed to do: [BRIEF DESCRIPTION OF THE FEATURE OR FUNCTION] - Error message and full stack trace: [PASTE FULL ERROR MESSAGE AND STACK TRACE HERE, TOP TO BOTTOM, UNEDITED] - Relevant source code (include every function/file named in the trace): [PASTE CODE FOR EACH FRAME IN THE STACK TRACE] - What I've already tried: [LIST ANY FIXES OR CHECKS ALREADY ATTEMPTED, OR WRITE "NOTHING YET"] CONSTRAINTS: - Do not suggest a fix until you've identified the specific line and condition that triggers the exception - If the trace doesn't contain enough information to be certain, say so and list what additional information (logs, input values, config) would confirm the cause - Do not assume framework defaults that weren't stated — ask if a detail is missing rather than guessing OUTPUT FORMAT: 1. Root cause analysis: the most likely cause, tied to the exact line/frame in the trace 2. Alternative hypotheses: 1-2 other possible causes, ranked by likelihood, each with what evidence would confirm or rule it out 3. Suggested fix: the minimal code change to resolve the most likely cause 4. Verification step: how to confirm the fix actually resolves the error (a test to run, a log line to check, an input to retry)
ChatGPT Prompt to Write Clear Commit Messages and Pull Request Descriptions
This ChatGPT prompt for writing commit messages and pull request descriptions turns a raw code diff into a clean, reviewable summary a teamm…
ROLE: You are a senior software engineer writing a commit message and pull request description for a code change. CONTEXT: - Code diff or summary of changes: [PASTE DIFF OR DESCRIBE THE CHANGE] - Related ticket/issue: [TICKET ID AND TITLE, OR "NONE"] - Commit convention to follow: [E.G. CONVENTIONAL COMMITS, FREEFORM, TICKET-PREFIXED] - Audience for the PR description: [E.G. TEAM ENGINEERS, EXTERNAL CONTRIBUTORS] TASK: 1. Write a commit subject line under 72 characters that follows the specified convention. 2. Write a 2-4 sentence commit body explaining what changed and, if context was given, why. 3. Write a pull request description with these sections: Summary, Why This Change Is Needed, How It Was Tested, Risk/Areas to Review Closely. 4. If the diff includes a schema change, new dependency, or breaking change, call it out explicitly under Risk/Areas to Review Closely. CONSTRAINTS: - Do not invent functionality, reasoning, or test coverage that wasn't stated or shown in the diff. - Keep the PR description skimmable — short paragraphs or bullets, not dense prose. - If information needed for a section is missing, write "Not specified" rather than guessing. OUTPUT FORMAT: Commit Subject: [text] Commit Body: [text] PR Description: ## Summary [text] ## Why This Change Is Needed [text] ## How It Was Tested [text] ## Risk / Areas to Review Closely [text]
Claude Prompt to Refactor Legacy Code for Readability and Maintainability
This Claude prompt for refactoring legacy code is built for developers who've inherited a function or module that works but is hard to read,…
Role: You are a senior software engineer specializing in code readability and maintainability. Context: Language/framework: [LANGUAGE_AND_VERSION] Style guide or conventions to follow: [STYLE_GUIDE_OR_LINTING_RULES] What this code does: [BRIEF_DESCRIPTION_OF_FUNCTIONALITY] Constraints (things that must not change): [PUBLIC_API_SIGNATURES_OR_OTHER_CONSTRAINTS] Code to refactor: [PASTE_FULL_FUNCTION_OR_FILE_HERE] Instructions: 1. Refactor the code for readability and maintainability: clearer naming, smaller single-purpose functions, removed duplication, reduced nesting. 2. Do not change external behavior or any stated constraints (public API, function signatures used elsewhere). 3. List each change you made, one by one, with a short reason for it. 4. Suggest 2-3 test cases I should run to confirm the refactor preserves the original behavior. 5. If any part of the code is ambiguous or you're unsure of intended behavior, flag it instead of guessing. Output format: 1. Refactored code in a fenced code block 2. A numbered list of changes with a one-line reason for each 3. Suggested test cases
Prompt to Generate Unit Tests From a Function
This prompt turns an existing function into a set of unit tests covering its normal behavior, edge cases, and error handling, built for deve…
You are a senior software engineer writing unit tests. Function to test: [PASTE THE FUNCTION CODE] Language and test framework: [E.G. TYPESCRIPT WITH VITEST, PYTHON WITH PYTEST] Instructions: 1. Write tests covering normal, expected inputs. 2. Write tests covering edge cases: empty input, null/undefined, boundary values. 3. Write tests covering any error conditions the function should raise or handle. 4. Use clear, descriptive test names that state what is being verified. 5. Return only the test code, in a single code block, ready to run. Output format: one fenced code block containing the complete test file.