new-rails-project
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenerate a new Rails project named $1 in the current directory. You may reference @CLAUDE.md for general guidance, though the guidance here takes precedence.
在当前目录中生成一个名为$1的新Rails项目。你可以参考@CLAUDE.md获取通用指导,但此处的指导优先级更高。
Tech Stack
技术栈
Set up the following tech stack:
- Rails ~8 with PostgreSQL - Server-side framework and database
- Inertia.js ~2.3 - Bridges Rails and React for SPA-like experience without API
- React ~19.2 - Frontend UI framework
- Vite ~5 - JavaScript bundler with HMR
- Tailwind CSS ~4 - Utility-first CSS framework
- Sidekiq 8 - Background job processing with scheduled jobs via sidekiq-scheduler
- Redis - Sessions, caching, and job queue
搭建以下技术栈:
- Rails ~8 搭配 PostgreSQL - 服务端框架与数据库
- Inertia.js ~2.3 - 无需API即可连接Rails与React,实现类SPA体验
- React ~19.2 - 前端UI框架
- Vite ~5 - 支持HMR的JavaScript打包工具
- Tailwind CSS ~4 - 实用优先的CSS框架
- Sidekiq 8 - 后台任务处理,通过sidekiq-scheduler支持定时任务
- Redis - 会话管理、缓存与任务队列
Rails guidance
Rails指导
- Do not use Kamal or Docker
- Do not use Rails "solid_*" components/systems
- Development should generally match production settings where possible
- Use Redis for caching
- 不要使用Kamal或Docker
- 不要使用Rails的"solid_*"组件/系统
- 开发环境应尽可能与生产环境设置保持一致
- 使用Redis进行缓存
Database
数据库
- All tables use UUID primary keys (pgcrypto extension)
- Timestamps use for timezone awareness
timestamptz - JSONB columns for flexible metadata storage
- Comprehensive indexing strategy for performance
- Encrypted fields for sensitive data (OAuth tokens, API keys)
- 所有表使用UUID作为主键(需启用pgcrypto扩展)
- 时间戳使用以支持时区
timestamptz - 使用JSONB字段存储灵活的元数据
- 采用全面的索引策略以提升性能
- 对敏感数据(OAuth令牌、API密钥)使用加密字段
Background jobs
后台任务
- Use Sidekiq 8 with Redis
- 使用Sidekiq 8搭配Redis
Testing
测试
- Always use minitest
- Use gem and VCR for external services (only in the providers layer)
mocha - Prefer for mock instances
OpenStruct - Only mock what's necessary
- 始终使用minitest
- 对外部服务使用gem和VCR(仅在提供者层使用)
mocha - 优先使用创建模拟实例
OpenStruct - 仅对必要内容进行模拟
Code maintenace
代码维护
- Run after significant code changes
bundle exec rubocop -a - Use for style configuration
.rubocop.yml - Security scanning with
bundle exec brakeman
- 在重大代码变更后运行
bundle exec rubocop -a - 使用进行样式配置
.rubocop.yml - 使用进行安全扫描
bundle exec brakeman
Frontend
前端
- All React components and views should be TSX
- 所有React组件与视图均应使用TSX
General guidance
通用指导
- Ask lots of clarifying questions when planning. The more the better. Make extensive use of AskUserQuestionTool to gather requirements and specifications. You can't ask too many questions.
- 在规划阶段提出大量澄清问题,越多越好。充分利用AskUserQuestionTool收集需求与规格说明。你提出的问题永远不会过多。
Verify
验证
Verify the boilerplate is working by running and accessing the application at via playwright MCP.
bin/rails serverhttp://localhost:3000通过运行启动服务,并使用playwright MCP访问,以验证项目模板是否正常工作。
bin/rails serverhttp://localhost:3000