Skip to main content
CodeLint.Dev Dev Tools

Structured Prompt Builder

Compose prompts from role, context, task and format sections, with a live token count as you write.

Prompt Builder
optional
optional
optional
optional
Assembled Prompt
0/6 sections · 0 tokens

Fill in sections on the left to build your prompt

The sections, and why the order matters

Ordering is not cosmetic. Stable content first makes prompt caching possible; task last keeps the instruction adjacent to the generation.

  • 1. Role and behaviourWho the model is acting as and how it should behave. Stable across requests, so it belongs first for caching.
  • 2. Reference materialDocumentation, examples, retrieved passages. Wrap each in a clear delimiter so the model can tell where one ends and the next begins.
  • 3. ConstraintsWhat it must not do, what to do when information is missing, when to refuse. Phrase positively where you can — "if the answer is not in the context, say so" works better than "never make things up".
  • 4. Output formatThe exact shape required, with an example. If you need JSON, show the JSON.
  • 5. The taskThe specific request, last. It stays closest to the generation, which measurably improves adherence on long prompts.

Prompt problems and their fixes

The model ignores an instruction buried in a long prompt

Cause:Middle-of-context attention weakness. An instruction in paragraph nine of twenty gets less weight than one at either end.

Fix:Move critical instructions to the start or the very end. For a genuinely essential constraint, stating it in both places is not redundant.

Output format drifts after a few turns

Cause:The format instruction is in the system prompt and is being outweighed by many turns of differently-shaped conversation.

Fix:Use the provider’s structured-output or JSON-schema mode where available — it constrains decoding rather than requesting compliance. Otherwise restate the format in the final user message.

The model treats content in the prompt as instructions

Cause:Prompt injection. Retrieved documents, user uploads and web content can contain text aimed at the model, and there is no reliable way for it to distinguish that from your instructions.

Fix:Delimit untrusted content explicitly, state that it is data and not instructions, and — most importantly — do not grant the model authority it should not have. Treat prompt-level defences as mitigation, never as a boundary.

Contradictory instructions produce erratic behaviour

Cause:"Be concise" alongside "explain your reasoning in detail", usually accumulated over months of edits by different people.

Fix:Read the whole prompt end to end periodically. The <a href="/ai-tools/system-prompt-analyzer">system prompt analyzer</a> flags contradictions of this kind.

Few-shot examples make output worse

Cause:Examples that are inconsistent with each other, or that all share an incidental feature the model then copies — such as every example answer being exactly two sentences.

Fix:Make examples consistent in format and varied in content. Three good examples beat ten sloppy ones.

About

The Prompt Builder provides a structured form for composing LLM prompts following prompt engineering best practices. Six sections guide you through: Role (who the AI should be), Context (background the AI needs), Task (the core instruction), Constraints (rules to follow), Examples (few-shot demonstrations), and Output Format (response structure). The assembled prompt is shown live on the right with a token count. Templates can be saved to and loaded from localStorage — your templates persist between sessions without any account or server. Four starter templates are provided for common use cases.

How to use

  1. 1 Fill in any combination of the six sections: Role, Context, Task, Constraints, Examples, and Output Format.
  2. 2 The assembled prompt updates live on the right side as you type.
  3. 3 Click "Copy" to copy the full assembled prompt to your clipboard.
  4. 4 To save a template, give it a name and click "Save Template" — it's stored in your browser's localStorage.
  5. 5 Load a saved template by selecting it from the Templates dropdown.
  6. 6 Use a Starter Template to begin with a pre-filled structure for common tasks.
What is structured prompt engineering?
Structured prompting breaks a prompt into distinct sections — role, context, task, constraints, examples, and output format — rather than writing freeform instructions. Research shows that explicitly separated sections reduce ambiguity and improve response consistency, especially for complex tasks.
Where are my saved templates stored?
Templates are saved in your browser's localStorage under the key "codelint_prompt_templates". They persist across sessions on the same device and browser. They are never sent to any server.
What is a "role" in a prompt?
The role section sets the AI's persona — "You are a senior TypeScript engineer with 10 years of experience." This activates relevant domain knowledge and constrains the tone and expertise level of responses. Claude and GPT both respond well to explicit role instructions.
What are few-shot examples?
Few-shot examples are input/output pairs included in the prompt to demonstrate the expected format or style. For example, showing 2-3 example Q&A pairs before the real question. The Examples section in the builder is designed for this.