strocs/.dotfiles/astro-react-islands

Claude Code and agent skill by strocs/.dotfiles

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Trigger: astro react, react in astro, astro islands, client:load, client:only, astro + react. Enforce static-first islands: atomic React client islands, no monolithic wrappers, state via project-detected stores.

Install

npx vskill@latest install strocs/.dotfiles/astro-react-islands

SKILL.md

The same SKILL.md was published earlier as strocs/.dotfiles/astro-react-islands.

Astro React Islands

Activation Contract

Load this skill when:

  • Creating or modifying React components in an Astro project
  • Adding client:* directives to any framework component
  • User asks about Astro + React integration, interactivity, or hydration
  • Reviewing code that mixes .astro and .jsx/.tsx files

Hard Rules

  • Astro owns the static shell. Layout, wrappers, text, images, and non-interactive markup stay in .astro components.
  • React handles ONLY interactivity. Every client:* directive requires a justified interactive need (state changes, event handlers, DOM manipulation, real-time updates).
  • No monolithic React wrappers. Never wrap an entire feature tree in a single client:load React component. This defeats islands architecture and ships unnecessary JavaScript.
  • Islands are atomic. Each React island has ONE interactive responsibility. Split compound features into independent islands.
  • Detect, don't dictate state stores. Check package.json for existing state management (zustand, nanostores, jotai, valtio, @reduxjs/toolkit, mobx, recoil, xstate). Use what the project already has. If none exists, propose Nanostores (Astro's official recommendation, <1KB, framework-agnostic).
  • Astro `<script>` beats React for simple interactivity. A click handler, DOM toggle, or event listener that does not need hooks, React state, or cross-component communication belongs in an Astro <script> tag — not a React island.

Decision Gates

Before writing ANY React component, apply these three gates in order:

GateQuestionIf YES
1. Static extractionCan this render as static .astro markup?Keep it in .astro. Do NOT add client:*.
2. Script sufficiencyCan this be a plain <script> in .astro? (e.g., DOM toggle, event listener, no hooks needed)Use <script> in .astro. Do NOT create a React component.
3. Atomic splitDoes this React component do more than ONE interactive thing?Split into multiple independent islands. Use a state store for cross-island communication if needed.

Only after ALL THREE gates pass with "NO" — create a focused React island with the most appropriate client:* directive.

Execution Steps

  1. Analyze the feature. Identify what is static vs. what is interactive. List ALL interactive behaviors.
  2. Exhaust static extraction. For each behavior, ask: can .astro handle this? Can a <script> tag handle this?
  3. Design atomic islands. For remaining interactive behaviors, design one React component per behavior. Each must have a single, clear responsibility.
  4. Detect state store. Grep package.json for zustand\|nanostores\|jotai\|valtio\|@reduxjs/toolkit\|mobx\|recoil\|xstate. Use the detected store. If none, propose Nanostores + @nanostores/react.
  5. Choose hydration strategy:
  • client:load — critical above-fold interactivity, immediate need
  • client:visible — below-fold, defer until component enters viewport
  • client:idle — non-critical, hydrate when browser is idle
  • client:only — skip SSR entirely (rare; only when component breaks during server render)
  • client:media — only on matching media query
  1. Wire cross-island state. If two atomic islands need shared state, connect them through the detected store. Do NOT create a parent React wrapper to pass props or React context — context does not cross island boundaries.
  2. Verify. Confirm no static markup leaked into React components. Confirm each client:* directive is justified.

Anti-Pattern — Monolithic Wrapper

astro
// ❌ BAD: Astro is reduced to a shell. ReactFeature owns everything.
---
import ReactFeature from './ReactFeature';
---
<ReactFeature client:load />

Where ReactFeature contains layout divs, static text, static images, interactive toggles, forms, and modals — all in one React tree shipped as client JavaScript.

astro
// ✅ GOOD: Astro owns the layout. React owns only interactive atoms.
---
import Toggle from './Toggle';
import Modal from './Modal';
---
<section>
<h2>Feature Title</h2>
<p>Static description text lives in .astro — zero JS shipped.</p>
<Toggle client:idle />
<Modal client:visible />
</section>

State Store Detection

Run before proposing any state management:

bash
grep -oE "zustand|nanostores|jotai|valtio|@reduxjs/toolkit|mobx|recoil|xstate" package.json | head -1
  • Match found — use that store. Wire islands through it. Never force a migration.
  • No match — propose nanostores + @nanostores/react.

Script Over React

When interactivity is simple and self-contained, use <script> in .astro:

astro
---
// ✅ Simple toggle — no React needed
---
<button id="menu-toggle">Menu</button>
<nav id="menu" hidden>...</nav>
<script>
document.getElementById('menu-toggle').addEventListener('click', () => {
document.getElementById('menu').hidden = !document.getElementById('menu').hidden;
});
</script>

Use React only when the behavior needs: React hooks, React state management, integration with a state store, or composition with other React islands.

Output Contract

After designing or implementing React components in Astro, report:

  1. Each React island created, its client:* directive, and its single responsibility.
  2. Justification for why each island could NOT be static .astro or a <script> tag.
  3. The detected state store (or proposed Nanostores if none exists).
  4. Confirmation that no static markup leaked into React components.

References

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/strocs/.dotfiles/astro-react-islands/badge)](https://verified-skill.com/skills/strocs/.dotfiles/astro-react-islands)

Something wrong with this skill or its page? Tell us.