Jr Rails Phlex logo

Jr Rails Phlex

Community
julianrubisch
jr-rails-phlex

Write Phlex views and components for Rails: class hierarchy, slots, helpers, custom elements, scaffold generator. Use when building UI with phlex-rails.

Overview

Publisherjulianrubisch
Repositoryskills
Skill namejr-rails-phlex
Stars
30
Forks
2
Bundled files
39
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 39 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by julianrubisch on GitHub. Read the source before you install it.

Installation

Install the Jr Rails Phlex AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/julianrubisch/skills/tree/main/jr-rails-phlex
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/julianrubisch/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/jr-rails-phlex .claude/skills/jr-rails-phlex
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Jr Rails Phlex in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Jr Rails Phlex on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Jr Rails Phlex is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Phlex Views & Components

Components are Ruby objects — no template language, no DSL. Views replace ERB templates (one per controller action). Components are reusable UI building blocks.

Core Workflow

  1. Use the scaffold generator — custom PhlexControllerGenerator produces Phlex views instead of ERB. See reference/coding-phlex.md § Scaffolding for the full generator code and all 5 templates.
  2. Implementation order — models → controllers → views/components → tests.
  3. Forms default to ERB partials — Rails form builders are ergonomic there. Phlex form helpers exist for simple cases.

Class Hierarchy

Components::Base < Phlex::HTML   (include Components, route helpers, dev comments)
  ├── Views::Base                (+ Debug, ContentFor, caching)
  ├── Components::Layout         (+ Phlex::Rails::Layout)
  └── Components::PageHeader, TitleBar, List, GridCell, ...
ruby
# app/components/base.rb
class Components::Base < Phlex::HTML
  include Components
  include Phlex::Rails::Helpers::Routes

  if Rails.env.development?
    def before_template
      comment { "Before #{self.class.name}" }
      super
    end
  end
end

# app/views/base.rb
class Views::Base < Components::Base
  include Phlex::Rails::Helpers::Debug

  def cache_store = Rails.cache
end

Short-form Component Calls

include Components on the base class enables method-style rendering:

ruby
# Instead of:
render Components::PageHeader.new(title: "Labels")

# Write:
PageHeader(title: "Labels")

Component Slots via Methods

Public methods on components yield named content areas:

ruby
class Components::TitleBar < Components::Base
  def view_template(&) = div(class: "title-bar", &)
  def leading_action(&) = div(class: "leading-action", &)
  def title(&) = h1(&)
  def actions(&) = div(class: "actions", &)
end

# Usage:
render Components::TitleBar.new do |bar|
  bar.leading_action { link_to("Back", labels_path) }
  bar.title { "My Page" }
  bar.actions { button_to("Delete", @label, method: :delete) }
end

Helper Includes

Include only the Phlex::Rails::Helpers::* each view needs — never on Base:

ruby
class Views::Labels::Show < Views::Base
  include Phlex::Rails::Helpers::ContentFor
  include Phlex::Rails::Helpers::DOMID
  include Phlex::Rails::Helpers::ButtonTo
  include Phlex::Rails::Helpers::LinkTo
  include Phlex::Rails::Helpers::TurboFrameTag
  # ...
end

Common helpers: Routes, ContentFor, DOMID, ButtonTo, LinkTo, TurboFrameTag, TurboStreamFrom, ImageTag, ClassNames, Request, Notice, Debug, Sanitize, StripTags.

Content Areas

Layout yields named areas; views populate via content_for:

ruby
content_for :title, "Labels"

content_for :main_header do
  render Components::PageHeader.new do |header|
    header.title_bar { |bar| bar.title { "Labels" } }
  end
end

content_for :floating_action do
  render Components::FloatingActionMenu.new
end

Standard areas: :title, :main_header, :floating_action, :head.

Controller Rendering

Controllers render Phlex views directly, passing data via new:

ruby
class LabelsController < ApplicationController
  def index
    @pagy, @labels = pagy(Label.all)
    render Views::Labels::Index.new(@labels, @pagy)
  end

  def show
    render Views::Labels::Show.new(@label)
  end

  def create
    @label = Label.new(label_params)
    if @label.save
      redirect_to @label, notice: "Label was successfully created."
    else
      render Views::Labels::New.new(@label), status: :unprocessable_entity
    end
  end
