performance
它能做什么
这项技能指导智能体找出应用中变慢的部分,例如数据过多或重复工作,并加以减少。适合页面感觉卡顿、跳动或延迟时的开发者。
适用场景
- ✓当页面加载感觉很慢,或点击时出现卡顿的时候。
- ✓当列表随着数据量增加而变慢的时候。
- ✓当你在对性能敏感的界面上修改数据读取、轮询路径或启动代码的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/performance/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“当记录很多时,我的仪表板加载非常慢。请帮我让它变快。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体测量等待发生在哪里,只加载界面所需的数据,合并读取请求,并且只有在测量表明有帮助时才添加缓存。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Performance
Find the cost that users actually wait on, then reduce it without weakening the result. A slow screen may be waiting on the server, moving too much data, serial reads, repeated computation, or browser rendering; measure before adding caches or extra complexity.
Load only what the current view needs
- Shape list reads around the fields the list displays. Keep large document bodies, histories, rendered output, and other rarely viewed data on a detail or on-demand path. Return a small preview when the list needs one.
- Paginate or window unbounded histories and activity feeds. Start with the recent or visible range and load more as the user asks for it.
- Batch related reads instead of issuing one query per row. Compute counts and other aggregates in the database when the result can be much smaller than the source rows.
- Start independent reads together. Do not make the first useful content wait for unrelated settings, below-the-fold panels, or secondary details.
- Index fields used by frequent filters, joins, and sorts when the data and observed query cost justify it. Keep indexes aligned with real query shapes.
For action-backed screens, shape the action response for the screen's current need and keep the UI on the app's existing action and query hooks. Do not add a second fetch path that duplicates the same read.
Keep repeated work cheap
- Keep list and frequently refreshed reads inexpensive. Avoid parsing, reformatting, or rebuilding large values on every read when the result can be prepared once or computed only for the view that needs it.
- Use the app's existing live-update path when fresh data must reach an open screen. Poll only when needed, and keep polled reads bounded and cheap.
- Keep large file contents and long records out of list responses. Load them when the user opens the relevant item rather than sending them on every list refresh.
- Defer nonessential data and expensive child views until after the main content is usable. Window a rendered list when rendering all rows makes scrolling or updates slow.
Protect startup and the first paint
- Keep migrations, backfills, data scans, aggregations, provider handshakes, and cache warming out of module evaluation and application startup. Hosted serverless instances can restart, so startup work can repeat on user requests. Use the app's deliberate migration, job, or on-demand path.
- Keep optional heavy runtimes out of modules loaded by ordinary page requests. Load a browser, media processor, or other large dependency only in the feature or job that needs it, and inspect the deployed bundle when adding one.
- Keep the server-rendered shell public and independent of a visitor's session. Resolve user-specific state after the shell loads through the app's authenticated client data path. Reads that must reflect a recent mutation should not depend on cached server-rendered loader data.
- Give loading placeholders the final content's basic geometry. Reserve space for content whose size is known; avoid showing a temporary layout that shifts the user's reading position when data arrives.
Keep interactions responsive
Show that an interaction registered as soon as it happens, aiming for 100 ms. If the work needs the network or takes longer, acknowledge it before waiting and show a focused pending state within 400 ms. Use an optimistic update when it is safe, then confirm or roll back on failure.
When investigating a slow experience, separate server response time, data transfer, serial waits, rendering, layout movement, and long interaction work. Use representative data and the production build when development tooling changes the cost. Verify that the user-visible action completed before comparing timings or memory.
常见问题
智能体是否总要添加缓存?
不是。技能要求先测量,因为缓存会增加复杂性。
哪些数据应延后加载?
大型文档正文、较长的历史记录以及很少查看的细节,应按需加载,而不是在列表页加载。
这会改变用户看到的内容吗?
不应削弱结果。目标是在结果相同的前提下,让界面更快。
详情
作者的原始描述
Keep app loads and interactions responsive as data grows. Use when a page feels slow, jumps, or lags, or when changing a data read, list, polling path, startup path, or performance-sensitive UI.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13171
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …