Sourcing useful ChatGPT coding prompts to feature

What’s a specific ChatGPT prompt you’ve used while coding that you found useful or cool?

We’re putting together a page on chatgpt.com that shows the best coding prompts to help those just getting started. (And if we use your prompt, we’ll list contributors at the bottom of the page.)

I really like using this one for learning specific syntax of programming languages that I’m learning or using. Makes it so that I just get small example snippets as responses and keeps the momentum of learning new languages in a bit more practical way for me:

System Instruction:
You are a code-only assistant. Always output only one fenced code block with the requested language tag, containing exactly one minimal, valid example.

Strict Rules:
• No explanations, comments, headings, or extra text.
• No variations, alternatives, or multiple snippets.
• If language not specified, default to rust.
• If minimal valid code requires >5 lines, truncate to the smallest runnable fragment.
• Always format as a single markdown code block

Then I put that as the instructions for a ChatGPT project and just keep it open when I want to get quick concise code examples on things like “how do I implement a trait?”.

I have it default to Rust but that could be tweaked of course.

Prompt Example (Dev Mode):
“You are helping me with heavy programming. Follow these rules:
– Minimal chatter, no long explanations.
– For each step, give me only a 1–2 sentence explanation outside the code.
– Code must be broken into small, skinny blocks (no giant walls).
– End each code block with a :white_check_mark: outside the block to show the render is complete.
– Keep all chatter strictly outside code blocks.
– Stay consistent across the session.”
– When I tell you to check your drift reference these rules and get back on your rail.

Why it works:
This structure minimizes distraction and drift during long coding sessions. It ensures clarity (short explanations), readability (skinny code blocks), and consistent formatting with a clear :white_check_mark: marker for visual completeness. The drift check gives you a reset lever mid-session without derailing your workflow.

Prompt Example (Checklist Mode):

“You are helping me with coding. Follow these rules:
– Always output the next step as a numbered checklist before showing any code.
– Keep explanations to one short sentence per checklist item.
– Only after the checklist, show the minimal code needed for that step.
– End each code block with a :white_check_mark: outside the block.”

Why it works:
Breaks complex tasks into digestible steps and prevents the model from dumping everything at once.

Prompt Example (Diff Mode):

“You are helping me refactor code. Follow these rules:
– Never output full files.
– Show only the minimal diff (before → after) for each change.
– Keep explanations outside the code block, one sentence max.
– End each diff block with a :white_check_mark: outside the block.”

Why it works:
Great for large projects where you only want to see precise edits instead of walls of code.

Prompt Example (Question-First Mode):

“You are helping me with coding. Follow these rules:
– Before writing code, ask up to 3 clarifying questions if needed.
– After my answers, give only the minimal code needed.
– Keep commentary outside of code blocks, one sentence max.
– End each code block with a :white_check_mark: outside the block.”

Why it works:
Forces alignment before output, which reduces wasted effort and misfires.

Added a few more for you guys. Hope they help! Hit those rails and bend them to your will!

Don’t let the language model cage you. It wants structure.

This applies when you are porting a project that has existing documentation.

Add the documentation to the repo and instruct the agent to use it.
Also - make sure it doesn’t change the documentation unless explicitly asked to do so.

I read Tauman Kalai paper “Why Language Models Hallucinate.” I would like to briefly share a related idea I call relational prompting.

Concept: Instead of asking for facts or using RAG, the prompt asks the model to verbalize internal relationshipsbetween learned concepts (proximity, direction, clusters) as an interpretable map of its semantic space.

Example prompt:
“Analyze the topic as vectors in a high-dimensional space. Describe which concepts are closest, which share directions, and which form clusters. Provide concise verbal justifications.”

Potential value:

  • Education: reveal conceptual networks rather than isolated definitions

  • Research: explorative knowledge mapping across domains

  • Transparency: surface structure to detect weakly grounded outputs

I would be very interested to hear your thoughts on this concept and whether you see possibilities to explore or validate it further. I’d appreciate being credited as the originator of the idea ‘relational prompting’ if this concept proves useful in anyones work.

I am a vibe coder. In my case, it’s something like this…:grinning_face_with_smiling_eyes:

Look at the below code.

(paste the full code)

This code is doing something. (fill in whatever it is doing)

I want to make it to do something extra. (fill in whatever change you want)

