astro

Enforce Astro framework code standards for components, content collections, and environment variables.

2|Updated Aug 8, 2024
One-click install
npx skills add https://github.com/walid-mos/mac-config --skill astro-walid-mos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: astro
Source: https://github.com/walid-mos/mac-config/tree/main/claude/.claude/skills/astro
Command: npx skills add https://github.com/walid-mos/mac-config --skill astro-walid-mos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide to writing clean, performant, and secure code within the Astro framework, ensuring adherence to best practices for component development, content management, and environment variable handling.

Core Features & Use Cases

  • Component Architecture: Guides on server-first design, Islands architecture, and client directive usage for optimal performance.
  • Content Collections: Enforces schema validation and proper data loading patterns for structured content.
  • Environment Variables: Details secure and future-proof methods for managing sensitive data, distinguishing between client and server contexts.
  • Use Case: When developing a new Astro website, use this Skill to ensure all components are optimized for hydration, content is properly typed and validated, and API secrets are handled securely.

Quick Start

Follow the Astro framework code standards for writing new components.

Frequently Asked Questions about astro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best practices for Astro component architecture and hydration?

Astro best practices enforce a server-first design using Islands architecture, applying client directives selectively for optimal hydration and performance. This approach minimizes client-side JavaScript by rendering components on the server and only hydrating interactive islands when needed.

How do I validate content collections in an Astro project?

To validate content collections in Astro, use Zod schema validation to enforce proper data loading patterns and structured content types. This ensures your markdown and data entries are strictly typed and safely queried during the build process.

What is the best way to manage environment variables in Astro securely?

The best way to manage Astro environment variables securely is using astro:env/server to distinguish between client and server contexts. This future-proofs sensitive data handling by ensuring secrets are only exposed during server-side build-time or runtime operations.

When should I use client directives in Astro Islands?

You should use client directives in Astro Islands only when a component requires client-side interactivity. Relying on server-first architecture by default, you add hydration directives solely to interactive elements to minimize JavaScript payload and maximize web performance.

How do I handle build-time versus runtime variables in the Astro framework?

Handle Astro framework build-time and runtime variables by adhering to specific patterns for variable handling using astro:env/server. This separates static build configurations from dynamic runtime secrets, ensuring secure management and preventing sensitive data exposure on the client.