
Bootstrap Registration Toggle
- 1 installs
- 1 repo stars
- Updated May 29, 2026
- agoodway/goodskills
bootstrap-registration-toggle is a Claude Code skill that adds an environment-variable registration toggle to a Phoenix 1.8 phx.gen.auth app.
About
bootstrap-registration-toggle adds the ability to enable or disable user registration via an environment variable in a Phoenix 1.8 app built with phx.gen.auth. It audits the app, adds a runtime.exs boolean_env helper and config entry, a controller plug that redirects when registration is off, conditional rendering of the signup link, and controller tests. A developer uses it to close signups in production while keeping them open in dev.
- Adds an ENV-controlled registration toggle to a Phoenix 1.8 phx.gen.auth app
- Wires runtime config, a controller plug guard, and conditional signup-link UI
- Audits the app first and only adds missing pieces, with test coverage
Bootstrap Registration Toggle by the numbers
- 1 all-time installs (skills.sh)
- Ranked #3,836 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Jul 7, 2026 (Skillselion catalog sync)
bootstrap-registration-toggle capabilities & compatibility
- Capabilities
- feature toggle · auth configuration · test generation
- Use cases
- api development · testing
- Pricing
- Free
What bootstrap-registration-toggle says it does
Add the ability to enable/disable user registration via an environment variable in a Phoenix 1.8 app generated with `phx.gen.auth`.
Add a private plug to the registration controller that checks the config
npx skills add agoodway/GoodSkills --skill bootstrap-registration-toggle -g
npx skills add https://github.com/agoodway/goodskills --skill bootstrap-registration-toggleAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 1 |
| Last updated | May 29, 2026 |
| Repository | agoodway/goodskills ↗ |
What it does
Add an ENV-controlled signup on/off toggle to a Phoenix 1.8 phx.gen.auth app.
Who is it for?
closing signups in prod while keeping them open in dev on a phx.gen.auth Phoenix app
Skip if: apps not using phx.gen.auth or non-Phoenix stacks
When should I use this skill?
the user says toggle/disable/close registrations or wants ENV-controlled signup
What you get
Registration can be toggled via an ENV var, with a redirecting plug guard, conditional signup link, and passing tests.
- runtime.exs config and boolean_env helper
- ensure_registration_enabled plug
- conditional signup link
By the numbers
- 5-item discovery checklist
- 6-step Phase 2 implementation
- supported truthy values: true, 1, yes
Files
Bootstrap Registration Toggle
Add the ability to enable/disable user registration via an environment variable in a Phoenix 1.8 app generated with phx.gen.auth.
Prerequisites
Verify before starting: 1. Phoenix 1.8 app with phx.gen.auth completed 2. A registration controller exists (e.g., UserRegistrationController) 3. A login page exists with a "Sign up" link
App Name Detection
Detect the app module name from mix.exs (e.g., MyApp) and the OTP app name (e.g., my_app). Replace all template references accordingly.
Phase 0: Discovery
CRITICAL: Before generating anything, audit the target app to understand what's already in place.
Discovery Checklist
1. Registration controller — Find the registration controller
Grep("UserRegistrationController")orGrep("RegistrationController")- Note the module name and file path
2. Existing toggle — Check if a registration toggle already exists
Grep("registration_enabled")in config/ and lib/- If found: report what exists and skip
3. Runtime config — Check for runtime.exs and existing boolean_env helper
Read("config/runtime.exs")- Note if
boolean_envhelper already exists (reuse it)
4. Login page — Find the login template with signup link
Grep("register")in the session HTML templates- Note the file path for conditional rendering
5. Router — Find registration routes
Grep("register")in the router- Note the scope and pipeline they're in
Discovery Report
Present findings and confirm before proceeding.
Phase 1: Configuration (only if no env var exists)
Ask the user:
1. ENV var name — What should the environment variable be called? Default: {APP_NAME_UPPER}_USER_REGISTRATION_ENABLED (e.g., MY_APP_USER_REGISTRATION_ENABLED)
2. Default behavior — Should registration be open or closed by default? Default: open in dev/test, closed in prod (config_env() != :prod)
3. Flash message — What message to show when registration is disabled? Default: "New account registration is temporarily unavailable."
4. Redirect path — Where to redirect when registration is disabled? Default: /users/log-in
Phase 2: Implementation
Step 1: Add boolean_env helper to runtime.exs (if not present)
If config/runtime.exs does not already have a boolean_env helper, add one near the top:
boolean_env = fn name, default ->
case System.get_env(name) do
nil -> default
val -> String.downcase(val) in ~w(true 1 yes)
end
endStep 2: Add config entry to runtime.exs
Add the registration toggle config:
config :my_app,
:user_registration_enabled,
boolean_env.("MY_APP_USER_REGISTRATION_ENABLED", config_env() != :prod)This means:
- dev/test: registration enabled by default (override with
MY_APP_USER_REGISTRATION_ENABLED=false) - prod: registration disabled by default (override with
MY_APP_USER_REGISTRATION_ENABLED=true)
Step 3: Add controller plug guard
Add a private plug to the registration controller that checks the config:
plug(:ensure_registration_enabled)
# ... existing actions ...
@spec ensure_registration_enabled(Plug.Conn.t(), keyword()) :: Plug.Conn.t()
defp ensure_registration_enabled(conn, _opts) do
if Application.get_env(:my_app, :user_registration_enabled, true) do
conn
else
conn
|> put_flash(:error, "New account registration is temporarily unavailable.")
|> redirect(to: ~p"/users/log-in")
|> halt()
end
endImportant: The plug must be added BEFORE any action functions so it runs on every request.
Step 4: Conditionally hide the signup link on the login page
Find the login template (typically user_session_html/new.html.heex) and wrap the "Sign up" / "Register" link in a conditional:
<%= if Application.get_env(:my_app, :user_registration_enabled, true) do %>
<p class="...">
Don't have an account?
<.link navigate={~p"/users/register"} class="...">Sign up</.link>
</p>
<% end %>This prevents confusion — users won't see a signup link that leads to a redirect.
Step 5: Add test coverage
Create or update tests for the registration controller:
describe "registration toggle" do
test "allows registration when enabled", %{conn: conn} do
Application.put_env(:my_app, :user_registration_enabled, true)
on_exit(fn -> Application.delete_env(:my_app, :user_registration_enabled) end)
conn = get(conn, ~p"/users/register")
assert html_response(conn, 200) =~ "Register"
end
test "redirects when registration is disabled", %{conn: conn} do
Application.put_env(:my_app, :user_registration_enabled, false)
on_exit(fn -> Application.delete_env(:my_app, :user_registration_enabled) end)
conn = get(conn, ~p"/users/register")
assert redirected_to(conn) == "/users/log-in"
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~ "unavailable"
end
endNote: These tests must NOT be async: true since they modify application env.
Step 6: Verify
Run mix test to ensure nothing is broken.
Summary of Changes
| File | Change |
|---|---|
config/runtime.exs | Add boolean_env helper (if needed) + registration config |
| Registration controller | Add ensure_registration_enabled plug |
| Login template | Wrap signup link in registration-enabled conditional |
| Registration controller test | Add toggle on/off test cases |
ENV Variable Reference
| Variable | Values | Default |
|---|---|---|
{APP}_USER_REGISTRATION_ENABLED | true/1/yes or false/0/no | true in dev/test, false in prod |
Bootstrap Registration Toggle
Add ENV-based registration toggle to a Phoenix 1.8 app.
Install
Install this skill globally:
npx skills add agoodway/GoodSkills --skill bootstrap-registration-toggle -gInstall into the current project:
npx skills add agoodway/GoodSkills --skill bootstrap-registration-toggleUsage
/bootstrap-registration-toggleRelated skills
FAQ
What is the default behavior per environment?
Registration is enabled by default in dev and test and disabled by default in prod, overridable via the ENV var.
Does it change the login page?
Yes, it wraps the signup link in a registration-enabled conditional so users do not see a link that just redirects.