Initialize Rails coding conventions for a project by detecting dependencies and copying matching rules with examples to .claude/rules/hustler-rails/. Use when setting up Rails conventions for a new project or updating existing rules. Trigger with phrases like "initialize rails rules", "setup rails conventions", "init hustler-rails".
This skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/rules/README.mdassets/rules/architecture/conventions.mdassets/rules/architecture/topics/complexity-signals.mdassets/rules/authorization/topics/pundit/pundit-controllers.mdassets/rules/authorization/topics/pundit/pundit-policies.mdassets/rules/authorization/topics/pundit/pundit-views.mdassets/rules/business-logic/conventions.mdassets/rules/code-style/conventions.mdassets/rules/controllers/conventions.mdassets/rules/database/conventions.mdassets/rules/database/topics/sql-objects.mdassets/rules/database/topics/sqlite/fts5-search.mdassets/rules/database/topics/sqlite/multi-db.mdassets/rules/jobs/conventions.mdassets/rules/locales/conventions.mdassets/rules/locales/topics/simple_form/simple-form-i18n.mdassets/rules/models/conventions.mdassets/rules/models/topics/associations.mdassets/rules/models/topics/concerns.mdassets/rules/models/topics/data-patterns.mdYou are the init-rules skill for the hustler-rails plugin. When invoked, copy Rails coding conventions from the plugin to the user's project, filtering by detected dependencies.
Build comprehensive dependency list:
# Gems from Gemfile.lock
grep "^ " Gemfile.lock 2>/dev/null | awk '{print $1}' | sort
# Database adapter
grep "adapter:" config/database.yml 2>/dev/null | head -1 | awk '{print $2}'
# JS/UI from importmap
grep 'pin "' config/importmap.rb 2>/dev/null | awk -F'"' '{print $2}'
# JS/UI from CDN links in views
grep -rh "cdn\|unpkg\|jsdelivr" app/views/ 2>/dev/null | grep -oE "(beercss|tailwind|bootstrap|alpinejs|htmx)" | sort -u
# JS/UI from vendor assets
find vendor/javascript vendor/assets app/assets -type f 2>/dev/null | grep -oE "(beercss|turbo|stimulus|tailwind|bootstrap)" | sort -u
# JS/UI from package.json
grep -E '"(dependencies|devDependencies)"' package.json 2>/dev/null | grep -oE "(beercss|turbo|stimulus)" | sort -u
Normalize detected dependencies to lowercase. Build a single master list of all detected dependencies.
Check if .claude/rules/hustler-rails/ exists and has files.
If existing rules found, use AskUserQuestion tool:
{
"questions": [
{
"question": "hustler-rails rules already exist. How should I proceed?",
"header": "Existing rules",
"multiSelect": false,
"options": [
{
"label": "Backup and recreate",
"description": "Renames existing to .backup-[timestamp]"
},
{
"label": "Merge new files",
"description": "Keep existing, add new only"
},
{ "label": "Cancel", "description": "Exit without changes" }
]
}
]
}
Handle response:
mv .claude/rules/hustler-rails .claude/rules/hustler-rails.backup-$(date +%Y%m%d-%H%M%S)Get list of all rule markdown files:
find {baseDir}/assets/rules -name "*.md" -type f | grep -v README.md
For each rule file found:
dependencies: [...] and examples: [...] arraysdependencies: [] (empty) → Rule is universal, COPYmkdir -p "$(dirname .claude/rules/hustler-rails/[relative-path])"
cp [source-path] .claude/rules/hustler-rails/[relative-path]
examples: [...]:
mkdir -p .claude/rules/hustler-rails/views/examples
cp -r {baseDir}/assets/rules/views/examples/[name] .claude/rules/hustler-rails/views/examples/
Dependency matching notes:
sqlite or sqlite3 → matches sqlite3 adapterpg or postgresql → matches postgresql adaptermysql or mysql2 → matches mysql2 adapterTrack:
Report detailed summary:
✅ hustler-rails rules initialized
📊 Results:
Rules: [X] copied, [Y] skipped
Examples: [Z] directories copied
📍 Destination: .claude/rules/hustler-rails/
Matched dependencies:
- pundit (Gemfile.lock)
- beercss (CDN in app/views/layouts/application.html.erb)
- sqlite3 (database.yml)
Skipped rules (missing dependencies):
- views/topics/tailwind/tailwind-components.md (requires: tailwind)
- authorization/topics/cancancan/cancancan-abilities.md (requires: cancancan)
List each copied example with the rule that referenced it.