Packages
corex
0.1.0
0.1.2
0.1.1
0.1.0
0.1.0-rc.1
0.1.0-rc.0
0.1.0-beta.5
0.1.0-beta.4
0.1.0-beta.3
0.1.0-beta.2
0.1.0-beta.1
0.1.0-alpha.33
0.1.0-alpha.32
0.1.0-alpha.31
0.1.0-alpha.30
0.1.0-alpha.29
0.1.0-alpha.28
0.1.0-alpha.27
0.1.0-alpha.26
0.1.0-alpha.25
0.1.0-alpha.24
0.1.0-alpha.23
0.1.0-alpha.22
0.1.0-alpha.21
0.1.0-alpha.20
0.1.0-alpha.19
0.1.0-alpha.18
0.1.0-alpha.17
0.1.0-alpha.16
0.1.0-alpha.15
0.1.0-alpha.14
0.1.0-alpha.13
0.1.0-alpha.12
0.1.0-alpha.11
0.1.0-alpha.10
0.1.0-alpha.9
0.1.0-alpha.8
0.1.0-alpha.7
0.1.0-alpha.6
0.1.0-alpha.5
0.1.0-alpha.4
0.1.0-alpha.3
0.1.0-alpha.2
0.1.0-alpha.1
Accessible and unstyled UI components library written in Elixir and TypeScript that integrates Zag.js state machines into the Phoenix Framework.
Current section
Files
Jump to
Current section
Files
usage-rules.md
# Rules for working with Corex
## Understanding Corex
Corex is an accessible, unstyled Phoenix component library powered by Zag.js state machines. Every component exposes a **server API** (LiveView/socket helpers) and a **client API** (JS commands). Corex Design is optional token-based CSS with modifier classes such as `button--accent`.
Read documentation and call Corex MCP tools **before** guessing attrs, slots, or install steps.
Hexdocs: https://hexdocs.pm/corex
## Package layout
| Layer | Path | Consumer use |
|-------|------|--------------|
| Main rules | `usage-rules.md` | `:corex` in AGENTS.md config |
| Sub-rules | `usage-rules/<topic>.md` | `"corex:<topic>"` or `"corex:all"` |
| Pre-built skills | `usage-rules/skills/<name>/SKILL.md` | `package_skills: [:corex]` in mix.exs |
Sub-rules hold depth for AGENTS.md. Skills hold short triggers + examples for Cursor. Do not duplicate full sub-rules inside skills.
## Non-negotiables
1. **Never enable `plug Corex.MCP` in production.** Dev and test only.
2. **Call MCP before writing HEEx.** `list_components` then `get_component` — never invent attrs, slots, or event names.
3. **Every API-driven component needs a stable `id`.**
4. **Esbuild must use ESM splitting.** `--format=esm --splitting`; load `app.js` with `type="module"`.
5. **Do not web-search Hexdocs.** Use `mix usage_rules.search_docs -p corex`.
## Doc lookup
```sh
mix usage_rules.search_docs "accordion set_value" -p corex
mix usage_rules.search_docs "on_value_change" -p corex --query-by title
```
## Sub-rules
| Sub-rule | When to read |
|----------|--------------|
| `corex:installation` | `mix corex.new`, manual install, esbuild, hooks, `use Corex`, `mix corex.design` |
| `corex:components` | HEEx wiring, MCP lookup, data builders, slots, hooks |
| `corex:design` | Modifiers, tokens, `.typo`, themes — no custom template CSS |
| `corex:mcp` | Dev MCP plug, `.cursor/mcp.json`, tool call order |
| `corex:api` | Imperative `Corex.*` helpers, `<.action>`, controlled mode |
| `corex:events` | `on_*_change` server and client event subscriptions |
| `corex:forms` | Phoenix `to_form` + Corex input components (no Form component) |
| `corex:navigation` | `<.navigate>`, `<.action>`, `redirect` on select/menu/combobox |
Include all: `"corex:all"` in AGENTS.md config.
## Three complementary tools
| Tool | Role |
|------|------|
| **usage_rules** | Static rules and skills from the `corex` dep |
| **Corex MCP** | Live `list_components`, `get_component`, `installation_guide` |
| **mix usage_rules.search_docs** | Hexdocs search |
## Agent skills
Enable pre-built skills:
```elixir
skills: [location: ".cursor/skills", package_skills: [:corex]]
```
Run `mix usage_rules.sync`. Do **not** also set `deps: [:corex]` — that creates a redundant `use-corex` skill.
Skills synced: `corex-installation`, `corex-components`, `corex-design`, `corex-mcp`, `corex-api`, `corex-events`, `corex-forms`, `corex-navigation`.
## Quick install
```sh
mix archive.install hex phx_new
mix archive.install hex corex_new
mix corex.new my_app
```
Existing app: see `corex:installation`. Design: `mix corex.design` then `corex:design`.