ShareYourGroupShareYourGroupAI Prompts

All tasks · Work and office · 6 prompts

AI prompts for coding help

For learners and working programmers alike, an AI assistant is a patient colleague who has read a great deal of code. It explains errors well and writes small functions quickly. It also produces code that looks right and is not, uses functions that do not exist, and cannot see the rest of your project. The prompts below give it what it needs and ask it to show its reasoning so that you can check it.

The prompts

Explain this error

I am writing [LANGUAGE AND VERSION] on [OPERATING SYSTEM]. I get this error:

[PASTE THE FULL ERROR MESSAGE]

from this code:

[PASTE THE SMALLEST PIECE OF CODE THAT SHOWS THE PROBLEM]

Explain in plain words what the error means, which line causes it and why. Then show the fix. If there is more than one possible cause, list them and tell me how to find out which applies.

Replace the parts in [CAPITALS] first, or after pasting.

Review my code

Review this [LANGUAGE] code. It is meant to [WHAT IT SHOULD DO]. I am a [BEGINNER / INTERMEDIATE] programmer.

Tell me, in this order: bugs or cases where it gives a wrong result, anything unsafe, and then ways to make it clearer. For each point, quote the line and explain why. Do not rewrite the whole thing unless I ask.

[PASTE THE CODE]

Replace the parts in [CAPITALS] first, or after pasting.

Write a small function

Write a [LANGUAGE] function that [WHAT IT SHOULD DO].

Input: [DESCRIBE, WITH AN EXAMPLE]
Output: [DESCRIBE, WITH AN EXAMPLE]
Edge cases to handle: [EMPTY INPUT, NEGATIVE NUMBERS, AND SO ON]

Use only the standard library. Add short comments. After the function, give three test calls with the results I should expect, so that I can check it.

Replace the parts in [CAPITALS] first, or after pasting.

Explain code I did not write

Explain what this code does, first in two sentences overall, then section by section. Point out anything unusual or risky. Assume I know basic [LANGUAGE] but not this project.

[PASTE THE CODE]

Replace the parts in [CAPITALS] first, or after pasting.

Teach me a concept

Teach me [CONCEPT, FOR EXAMPLE RECURSION OR A DATABASE JOIN] in [LANGUAGE]. I already understand [WHAT YOU KNOW].

Use one everyday comparison, then one very small code example that I can run, then one slightly larger one. Finish with two short exercises and do not give the answers until I ask.

Replace the parts in [CAPITALS] first, or after pasting.

Help me plan before I code

I want to build [WHAT, IN ONE OR TWO SENTENCES] using [LANGUAGE OR TOOLS]. I am a [LEVEL] programmer.

Do not write the code yet. Break the work into small steps I can build and test one at a time, in order. For each step, say what I will have working at the end of it. Point out the part most likely to be difficult.

Replace the parts in [CAPITALS] first, or after pasting.

How to adapt these prompts

Run it, read it, and protect your secrets

Treat code from an assistant as a suggestion from a stranger. Read it until you understand each line, then run it on test data before real data. Use the test calls it gives, and add one of your own that it did not think of. If it uses a function or library you have not heard of, check that the thing exists in the official documentation, because assistants sometimes invent convincing names.

Never paste passwords, API keys, connection strings or customer data into a prompt. Replace them with made-up values. If the code belongs to your employer, check whether you are allowed to share it with an outside service at all.

If you are a student, find out what your course allows. Using an assistant to explain an error is different from handing in code you did not write.

Related tasks

This is an independent site. It is not connected with any company that makes AI assistants. The prompts are plain text and can be used in any AI chat assistant. An AI assistant can give wrong or made-up answers: check anything important before you rely on it, and do not paste private details into a prompt.