|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +Guidance for AI agents working at the root of the `ruby-ui/ruby_ui` monorepo. |
| 4 | + |
| 5 | +## Layout |
| 6 | + |
| 7 | +Two sibling projects, each independent (own `Gemfile`, `package.json`, tests, lockfiles): |
| 8 | + |
| 9 | +| Path | What it is | |
| 10 | +| --- | --- | |
| 11 | +| [`gem/`](gem/) | The `ruby_ui` gem — Phlex components, generators, gemspec, Minitest suite. Published to RubyGems from here. | |
| 12 | +| [`docs/`](docs/) | Rails 8 app powering https://rubyui.com. Consumes the local gem via `path: "../gem"`. | |
| 13 | +| `.github/workflows/ci.yml` | Unified CI: gem tests (Ruby 3.3 + 3.4), docs Rails tests, docker build for docs devcontainer. | |
| 14 | + |
| 15 | +Subproject-specific instructions live in `gem/AGENTS.md` and `docs/CLAUDE.md` (→ `docs/AGENTS.md`). Read those before editing inside a subdir. |
| 16 | + |
| 17 | +## Routing changes |
| 18 | + |
| 19 | +- Component code → `gem/lib/ruby_ui/<component>/`. Tests → `gem/test/ruby_ui/<component>_test.rb`. |
| 20 | +- Component docs view → `docs/app/views/docs/<component>.rb`. Update in same PR as the component. |
| 21 | +- Generator/installer logic → `gem/lib/generators/ruby_ui/`. Dependency map → `gem/lib/generators/ruby_ui/dependencies.yml`. |
| 22 | +- Site chrome, routes, marketing pages → `docs/app/`. |
| 23 | + |
| 24 | +## Common commands |
| 25 | + |
| 26 | +Run from the relevant subdir, not root. |
| 27 | + |
| 28 | +```bash |
| 29 | +# Gem |
| 30 | +cd gem |
| 31 | +bundle exec rake # tests + standardrb |
| 32 | +bundle exec rake test TEST=test/ruby_ui/button_test.rb |
| 33 | +bundle exec standardrb --fix |
| 34 | + |
| 35 | +# Docs site |
| 36 | +cd docs |
| 37 | +bin/setup |
| 38 | +bin/dev # local server |
| 39 | +pnpm build && pnpm build:css # assets |
| 40 | +bin/rails db:test:prepare test |
| 41 | +bundle exec standardrb |
| 42 | +``` |
| 43 | + |
| 44 | +## Conventions |
| 45 | + |
| 46 | +- Ruby 3.2+, 2-space indent, `snake_case` files/methods, `CamelCase` classes. StandardRB enforced. |
| 47 | +- Components extend `RubyUI::Base < Phlex::HTML`; classes merged via `tailwind_merge`. Invoke as `RubyUI.<Name>()` (Phlex::Kit). |
| 48 | +- Stimulus controllers colocated with components: `<component>_controller.js`. JS deps declared in `gem/package.json` and per-component in `dependencies.yml`. |
| 49 | +- Tests extend `ComponentTest`; render via `phlex { ... }` helper. |
| 50 | + |
| 51 | +## Commits & PRs |
| 52 | + |
| 53 | +- Bracketed prefixes (`[Feature]`, `[Bug Fix]`, `[Documentation]`) or scoped conventional (`feat(scope): ...`). |
| 54 | +- Imperative, focused commits. Reference issues/PRs as `(#123)`. |
| 55 | +- PRs: linked issue, concise description, before/after screenshots for UI changes, explicit test steps. |
| 56 | + |
| 57 | +## Don'ts |
| 58 | + |
| 59 | +- Don't run commands from repo root expecting them to work — `cd gem` or `cd docs` first. |
| 60 | +- Don't edit a component without updating its `docs/app/views/docs/<component>.rb` counterpart. |
| 61 | +- Don't bump the gem version or release from `docs/`; releases happen in `gem/`. |
| 62 | +- Don't commit secrets; each app uses local env config. |
0 commit comments