end

Custom Element Wrappers

Use register_element for web component custom elements (Web Awesome, Shoelace, etc.):

ruby
module Components::MyLibrary
  class MyButton < Phlex::HTML
    register_element :my_button  # renders <my-button>

    def initialize(variant: "neutral", size: "medium", **attributes)
      @attributes = attributes.with_defaults(variant: variant, size: size)
    end

    def view_template(&) = my_button(**@attributes, &)
  end
end

Use phlex_custom_element_generator to auto-generate wrappers from custom element manifests.

Register Helpers

For Rails helpers that output HTML or return values:

ruby
register_output_helper :vite_client_tag       # returns HTML
register_output_helper :vite_javascript_tag
register_output_helper :column_chart          # chartkick
register_value_helper :alert                  # returns a value

ERB Partials for Forms

Phlex views render ERB form partials seamlessly:

ruby
# In a Phlex view:
section { render partial("form", label: @label) }

# The ERB partial uses standard form_with / form_for

Fragment Caching

ruby
def view_template
  cache("labels/#{@label.id}/card") {
    # expensive rendering
  }
end

Multiple Layouts

ruby
class Components::Layout < Components::Base
  include Phlex::Rails::Layout
  # app shell
end

class Components::MarketingLayout < Components::Base
  include Phlex::Rails::Layout
  # landing pages
end

Set in controllers: layout -> { Components::Layout }

Frontend Integration

Stimulus

ruby
div(data: {
  controller: "faceted-search",
  action: "input->faceted-search#perform:prevent",
  faceted_search_url_value: labels_path
}) { ... }

Turbo Frames (Lazy Loading)

ruby
turbo_frame_tag(album, src: album_path(album), loading: :lazy) {
  render Components::Spinner.new
}

Turbo Streams & Morphing

ruby
turbo_stream_from([@budget, :items])

# In layout <head>:
meta name: "turbo-refresh-method", content: "morph"
meta name: "turbo-refresh-scroll", content: "preserve"

Pagy

ruby
class Views::Labels::Index < Views::Base
  include Pagy::Frontend

  def initialize(labels, pagy)
    @labels = labels
    @pagy = pagy
  end

  def view_template
    # ... render labels ...
    raw safe(pagy_nav(@pagy))
  end
end

Heuristics

  • Component vs View: reusable UI = component; page-level (one per action) = view
  • When to use ERB: forms with Rails form builder, complex form logic
  • Naming: Components::PageHeader, Views::Labels::Index
  • One view per controller action; views receive data via initialize
  • Composition over inheritance — slot methods, not deep class hierarchies
  • Data flow: controller → view (initialize) → components (render)

Anti-patterns

  • God components — split into smaller, focused components
  • Business logic in views/components — belongs in models
  • Over-including helpers on Base — include per-view
  • Reimplementing form builders — use ERB partials for forms
  • Passing request context into components — components receive data, not request objects

Preferred Stack

ConcernChoice
Componentsphlex-rails 2.x
Bundlingvite_rails / importmap / esbuild
PaginationPagy
Custom elementslibrary of choice + phlex_custom_element_generator
ScaffoldingCustom PhlexControllerGenerator
Frontendturbo-rails + stimulus-rails
Feature flagsFlipper (inline: if Flipper.enabled?(:feature))

Deep Reference Files

Read these on demand when the task requires deeper guidance:

For frontend patterns (Stimulus controllers, Turbo Frames/Streams), invoke the relevant hwc-* skill alongside this one.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Jr Rails Phlex AI skill do?

Write Phlex views and components for Rails: class hierarchy, slots, helpers, custom elements, scaffold generator. Use when building UI with phlex-rails.

Why use Jr Rails Phlex on TypingMind?

Because you install it once and use it with any model. Jr Rails Phlex is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Jr Rails Phlex in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/julianrubisch/skills/tree/main/jr-rails-phlex. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Jr Rails Phlex?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Jr Rails Phlex?

As many as you like. As long as a model supports skills, you can use Jr Rails Phlex with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Jr Rails Phlex AI skill free?

Yes. It is published on GitHub by julianrubisch under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