inertia-rails-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInertia Rails Project Setup
Inertia Rails项目设置
Detect stack, offer recommended deps, generate CLAUDE.md configuration.
Run once per project. Re-run when the stack changes.
NEVER:
- Run setup without gem in Gemfile — all skills assume it exists. If missing, tell the user to install it first.
inertia_rails - Overwrite existing in CLAUDE.md without reading it — the user may have manual customizations. Replace only the auto-generated block.
## Inertia Rails Stack - Add resolve aliases to
@/—vite.config.tsalready provides them. Only add tovite-plugin-ruby.tsconfig.json - Recommend if the project uses
alba-inertiaAND the user hasn't expressed interest in switching — suggest it, but don't push. You CAN still suggest it if the project hasjbuilder(alba is a direct upgrade path).blueprinter - Generate CLAUDE.md blocks for skills the user doesn't have installed — saying "alba-inertia skill does NOT apply" is correct; saying "use alba-inertia" when the gem is absent is wrong.
检测技术栈,提供推荐依赖,生成CLAUDE.md配置。
每个项目仅需运行一次。技术栈变更时可重新运行。
禁止操作:
- 当Gemfile中没有gem时运行本设置——所有技能都假设该gem已存在。若缺失,请告知用户先安装它。
inertia_rails - 未读取就覆盖CLAUDE.md中已有的部分——用户可能已进行手动自定义。仅替换自动生成的区块。
## Inertia Rails Stack - 向中添加
vite.config.ts解析别名——@/已提供该功能。仅需添加到vite-plugin-ruby中。tsconfig.json - 若项目使用且用户未表示有切换意向,请勿推荐
jbuilder——可提出建议,但不要强行推荐。若项目使用alba-inertia,则仍可推荐blueprinter(alba是直接升级方案)。alba-inertia - 为用户未安装的技能生成CLAUDE.md区块——说明“alba-inertia skill does NOT apply”是正确的;但若gem未安装却提示“use alba-inertia”则是错误的。
Step 1: Detect Current Stack
步骤1:检测当前技术栈
Read (NOT ) and and check for:
GemfileGemfile.lockpackage.json| Look for | Means |
|---|---|
| Inertia Rails installed (required) |
| React frontend |
| Vue 3 frontend |
| Svelte frontend |
| Convention-based rendering active |
| Alba serialization without convention rendering |
| Pagy pagination |
| Kaminari pagination |
| RSpec testing |
| Typed frontend path helpers |
| Devise authentication |
| Pundit authorization |
| Action Policy authorization |
| shadcn installed (React: shadcn/ui, Vue: shadcn-vue, Svelte: shadcn-svelte) |
读取(不要读取)和,检查以下内容:
GemfileGemfile.lockpackage.json| 检测目标 | 含义 |
|---|---|
| 已安装Inertia Rails(必填) |
| React前端 |
| Vue 3前端 |
| Svelte前端 |
| 已启用约定式渲染 |
| 使用Alba序列化但未启用约定式渲染 |
| Pagy分页 |
| Kaminari分页 |
| RSpec测试 |
| 类型化前端路径助手 |
| Devise身份验证 |
| Pundit授权 |
| Action Policy授权 |
根目录存在 | 已安装shadcn(React:shadcn/ui,Vue:shadcn-vue,Svelte:shadcn-svelte) |
Step 2: Recommend Missing Deps
步骤2:推荐缺失的依赖
Present detected stack, then offer deps that unlock skill features but aren't
installed yet. Use AskUserQuestion with multiSelect for the recommendations.
Only recommend what's missing. Skip anything already detected in Step 1.
| Dep | Type | Install command | What it unlocks |
|---|---|---|---|
| gems | | Convention-based rendering, auto-generated TypeScript types from Ruby. Eliminates |
| gem | | Typed path helpers ( |
| gem | | Lightweight pagination with Inertia-friendly metadata. |
| shadcn/ui (React) | npx | | Pre-built React components adapted for Inertia. Unlocks |
| shadcn-vue (Vue) | npx | | Pre-built Vue components adapted for Inertia. Unlocks |
| shadcn-svelte (Svelte) | npx | | Pre-built Svelte components (bits-ui) adapted for Inertia. Unlocks |
Do NOT recommend gems the user clearly chose alternatives for (e.g., don't suggest Pagy if Kaminari is present, you can still suggest alba if the project has or ).
jbuilderblueprinter展示检测到的技术栈,然后提供可解锁技能功能但尚未安装的依赖。使用AskUserQuestion的多选功能呈现推荐项。
仅推荐缺失的依赖,跳过步骤1中已检测到的内容。
| 依赖 | 类型 | 安装命令 | 解锁功能 |
|---|---|---|---|
| gems | | 约定式渲染,从Ruby自动生成TypeScript类型。消除 |
| gem | | React中的类型化路径助手( |
| gem | | 轻量级分页,支持Inertia友好的元数据。 |
| shadcn/ui (React) | npx | | 适配Inertia的预构建React组件。解锁 |
| shadcn-vue (Vue) | npx | | 适配Inertia的预构建Vue组件。解锁 |
| shadcn-svelte (Svelte) | npx | | 适配Inertia的预构建Svelte组件(bits-ui)。解锁 |
请勿推荐用户已明确选择替代方案的gem(例如,若已存在Kaminari,则不要推荐Pagy;但若项目使用或,仍可推荐alba)。
jbuilderblueprinterStep 3: Install Opted-In Deps
步骤3:安装用户选择的依赖
Post-install scaffolding per dep:
- alba-inertia — also scaffold :
ApplicationResourceAnd add Typelizer initializer:ruby# app/resources/application_resource.rb class ApplicationResource include Alba::Resource helper Typelizer::DSL helper Alba::Inertia::Resource include Rails.application.routes.url_helpers endruby# config/initializers/typelizer.rb Typelizer.configure do |config| config.output_dir = Rails.root.join("app/frontend/types/generated") end - js-routes — run if the generator exists
rails generate js_routes - shadcn — framework-specific init:
- React:
npx shadcn@latest init - Vue:
npx shadcn-vue@latest init - Svelte: After init, add
npx shadcn-svelte@latest initresolve aliases to@/if not presenttsconfig.json
- React:
根据安装的依赖进行后续脚手架搭建:
- alba-inertia —— 同时生成:
ApplicationResource并添加Typelizer初始化文件:ruby# app/resources/application_resource.rb class ApplicationResource include Alba::Resource helper Typelizer::DSL helper Alba::Inertia::Resource include Rails.application.routes.url_helpers endruby# config/initializers/typelizer.rb Typelizer.configure do |config| config.output_dir = Rails.root.join("app/frontend/types/generated") end - js-routes —— 若生成器存在,运行
rails generate js_routes - shadcn —— 框架专属初始化:
- React:
npx shadcn@latest init - Vue:
npx shadcn-vue@latest init - Svelte: 初始化完成后,若
npx shadcn-svelte@latest init中未包含tsconfig.json解析别名,则添加进去@/
- React:
Step 4: Generate CLAUDE.md
步骤4:生成CLAUDE.md
Find or create in the project root. If
exists, replace it (up to next or EOF). Otherwise, append.
CLAUDE.md## Inertia Rails Stack##MANDATORY — READ ENTIRE FILE before assembling the CLAUDE.md block:
(~90 lines) — all
template blocks for each stack variant (serialization, UI, pagination, testing, routing,
authorization). Pick one block per category based on the detected stack.
references/claude-md-templates.mdDo NOT load the templates file until Step 4 — Steps 1-3 determine which blocks to use.
在项目根目录中查找或创建。若已存在部分,则替换该部分(直到下一个或文件末尾)。若不存在,则追加到文件末尾。
CLAUDE.md## Inertia Rails Stack##强制要求 —— 组装CLAUDE.md区块前请完整阅读以下文件:
(约90行)—— 包含各技术栈变体(序列化、UI、分页、测试、路由、授权)的所有模板区块。根据检测到的技术栈,为每个类别选择一个区块。
references/claude-md-templates.md请勿提前加载模板文件 —— 步骤1-3将决定使用哪些区块。
Troubleshooting
故障排查
| Symptom | Cause | Fix |
|---|---|---|
| Missing or misconfigured | Ensure |
| Typelizer generates types in wrong directory | Missing or wrong | Add |
| Aliases added to | |
| CLAUDE.md has conflicting instructions | Multiple | Delete duplicates — only one auto-generated block should exist |
Skills reference | Setup wasn't run, or alba wasn't selected | Re-run setup; CLAUDE.md should say "alba-inertia skill does NOT apply" if gem is absent |
| | Run |
| 症状 | 原因 | 解决方法 |
|---|---|---|
| | 运行初始化前,确保已配置 |
| Typelizer在错误目录生成类型 | 初始化文件缺失或 | 添加 |
| 别名被添加到 | |
| CLAUDE.md存在冲突指令 | 存在多个 | 删除重复内容 —— 仅保留一个自动生成的区块 |
技能引用 | 未运行本设置,或未选择安装alba | 重新运行本设置;若gem未安装,CLAUDE.md应显示“alba-inertia skill does NOT apply” |
| 已安装 | 先运行 |
Step 5: Summary
步骤5:总结
Tell the user:
- What was installed
- Which skills are relevant to their stack (and which to ignore)
- Review in CLAUDE.md — it takes precedence over generic examples in individual skills
## Inertia Rails Stack
告知用户:
- 已安装的内容
- 哪些技能与他们的技术栈相关(以及哪些可忽略)
- 查看CLAUDE.md中的部分 —— 该部分优先级高于单个技能中的通用示例
## Inertia Rails Stack