strocs/.dotfiles/astro-react-islands
Claude Code and agent skill by strocs/.dotfiles
- community
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-islandsSKILL.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
.astroand.jsx/.tsxfiles
Hard Rules
- Astro owns the static shell. Layout, wrappers, text, images, and non-interactive markup stay in
.astrocomponents. - 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:loadReact 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.jsonfor 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:
| Gate | Question | If YES | |
|---|---|---|---|
| 1. Static extraction | Can this render as static .astro markup? | Keep it in .astro. Do NOT add client:*. | |
| 2. Script sufficiency | Can 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 split | Does 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
- Analyze the feature. Identify what is static vs. what is interactive. List ALL interactive behaviors.
- Exhaust static extraction. For each behavior, ask: can
.astrohandle this? Can a<script>tag handle this? - Design atomic islands. For remaining interactive behaviors, design one React component per behavior. Each must have a single, clear responsibility.
- Detect state store. Grep
package.jsonforzustand\|nanostores\|jotai\|valtio\|@reduxjs/toolkit\|mobx\|recoil\|xstate. Use the detected store. If none, propose Nanostores +@nanostores/react. - Choose hydration strategy:
client:load— critical above-fold interactivity, immediate needclient:visible— below-fold, defer until component enters viewportclient:idle— non-critical, hydrate when browser is idleclient:only— skip SSR entirely (rare; only when component breaks during server render)client:media— only on matching media query
- 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.
- Verify. Confirm no static markup leaked into React components. Confirm each
client:*directive is justified.
Anti-Pattern — Monolithic Wrapper
Where ReactFeature contains layout divs, static text, static images, interactive toggles, forms, and modals — all in one React tree shipped as client JavaScript.
State Store Detection
Run before proposing any state management:
- 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:
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:
- Each React island created, its
client:*directive, and its single responsibility. - Justification for why each island could NOT be static
.astroor a<script>tag. - The detected state store (or proposed Nanostores if none exists).
- 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
- SKILL.md in the repositoryCheckingskills/.agents/skills/astro-react-islands/SKILL.md
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
[](https://verified-skill.com/skills/strocs/.dotfiles/astro-react-islands)