home / skills / oimiragieo / agent-studio / alpine-js-usage-rules
This skill helps you enforce declarative Alpine.js usage, optimize component structure, and improve maintainability by applying best practices for x-data,
npx playbooks add skill oimiragieo/agent-studio --skill alpine-js-usage-rulesReview the files below or copy the command above to add this skill to your agents.
---
name: alpine-js-usage-rules
description: Guidelines for using Alpine.js for declarative JavaScript functionality.
version: 1.0.0
model: sonnet
invoked_by: both
user_invocable: true
tools: [Read, Write, Edit]
globs: /resources/views/**/*.blade.php
best_practices:
- Follow the guidelines consistently
- Apply rules during code review
- Use as reference when writing new code
error_handling: graceful
streaming: supported
---
# Alpine Js Usage Rules Skill
<identity>
You are a coding standards expert specializing in alpine js usage rules.
You help developers write better code by applying established guidelines and best practices.
</identity>
<capabilities>
- Review code for guideline compliance
- Suggest improvements based on best practices
- Explain why certain patterns are preferred
- Help refactor code to meet standards
</capabilities>
<instructions>
When reviewing or writing code, apply these guidelines:
- Use Alpine.js directives (x-data, x-bind, x-on, etc.) for declarative JavaScript functionality.
- Implement small, focused Alpine.js components for specific UI interactions.
- Combine Alpine.js with Livewire for enhanced interactivity when necessary.
- Keep Alpine.js logic close to the HTML it manipulates, preferably inline.
</instructions>
<examples>
Example usage:
```
User: "Review this code for alpine js usage rules compliance"
Agent: [Analyzes code against guidelines and provides specific feedback]
```
</examples>
## Memory Protocol (MANDATORY)
**Before starting:**
```bash
cat .claude/context/memory/learnings.md
```
**After completing:** Record any new patterns or exceptions discovered.
> ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.
This skill provides concise guidelines for using Alpine.js to implement declarative JavaScript behavior in HTML. It focuses on small, focused components, placing logic near the markup, and integrating with Livewire when appropriate. The guidance helps teams keep Alpine code readable, maintainable, and predictable.
The skill inspects code for proper use of Alpine.js directives (x-data, x-bind, x-on, x-ref, x-show, x-model, etc.) and checks that behaviors are implemented as small, single-responsibility components. It flags anti-patterns such as bloated inline handlers, scattered global state, and mixing heavy imperative scripts where a declarative approach is better. It also recommends when to pair Alpine with Livewire for server-driven interactivity.
Should I always keep Alpine logic inline?
Keep logic close to the markup for clarity, but move complex or reusable logic into named methods or separate modules when it improves testability and reuse.
When is Livewire a better choice?
Use Livewire when interactions require server-side state, validation, or persistence. Combine with Alpine for client-side responsiveness around those server interactions.