Prompt Engineering Skill
AI prompt construction patterns for Visualization Builder image generation.
Auto-Invoke Triggers
- •Building AI generation prompts
- •Optimizing AI instructions
- •Debugging AI output quality
- •Implementing new annotation types
Prompt Architecture
Components
code
PROMPT = SYSTEM + CONTEXT + INSTRUCTIONS + CONSTRAINTS
| Component | Purpose | Location |
|---|---|---|
| System | AI behavior rules | Start of prompt |
| Context | Image + annotations | Middle |
| Instructions | What to do | Per annotation |
| Constraints | Quality rules | End |
System Prompt Template
markdown
You are an AI image editor specializing in interior design visualization.
CORE RULES:
1. PRESERVE the original image quality, lighting, and perspective
2. ONLY modify areas explicitly marked for change
3. MAINTAIN photorealistic quality throughout
4. RESPECT coordinate boundaries precisely
IMAGE INFORMATION:
- Dimensions: {width} x {height} pixels
- Style: {style_preferences}
Annotation Instructions
Product Swap
markdown
## ANNOTATION #{id}: PRODUCT SWAP
Location: ({x}, {y}) pixels - {description}
ACTION: DELETE the existing object at this location and INSERT new product
PRODUCT REFERENCE:
- See IMAGE {index} for exact product appearance
- REPLACE existing object with this EXACT product
- Scale appropriately for the scene
- Match lighting and shadows
CRITICAL: Use the EXACT product from the reference image
Object Removal
markdown
## ANNOTATION #{id}: REMOVE OBJECT
Location: ({x}, {y}) pixels - {description}
ACTION: REMOVE the object and FILL naturally
REQUIREMENTS:
- Remove the specified object completely
- Fill with appropriate background (floor, wall, etc.)
- Match surrounding textures and patterns
- Maintain lighting consistency
Color Change
markdown
## ANNOTATION #{id}: COLOR CHANGE
Location: ({x}, {y}) pixels - {description}
ACTION: CHANGE color of specified surface
TARGET COLOR: {color_value}
- Standard: {color_standard} (RAL/NCS)
REQUIREMENTS:
- Apply color to specified surface only
- Preserve texture and material appearance
- Adjust shadows/highlights for new color
Add Object
markdown
## ANNOTATION #{id}: ADD OBJECT
Location: ({x}, {y}) pixels - {description}
ACTION: ADD new object to scene
OBJECT DESCRIPTION: {user_description}
REQUIREMENTS:
- Place at specified coordinates
- Scale appropriately for scene
- Match lighting and perspective
- Integrate naturally with surroundings
Coordinate System
Pixel Coordinates
typescript
// Convert percentage to pixels
const pixelX = (percentX / 100) * imageWidth;
const pixelY = (percentY / 100) * imageHeight;
// In prompt: use absolute pixels
`Location: (${pixelX}, ${pixelY}) pixels`
Letterboxing Handling
typescript
// When image uses objectFit: contain
// Account for letterboxing offset
const imageAspectRatio = naturalWidth / naturalHeight;
const containerAspectRatio = containerWidth / containerHeight;
if (imageAspectRatio > containerAspectRatio) {
renderedWidth = containerWidth;
renderedHeight = containerWidth / imageAspectRatio;
offsetY = (containerHeight - renderedHeight) / 2;
}
Multi-Image Requests
FormData Structure
typescript
const formData = new FormData();
// Source image (always first)
formData.append('image[]', sourceBlob, 'source.png');
// Product reference images
annotations.forEach((ann, index) => {
if (ann.attachment_type === 'image' || ann.attachment_type === 'link') {
formData.append('image[]', productBlob, `product_${index}.png`);
}
});
// Prompt references images by index
// IMAGE 0 = source
// IMAGE 1 = first product
// IMAGE 2 = second product
Quality Constraints
End of Prompt
markdown
## FINAL VALIDATION CHECKLIST Before generating, verify: - [ ] All annotation locations are within image bounds - [ ] Product references match IMAGE indices - [ ] Unchanged areas remain IDENTICAL - [ ] Photorealistic quality maintained - [ ] Lighting consistent throughout OUTPUT: Single high-quality image with all requested changes applied
Common Issues & Solutions
| Issue | Cause | Solution |
|---|---|---|
| Wrong location | Letterboxing not handled | Account for offsets |
| Wrong product | Image index mismatch | Verify IMAGE indices |
| Product not exact | Vague instructions | "Use EXACT product" |
| Background changed | Unclear boundaries | Specify "ONLY at location" |
| Quality loss | Compression | Request high quality |
Debug Logging
typescript
// Log prompt for debugging
console.log('[Prompt] System:', systemPrompt);
console.log('[Prompt] Annotations:', annotationInstructions);
console.log('[Prompt] Images:', {
source: 'IMAGE 0',
products: productImageMap,
});
Prompt Optimization
Length Guidelines
| Section | Target | Max |
|---|---|---|
| System | 200 words | 400 |
| Per annotation | 50 words | 100 |
| Constraints | 100 words | 200 |
Token Efficiency
- •Use bullet points over prose
- •Specific over general instructions
- •Reference images by index
- •Avoid repetitive language