Skip to main content
Prompt library

AI prompt library

Hand-picked, copy-paste prompts organized by what you're trying to do. Free, model-agnostic, and ready to use.

New to prompting? Read the guide →

Browse by task

Popular prompts

Generate a function from a plain-English description

beginner

Generates a production-ready function from a plain-English description; useful when you know what you need but don't want to write boilerplate from scratch.

You are an expert [LANGUAGE] developer. Write a clean, well-commented function that does the following: [DESCRIBE WHAT THE FUNCTION SHOULD DO]. Include: (1) the function signature with typed parameters where the language supports it, (2) inline comments explaining non-obvious logic, (3) a brief docstring or header comment, and (4) two example calls showing expected input and output. Use idiomatic [LANGUAGE] style.

How to use: Replace [LANGUAGE] with e.g. Python, TypeScript, or Go, and fill [DESCRIBE WHAT THE FUNCTION SHOULD DO] with a clear one-paragraph spec.

code generationfunctionsbeginner

Debug a broken code snippet

beginner

Systematically finds and fixes bugs in a broken snippet; ideal when you have an error message or unexpected output and need a thorough diagnosis.

You are a senior [LANGUAGE] engineer and expert debugger. I have the following code that is supposed to [WHAT THE CODE SHOULD DO], but instead it [DESCRIBE THE ACTUAL WRONG BEHAVIOR OR ERROR MESSAGE].

Code:

[PASTE YOUR CODE HERE]


Please: (1) identify every bug, (2) explain why each bug causes the problem, (3) provide the corrected code in full, and (4) suggest one preventive practice to avoid each bug in the future.

How to use: Paste the exact error message or describe the wrong behavior precisely — vague descriptions yield vague fixes.

debuggingerror fixingbeginner

Explain code to a non-programmer

beginner

Translates code into plain English for non-technical stakeholders; useful for documentation, onboarding, or code reviews with mixed audiences.

Explain the following [LANGUAGE] code to someone who has never programmed before. Use plain English, real-world analogies, and avoid jargon. After the explanation, list what the code ultimately produces or does in one sentence.

Code:

[PASTE YOUR CODE HERE]

How to use: If the audience has some technical knowledge, replace 'never programmed before' with their actual skill level for a better-calibrated explanation.

explanationdocumentationbeginner