basforge

Search titles, text and the “If it doesn’t work” cases.

    RU
    ConfigAIPrompts

    A prompt, block by block: context, materials, task, format, examples

    A prompt works when it holds what the model can’t guess: who the result is for, what to base it on, what counts as done and in what form to deliver it. Here’s a prompt for reviewing a compose file, block by block; at the end, habits from 2023 that get in the way of newer models.

    What a prompt is made of

    Order the blocks from constant to specific: first who you are and what for, then the materials, and at the end the task and the format. Long materials go before the question: the model answers more precisely that way (Long document first). Tags like <compose> aren’t special syntax, just labels the model distinguishes well; any names will do.

    The prompt, block by block

    prompt: reviewing a compose file
    We're reviewing a docker-compose file for a server that hosts live sites.
    One server, one admin, changes rolled out by hand. The goal is to find
    what will break on restart or expose more than it should.

    Context: who reads the answer and why. The model adjusts depth and tone to the reader — “a lone admin, a server with live sites” gets different advice than “a training sandbox”. A one-line role works too, but facts about the situation give more than a title.

    <environment>
    Ubuntu 24.04, Docker 29, Compose v5.6, Traefik 3.7 in a neighbouring stack,
    external network proxy.
    </environment>
    
    <compose>
    services:
      memos:
        image: neosmemo/memos:stable
        ports:
          - "5230:5230"
        volumes:
          - ./data:/var/opt/memos
    …
    </compose>
    Key part

    Materials in tags, before the question. Everything the model should rely on: the whole file, versions, command output. Without them it answers from general memory of similar files. Versions are a must: compose and Traefik syntax has changed (Put the date, versions and environment in the prompt).

    Find problems that:
    - expose a port or data to the outside;
    - break the service on restart or image update;
    - diverge from how the neighbouring stacks behind Traefik are set up.
    Leave style and key order alone.

    The task and the done criterion. Not “look at the file” but what exactly to look for and when to stop. If you want a list, say how many items and how to order them.

    Don't pin the image to a specific version: we install updates deliberately
    through `stable`, and that decision is already made.

    Constraints, with a reason. The reason gives the model a rule for cases you didn’t list. Without it, the model either ignores the constraint or applies it too broadly (A rule in a prompt gets a reason instead of caps).

    Answer as a table: | line | what's wrong | what it risks | how to fix |.
    Rows by descending risk. The fix is a ready YAML snippet.
    If you find nothing for an item, say so; don't add trivia for volume.

    The answer format — show it, don’t describe it. A table, JSON or a list with fields: that way you can read the answer in a minute or parse it with a script (JSON by schema).

    <example>
    | `ports: "5230:5230"` | port open on all interfaces, bypassing Traefik | service reachable by IP without HTTPS or protection | `"127.0.0.1:5230:5230"`, or drop `ports` and keep the proxy network |
    </example>

    An example answer — one row of the kind you want. An example sets length, detail and tone more precisely than any description. Two or three examples if the cases differ (An example over a description).

    If you lack data for a conclusion (the Traefik config, say), tell me what's
    missing instead of assuming. If you're unsure about a key's version, flag it.

    Permission not to know, and to ask. Without it the model fills gaps with guesses. With it, the model honestly flags where it’s unsure and asks questions first if data is short (Questions and a plan first).

    You are a world-class DevOps expert with 20 years of experience.

    A “title” instead of context. Newer models don’t get smarter from “world-class expert”; they write more confidently and at greater length. The facts about the situation in the first block are what works.

    MANDATORY!!! NEVER change the ports. This is CRITICALLY IMPORTANT.

    Caps and threats. A habit from the days of models that skipped instructions. Newer models read them literally and overdo it: “NEVER” spreads where it wasn’t meant to.

    Let's think step by step.

    “Think step by step”. On reasoning models, reasoning is on and controlled by effort (Match reasoning to the task); the phrase adds nothing. It helped on older models without reasoning.

    Shorter, when you can

    Not every request needs every block. “Translate into Spanish, README tone” is enough. Add blocks as the answer misses: wrong level — context; invents things — materials; wrong shape — format and example.

    How to check

    Send the same prompt three times in new chats. If the answers match in substance and shape, the prompt sets the task unambiguously. If the structure or the findings differ each time, a format or done criterion is missing; add the block and repeat.

    If it doesn’t work

    The answer covers everything at once, and what you need is one paragraph in ten

    Cause
    No done criterion and no format: the model doesn’t know what matters, so it covers everything.
    Fix
    A “task” block with what counts as the result, and a “format” block with a length limit.

    The model mixes up your question and the pasted text

    Cause
    The material and the instruction are fused into one paragraph, and the material has phrases that look like requests.
    Fix
    Materials in tags, <compose>…</compose>; the instruction separately, after them.

    After “NEVER change ports” the model refuses to fix even a typo in a port

    Cause
    Newer models follow instructions literally and read caps as an order of the highest priority.
    Fix
    Give the reason instead of caps: “don’t change ports — the firewall is set up for them”, and the model works out the exceptions itself (A rule in a prompt gets a reason instead of caps).