Writing Pattern and Product Emphasis
How writing style and product emphasis are configured.
Overview
Two prompt layers give operators control over generated copy tone and focus without requiring them to write prompts:
- Writing Pattern — store-level approach set in Settings. Shapes how content is written across all products.
- Product Emphasis — per-product intent set in the product editor. Narrows focus for a specific product.
Both operate inside the Business Context baseline, which always dominates.
For core product content there is now one additional middle layer:
- Category Context — category-level positioning for the product group, generated in Categories Workspace and inherited from the best assigned WooCommerce category when available.
Writing Pattern
Storage: mdrfts_custom_writing_pattern (WordPress option)
Read by: mdrfts_get_custom_writing_pattern()
Location: Settings → Brand tab → Writing Pattern card
Scope: Store-level only. One pattern applies to all products.
Operators write in plain language: what to lead with, what angle to take, what to avoid. Examples:
- "Lead with the sensory experience. Avoid listing raw specs first."
- "Use a conversational, friendly tone. No jargon."
- "Emphasize durability and real-world use. Speak to buyers who will use this daily."
UI — Button Map
| Button | Type | What it does |
|---|---|---|
| Suggest from Business Context | Primary (blue), left-aligned | Calls Gemini with saved Business Context → generates 2–4 sentence writing pattern → auto-saves to DB → fills textarea |
| Save Manual Edits | Secondary, right-aligned | Submits the form — persists any manual text edits to the textarea |
Copy icon (dashicons-clipboard) | Icon overlay, top-right of textarea | Copies textarea content to clipboard; switches to dashicons-yes for 2 s then reverts |
Trash icon (dashicons-trash) | Icon overlay, top-right of textarea; only visible when a value exists | Clears writing pattern (separate hidden form with confirm dialog) |
The icon toolbar uses the same .mdrfts-ta-toolbar pattern as Business Context — fades in on hover/focus-within.
Loading Feedback
During a Suggest operation the button shows an inline spinner (dashicons-update + mdrfts-spin) and its label changes to "Generating…". The status paragraph above the button row:
- During generation: "Analysing your Business Context…"
- During auto-save: "Saving…"
- Success: "✓ Saved automatically at [timestamp]."
- Save fallback (if auto-save AJAX fails): "Suggestion ready — click Save Manual Edits to store it."
- Error: "Error: [message]"
A live word count (<span id="mdrfts-wp-wordcount">) is shown below the textarea in soft grey.
Auto-save behaviour
When a suggestion is returned, it is immediately saved to the database via a second AJAX call (mdrfts_save_writing_pattern) before the success message is shown. This mirrors Business Context auto-save. Save Manual Edits is available for any subsequent manual edits.
AI suggestion requirements: Business Context must be set and Gemini access must be available (hosted or BYOK).
Injection: Injected into the prompt between Business Context and Product Emphasis. Empty = skipped safely.
Auto-height textarea
field-sizing: content with resize: none; overflow: hidden; min-height: 80px; padding: 36px; font-size: 11px; line-height: 1.4 (inline styles). JS fallback mdrftsResizePattern() mirrors the Business Context approach.
Product Emphasis ("What to emphasize")
Storage: _mdrfts_custom_instructions (post meta)
Location: Product editor controls pane, above Tone and Description Length
Scope: Per-product.
Operators write raw intent: what to highlight for this specific product. Input is treated as operator intent, not a literal prompt instruction. The engine interprets it within the Business Context baseline — conservative enrichment only; angles not implied by the operator's input are not introduced.
Auto-save: Input is auto-saved via AJAX (800ms debounce) with inline Saved / Save failed feedback. No manual save step required.
Info tab display: After generation, a deterministic "Emphasized:" line appears in the Info tab confirming what was applied. JS-side normalization strips filler openers and normalizes phrases — no AI call involved.
Workspace role
Product Emphasis is not only a core-content helper. In the workspace architecture it is the Product Custom Instructions layer.
This means the same field should be interpreted as the per-product instruction layer for:
- Core Product Content
- Google Merchant Center
- future workspace-specific generation flows
It should stay distinct from:
- Prompt Supplement — global rules
- Workspace Instructions — workspace-level persistent rules
- Writing Pattern — store-level approach guidance
Active Layer Indicators
Info tab (post-generation)
After every generation the Info tab shows an Active layers row:
- ✓ Business Context → Edit — Business Context was injected; links to Settings.
- ✓ [Category path] → Open — effective Category Context was injected; links to Categories Workspace.
- ✓ Writing pattern (first ~60 chars) → Edit — Writing Pattern was injected; links to Settings.
- ⚠ No business context — warning with Settings link when Business Context is empty.
- – Not set — open Categories Workspace — Category Context is optional and no saved effective category summary was found.
These are read from mdrfts_ajax.business_context, mdrfts_ajax.writing_pattern, and mdrfts_ajax.effective_category_context passed at page load.
Controls sidebar (pre-generation)
Inside Advanced Options (below the checkboxes), three status rows are always visible:
- Business Context — Active pill (green) or Not set pill (amber) + "Edit in Settings" / "Add in Settings" link →
?page=mdrfts_settings&tab=brand - Category Context — Active pill or Not set pill + "Open Workspace" link →
?page=mdrfts_categories_workspace - Writing Pattern — same pattern
Business Context and Writing Pattern are rendered from saved options. Category Context is rendered from the effective per-product category lookup. Together they give the operator a quick at-a-glance check before generating.
Precedence Rules
- Business Context dominates: all copy must stay within the brand baseline it defines.
- Category Context narrows the product-group frame inside the Business Context baseline. It does not override the brand baseline and it is not raw Woo category description text.
- Writing Pattern shapes the approach within the baseline — it does not override brand voice or conflict with Tone/Length.
- Product Emphasis narrows focus for a specific product within the baseline — it does not override it.
- If emphasis conflicts with Business Context, the baseline wins.
- Expansion of emphasis is conservative: resolve obvious implicit context only.
Design Decisions
DEC-008 — Baseline + focus prompt model. Business Context = the room, Product Emphasis = the corner of the room to stand in. Prompt framing encodes hierarchy so no extra validation layer is needed.
DEC-009 — Built-in presets abandoned. A "Technical" preset overlapped with the Tone dropdown; "Gift & Occasion" was not universal across store types. Replaced with a single store-level free-text Writing Pattern field that operators define for their own context.