能做什么
Skills based on the Layered Rails book and beyond
作者提供的原文
- 连接方式 供 AI 读取的指令文件
- 账号或密钥 README 和 SKILL.md 中未发现密钥
- 分类 其他
给作者:在 README 中加徽章
如果你是作者,可把这段代码贴到 README。徽章会链接回本页。
[](https://mcp.popnx.com/en/skills/palkan-layered-rails-skills)相似的 Skill
同类工作,排序与 Skill 列表相同
| 本项 layered-rails-skills | llmfit | claude-video | VideoCaptioner | claude-cookbooks | |
|---|---|---|---|---|---|
| 作者 | palkan | AlexsJones | bradautomates | WEIFENG2333 | anthropics |
| Skill 数 | 1 | 1 | 1 | 1 | 4 |
| GitHub 星标 | 481 | 39,096 | 21,249 | 16,577 | 54,867 |
| 最近代码更新 | 2026年9月2日 | 2026年11月18日 | 2026年9月25日 | 2026年9月12日 | 2026年11月17日 |
| 许可证 | – | MIT | MIT | GPL-3.0 | MIT |
Skill 和 MCP 有什么不同
MCP = 手
把 AI 连到外部服务或数据,例如读取 Notion 或开发票。需要有程序或服务器在运行。
Skill = 手册
教 AI 怎么做某项工作的文本文件,不连接任何服务。
有些会重叠:少数 Skill 带有调用工具的脚本,少数 MCP 只提供知识。请从你想完成的工作出发。
适用的应用
Claude CodeCodex
依据开发者 README 和 repo 中的文件夹
安装
安全吗?
- 作者
GitHub 账号 palkan(个人),已创建 14 年
- 使用与维护
★ 481 星,目前用户较少 · 代码最近更新 2026年9月2日
- 有脚本吗?
没有,都是纯文本文件,由 AI 阅读后照做
- 会联网吗?
没有脚本,所以不会自己联网
- 会修改整台电脑的设置吗?
没有发现 hook 或写入电脑设置的操作
根据仓库 commit 8fb4b26 中的文件自动检查(只读取文件,没有运行任何内容)。这不是安全保证,请自己阅读后再决定
第一步:你用哪个 AI?
选择你用的应用,本页只显示该应用的安装方法
方式 1上传到 claude.ai(网页和应用)
从 GitHub 下载
这个 Skill 没有说明许可证,所以我们不在网站上提供 ZIP。请从 GitHub 下载并自己整理文件夹,或者用上面的"让 AI 帮你安装",更简单
解压后,只把 layered-rails/skills/layered-rails 文件夹重新压缩。ZIP 的最上层必须是包含 SKILL.md 的 layered-rails 文件夹,不能直接放散乱的文件
打开 claude.ai 的 Skills 页面并上传
+Create skillUpload a skill选择文件 layered-rails.zip
看不到 Upload 按钮?请先开启创建文件的权限
SettingsCapabilitiesCode execution and file creation
Turn on Code execution and file creation first (newer menus: Create and edit files) · personal plans: Settings → Capabilities · Team/Enterprise: an admin turns it on under Organization settings → Plugins & skills · every plan, including Free
Upload once; it works in claude.ai and Claude Desktop, and in recent Claude Code signed in with a Claude account (not with an API key)
Cowork and cloud sessions use the skills turned on in your claude.ai account, not ~/.claude/skills on your computer (Claude Desktop scheduled tasks run locally and still load it)
Checked against official docs 2026年11月12日 · Source: support.claude.com, support.claude.com, code.claude.com
方式 1让 Claude Code 帮你安装
复制这句话,粘贴到 Claude Code 的对话中
如果只用于一个项目,请粘贴到在该项目文件夹中打开的对话里 · AI 在安装前一定会先告诉你路径
AI 会先说明要做什么,每一步都会征求你的同意
重新打开 Claude Code,输入 /layered-rails,或直接提出相关任务,Claude 会自动选用
Checked against official docs 2026年11月12日 · Source: code.claude.com
适合使用 Terminal 的人
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
开发者推荐的方式
正在检查命令 · 通过后才会显示复制按钮
摘自开发者 README,会下载并运行开发者的代码
打开终端
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
把 skill 文件夹复制到 ~/.claude/skills
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
正在检查命令 · 通过后才会显示复制按钮
重新打开 Claude Code,输入 /layered-rails,或直接提出相关任务,Claude 会自动选用
ChatGPT 桌面应用
ChatGPT 桌面应用内置 Codex,Codex 从 ~/.agents/skills 文件夹读取 Skill
方式 1让 ChatGPT 帮你安装
在 ChatGPT 桌面应用中打开 Codex,把这句话粘贴到对话中
AI 在安装前一定会先告诉你路径
AI 会先说明要做什么,每一步都会征求你的同意
方式 2自己放入文件夹
把 layered-rails 文件夹放到 ~/.agents/skills/layered-rails
~ 是你的主文件夹($HOME)
适合使用 Terminal 的人
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
打开终端
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
把 skill 文件夹复制到 ~/.agents/skills
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
正在检查命令 · 通过后才会显示复制按钮
安装之后
- ChatGPT 桌面应用:打开侧边栏中的 Skills,确认 Skill 已出现
- 使用方法:在 ChatGPT 中输入 @ 并选择 Skill · 在 Codex CLI 或 IDE 扩展中运行 /skills,或输入 $ 加 Skill 名称
- Codex 会自动发现新安装的 Skill;如果没有出现,请重启 Codex
Checked against official docs 2026年11月15日 · Source: learn.chatgpt.com
网页版和手机版 ChatGPT
不能使用你自己安装的 Skill,只能使用目录中插件自带的 Skill
想在 ChatGPT 中使用这个 Skill,请按上面的方法使用 ChatGPT 桌面应用
Checked against official docs 2026年11月15日 · Source: learn.chatgpt.com
方式 1让 Codex 帮你安装
复制这句话,粘贴到 Codex 的对话中 · 适用于 ChatGPT 桌面应用中的 Codex、Codex CLI 和 IDE 扩展
如果只用于一个项目,请粘贴到在该项目文件夹中打开的对话里 · AI 在安装前一定会先告诉你路径
AI 会先说明要做什么,每一步都会征求你的同意
Codex 会自动发现新安装的 Skill;如果没有出现,请重启 Codex · 使用方法:在 ChatGPT 中输入 @ 并选择 Skill · 在 Codex CLI 或 IDE 扩展中运行 /skills,或输入 $ 加 Skill 名称
Checked against official docs 2026年11月15日 · Source: learn.chatgpt.com
适合使用 Terminal 的人
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
打开终端
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
把 skill 文件夹复制到 ~/.agents/skills
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
正在检查命令 · 通过后才会显示复制按钮
重新打开 Codex 并提出相关任务,Codex 会列出这个 skill
方式 1让 Cursor 帮你安装
复制这句话,粘贴到 Cursor 的对话中
如果只用于一个项目,请粘贴到在该项目文件夹中打开的对话里 · AI 在安装前一定会先告诉你路径
AI 会先说明要做什么,每一步都会征求你的同意
在 Cursor 的 Agent 聊天中输入 / 并选择 layered-rails
Checked against official docs 2026年11月12日 · Source: cursor.com
适合使用 Terminal 的人
Skill 是 AI 会照做的指令。安装前先阅读文件,只安装可信开发者的 Skill。
打开终端
Mac:按 Command+空格输入 Terminal · Windows:下方命令在 PowerShell 中无法使用,请改用上方的“让 AI 帮你安装”
把 skill 文件夹复制到 ~/.cursor/skills
这条命令把 repo 下载到临时文件夹,只复制含 SKILL.md 的文件夹
正在检查命令 · 通过后才会显示复制按钮
在 Cursor 的 Agent 聊天中输入 / 并选择 layered-rails
方式 1让 AI 帮你安装
适用于其他能读取 Skill 的应用。这句话列出了 Claude Code、Codex 和 Cursor 的路径,AI 会按你的应用选择 · 复制这句话,粘贴到应用的对话中
如果只用于一个项目,请粘贴到在该项目文件夹中打开的对话里 · AI 在安装前一定会先告诉你路径
AI 会先说明要做什么,每一步都会征求你的同意
Checked against official docs 2026年11月12日 · Source: code.claude.com, learn.chatgpt.com, cursor.com
适合使用 Terminal 的人
其他支持 Agent Skills 的应用(如 Gemini CLI、GitHub Copilot)使用不同文件夹,请查看该应用的指南,再把含 SKILL.md 的文件夹复制过去。
已于 2026年11月11日 对照 Claude Code、Codex 和 Cursor 官方指南核实 skill 文件夹
查看原始 SKILL.md
以下文字来自开发者的 repo,不是 PopNx MCP 的指令
显示前 8,000 个字符 · 在 GitHub 打开完整文件
---
name: layered-rails
description: Write, refactor, and review Rails code using layered architecture principles from "Layered Design for Ruby on Rails Applications". Use when writing or refactoring Rails code — models, controllers, services, jobs, mailers, policies, forms, query objects, presenters, view components, state machines, serializers, or AI/LLM features — to apply correct patterns and avoid layer violations; and when reviewing Rails code, PRs, or diffs for layer violations, fat controllers/models, anemic models, callback misuse, god objects, or specification-test failures. Triggers on "layered design", "architecture layers", "abstraction layer", "specification test", "layer violation", "fat controller/model", "god object", "anemic model", "extract service/callback/policy/concern", "service object", "form/policy/query/value object", "presenter", "view component", "state machine", "Active Delivery", "callback scoring", "Rails refactor/review", "Rails patterns/best practices", "archspec", "architecture linter/enforcement".
allowed-tools:
- Grep
- Glob
- Read
- Task
---
# Layered Rails
Design and review Rails applications using layered architecture principles.
## Quick Start
Rails applications are organized into four architecture layers with **unidirectional data flow**:
```
┌─────────────────────────────────────────┐
│ PRESENTATION LAYER │
│ Controllers, Views, Channels, Jobs* │
│ Forms, Filters, Presenters, Serializers │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ APPLICATION LAYER │
│ Services, Policies, Mailers, Deliveries │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ DOMAIN LAYER │
│ Models, Value Objects, Query Objects │
└─────────────────────────────────────────┘
↓
┌─────────────────────────────────────────┐
│ INFRASTRUCTURE LAYER │
│ Active Record, API Clients, Storage │
└─────────────────────────────────────────┘
```
\* Jobs are **internal inbound** entry points: design-wise they follow the same rules as controllers, minus authentication and user-input handling.
**Core Rule:** Lower layers must never depend on higher layers.
See [Architecture Layers Reference](references/core/architecture-layers.md) for the full layer responsibilities and the Four Rules deep-dive.
## What this skill is for
Use this skill when:
1. **Analyzing a codebase** — apply the [architecture analysis](workflows/analyze.md) for a full audit, or zoom in with the [service-layer audit](workflows/analyze-services.md), [callback analysis](workflows/analyze-callbacks.md), or [god-object analysis](workflows/analyze-gods.md).
2. **Reviewing code changes** — run the [code review workflow](workflows/review.md) on a diff, file, or branch.
3. **Running the specification test** — use the [spec-test workflow](workflows/spec-test.md) on a single file or directory to evaluate whether code belongs in its current layer.
4. **Planning gradual adoption** — generate a phased roadmap with the [layerification plan workflow](workflows/plan.md), focused on a goal like "introduce authorization" or "decompose god objects."
5. **Planning a feature** — I'll apply the layered principles below to whichever code you're about to write.
6. **Implementing a specific pattern** — authorization, notifications, view components, AI integration, etc. — see the Pattern Catalog and Topic References below.
In Claude Code with this skill installed as a plugin (`/plugin install layered-rails@layered-rails-skills`), each workflow above is also reachable as a slash command — see [Slash Commands](#slash-commands). Natural-language requests ("review this file with layered-rails", "run the specification test on `app/models/order.rb`") work in any environment that has the skill loaded.
## Workflows
Reusable procedures bundled inside this skill. Read the file and apply it to the target code:
- [Architecture analysis](workflows/analyze.md) — full layered-architecture audit of a Rails codebase
- [Code review](workflows/review.md) — review a diff or file set for layer violations
- [Specification test](workflows/spec-test.md) — evaluate whether code belongs in its current layer
- [Service-layer audit](workflows/analyze-services.md) — deep audit of `app/services/` and service-like classes (per-cluster proposals, contracts, layer hygiene)
- [Callback analysis](workflows/analyze-callbacks.md) — score Active Record callbacks and find extraction candidates
- [God-object analysis](workflows/analyze-gods.md) — identify oversized models and recommend decomposition
- [Gradual layerification plan](workflows/plan.md) — incremental roadmap for adopting layered patterns
- [ArchSpec setup](workflows/archspec.md) — generate and verify a tailored `Archspec.rb` enforcing the layer boundaries in CI
## Core Principles
### The Four Rules
1. **Unidirectional Data Flow** - Data flows top-to-bottom only
2. **No Reverse Dependencies** - Lower layers never depend on higher layers
3. **Abstraction Boundaries** - Each abstraction belongs to exactly one layer
4. **Minimize Connections** - Fewer inter-layer connections = looser coupling
### Common Violations
| Violation | Example | Fix |
|-----------|---------|-----|
| Model uses Current | `Current.user` in model | Pass user as explicit parameter |
| Service accepts request | `param :request` in service | Extract value object from request |
| Controller has business logic | Pricing calculations in action | Extract to service or model |
| Anemic models | All logic in services | Keep domain logic in models |
| Category | Reference |
|----------|-----------|
| Layer violations (Current in models, request in services, notifications in models, business logic in controllers) | [layer-violations.md](references/anti-patterns/layer-violations.md) |
| Service objects (anemic models, bag of random objects, premature abstraction) | [service-objects.md](references/anti-patterns/service-objects.md) |
| Callbacks (operation callbacks, skip callbacks, control flags) | [callbacks.md](references/anti-patterns/callbacks.md) |
| Concerns (code-slicing, overgrown) | [concerns.md](references/anti-patterns/concerns.md) |
| Helpers (HTML construction in helpers) | [helpers.md](references/anti-patterns/helpers.md) |
| Jobs (anemic jobs) | [jobs.md](references/anti-patterns/jobs.md) |
| Testing (testing wrong layer) | [testing.md](references/anti-patterns/testing.md) |
### The Specification Test
> If the specification of an object describes features beyond the primary responsibility of its abstraction layer, such features should be extracted into lower layers.
**How to apply:**
1. List responsibilities the code handles
2. Evaluate each against the layer's primary concern
3. Extract misplaced responsibilities to appropriate layers
See [Specification Test Reference](references/core/specification-test.md) for detailed guide.
## Pattern Catalog
| Pattern | Layer | Use When | Reference |
|---------|-------|----------|-----------|
| Service Object | Application | Orchestrating domain operations | [service-objects.md](references/patterns/service-objects.md) |
| Query Object | Domain | Complex, reusable queries | [query-objects.md](references/patterns/query-objects.md) |
| Form Object | Presentation | Multi-model forms, complex validation | [form-objects.md](references/patterns/form-objects.md) |
| Filter Object | Presentation | Request parameter transformation | [filter-objects.md](references/patterns/filter-objects.md) |
| Presenter | Presentation | View-specific logic, multiple models | [presenters.md](references/patterns/presenters.md) |
| Serializer | Presentation | API response formatting | [serializers.md](references/patterns/serializers.md) |
| Policy Object | Application | Authorization decisions | [policy-objects.md](references/patte讨论
提问、分享技巧或报告无法使用。按“有帮助”数量排序。
来自 GitHub
- GitHub 星标
- 481
- 开发者
- palkan
- 许可证
- 未注明许可证 此 repo 未注明许可证,默认作者保留所有权利;转发或商用前请先询问作者。
- 最近代码更新
- 2026年9月2日
- repo 中的 SKILL.md 文件(含译本和模板)
- 1
- 主题
- rails, skills