Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

rails-conventionsRails conventions 搜索

Agent Skill

rails-conventions 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

808

周安装

33

GitHub Stars

37

下载量

259
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:rails-conventions(Rails conventions 搜索)
来源仓库:https://github.com/majesticlabs-dev/majestic-marketplace
仓库路径:skills/rails-conventions
安装命令:
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill rails-conventions
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill rails-conventions

简介

用于查找 Rails 开发约定与编码风格的权威指引与实例。

  • 适合在团队标准化或代码迁移时统一命名、结构与组织方式。
  • 通过 GitHub 安装,可结合社区主流项目筛选推荐做法。
  • 应尊重既有项目习惯,渐进式引入新规范而非强制替换。rails-conventions 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 建议制定内部编码指南,并辅以自动化 lint 工具落地。

SKILL.md

Rails Conventions

Opinionated Rails patterns for clean, maintainable code.

Core Philosophy

  1. Duplication > Complexity: Simple duplicated code beats complex DRY abstractions

- "I'd rather have four simple controllers than three complex ones"

  1. Testability = Quality: If it's hard to test, structure needs refactoring
  2. Adding controllers is never bad. Making controllers complex IS bad.

Turbo Streams

Simple turbo streams MUST be inline in controllers:

# FAIL: Separate .turbo_stream.erb files for simple operations
render "posts/update"

# PASS: Inline array
render turbo_stream: [
  turbo_stream.replace("post_#{@post.id}", partial: "posts/post", locals: { post: @post }),
  turbo_stream.remove("flash")
]

Controller & Concerns

Business logic belongs in models or concerns, not controllers.

# Concern structure
module Dispatchable
  extend ActiveSupport::Concern

  included do
    scope :available, -> { where(status: "pending") }
  end

  class_methods do
    def claim!(batch_size)
      # class-level behavior
    end
  end
end

Service Extraction

Extract when you see MULTIPLE of:

  • Complex business rules (not just "it's long")
  • Multiple models orchestrated
  • External API interactions
  • Reusable cross-controller logic

Service structure:

  • Single public method
  • Namespace by responsibility (Extraction::RegexExtractor)
  • Constructor takes dependencies
  • Return data structures, not domain objects

Modern Ruby Style

# Hash shorthand
{ id:, slug:, doc_type: kind }

# Safe navigation
created_at&.iso8601
@setting ||= SlugSetting.active.find_by!(slug:)

# Keyword arguments
def extract(document_type:, subject:, filename:)
def process!(strategy: nil)

Enum Patterns

# Frozen arrays with validation
STATUSES = %w[processed needs_review].freeze
enum :status, STATUSES.index_by(&:itself), validate: true

Scope Patterns

# Guard with .present?, chainable design
scope :by_slug, ->(slug) { where(slug:) if slug.present? }
scope :from_date, ->(date) { where(created_at: Date.parse(date).beginning_of_day..) if date.present? }

def self.filtered(params)
  all.by_slug(params[:slug]).by_kind(params[:kind])
rescue ArgumentError
  all
end

Error Handling

# Domain-specific errors
class InactiveSlug < StandardError; end

# Log with context, re-raise for upstream
def handle_exception!(error:)
  log_error("Exception #{error.class}: #{error.message}", error:)
  mark_failed!(error.message)
  raise
end

Testing (Minitest + Fixtures)

test "describes expected behavior" do
  email = emails(:two)
  email.process
  email.reload
  assert_equal "finished", email.processing_status
end

Principles:

  • Behavior-driven: Test what, not how
  • Fixture-based: Use emails(:two) for setup
  • Mock externals: Stub S3, APIs, PDFs
  • State verification: .reload after operations
  • Helper methods: build_valid_email, with_stubbed_download

Naming (5-Second Rule)

If you can't understand in 5 seconds:

# FAIL
show_in_frame
process_stuff

# PASS
fact_check_modal
_fact_frame

JavaScript & Importmap

Rails 7+ uses importmap for JS dependency management. Scope dependencies to the narrowest entrypoint.

Multiple Entrypoints

# config/importmap.rb
pin "application"                    # Public entrypoint
pin "@hotwired/turbo-rails", to: "turbo.min.js"
pin "@hotwired/stimulus", to: "stimulus.min.js"

# Admin-only dependencies - pinned but only imported in admin entrypoint
pin "chartkick", to: "chartkick.js"
pin "Chart.bundle", to: "Chart.bundle.js"
// app/javascript/application.js — public pages only
import "@hotwired/turbo-rails"
import "@hotwired/stimulus"
import "controllers"

// app/javascript/admin.js — imports public base + admin-only libs
import "application"
import "chartkick"
import "Chart.bundle"
<%# Admin layout %>
<%= javascript_importmap_tags("admin") %>

<%# All other layouts %>
<%= javascript_importmap_tags %>

Adding New JS Dependencies

  1. Determine scope: public-facing or admin-only?
  2. Pin in config/importmap.rb
  3. Import in the correct entrypoint
  4. Never add admin-only libraries to application.js

Performance

  • Consider scale impact
  • No premature caching
  • KISS - Keep It Simple
  • Indexes slow writes - add only when needed

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.44%
按下载量换算100

Claude

28.66%
按下载量换算74

Cursor

17.76%
按下载量换算46

Gemini CLI

9.21%
按下载量换算24

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills