Skip to content

Commit 21a6818

Browse files
authored
Add Rails official documentation skill (#746)
Start using Claude skills with this project by referencing online coding guides.
1 parent 613f497 commit 21a6818

3 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: hotwire-docs
3+
description: Use when asked about Turbo (Turbo Drive, Turbo Frames, Turbo Streams, ActionCable-broadcasted streams) or Stimulus (controllers, targets, actions, values, outlets) — including "how do I do X with Turbo/Stimulus", debugging a Turbo Stream broadcast, or wiring up a Stimulus controller. Always consult the official Hotwire docs rather than answering from memory alone, since Turbo/Stimulus APIs and idioms have shifted across versions and this project has no SPA framework — all interactivity goes through Hotwire.
4+
---
5+
6+
# Hotwire (Turbo + Stimulus) documentation lookup
7+
8+
This project (HostedGPT) uses Hotwire (Turbo + Stimulus) for all frontend interactivity — no SPA
9+
framework. Streaming chat updates arrive via Turbo Stream broadcasts over ActionCable, rendered
10+
from server-side partials (see `app/views/messages/_message.html.erb` and `CLAUDE.md`). Trained
11+
knowledge about Turbo/Stimulus can be stale or blend behavior across versions — check the official
12+
docs before relying on specifics.
13+
14+
## Sources
15+
16+
- **Turbo Handbook & reference**: https://turbo.hotwired.dev
17+
- Overview: https://turbo.hotwired.dev/handbook/introduction
18+
- Drive: https://turbo.hotwired.dev/handbook/drive
19+
- Frames: https://turbo.hotwired.dev/handbook/frames
20+
- Streams: https://turbo.hotwired.dev/handbook/streams
21+
- Reference (attributes, actions, events): https://turbo.hotwired.dev/reference/attributes
22+
- **Stimulus Handbook & reference**: https://stimulus.hotwired.dev
23+
- Overview: https://stimulus.hotwired.dev/handbook/introduction
24+
- Controllers/targets/actions/values/outlets: https://stimulus.hotwired.dev/handbook/hello-stimulus
25+
- Reference: https://stimulus.hotwired.dev/reference/controllers
26+
27+
## When to look things up
28+
29+
Use `WebFetch` against the sources above when:
30+
- You need the exact Turbo Stream action list/syntax (`append`, `prepend`, `replace`, `update`,
31+
`remove`, `before`, `after`, `refresh`) or how targeting (`target=`/`targets=`) works.
32+
- You're unsure how Turbo Frame lazy-loading, `data-turbo-*` attributes, or navigation
33+
interception behaves.
34+
- You're writing or debugging a Stimulus controller and need exact lifecycle callback names,
35+
target/value/outlet declaration syntax, or action descriptor syntax (`event->controller#method`).
36+
- The user asks "how do I do X with Turbo/Stimulus" and it's not already answered by this
37+
project's own patterns in `CLAUDE.md`.
38+
39+
Skip the lookup for questions answered faster by reading this codebase directly — e.g. how this
40+
app's own streaming job builds and broadcasts updates is answered by
41+
`app/services/ai_backend/`, `GetNextAIMessageJob`, and the `_message.html.erb` partials, not the
42+
Hotwire docs.
43+
44+
## Applying this project's conventions
45+
46+
The Hotwire docs describe the general framework; this project's own streaming architecture (see
47+
`CLAUDE.md`'s "Message generation flow") governs how it's actually used here — e.g. partial
48+
updates are broadcast roughly every 100ms during streaming and only persisted once the stream
49+
finishes. Confirm Turbo/Stimulus behavior against the docs, but follow this repo's existing
50+
patterns for where controllers and broadcasts live.

.claude/skills/rails-docs/SKILL.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: rails-docs
3+
description: Use when asked about any Rails-specific topic — ActiveRecord, routing, controllers, views, mailers, jobs, Action Cable, Action Text, Active Storage, migrations, validations, callbacks, associations, caching, security, or Rails internals — including "how do I do X in Rails", debugging Rails behavior, or checking whether an API/option still exists or changed in Rails 8. Always consult the official guides and API docs rather than answering from memory alone, since trained knowledge can be stale or wrong about version-specific details, and this project pins Rails 8.0.
4+
---
5+
6+
# Rails official documentation lookup
7+
8+
This project (HostedGPT) runs Rails 8.0, per the project's `CLAUDE.md`. Trained knowledge about
9+
Rails APIs can be outdated, mixed across versions, or simply wrong on specifics (option names,
10+
defaults, deprecations, callback ordering, etc.). Before answering a Rails-specific question or
11+
relying on a Rails API's exact behavior, check the official docs rather than guessing.
12+
13+
## Sources
14+
15+
- **Guides** (concepts, how-tos, conventions): https://guides.rubyonrails.org
16+
- Version-pinned guides are available at `https://guides.rubyonrails.org/v8.0/<guide-name>.html`
17+
if you need to confirm you're reading the Rails 8.0 version rather than edge/main.
18+
- **API reference** (exact method signatures, options, source): https://api.rubyonrails.org
19+
- Version-pinned API docs: `https://api.rubyonrails.org/v8.0/`
20+
21+
## When to look things up
22+
23+
Use `WebFetch` against the sources above when:
24+
- The question is about a specific Rails API's options, defaults, or behavior (e.g. "does
25+
`has_many` support `:strict_loading`?", "what does `config.active_record.encryption` need?").
26+
- You're unsure whether something changed between Rails versions (deprecated, renamed, new in 8.0).
27+
- You're about to write code that depends on exact method signatures, callback ordering, or
28+
routing/DSL syntax you're not fully certain of.
29+
- The user asks a "how do I do X in Rails" question that isn't already answered by this project's
30+
own conventions in `CLAUDE.md`.
31+
32+
Skip the lookup for things you can verify faster by reading this codebase directly (e.g. "how does
33+
this app handle streaming?" — that's answered by `app/services/ai_backend/`, not the guides), or for
34+
very basic Ruby/Rails knowledge you're confident hasn't changed across versions.
35+
36+
## How to look things up
37+
38+
1. Identify the right guide or API page (e.g. Active Record Associations, Action Mailer Basics).
39+
2. Fetch it with `WebFetch`, preferring the `/v8.0/` pinned URL when version accuracy matters.
40+
3. If the guide doesn't have the exact method signature, cross-check `api.rubyonrails.org` for the
41+
precise method/class documentation.
42+
4. Prefer the official source over Stack Overflow, blog posts, or other secondary sources when they
43+
conflict.
44+
45+
## Applying this project's conventions
46+
47+
Official Rails docs describe what's *possible*; they don't override this project's own patterns.
48+
After confirming Rails behavior, still follow `CLAUDE.md`'s conventions — e.g. provider logic goes
49+
in `app/services/ai_backend/`, soft deletion via `deleted_at` + `not_deleted` scopes, feature flags
50+
via `Feature.<name>?`/`Setting.<name>`, and don't hard-code model lists (`models.yml` instead).
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: tailwind-docs
3+
description: Use when asked about Tailwind CSS — utility classes, responsive/state variants, `tailwind.config.js` theme customization, `@apply`, dark mode, or "how do I style X with Tailwind". Always consult the official Tailwind docs rather than answering from memory alone, since utility class names and config syntax have changed between Tailwind v3 and v4, and this project pins Tailwind v3 (via `tailwindcss-rails` gem, config in `config/tailwind.config.js`).
4+
---
5+
6+
# Tailwind CSS documentation lookup
7+
8+
This project (HostedGPT) styles its Hotwire-rendered views with Tailwind CSS via the
9+
`tailwindcss-rails` gem (`~> 2.7`, see `Gemfile`), which bundles **Tailwind CSS v3** — it still
10+
uses a JS config file at `config/tailwind.config.js`, not Tailwind v4's CSS-first `@theme`
11+
config. This matters because Tailwind v4 renamed/changed a number of utilities and the config
12+
approach entirely, so answers pulled from memory can silently mix v3 and v4 syntax.
13+
14+
## Sources
15+
16+
- **Docs**: https://tailwindcss.com/docs
17+
- The current site defaults to the latest major version's docs. If a page's syntax looks like
18+
v4 (e.g. CSS `@import "tailwindcss"` / `@theme` blocks, no `tailwind.config.js`), that's a
19+
mismatch with this project — look for the v3 equivalent or verify against the
20+
`config/tailwind.config.js` file already in this repo, which follows v3 conventions.
21+
- The docs site also has a version switcher; prefer the v3 docs when available/linked from a
22+
page (URLs are sometimes of the form `https://v3.tailwindcss.com/docs/...`).
23+
24+
## When to look things up
25+
26+
Use `WebFetch` when:
27+
- You need the exact utility class name/values for something (spacing scale, color palette,
28+
arbitrary value syntax) rather than guessing.
29+
- You're customizing `config/tailwind.config.js` (theme extension, plugins, safelist) and need
30+
the v3 config shape.
31+
- You're unsure whether a utility/variant exists in v3 (e.g. some newer utilities and variants
32+
were only added in v4).
33+
34+
Skip the lookup for basic, version-stable utilities you're confident about (e.g. `flex`,
35+
`items-center`, `p-4`), or when the existing codebase already shows the exact class/pattern to
36+
follow — check `app/views/` and `config/tailwind.config.js` for this project's own conventions
37+
first.

0 commit comments

Comments
 (0)