一键导入
optimize
Improve Puree UI (YAML/SCSS/Python) performance across rendering speed, container efficiency, and resource usage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Improve Puree UI (YAML/SCSS/Python) performance across rendering speed, container efficiency, and resource usage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | optimize |
| description | Improve Puree UI (YAML/SCSS/Python) performance across rendering speed, container efficiency, and resource usage. |
| user-invocable | true |
| argument-hint | Describe the panel or component to optimize (e.g. "main panel with 200+ containers", "transition-heavy toolbar") |
Identify and fix performance issues in Puree UIs. Puree renders via ModernGL compute shaders — performance characteristics differ fundamentally from web browsers.
Understand current performance and identify problems:
Measure current state:
assets/fonts/mark_dirty() frequency: How often relayout is triggered from PythonIdentify bottlenecks:
mark_dirty() calls happening too frequently? (Each triggers a full relayout)CRITICAL: Measure before and after. Premature optimization wastes time. Optimize what actually matters.
Create systematic improvement plan:
Minimize container count — every YAML node creates a GPU-rendered container:
# ❌ Bad: unnecessary wrapper containers
wrapper:
inner_wrapper:
content_wrapper:
actual_content:
text: "Hello"
# ✅ Good: flat structure, fewer containers
actual_content:
text: "Hello"
Flatten the YAML tree — fewer nesting levels means fewer containers to render:
padding and margin on the content container instead of adding spacer containersUse display: none for hidden content:
// Hide sections that aren't currently needed
.collapsed_section {
display: none;
}
Containers with display: none are excluded from layout calculation and rendering entirely — use this aggressively for tabbed interfaces, conditional panels, and sections the user hasn't opened.
Use components to avoid YAML duplication — but be aware each instance creates its own container subtree:
# ❌ Bad: duplicating the same structure 10 times in index.yaml
item_1:
style: list_item
icon_1:
style: item_icon
label_1:
style: item_label
text: "Item 1"
item_2:
style: list_item
icon_2:
style: item_icon
# ... repeated 10 times
# ✅ Good: use a component, but consider if you need all instances visible
item_1:
data: '[list_item]'
item_text: 'Item 1'
item_icon: 'icon_1'
Limit visible list items — if you have 50+ items, don't render them all. Use Python to dynamically populate a fixed number of visible containers and hide the rest.
Avoid deeply nested selectors — Puree's SCSS engine processes every rule against every container:
// ❌ Bad: deep nesting creates complex selectors
.root {
.panel {
.section {
.subsection {
.item {
.label {
color: #fff;
}
}
}
}
}
}
// ✅ Good: flat, targeted selectors
.item_label {
color: #fff;
}
Use SCSS variables to avoid repetition:
$bg-dark: #1a1d24;
$text-muted: rgba(181, 188, 199, 0.9);
$border-radius: 8px;
.card {
background-color: $bg-dark;
border-radius: $border-radius;
}
.subtitle {
color: $text-muted;
}
Use class selectors, not deep descendant chains:
// ❌ Slower: engine must trace ancestry
.root .panel .content .label { color: #fff; }
// ✅ Faster: direct class match
.content_label { color: #fff; }
Use appropriate image sizes — don't load a 2000px image for a 50px icon:
assets/ to match their display sizeShare images across components — reference the same image name in multiple containers rather than duplicating files.
Only animate what's necessary — each active transition consumes GPU resources:
// ❌ Bad: transitioning everything
.button {
transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
}
// ✅ Good: only transition what the user will notice
.button {
transition: background-color 0.2s ease;
}
Keep transition durations short — Puree transitions run on the GPU, but long durations (>0.5s) keep the animation loop active longer:
Don't transition containers that are hidden — containers with display: none skip rendering, but transitioning them before hiding wastes frames.
Minimize mark_dirty() calls — each call triggers a full relayout of the container tree:
# ❌ Bad: multiple mark_dirty() calls for related changes
label.text = "New text"
label.mark_dirty()
icon.set_property('opacity', '1.0')
icon.mark_dirty()
status.text = "Updated"
status.mark_dirty()
# ✅ Good: batch changes, then mark dirty on a common ancestor
label.text = "New text"
icon.set_property('opacity', '1.0')
status.text = "Updated"
# Mark the parent dirty once — children update too
parent_container.mark_dirty()
Avoid mark_dirty() in loops or high-frequency callbacks:
# ❌ Bad: marking dirty on every hover event
def on_hover(container):
counter.text = str(int(counter.text) + 1)
counter.mark_dirty() # Triggers relayout on every mouse move
# ✅ Good: throttle updates or batch them
import time
last_update = 0
def on_hover(container):
nonlocal last_update
now = time.time()
if now - last_update < 0.1: # Throttle to 10 updates/sec
return
last_update = now
counter.text = str(int(counter.text) + 1)
counter.mark_dirty()
Limit font variety — each font file is loaded into GPU memory:
default_font in the theme to avoid loading unnecessary fontsfonts/Use @media to reduce visible content at smaller sizes:
// Hide non-essential panels when space is tight
@media (max-width: 350px) {
.detail_panel {
display: none;
}
.description_text {
display: none;
}
}
This reduces the number of containers that need rendering at smaller panel sizes.
During development, Puree supports hot reload. To maximize development speed:
What to watch:
grep -c on YAML to estimate)mark_dirty() callsProfiling approach:
mark_dirty() calls to identify excessive relayoutsIMPORTANT: Test on the target hardware. Development machines may mask performance issues that appear on lower-spec systems.
NEVER:
mark_dirty() in tight loops or high-frequency eventsdisplay: none is your best friend for performanceTest that optimizations worked:
Remember: Performance in Puree is primarily about container count, mark_dirty() frequency, and transition efficiency. Fewer containers, fewer relayouts, and targeted transitions make everything feel snappy.
Create distinctive, production-grade Puree UI interfaces with high design quality. Use this skill when the user asks to build UI panels, dashboards, toolbars, or Blender addon interfaces. Generates creative, polished YAML/SCSS/Python code that avoids generic AI aesthetics.
Review Puree UI code (YAML/SCSS/Python) for correctness, common mistakes, and best practices. Use when checking code quality, debugging render issues, or validating before shipping.
Improve Puree typography by fixing font choices, hierarchy, sizing, weight consistency, and readability in YAML/SCSS. Makes text feel intentional and polished.
Create distinctive, production-grade Puree UI interfaces with high design quality. Use this skill when the user asks to build UI panels, dashboards, toolbars, or Blender addon interfaces. Generates creative, polished YAML/SCSS/Python code that avoids generic AI aesthetics.
Review Puree UI code (YAML/SCSS/Python) for correctness, common mistakes, and best practices. Use when checking code quality, debugging render issues, or validating before shipping.
Improve Puree typography by fixing font choices, hierarchy, sizing, weight consistency, and readability in YAML/SCSS. Makes text feel intentional and polished.