perf-astro скилл для Claude Code: оптимизация Astro под Lighthouse
Скилл perf-astro для Claude Code настраивает сборку Astro: встраивает критический CSS, минифицирует файлы, задаёт неблокирующую загрузку шрифтов и preload LCP-картинки.
MIT ★ 7 191 обновлён 2026-10-24
npx skills add tech-leads-club/agent-skills --skill perf-astro -a claude-codeЧто делает perf-astro
Скилл разбирает производительность Astro-сайта по шагам. Сначала astro-critters: он находит элементы первого экрана, встраивает нужный им CSS прямо в HTML, остальное грузит лениво, а в логе сборки печатает, сколько килобайт удалось заинлайнить. Второй плагин, @playform/compress, сжимает HTML, CSS и JavaScript на финальной сборке; картинки и SVG в примере конфига выключены, их оставляют внешнему оптимизатору.
Дальше идёт шаблон Layout.astro: font-display: swap с локальным фолбэком, Google Fonts через media="print" и onload, preload для LCP-картинки с fetchpriority="high", аналитика на scroll, click и touchstart вместо загрузки сразу. Проверка — npx lighthouse https://your-site.com --preset=perf --form-factor=mobile.
Скилл узкий: он про Astro, и на другом фреймворке его интеграции ничего не дадут — там нужны perf-web-optimization или core-web-vitals. Запуск аудитов тоже вынесен отдельно, в perf-lighthouse.
Какие задачи решает
- встроить критический CSS в HTML на этапе сборки Astro
- убрать блокировку рендера из-за Google Fonts
- поднять приоритет загрузки LCP-картинки
- отложить стороннюю аналитику до первого скролла или клика
- включить минификацию HTML, CSS и JS в
astro.config.mjs
Примеры запросов агенту
- Подключи
astro-crittersи@playform/compressвastro.config.mjsи покажи, что ещё тормозит первый рендер. - Проверь мой
Layout.astro: шрифты идут черезmedia="print"сonload, а hero-картинка сfetchpriority="high"? - Собери чек-лист по LCP и отложенной загрузке скриптов для моего Astro-проекта.
Как установить perf-astro
1Через Skills CLI (Vercel)
npx skills add tech-leads-club/agent-skills --skill perf-astro -a claude-code2Вручную: положить файлы
~/.claude/skills/perf-astro/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/perf-astro/
1Через Skills CLI (Vercel)
npx skills add tech-leads-club/agent-skills --skill perf-astro -a codex2Вручную: положить файлы
.agents/skills/perf-astro/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add tech-leads-club/agent-skills --skill perf-astro -a cursor2Вручную: положить файлы
.cursor/skills/perf-astro/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install tech-leads-club/agent-skills 'packages/skills-catalog/skills/(performance)/perf-astro'2Вручную: положить файлы
.github/skills/perf-astro/SKILL.md1Через Skills CLI (Vercel)
npx skills add tech-leads-club/agent-skills --skill perf-astro -a gemini-cli2Командой платформы
gemini skills install https://github.com/tech-leads-club/agent-skills --path 'packages/skills-catalog/skills/(performance)/perf-astro'Вручную: положить файлы
.devin/skills/perf-astro/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о perf-astro
Как установить perf-astro в Claude Code?
Выполните npx skills add tech-leads-club/agent-skills --skill perf-astro -a claude-code. Файл скилла появится по пути ~/.claude/skills/perf-astro/SKILL.md.
Что делает perf-astro?
Проводит Astro-проект по настройкам под высокий Lighthouse: встраивание критического CSS, сжатие сборки, неблокирующая загрузка шрифтов и preload главной картинки. Внутри есть готовый шаблон Layout.astro и чек-лист.
Подойдёт ли скилл для сайта не на Astro?
Нет. Его настройки завязаны на интеграции Astro, для других сайтов есть perf-web-optimization и core-web-vitals. А сами аудиты запускает perf-lighthouse.
Исходный текст
SKILL.md · MIT
---
name: perf-astro
description: 'Astro-specific performance optimizations for 95+ Lighthouse scores. Covers critical CSS inlining, compression, font loading, and LCP optimization. Use when optimizing Astro site performance, improving Astro Lighthouse scores, or configuring astro-critters. Do NOT use for non-Astro sites (use perf-web-optimization or core-web-vitals) or running Lighthouse audits (use perf-lighthouse).'
---
# Astro Performance Playbook
Astro-specific optimizations for 95+ Lighthouse scores.
## Quick Setup
```bash
npm install astro-critters @playform/compress
```
```js
// astro.config.mjs
import { defineConfig } from 'astro/config'
import critters from 'astro-critters'
import compress from '@playform/compress'
export default defineConfig({
integrations: [
critters(),
compress({
CSS: true,
HTML: true,
JavaScript: true,
Image: false,
SVG: false,
}),
],
})
```
## Integrations
### astro-critters
Automatically extracts and inlines critical CSS. No configuration needed.
What it does:
- Scans rendered HTML for above-the-fold elements
- Inlines only the CSS those elements need
- Lazy-loads the rest
Build output shows what it inlined:
```
Inlined 40.70 kB (80% of original 50.50 kB) of _astro/index.xxx.css.
```
### @playform/compress
Minifies HTML, CSS, and JavaScript in the final build.
Options:
```js
compress({
CSS: true, // Minify CSS
HTML: true, // Minify HTML
JavaScript: true, // Minify JS
Image: false, // Skip if using external image optimization
SVG: false, // Skip if SVGs are already optimized
})
```
## Layout Pattern
Structure your `Layout.astro` for performance:
```astro
---
import '../styles/global.css'
---
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Font fallback (prevents FOIT) -->
<style>
@font-face {
font-family: 'Inter';
font-display: swap;
src: local('Inter');
}
</style>
<!-- Non-blocking Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap"
media="print"
onload="this.media='all'"
/>
<noscript>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap">
</noscript>
<!-- Preload LCP images -->
<link rel="preload" as="image" href="/hero.png" fetchpriority="high">
<title>{title}</title>
<!-- Defer third-party scripts -->
<script>
let loaded = false;
function loadAnalytics() {
if (loaded) return;
loaded = true;
// Load GTM, analytics, etc.
}
['scroll', 'click', 'touchstart'].forEach(e => {
document.addEventListener(e, loadAnalytics, { once: true, passive: true });
});
setTimeout(loadAnalytics, 5000);
</script>
</head>
<body>
<slot />
</body>
</html>
```
## Measuring
```bash
npx lighthouse https://your-site.com --preset=perf --form-factor=mobile
```
See also:
- **perf-lighthouse** - Running audits, reading reports, setting budgets
- **perf-web-optimization** - Core Web Vitals, bundle size, caching strategies
## Checklist
- [ ] `astro-critters` installed and configured
- [ ] `@playform/compress` installed and configured
- [ ] Google Fonts use `media="print" onload` pattern
- [ ] Third-party scripts deferred to user interaction
- [ ] LCP images preloaded in `<head>`
© tech-leads-club · MIT · tech-leads-club/agent-skills