# hyva-alpine-component

Guides the agent through building Alpine.js components for Hyvä themes in Magento 2 that keep working when Content Security Policy is strict.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1300 installs · ★ 85
- Author: hyva-themes
- License: OSL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/hyva-themes/hyva-ai-tools/tree/HEAD/skills/hyva-alpine-component/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/hyva-alpine-component

## What it does

The skill covers interactive Hyvä templates that must run in the Alpine CSP build, which avoids the `unsafe-eval` directive. Payment pages need that setup for PCI-DSS 4.0, mandatory from April 1, 2025. Treat CSP style as the default for any Alpine code you write.

The guidance is concrete. To toggle state, call a method such as `toggle` instead of assigning inline; to pass an argument, put it in a `data-*` attribute and read `this.$el.dataset`. `x-model` has no equivalent in Alpine CSP, so inputs use `:value` plus `@input`. Range loops are out too. Each component follows a template: a named global constructor function, registered with `Alpine.data()` inside an `alpine:init` listener that passes `{once: true}`, and `$hyvaCsp->registerInlineScript()` after every `<script>` block.

PHP values reach JavaScript through `$escaper->escapeJs()`; data attributes take `escapeHtmlAttr()` instead. Numeric input goes through `hyva.safeParseNumber()`, and combining objects uses spread with `.call(this)`. Skip the `registerInlineScript()` call and the inline script stays unregistered, so the policy blocks it.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add hyva-themes/hyva-ai-tools --skill hyva-alpine-component -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/hyva-alpine-component/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/hyva-alpine-component/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add hyva-themes/hyva-ai-tools --skill hyva-alpine-component -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/hyva-alpine-component/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add hyva-themes/hyva-ai-tools --skill hyva-alpine-component -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/hyva-alpine-component/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install hyva-themes/hyva-ai-tools hyva-alpine-component
```

2. **Manually: put the files in place**
- File: `.github/skills/hyva-alpine-component/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add hyva-themes/hyva-ai-tools --skill hyva-alpine-component -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/hyva-themes/hyva-ai-tools --path skills/hyva-alpine-component
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/hyva-alpine-component/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add hyva-themes/hyva-ai-tools --skill hyva-alpine-component -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/hyva-themes/hyva-ai-tools/tree/HEAD/skills/hyva-alpine-component/SKILL.md

## When to use it
- Build an Alpine component in a Hyvä template that passes CSP rules
- Port an existing `x-data` block to Alpine CSP without `unsafe-eval`
- Replace `x-model` with `:value` and `@input` handlers
- Register a component constructor once via `Alpine.data()`
- Pass a method argument through a data attribute with proper escaping

## Example prompts
- Build an Alpine component for the Hyvä cart: toggle the panel and update a quantity, no `unsafe-eval`
- Rewrite `checkout.phtml` so it works in the Alpine CSP build
- Add two-way binding for the coupon field using `:value` and `@input`

## Similar
- [frontend-design](https://affpapa.org/en/nevibecode/skills/frontend-design.md) — skill · 1025790 installs
- [design-taste-frontend](https://affpapa.org/en/nevibecode/skills/design-taste-frontend.md) — skill · 678700 installs
- [prototype](https://affpapa.org/en/nevibecode/skills/prototype.md) — skill · 986201 installs
- [hyperframes](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes.md) — skill · 1200000 installs
- [hyperframes-cli](https://affpapa.org/en/nevibecode/skills/heygen-com-hyperframes-cli.md) — skill · 1300000 installs
- [webapp-testing](https://affpapa.org/en/nevibecode/skills/webapp-testing.md) — skill · 186758 installs

From the same set: [hyva-themes/hyva-ai-tools](https://affpapa.org/en/nevibecode/by/hyva-themes/hyva-ai-tools.md) — 6 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
