Skip to content

Commit 1b1f6f5

Browse files
committed
Make rails-docs and tailwind-docs derive version dynamically
Hardcoded version claims (Rails 8.0, Tailwind v3) go stale the moment the project upgrades and nothing flags it. Both skills now instruct Claude to check Gemfile.lock / repo structure at query time instead, so they stay correct across future version bumps without edits.
1 parent 21a6818 commit 1b1f6f5

2 files changed

Lines changed: 63 additions & 29 deletions

File tree

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

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
---
22
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.
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 a given Rails version. 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.
44
---
55

66
# Rails official documentation lookup
77

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.
8+
Trained knowledge about Rails APIs can be outdated, mixed across versions, or simply wrong on
9+
specifics (option names, defaults, deprecations, callback ordering, etc.). Before answering a
10+
Rails-specific question or relying on a Rails API's exact behavior, check the official docs
11+
rather than guessing — pinned to the version this project actually runs, not whatever version
12+
training data assumed.
13+
14+
## Determine the version first
15+
16+
Don't assume the Rails version from memory or from prose in `CLAUDE.md` — that can go stale the
17+
moment someone bumps the gem without updating the docs. Check the source of truth instead:
18+
19+
```bash
20+
grep -m1 '^ rails (' Gemfile.lock
21+
```
22+
23+
That gives you the exact installed version (e.g. `rails (8.0.2.1)`). Use its `<major>.<minor>`
24+
for the pinned doc URLs below.
1225

1326
## Sources
1427

1528
- **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.
29+
- Version-pinned: `https://guides.rubyonrails.org/v<major>.<minor>/<guide-name>.html`
1830
- **API reference** (exact method signatures, options, source): https://api.rubyonrails.org
19-
- Version-pinned API docs: `https://api.rubyonrails.org/v8.0/`
31+
- Version-pinned: `https://api.rubyonrails.org/v<major>.<minor>/`
32+
33+
If a pinned URL 404s (e.g. docs for a brand-new version aren't published at that path yet), fall
34+
back to the unpinned root and flag to the user that you're reading possibly-newer docs than the
35+
installed version.
2036

2137
## When to look things up
2238

2339
Use `WebFetch` against the sources above when:
2440
- The question is about a specific Rails API's options, defaults, or behavior (e.g. "does
2541
`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).
42+
- You're unsure whether something changed between Rails versions (deprecated, renamed, new
43+
behavior in the installed version).
2744
- You're about to write code that depends on exact method signatures, callback ordering, or
2845
routing/DSL syntax you're not fully certain of.
2946
- The user asks a "how do I do X in Rails" question that isn't already answered by this project's
@@ -35,11 +52,12 @@ very basic Ruby/Rails knowledge you're confident hasn't changed across versions.
3552

3653
## How to look things up
3754

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
55+
1. Determine the installed Rails version from `Gemfile.lock` (see above).
56+
2. Identify the right guide or API page (e.g. Active Record Associations, Action Mailer Basics).
57+
3. Fetch it with `WebFetch`, using the version-pinned URL.
58+
4. If the guide doesn't have the exact method signature, cross-check `api.rubyonrails.org` for the
4159
precise method/class documentation.
42-
4. Prefer the official source over Stack Overflow, blog posts, or other secondary sources when they
60+
5. Prefer the official source over Stack Overflow, blog posts, or other secondary sources when they
4361
conflict.
4462

4563
## Applying this project's conventions
Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,53 @@
11
---
22
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`).
3+
description: Use when asked about Tailwind CSS — utility classes, responsive/state variants, config/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 changed substantially between Tailwind v3 and v4 — check which one this project is actually on before trusting either.
44
---
55

66
# Tailwind CSS documentation lookup
77

88
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.
9+
`tailwindcss-rails` gem. Tailwind v3 and v4 differ substantially — v3 uses a JS config file
10+
(`tailwind.config.js`, `module.exports = { theme: {...} }`), v4 uses CSS-first config
11+
(`@import "tailwindcss"` + `@theme` blocks in the stylesheet, often no JS config file at all) and
12+
renamed/changed a number of utilities. Trained knowledge can silently mix the two, so confirm
13+
which version this project is on before trusting either.
14+
15+
## Determine the version first
16+
17+
Check the repo structure rather than assuming:
18+
19+
```bash
20+
ls config/tailwind.config.js 2>/dev/null # present + module.exports = v3-style config
21+
grep -rn '@theme' app/assets/stylesheets/ 2>/dev/null # present = v4-style CSS config
22+
grep -m1 'tailwindcss-rails (' Gemfile.lock
23+
```
24+
25+
A present `config/tailwind.config.js` using `module.exports` (no `@theme` blocks in the CSS)
26+
means this project is on Tailwind v3. If that ever flips — `tailwind.config.js` disappears and
27+
`@theme` shows up in the stylesheet instead — the project has moved to v4, and this skill's
28+
default assumption below no longer holds.
1329

1430
## Sources
1531

1632
- **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/...`).
33+
- The current site defaults to the latest major version's docs, which won't match a v3 project.
34+
- If you determined this project is still on v3, prefer the v3-pinned docs at
35+
`https://v3.tailwindcss.com/docs/...` instead of the default (v4-or-later) docs site.
36+
- If a page's syntax looks like v4 (CSS `@import "tailwindcss"` / `@theme` blocks, no
37+
`tailwind.config.js` in examples) but the project is on v3, that's a mismatch — look for the
38+
v3-equivalent page instead.
2339

2440
## When to look things up
2541

2642
Use `WebFetch` when:
2743
- You need the exact utility class name/values for something (spacing scale, color palette,
2844
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).
45+
- You're customizing the theme/config and need the config shape for the version this project
46+
actually uses (JS config for v3, CSS `@theme` for v4).
47+
- You're unsure whether a utility/variant exists in the installed major version (some utilities
48+
and variants only exist in v4, or were renamed from their v3 equivalents).
3349

3450
Skip the lookup for basic, version-stable utilities you're confident about (e.g. `flex`,
3551
`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
52+
follow — check `app/views/` and the project's Tailwind config for this project's own conventions
3753
first.

0 commit comments

Comments
 (0)