DEV Community

Cover image for Auto-Appending Format Constraints to Prompts Programmaticall
PromptMaster
PromptMaster

Posted on

Auto-Appending Format Constraints to Prompts Programmaticall

Auto-Appending Format Constraints to Prompts Programmatically

Here's a tiny feature that punches far above its weight: automatically appending a format constraint to every prompt a user copies. It's maybe fifteen lines of code and it eliminates an entire category of user error. A good example of how small programmatic touches beat asking the user to remember things.

The problem it solves

AI video prompts need an aspect-ratio instruction — Vertical 9:16 format — or the model composes for the wrong frame. Users forget this constantly. They copy a prompt, paste it, generate, and get a mis-framed clip because they didn't manually add the format. Asking them to remember is a losing battle.

The pattern: format as global state, stamped at copy time

Store the chosen format once. Derive the constraint string from it. Append at the moment of copy, not at the moment of authoring:

const FMTS = {
  wide:  { tag: "Widescreen 16:9 format.",  label: "16:9" },
  tall:  { tag: "Vertical 9:16 format.",    label: "9:16" },
  square:{ tag: "Square 1:1 format.",       label: "1:1"  },
  ultra: { tag: "Ultra-wide 21:9 cinematic format.", label: "21:9" }
};
let fmt = "wide";

function fmtTag(){ return FMTS[fmt].tag; }

function fullPrompt(r){
  return `${r.body} ${r.camera} ${fmtTag()}`;
}
Enter fullscreen mode Exit fullscreen mode

Because the tag is derived from state at copy time, the user sets the format once and every subsequent copy — from anywhere in the app — carries it. Switch to tall, and the library, the builder, everything now copies vertical.

Why "at copy time" matters

The naive approach bakes the format into each prompt when it's created. That means changing format requires re-processing every prompt. Deriving it at copy time means format is a single source of truth that costs nothing to change. Toggle it and the next copy is correct — no re-render, no batch update.

The UX principle underneath

The general lesson: when a user must not forget something, don't remind them — do it for them. A reminder is a UX band-aid; automation is the cure. Any time you find yourself writing "remember to..." in your docs, ask whether the code could just handle it.

See it in action

The free Seedance Prompt Composer demo implements exactly this — a global format toggle across four ratios, stamped onto every copied prompt automatically. Toggle it and copy a couple of prompts to feel how the constraint follows the setting.

Try the free demo →

Top comments (0)