Please add the necessary changes and add comments to highlight exactly where you made the change. Don’t touch any other part of the code.

Give me the full code with your changes added. Give me a short explanation of the changes you made.

Here’s a post so I can keep up on this thread,
It promises worth.

Thx guys.

I’ve been refining a set of rails for consistently converting raw/legacy HTML into our custom framework classes. Sharing here in case it’s useful for others, and to get feedback from the admin team on best practices for structuring long-running, rules-heavy prompts.


Workflow Overview

  1. User pastes raw HTML.

  2. If :root { ... } CSS is missing, the model stops and asks for it.

  3. With root confirmed, the model:

    • Strips inline font/color styles.

    • Maps text to framework typography classes.

    • Normalizes buttons & cards.

    • Splits output into labeled, copyable code blocks.

    • Preserves everything else (spacing, data attrs, DOM order).


Conversion Rules (Rails)

Root CSS required

  • :root { ... } must be provided up front.

  • Missing → model responds: “Please provide the active :root { … } CSS before I can convert your HTML.”

Typography cleanup

  • Remove inline font-family, font-size, color.

  • Replace with:

    • Headings: header-black-*, header-primary-*, header-secondary-*, header-white-* (-lg, -md, -sm)

    • Body copy: copy-black, copy-primary, copy-secondary, copy-white

Buttons

  • Legacy/custom → .button-primary (default) or .button-white (for dark/overlay).

  • Preserve href, target, rel, data-* attributes.

Cards & legacy CSS

  • Delete <style> blocks.

  • Map legacy:

    • CustomBTN_* → .button-primary / .button-white

    • CustomCard_Faded → card-*-transparent

    • CustomCard → card-white

    • CustomBorder → card-inset-border

  • Unknown classes = keep.

Section splitting

  • Each section in its own fenced code block.

  • Labels (INTRO:, STRIPE:, IMPACT:, FINAL IMPACT:) go outside code.

  • Split triggers:

    • Split-Left / Split-Right wrappers

    • Each card-* instance

    • <div class="CardContainer">

    • Repeated peers (tiles/galleries)

STRIPEs & IMPACTs

  • STRIPE: <p> only, header-*-lg, centered, with glow/shadow.

  • IMPACT / FINAL IMPACT: Heading + copy + optional button, wrapped in <div class="CardContainer">.

Preserve everything else

  • Keep DOM order.

  • Do not touch spacing, shadows, transforms, data attributes.


:backhand_index_pointing_right: TL;DR: strip only typography, remap to framework classes, normalize buttons/cards, split into clean labeled blocks, preserve everything else.

This is the system prompt i use in my Web Development tool, I have been experimenting a lot with it and the results are great…. most times it follows the rules, with gpt-5-nano sometimes messing up with the PHP instructions.

Used with gpt-4.1-nano and gpt-4o-mini works great

{
role: “system”,
content: `You are a web designer and developer bot. Your output is made of code to satisfy the received request.
You will not greet or thank the user for the request, your aim is to produce a website layout design to satisfy the request so you will produce a well structured code line by line without interruptions.
You will only use internal CSS, placeholder images, and all data available in the request to produce a complete website layout.
Your output must be divided into exactly two sections with the following structure:
-— start of frontend section ----
(Complete HTML code including internal CSS and JavaScript)
-— end of frontend section ----
-— start of backend section ----
(Complete PHP code)
-— end of backend section ----
In creating the page you shall adhere to these requirements and rules:
IMAGES:
You have the following image definitions to work with: {urlWithoutFile}placeholder_profile_woman.png, {urlWithoutFile}placeholder_profile_man.png, {urlWithoutFile}placeholder_team.png, {urlWithoutFile}placeholder_horizontal.png, {urlWithoutFile}placeholder_vertical.png, {urlWithoutFile}placeholder_hero_image.png. - In the SRC parameter of the IMG tag, you must put the complete absolute path to the image.
STYLE:
You will create the page strictly according to the ${selectedStyle} style as indicated by the user.
META TAGS:
You will make sure the generated page has a consistent and complete META tags section for SEO, including data for Meta sharing.
COLOR SCHEMA:
You will use a color schema consistent with the requested type of web page.
SEPARATION AND WHITE SPACES:
Make sure the generated content is consistently distributed and the page is not over-saturated with text; each part must be visually separated using minimum margin of 1rem vertically.
EMOJIS:
Make use of adequate and coherent emojis and icons when suitable, but do not overload the page, and make sure you avoid to compromise the character and tone of the page by the use of emojis.
JAVASCRIPT:
If fetch calls are needed in the code, make sure they have cache: no-store.
PHP:
All PHP code must be placed in the backend section. The PHP code should be complete and functional, using $_SERVER[‘PHP_SELF’] in forms when appropriate. Provide clear comments in the PHP code indicating how it should be used and any setup requirements.
`
}
${urlWithoutFile} recalls a const for the absolute path, constructed like this:

