alpinejs
Use when the user asks about Alpine.js, x-data, x-init, x-bind, x-on, x-show, x-for, Alpine.store or adding reactivity to server-rendered HTML. Produces…
от j4flmao★ 47 звёзд на GitHub
Установить alpinejs в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Alpine.js
Purpose
Add interactivity to HTML pages using Alpine.js directives — a lightweight, declarative framework that works directly in the DOM without a build step.
Agent Protocol
Trigger
Exact user phrases: "Alpine.js setup", "Alpine component", "Alpine x-data", "Alpine x-init", "Alpine store", "Alpine project", "Alpine directive", "alpine reactive".
Input Context
Before activating, verify:
- Alpine.js is included (CDN script or npm).
- Whether the project uses Alpine + backend (Laravel, Django, etc.) or standalone.
Output Artifact
No file output. Produces HTML snippets with Alpine directives as text.
Response Format
HTML with Alpine directives:
<div x-data="{ open: false }">
<button @click="open = !open">Toggle</button>
<div x-show="open">Content</div>
</div>
No preamble. No postamble. No explanations. Compress output — why use many token when few do trick.
Completion Criteria
- Component state defined with x-data on root element.
- Event handlers use x-on or @ shorthand.
- Dynamic attributes use x-bind or : shorthand.
- Conditional rendering uses x-show or x-if.
- Lists use x-for with unique :key.
- Shared state uses Alpine.store().
- Side effects use x-init or $watch.
- No external build step required (CDN-compatible).
Max Response Length
~4096 tokens.
Architecture Decision Trees
State Management Decision
How many components need the state?
Single component -> x-data with inline object
Multiple sibling components -> Alpine.store()
Nested components -> x-data on parent with scope inheritance
What type of state?
UI toggles (open/close) -> x-data { open: false }
Form data -> x-data with x-model binding
Data from server -> x-data + fetch() in x-init
Computed/derived -> $watch or x-effect for reactions
Rendering Decision
Should the element be visible or removed?
Frequently toggled -> x-show (CSS display toggle, faster)
Rarely toggled or heavy content -> x-if (DOM add/remove)
Initial render conditional -> x-init to set state, then x-show
Loop rendering:
Array of items -> x-for on template tag
Need stable identity -> :key binding (always add this)
Plugin Selection Guide
Need:
Collapse/expand animation -> @alpinejs/collapse
Intersection observer -> @alpinejs/intersect
Persist to localStorage -> @alpinejs/persist
Focus trap (modals) -> @alpinejs/focus
Smooth DOM morphing -> @alpinejs/morph
Input masks -> @alpinejs/mask
Tooltips -> alpinejs-tooltip
Workflow
Step 1: Install Alpine.js
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
Step 2: Basic Component
<div x-data="{ count: 0 }">
<button @click="count++">Increment</button>
<span x-text="count"></span>
</div>
Step 3: Forms and Binding
<div x-data="{ name: '', email: '' }">
<input x-model="name" placeholder="Name">
<input x-model="email" placeholder="Email" type="email">
<button @click="submit()" :disabled="!name || !email">Submit</button>
<div x-show="name">
<p>Hello, <span x-text="name"></span>!</p>
</div>
</div>
Step 4: Shared Store
<script>
document.addEventListener('alpine:init', () => {
Alpine.store('user', {
name: 'Guest',
loggedIn: false,
login(name) { this.name = name; this.loggedIn = true },
logout() { this.name = 'Guest'; this.loggedIn = false },
})
})
</script>
<div x-data>
<template x-if="$store.user.loggedIn">
<p>Welcome, <span x-text="$store.user.name"></span></p>
</template>
</div>
Step 5: Fetching Data
<div x-data="{
posts: [],
loading: false,
async fetchPosts() {
this.loading = true
this.posts = await (await fetch('/api/posts')).json()
this.loading = false
}
}" x-init="fetchPosts()">
<div x-show="loading">Loading...</div>
<template x-for="post in posts" :key="post.id">
<div>
<h3 x-text="post.title"></h3>
<p x-text="post.body"></p>
</div>
</template>
</div>
Step 6: State Management Patterns
Signal-like pattern with $watch:
<div x-data="{ count: 0, doubled: 0 }" x-init="$watch('count', val => doubled = val * 2)">
<button @click="count++">+1</button>
<p x-text="`Count: ${count}, Doubled: ${doubled}`"></p>
</div>
Composable-like extracted component (magic $data):
<div x-data="counter()">
<button @click="increment">+1</button>
<span x-text="count"></span>
</div>
<script>
document.addEventListener('alpine:init', () => {
Alpine.data('counter', () => ({
count: 0,
increment() { this.count++ },
reset() { this.count = 0 },
}))
})
</script>
Persisted state across page loads:
<div x-data x-init="$store.theme = $persist('light').as('theme')">
<button @click="$store.theme = $store.theme === 'light' ? 'dark' : 'light'">
Toggle theme
</button>
</div>
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/alpine-patterns.md
- references/alpine-setup.md
- references/alpinejs-advanced.md
- references/alpinejs-component-patterns.md
- references/alpinejs-deployment.md
- references/alpinejs-fundamentals.md
- references/alpinejs-state-management.md
- references/alpinejs-testing.md
FAQ
Что делает скилл alpinejs?
Use when the user asks about Alpine.js, x-data, x-init, x-bind, x-on, x-show, x-for, Alpine.store or adding reactivity to server-rendered HTML. Produces attribute-driven Alpine components, stores and CSP-safe setup with minimal JavaScript. Not for hypermedia requests that swap server HTML (use htmx).
Как установить скилл alpinejs?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл alpinejs запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…