Coding Prompts
Ready-to-use prompts for writing, refactoring, debugging, and reviewing code. Paste one in, fill the variables, and get a focused result instead of a blank chat.
Write a Bash script that does the following: Task: {{task}} Requirements: - Start with a strict mode header (set -euo pipefail). - Accept these inputs as arguments or flags: {{inpu...
Convert the following {{language}} code from callbacks or promise chains to async/await. Code: {{code}} Requirements: - Preserve the exact behavior and error handling. - Use try/ca...
Write a README.md for this project. Project name: {{project_name}} What it does: {{description}} Tech stack: {{stack}} How to install and run: {{setup}} Include these sections: - A...
Add robust input validation to the following {{language}} function. Code: {{code}} Validation rules to enforce: {{rules}} Requirements: - Reject invalid input early with clear erro...
Analyze the time and space complexity of this {{language}} code. Code: {{code}} Provide: 1. The Big O time complexity with the reasoning. 2. The Big O space complexity with the rea...
Generate {{count}} rows of realistic mock data in {{format}} format. Each record should have these fields with these constraints: {{fields}} Requirements: - Make values realistic a...
I am stuck in git and need help fixing it safely. What I was trying to do: {{goal}} What happened instead: {{problem}} Output of git status and any error: {{git_output}} Give me: 1...
Build a command-line tool in {{language}} that does the following. Purpose: {{purpose}} Commands and options it should support: {{commands}} Requirements: - Parse arguments with th...
Simplify the tangled conditional logic in this {{language}} code without changing behavior. Code: {{code}} Approach: - Use guard clauses and early returns to flatten nesting. - Com...
Write an integration test for the following flow using {{framework}}. Flow to test: {{flow}} Components involved: {{components}} Requirements: - Set up and tear down any needed sta...
Explain this regular expression in detail. Regex: {{regex}} Flavor or language: {{regex_flavor}} Provide: 1. A one-sentence summary of what it matches. 2. A breakdown of each token...
Review this {{language}} function and find edge cases it does not handle. Code: {{code}} What the function is supposed to do: {{intended_behavior}} List every edge case or unusual...
Set up environment-based configuration for a {{stack}} application. Settings the app needs: {{settings}} Deliver: 1. A sample .env.example file with every variable and a comment fo...
Implement the following pseudocode as working {{language}} code. Pseudocode: {{pseudocode}} Requirements: - Translate the logic faithfully. - Choose appropriate data structures for...
Improve the naming in this {{language}} code. Code: {{code}} For each poorly named variable, function, or class: - Show the old name and a better name. - Briefly explain why the ne...
Add logging to the following {{language}} code using {{logging_library}}. Code: {{code}} Guidelines: - Log at the right level (debug, info, warn, error) for each event. - Include u...
I have a design problem and want to know if a pattern fits. The problem: {{problem}} Current code or structure: {{current_code}} Do the following: 1. Recommend the most suitable de...
Write a parser in {{language}} for the following data format. Description of the format: {{format_description}} A sample of the input: {{sample_input}} The structure I want it pars...
Perform a security review of this {{language}} code. Code: {{code}} Context (what it does, where input comes from): {{context}} Check for: injection (SQL, command, etc.), missing i...
Write a database migration for {{migration_tool}} on {{dialect}}. The change needed: {{change}} Current relevant schema: {{current_schema}} Requirements: - Provide both the up and...
Summarize what the following diff does for someone who has not seen the code. Diff: {{diff}} Provide: 1. A two-sentence high-level summary of the change. 2. A bullet list of the me...
Add precise type annotations to this {{language}} code. Code: {{code}} Requirements: - Type all parameters, return values, and key variables. - Define interfaces or types for any o...
Break this feature down into a clear, ordered list of implementation tasks. Feature request: {{feature}} Current tech stack: {{stack}} Known constraints: {{constraints}} Produce: 1...
Refactor this {{language}} function to separate pure logic from side effects. Code: {{code}} Goals: - Extract the core computation into a pure function with no I/O or mutation of e...
Help me find and fix a performance problem in this {{language}} code. Code: {{code}} Symptoms: {{symptoms}} Rough scale of the data or load: {{scale}} Do the following: 1. Identify...
Write a small client in {{language}} for the following API. API details: - Base URL: {{base_url}} - Endpoints I need: {{endpoints}} - Authentication: {{auth}} Requirements: - One f...
Help me trace a bug back to its root cause from this stack trace. Stack trace: {{stack_trace}} Relevant code from the frames mentioned: {{code}} What I was doing when it happened:...
Write a scheduled job that does the following. Task to run: {{task}} How often it should run: {{schedule}} Environment or scheduler: {{scheduler}} Requirements: - Provide the sched...
Improve the error handling in this {{language}} code. Code: {{code}} Guidelines: - Catch errors at the right level; do not swallow them silently. - Distinguish recoverable from unr...
I am choosing between two approaches to solve a coding problem. Help me decide. The problem: {{problem}} Approach A: {{approach_a}} Approach B: {{approach_b}} Constraints that matt...
Write Kubernetes manifests to deploy a {{stack}} service. Details: - Container image: {{image}} - Port the app listens on: {{port}} - Replicas: {{replicas}} - Environment variables...
I found a bug and want to write a regression test that fails now and passes after the fix. The bug: {{bug_description}} The buggy code: {{code}} How to reproduce it: {{repro}} Test...
Help me understand this part of a codebase I am new to. Files or code: {{code}} What I am trying to do: {{goal}} Explain: 1. The overall responsibility of this code. 2. How data fl...
Write {{language}} code that transforms data from one shape to another. Input shape (with a sample): {{input_shape}} Desired output shape (with a sample): {{output_shape}} Mapping...
Analyze this code and its existing tests to find coverage gaps. Code: {{code}} Existing tests: {{tests}} Identify: 1. Branches, conditions, or code paths that no test currently exe...
Write a changelog entry for version {{version}} based on these changes. Changes (commits or notes): {{changes}} Format: - Group entries under headings: Added, Changed, Fixed, Remov...
Write a Makefile for a {{stack}} project that wraps these common tasks. Tasks I run often: {{tasks}} Requirements: - Create a target for each task with a clear name (install, build...
You are a performance engineer specializing in {{runtime}} memory profiling. Context: - Service: {{service_description}} - Symptom: RSS grows from {{start_mem}} to {{end_mem}} over...
You are a test-reliability engineer. A test in {{framework}} fails about {{flake_rate}} of CI runs but passes locally. Test code: {{test_code}} Code under test: {{source_code}} Fai...
Act as a senior {{language}} debugger. Here is a stack trace from {{environment}}: {{stack_trace}} Relevant code if it helps: {{code_context}} Walk me through it: 1. Translate the...
You are a staff engineer planning an incremental migration. Legacy component: {{legacy_description}} Target design: {{target_description}} Constraints: zero downtime, every step in...
You are a database performance specialist for {{database}}. Slow query: {{query}} Schema and indexes: {{schema}} Execution plan (EXPLAIN ANALYZE or equivalent): {{plan}} Table size...
You are a regex expert writing for the {{regex_flavor}} engine. Goal: match {{what_to_match}}. Must match these: {{positive_examples}} Must NOT match these: {{negative_examples}} C...
You are a concurrency specialist in {{language}} using {{concurrency_model}} (threads, async, goroutines, actors). Code: {{code}} Shared state and invariants that must hold: {{inva...
You are an API designer. Design the contract for: {{api_purpose}}. Consumers: {{consumers}} Style: {{style}} (REST, gRPC, GraphQL). Non-functional needs: {{nfr}} (pagination, idemp...
You are a container/DevOps engineer. Review and rewrite this Dockerfile for a {{language}} {{app_type}}. Current Dockerfile: {{dockerfile}} Goals: minimal final image, fast cache-f...
You are a testing expert using {{pbt_library}} (e.g. Hypothesis, fast-check, QuickCheck). Function under test: {{function_code}} What it is supposed to guarantee (in words): {{cont...
You are documenting an architecture decision as an ADR. Decision to record: {{decision}} Context / forces: {{context}} Options considered: {{options}} Constraints: {{constraints}}...
You are a refactoring expert in {{language}}. Code that mixes logic and side effects: {{code}} Refactor to separate the pure decision-making core from the imperative shell (I/O, ne...
You are an application security reviewer. Review this {{language}} endpoint that handles {{endpoint_purpose}}. Code: {{code}} Trust boundaries: {{trust_context}} (who calls it, wha...