跳到主内容
@wquguru
精选85VoxAI 产品与模型

Claude Code 技巧:用 Opus 5.5 子代理检查并修复网站性能问题

Claude Code tip: before you ship a vibe-coded site, have Opus 5.5 send out 𝟰 𝘀𝘂𝗯…

原文
发到 X
推荐理由

这篇把 Claude Code 的用法讲得很具体,有清晰的分类清单和可复制的指令,读者能直接照着操作,是值得参考的实操型合作稿。

Claude Code tip: before you ship a vibe-coded site, have Opus 5.5 send out 𝟰 𝘀𝘂𝗯𝗮𝗴𝗲𝗻𝘁𝘀 to check 𝘁𝗵𝗲𝘀𝗲 𝟮𝟬 𝘁𝗵𝗶𝗻𝗴𝘀 𝘁𝗵𝗮𝘁 𝘀𝗹𝗼𝘄 𝗶𝘁 𝗱𝗼𝘄𝗻, then fix them all in one pass:

Claude Code 提示:在发布一个 vibe-coded 网站之前,让 Opus 5.5 派出 4 个子代理检查这 20 个拖慢网站速度的问题,然后一次性修复它们:

Images and fonts → Convert every image to WebP or AVIF, sized to how big it actually shows on the page → Serve big images from Supabase Storage through next/image at the right size. On the Pro plan, Supabase's own image transformations work too → Lazy-load images and videos below the fold, and load the big image at the top of the page first → Load fonts the way your framework does it (next/font in Next.js), and keep it to one or two fonts → Remove third-party scripts you don't use, and run analytics and chat widgets after the page has loaded

图片和字体 → 将所有图片转换为 WebP 或 AVIF,并根据页面实际显示大小调整尺寸 → 通过 next/image 从 Supabase Storage 以正确尺寸提供大图。在 Pro 计划中,Supabase 自带的图片转换功能也可用 → 对首屏以下的图片和视频进行懒加载,并优先加载页面顶部的大图 → 按照框架的方式加载字体(Next.js 中使用 next/font),并限制为一到两种字体 → 移除不使用的第三方脚本,并在页面加载完成后再运行分析和聊天组件

Frontend code → Run a bundle analyzer to find the biggest packages, and where a whole library gets imported, import only the parts you use, like single lodash functions → Load heavy components the first screen doesn't need, like charts, editors and maps, with dynamic import when they're needed → Fetch the homepage data on the server, so the page opens with content already in it → Stream AI answers as they're generated → Show skeletons while data is still loading

前端代码 → 运行打包分析器找出最大的包,以及整个库被导入的地方,只导入你使用的部分,比如单独的 lodash 函数 → 对首屏不需要的重组件(如图表、编辑器、地图)使用动态导入,在需要时加载 → 在服务器端获取首页数据,这样页面打开时内容已经就绪 → 流式传输 AI 回答,边生成边输出 → 在数据加载时显示骨架屏

Database and APIs → Index the columns you filter and sort by, including the ones your RLS policies use, like user_id → In RLS policies, write auth.uid() as (select auth.uid()) so it runs once per query → Find N+1 queries and turn them into a single query → Paginate long lists → Cache API responses that are the same for everyone, and never cache anything tied to a logged-in user → Move heavy work like sending emails, processing images and building reports to background jobs

数据库和 API → 为筛选和排序所用的列创建索引,包括 RLS 策略中使用的列(如 user_id) → 在 RLS 策略中,将 auth.uid() 写成 (select auth.uid()),这样每个查询只执行一次 → 找出 N+1 查询,并将其合并为单个查询 → 对长列表进行分页 → 缓存对所有用户相同的 API 响应,但绝不缓存与登录用户相关的任何内容 → 将发送邮件、处理图片和生成报告等重任务移至后台任务

Servers and network → Put your server functions in the same region as your database. New Vercel projects run functions in US East by default → Turn pages whose content rarely changes into static pages or ISR → When a page calls APIs one after another, run them in parallel or merge them into one → In Chrome, emulate a low-end Android phone on slow 4G and click through the main flows

服务器和网络 → 将服务器函数部署在与数据库相同的区域。新的 Vercel 项目默认在美东运行函数 → 将内容很少变化的页面转换为静态页面或 ISR → 当页面依次调用 API 时,改为并行调用或合并为一个请求 → 在 Chrome 中模拟低端 Android 手机和慢速 4G 网络,点击测试主要流程

The default medium effort is enough. The database group has to read queries and decide which indexes to add, so raise that one to high.

默认的中等努力程度就足够了。数据库组需要读取查询并决定添加哪些索引,因此将该组提升为高优先级。

Send this whole post to Claude Code. If you need to, add this line at the end 👇 "Send one subagent per group to check it without editing anything, and note which file each issue is in and which page it affects. Run the database subagent at high effort. Before changing anything, run a production build (next build && next start in Next.js) or use a preview link, then run Lighthouse three times in mobile mode on the homepage and the two or three slowest pages and note the median. Then fix everything yourself from their lists, measure again the same way, and give me the before-and-after numbers. Don't remove features to gain speed. Ask me before removing dependencies, changing the deploy region or changing the database."

把这篇帖子整个发给 Claude Code。如果需要,在末尾加上这一行👇 "每组派一个子代理去检查,不要编辑任何内容,并记录每个问题所在的文件和影响的页面。以高努力模式运行数据库子代理。在改动任何东西之前,先运行一次生产构建(Next.js 中为 next build && next start)或使用预览链接,然后在移动模式下对首页和两三个最慢的页面各运行三次 Lighthouse,记录中位数。之后根据它们的清单自行修复所有问题,用同样的方式重新测量,并把前后数据给我。不要为了提速而移除功能。在移除依赖、更改部署区域或更改数据库之前先问我。"

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件