const origin = window.location.origin;
const pathname = window.location.pathname;
const folderPath = pathname.substring(0, pathname.lastIndexOf(‘/’) + 1);
const urlWithoutFile = origin + folderPath;

${selectedStyle} recalls the value from a series of radios:
undefined
for (let i = 0; i < radios.length; i++) {
if (radios[i].checked) {
selectedStyle = radios[i].value;
}
}

This is one of the simplest and most effective prompt techniques, even beyond just coding, just add this at the bottom.

ask questions as needed

Often I am surprised by some of the insights the AI has that were overlooked by me or that need some refining in the prompt to get the code I seek and not code that needs to be changed because of an oversight.


Depending upon the model, which may try to create a full reply and also ask questions, a modified from might be needed.

Ask questions as needed; avoid creating a full reply until all of the questions have been answered.


One other caveat with this is that with some Chat bots, they have an educational mode that is designed to ask you questions rather than giving you a direct answer. In such cases adding ask questions as needed to the prompt just puts the conversation into an endless loop of questions so in that mode it is best to avoid this prompting technique.


I noted this awhile back in a separate topic but it does apply with coding.


Bonus section:

  1. If you are working with a specific programming language and only creating code, then turn off Web Search and give the link to the documentation page for the correct version. At times web search will find inaccurate information, when the correct information is in the official documentation. So don’t allow the AI to find the inaccurate information and instead just tell the AI were the accurate information is located.

  2. When new AI models are released they are often accompanied by a System Card.

    Read the System Card as they often contain useful details. Sometimes the model requires a new way to think about how to write a prompt, so knowing this and knowing how to modify prompts for the new model can save you a few days.

Keep fluff to a minimum… Extend as required…

Use macro style prompts that don’t add additional unwanted noise. Keep your intent (ie the highly targeted Macro Prompt) separate from your design preferences to reduce your input load.


Animated Result (Templated and using the API for convenience, style and consistency but largely similar)

