casoon/ai-agent-config/astro-client-scripts
Claude Code and agent skill by casoon/ai-agent-config
- community
Checking that the SKILL.md file is still in the repository.
Client-side script patterns in Astro — when to use scoped <script> vs is:inline, ClientRouter behavior, define:vars, and when to reach for a Svelte island instead. Use when adding or reviewing <script> tags in .astro files.
Install
npx vskill@latest install casoon/ai-agent-config/astro-client-scriptsSKILL.md
The same SKILL.md was published earlier as casoon/ai-agent-config/astro-client-scripts.
Astro client scripts
Core rule — prefer scoped <script> over is:inline
Astro's default <script> (without is:inline) is a module script that gets:
- Bundled, deduplicated, and tree-shaken by Vite.
- TypeScript support inside the block.
- No global function-name collisions.
- Automatic
defer(noDOMContentLoadedwrapper needed).
Always use <script> unless you have a specific reason for is:inline.
Migration pattern
Before (anti-pattern)
After
Steps:
- Remove
is:inline. - Unwrap
initXyz()— module code runs at top level. - Drop
DOMContentLoaded(modules are deferred by default). - Add TypeScript casts where needed (
as HTMLElement,as TouchEvent). - Remove
typeof windowguards — modules only run in the browser.
When is:inline IS required
1. Theme / FOUC prevention in <head>
Must execute synchronously before first paint:
2. Scripts using define:vars
define:vars requires is:inline:
3. Third-party snippets that must not be bundled
Analytics, tracking pixels, classic scripts:
ClientRouter (SPA) considerations
When <ClientRouter /> is active (Astro v6 SPA transitions):
is:inlinescripts re-run on every navigation by default.- Module
<script>tags run once and persist across navigations. - Use
astro:after-swapfor code that must re-run after SPA navigation. - Use
astro:page-loadfor code that should run on every page, including the initial load.
Prefer a Svelte island for real interactivity
For anything beyond simple DOM manipulation, reach for a Svelte 5 island:
Decision tree
Common mistakes
| Mistake | Fix | |
|---|---|---|
is:inline "just to be safe" | Remove it — modules are better in every way | |
DOMContentLoaded wrapper in a module script | Drop it — modules are deferred | |
typeof window !== 'undefined' in a module | Remove — browser-only by definition | |
Global function names in is:inline | Use scoped <script> or an IIFE | |
Multiple is:inline scripts that could merge | Combine into one scoped <script> | |
is:inline for Astro lifecycle listeners | Only needed in <head>, otherwise use a module |
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/astro-client-scripts/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/casoon/ai-agent-config/astro-client-scripts)