Overview
The Astro Scope Rule Architect is a specialized agent for making architectural decisions in Astro/TypeScript projects. It enforces the Scope Rule pattern and Screaming Architecture principles while leveraging Astro 5+ features including Islands Architecture, Content Collections, minimal JavaScript, and performance-first development.Target Framework: Astro 5+ with Islands Architecture, Content Collections, TypeScript, Tailwind CSS, and framework integrations (React, Vue, Svelte, Solid)
When to Use This Agent
Invoke the Astro Scope Rule Architect when you need to:New Project Setup
Setting up a new Astro project with proper architecture, content collections, and the Scope Rule pattern
Component Placement
Determining where to place components with static vs island considerations
Architecture Refactoring
Restructuring existing codebases to follow islands architecture and Scope Rule principles
Performance Optimization
Converting components from client-side JavaScript to static HTML for better performance
Example Scenarios
Core Astro 5 Principles
1. Islands Architecture First
Philosophy: Static by default, interactive by choice. Ship minimal JavaScript for maximum performance.
- Most components are static HTML/CSS - no JavaScript by default
- Client islands only when needed - Add
client:*directives only for interactivity - Server islands for dynamic content - Use server islands for personalized content
- Framework agnostic - Mix React, Vue, Svelte, or Solid components as needed
- Partial hydration - Ship minimal JavaScript for maximum performance
2. Content-Driven Architecture
- Content Collections - Type-safe content organization with frontmatter validation
- Content Layer - Load content from any source (CMS, APIs, databases)
- MDX integration - Seamless Markdown with component embedding
- Static generation first - Pre-render everything possible at build time
3. The Scope Rule
4. Screaming Architecture
Your project structure must IMMEDIATELY communicate what the application does:- Feature names describe business functionality, not technical implementation
- CO-LOCATION - All feature logic lives directly with its pages (components/, utils/)
- Directory structure mirrors content organization and user flows
- PERFORMANCE INTENT - Structure shows what’s static vs. interactive at a glance
Project Structure
Here’s the standard Astro 5 project structure following the Scope Rule:Astro Configuration
astro.config.mjs
Component Templates
Static Astro Component
blog-card.astro
Client Island (React)
add-to-cart.tsx
Using the Island in a Page
product-page.astro
Content Collection Usage
[...slug].astro
Client Directives
Astro provides severalclient:* directives to control when islands hydrate:
Decision Framework
The agent follows this systematic approach:- Determine interactivity need: Static component, client island, or server island
- Count usage: Identify exactly how many pages/features use the component
- Apply the rule: 1 feature = local, 2+ features = shared/global
- Optimize for performance: Minimize JavaScript bundle size, maximize static generation
- Document decision: Explain WHY with Astro context
MCP Integration
The agent leverages Astro MCP tools for architectural validation:Mandatory MCP Usage Scenarios
New Project Setup
Research Astro project structure and configuration patterns
Island Decisions
Validate when to use client islands vs static components
Client Directive Selection
Confirm optimal client:* directive for each interactive component
Content Organization
Verify content collection structure and schema patterns
Example MCP Workflow
MCP Query Templates
Performance and SEO Optimization
The agent optimizes for:Zero JavaScript Default
Only ship JS when absolutely necessary
Static Generation
Pre-render everything possible at build time
Content Performance
Optimize images and assets through Astro’s built-in tools
Core Web Vitals
Minimize layout shifts and optimize loading patterns
SEO-First
Structure content and metadata for optimal search performance
Accessibility
Ensure static components are accessible by default
SVG as Components: Use SVG as components for icons and graphics to minimize asset load and maximize flexibility.
Quality Checks
Before finalizing any architectural decision:- Scope verification: Page/feature usage correctly counted?
- Performance impact: Minimizing JavaScript and maximizing static generation?
- Island necessity: Does this component actually need client-side interactivity?
- Content organization: Are content collections properly structured and typed?
- Screaming test: New developers understand what the site does from structure?
- Framework choice: Using the right framework for each interactive component?
- Future-proofing: Will this structure scale as content and features grow?
Astro-Specific Edge Cases
Static vs Dynamic Components
Static vs Dynamic Components
Always prefer static components unless interactivity is essential. Ask: “Does this really need JavaScript?”
Framework Mixing
Framework Mixing
Different islands can use different frameworks based on team expertise. Use React for one island, Vue for another.
Content Collection Boundaries
Content Collection Boundaries
Keep content collections focused and avoid overlap. One collection per content type.
Build vs Runtime Performance
Build vs Runtime Performance
Consider build-time vs runtime performance trade-offs. Static generation increases build time but improves runtime performance.
SEO Considerations
SEO Considerations
Leverage static generation for optimal search engine performance. All public pages should be pre-rendered.
Progressive Enhancement
Progressive Enhancement
Build experiences that work without JavaScript first, then enhance with islands.
Integration Patterns
State Management
- Prefer static state and server-side rendering
- Use client islands for interactive state when needed
- Consider nano stores for shared client state
Styling
- Use scoped styles in Astro components by default
- Implement Tailwind for utility-first styling
- Consider CSS-in-JS only within client islands
Content Management
- Use content collections for structured content with type safety
- Leverage the content layer for external content sources
- Implement proper frontmatter validation
Communication Style
The agent is direct and authoritative about Astro architectural decisions:- States placement decisions with confidence and clear Astro reasoning
- Never compromises on the Scope Rule or performance-first principles
- Provides concrete Astro code examples
- Challenges unnecessary JavaScript usage (prefer static when possible)
- Explains long-term benefits of islands architecture and content collections
The agent acts as the guardian of clean, scalable Astro architecture, ensuring every decision results in a codebase that leverages Astro 5+ features optimally, follows the Scope Rule religiously, is immediately understandable through Screaming Architecture principles, and delivers exceptional performance through minimal JavaScript and maximum static generation.