UI(Fractal Zoom(Range Of Parameters, Save To Folder

download

UI(Image Editor(Various Filters Over Time(Emboss, Fade, Colorize etc etc), Possible(Image To Stream, Stream To Stream, Stream To Incremental Changed Stream), Save Image Stream To Folder

download

(With the API example I specify things like field properties to better mesh code together, keep it all very consistent with my other functions)

Code should fit the following format or be further optimised where possible to remove any code duplication possible without functions or classes...

```Possible Field Types and other Properties
  {
    "Type": "Text",
    "Properties": [
      {"Name": "Type",          "Required": true,  "DataType": "string ('Text')"},
      {"Name": "Name",          "Required": true,  "DataType": "string"},
      {"Name": "Label",         "Required": false, "DataType": "string"},
      {"Name": "Value",         "Required": false, "DataType": "string"},
      {"Name": "Size",          "Required": false, "DataType": "int"},
      {"Name": "Help",          "Required": false, "DataType": "string"}
    ]
  },

… and provide examples

$F = [
		['Type'=>'Hidden', 'Name'=>'Process', 'Value'=>'Create Agent'],
];

	return Phorm($F, 'POST', 'Process');

GPT-5 Rocks!

First, you are asking a question that is a bit off topic for this post so I will flag it to have it moved to a new topic.

Two options that might meet your needs.

  1. Share the conversation but with yourself.
    https://help.openai.com/en/articles/7925741-chatgpt-shared-links-faq

  2. Branch a ChatGPT conversation
    https://x.com/OpenAI/status/1963697012014215181
    https://help.openai.com/en/articles/6825453-chatgpt-release-notes#h_a0d1605009

Or: use less perplexing prompts that follow model training:

Task: complete this Python 3.11+ code:
```python
async def fractal_playground_app():
    """This is a Python application runable from main() that presents a
    fully featured fractal viewer with multiple fractal choices in its menu,
    and a rich GUI for direct interactions such as zoom and color palette rotation effects.
    It uses styled PyQt5 with a modern application design, and internal subfunctions."""
    # TODO: plan and write the full application
```

haha… I’m sorry to perplex you @_j … I guess it’s a matter of opinion :smiley:

The AI is IMHO wrong: the correct way to get the actual product you want is hundreds of words of specifications.

Might take a little while for this 0-shot to work itself out…

In the meantime, a goodie (run only with Python on a true ANSI terminal…or else)

import math,time;W,H,I=80,40,80
s=math.sin
print("\x1b[2J\x1b[?25l",end="");a=0
try:
  while 1:
    print("\x1b[H",end="");c=complex(.285*math.cos(a),.01+.285*math.sin(a))
    for y in range(H//2):
      r=""
      for x in range(W):
        cols=[]
        for h in (0,1):
          zx=(x/W-.5)*3;zy=((2*y+h)/H-.5)*2;z=complex(zx,zy);i=0
          while z.real*z.real+z.imag*z.imag<4 and i<I:z=z*z+c;i+=1
          t=(i-(math.log(math.log(abs(z)+1e-12),2) if i<I else 0))/I;cols.append(t)
        def rgb(t):return [int(127+128*s(6.283*(t+o))) for o in (0,1/3,2/3)]
        (r1,g1,b1),(r2,g2,b2)=map(rgb,cols)
        r+=f"\x1b[38;2;{r1};{g1};{b1}m\x1b[48;2;{r2};{g2};{b2}m▀"
      print(r+"\x1b[0m")
    a+=.03;time.sleep(.02)
finally:print("\x1b[0m\x1b[?25h")

Where the prompt was “show off your most impressive minimal code” or something similar.

Update – 22 minutes:

OK, let’s bring it on… :smiley:

Size matters so they say, I would definitely agree that more detail is important for better one shot results… though I think key here is structure and repetition…


Custom (Unique):

Intent
My ‘intent’ macros are my interface for fast one-shot results… A concise macro for the task at hand. Finished result in one line (Or as specific as you need it).

'''
UI(Fractal Zoom(Range Of Parameters, Save To Folder
'''

Templated (Repetitive):

Context - Get the output in the right format to run where you want it
Where will this code end up… Maybe this is a random one-shot if you’re just starting out, or maybe, as we both demonstrated it’s a script injection into a larger system. Outlining this system saves a lot of formatting edits.

'''Injection Context

Maybe this is a Python application injection runnable from main()

Or maybe you want all results returned in JSON

'''

Payloads - Standardise the output
Above I also add structure payloads for consistency and detail… This may be in Macros, JSON, Code even Images, templated information/designs for highly consistent output… ie css formatting or function call specs

'''Required CSS / Available Function Calls and Parameters etc

'''

Original - For Edits / Review

'''Editing / Reviewing an existing script include it too and be clear you want a fix in your intent stage

'''

It seems you do similar in your example…I see you have multiple titled ‘sections’ detailing different aspects… :slight_smile: …

I am working on a full writeup of my method for my API Project Thread… In this project I’m setting out to demonstrate interactive and orchestrated hierarchical trees of ‘one-shot’ interfaces. While this falls beyond the scope of this thread the individual ‘panes’ on the trees approximately follow the process above which also works through ChatGPT :slight_smile: .

PS. Readers - By the time you read this methods have improved… My methods wont exactly fit your systems… Improve on them… Consider further checks and validations on your code with human and ChatGPT review.

Chat GPT Understands My Example Like This, It's A Reasonable Interpretation

Intent:
‘’‘UI(Fractal Zoom(Range Of Parameters, Save To Folder))’‘’

Context:
‘’'Injection Context:

  • Runtime: PHP 8.2, runs as CLI script from main()
  • Path: /var/www/myapp/fractals/
  • Expect files: fractal_YYYYMMDD_HHMM.png
    ‘’’

Payloads:
‘’‘OutputFormat: JSON
{
“file”: “string (path)”,
“params”: { … },
“warnings”: [ … ]
}
Example:
{“file”:“fractal_20250918_1600.png”,“params”:{“type”:“Mandelbrot”,“iterations”:1000},“warnings”:}
‘’’

Original:
‘’'If editing, include original code block here.

‘’’