一键导入
astro
Astro framework patterns and best practices for content-focused sites. Trigger: When working with .astro files, content collections, or Astro routing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Astro framework patterns and best practices for content-focused sites. Trigger: When working with .astro files, content collections, or Astro routing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs. Use when the task involves `test web application`, `test frontend`, `browser testing`, `Playwright test`, `capture browser screenshot`, `debug UI behavior`, or `verify frontend functionality`.
Comprehensive Cloudflare platform skill covering Workers, Pages, storage (KV, D1, R2), AI (Workers AI, Vectorize, Agents SDK), networking (Tunnel, Spectrum), security (WAF, DDoS), and infrastructure-as-code (Terraform, Pulumi). Use for any Cloudflare development task. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
Testing Library patterns for user-centric, accessibility-driven component testing. Covers query priority, user events, async utilities, and practical patterns for testing React, Vue, and DOM components the way users interact with them. Use when the task involves `Testing Library`, `@testing-library/react`, `React component testing`, `accessible testing`, or `user-centric testing`.
Comprehensive Playwright E2E testing skill combining planning, generation, and healing. Trigger: When writing, debugging, or planning E2E tests, working with *.spec.ts files, Playwright config, test fixtures, or when asked to create/fix/plan browser tests.
Tailwind CSS 4 patterns and best practices. Trigger: When styling with Tailwind - :class/class usage, theme variables, no var() in class.
| name | astro |
| description | Astro framework patterns and best practices for content-focused sites. Trigger: When working with .astro files, content collections, or Astro routing. |
| allowed-tools | Read, Edit, Write, Glob, Grep, Bash |
Conventions for building content-focused, high-performance websites with Astro.
.astro componentsALWAYS minimize client-side JavaScript. Astro ships zero JS by default.
Static component – No JavaScript shipped to the client:
---
import Header from '../components/Header.astro';
---
<Header title="Welcome" />
Interactive island – JavaScript loaded only for this component (uses client:visible):
---
import Counter from '../components/Counter.vue';
---
<Counter client:visible />
| Directive | When to Use |
|---|---|
client:load | Critical interactivity needed immediately |
client:idle | Non-critical, can wait for browser idle |
client:visible | Below the fold, hydrate on scroll |
client:media="(max-width: 768px)" | Mobile-only interactivity |
client:only="vue" | No SSR, client-only rendering (see note) |
Default choice: client:visible unless there's a reason otherwise.
[!WARNING]
client:onlytrade-offs Components usingclient:onlyskip server-side rendering entirely, which increases the client JS payload and can harm SEO since no HTML is rendered initially. Use only for:
- Third-party widgets that cannot render on the server
- Complex client-only UI (e.g., canvas, WebGL, maps)
- Non-SEO-critical parts of the page (modals, admin dashboards)
Props typing options: Astro supports both runtime access via Astro.props and compile-time
typing.
---
// 1. Type definitions FIRST
type Props = {
title: string;
description?: string;
isActive?: boolean;
};
// 2. Props destructuring with defaults (runtime access)
const { title, description, isActive = false } = Astro.props;
// 3. Imports and logic
import { getCollection } from 'astro:content';
const posts = await getCollection('articles');
---
<!-- 4. Template -->
<section class:list={["hero", { active: isActive }]}>
<h1>{title}</h1>
{description && <p>{description}</p>}
<slot />
</section>
<!-- 5. Scoped styles -->
<style>
.hero {
padding: var(--space-8);
}
</style>
ALWAYS define schemas for type safety (see src/content.config.ts):
// src/content.config.ts
import {defineCollection, z, reference} from 'astro:content';
import {glob} from 'astro/loaders';
const articles = defineCollection({
loader: glob({pattern: '**/*.{md,mdx}', base: './src/data/articles'}),
schema: ({image}) => z.object({
title: z.string(),
description: z.string(),
date: z.coerce.date(),
cover: image().optional(),
author: reference('authors'),
tags: z.array(reference('tags')),
category: reference('categories'),
draft: z.boolean().optional().default(false),
}),
});
export const collections = {articles};
ALWAYS use Astro's Image component:
---
import { Image } from 'astro:assets';
import heroImage from '../assets/hero.jpg';
---
<!-- ✅ Optimized, responsive -->
<Image
src={heroImage}
alt="Hero banner"
width={1200}
height={600}
format="webp"
/>
<!-- ❌ NEVER use raw img for local images -->
<img src="/hero.jpg" alt="Hero" />
apps/portfolio/
├── src/
│ ├── pages/ # File-based routing
│ ├── components/
│ │ ├── atoms/ # Smallest elements
│ │ ├── molecules/ # Atom combinations
│ │ └── organisms/ # Full sections
│ ├── layouts/ # BaseLayout.astro, etc.
│ ├── data/ # Content collections
│ │ ├── articles/ # Blog posts (MDX)
│ │ ├── resume/ # Resume JSON by locale
│ │ ├── tags/ # Tag definitions
│ │ └── authors/ # Author profiles
│ ├── core/ # Business logic (domain)
│ ├── lib/ # Utilities
│ ├── i18n/ # Internationalization
│ └── styles/ # Global CSS (Tailwind)
├── public/ # Static assets
└── astro.config.mjs
❌ Shipping unnecessary JS - Use .astro for static content
❌ Using client:load everywhere - Most components don't need immediate hydration
❌ Raw <img> tags - Use <Image> for optimization
❌ Inline styles for everything - Use scoped <style> blocks
❌ Hardcoded meta tags - Use a reusable BaseHead.astro
---
// BaseHead.astro
type Props = {
title: string;
description: string;
image?: string;
};
const { title, description, image } = Astro.props;
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
---
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="canonical" href={canonicalURL} />
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={canonicalURL} />
{image && <meta property="og:image" content={new URL(image, Astro.site)} />}
Astro CLI Usage: Use
pnpm exec astroorpnpm --filter portfolio exec astro
# Development
pnpm --filter=portfolio dev
# Build
pnpm --filter=portfolio build
# Preview production build
pnpm --filter=portfolio preview
# Running Astro CLI commands directly
pnpm --filter=portfolio exec astro check # Type-check .astro files
pnpm --filter=portfolio exec astro add vue # Add integrations
When using Vue components as islands:
---
import InteractiveWidget from '../components/InteractiveWidget.vue';
---
<!-- Pass props, use appropriate hydration -->
<InteractiveWidget
client:visible
title="Dashboard"
:items={data.items}
/>