Agent skill
user-management
Implement user CRUD operations within an account with permission controls and feature flags. Use when building team member management, user administration, or account user settings in multi-tenant Rails applications.
Install this agent skill to your Project
npx add-skill https://github.com/rbarazi/agent-skills/tree/main/skills/user-management
SKILL.md
User Management Pattern
Implement team member management within a multi-tenant Rails application with feature flags and permission controls.
When to Use
- Adding team member management
- Implementing user administration within accounts
- Building "invite user" or "add team member" functionality
- Adding permission controls for user management
Architecture Overview
Account (has_many :users)
└── Feature Flag: allow_user_management
└── Settings::UsersController
├── index (list team members)
├── new/create (add member)
└── destroy (remove member, not self)
Quick Start
1. Add Feature Flag
# Migration
add_column :accounts, :allow_user_management, :boolean, default: false, null: false
2. Create Controller
# app/controllers/settings/users_controller.rb
module Settings
class UsersController < ApplicationController
before_action :ensure_user_management_enabled
before_action :set_user, only: [:destroy]
def index
@users = Current.account.users.order(:email_address)
end
def new
@user = Current.account.users.new
end
def create
@user = Current.account.users.new(user_params)
if @user.save
redirect_to settings_users_path, notice: t("settings.users.flash.create.success")
else
render :new, status: :unprocessable_content
end
end
def destroy
if @user == Current.user
redirect_to settings_users_path, alert: t("settings.users.flash.destroy.self_delete_error")
return
end
@user.destroy
redirect_to settings_users_path, notice: t("settings.users.flash.destroy.success")
end
private
def set_user
@user = Current.account.users.find(params[:id])
end
def user_params
params.require(:user).permit(:email_address, :password)
end
def ensure_user_management_enabled
return if Current.account.allow_user_management?
redirect_to settings_path, alert: t("settings.users.flash.disabled")
end
end
end
3. Add Routes
namespace :settings do
resources :users, only: [:index, :new, :create, :destroy]
end
Security Checklist
- Always scope to
Current.account.users - Prevent self-deletion (
@user == Current.user) - Feature flag disabled by default
- Password requirements enforced (min 8 chars)
- Use
:unprocessable_contentstatus for errors
Reference Files
For complete implementation details:
- controllers.md - Full controller with all actions
- views.md - Index, form, and account settings views
- i18n.md - All translation keys
- testing.md - Controller and system specs
- permissions.md - Role-based access, invitation system
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
test-auth-helpers
Implement authentication testing patterns with RSpec, FactoryBot, and test helpers for Rails applications. Use when writing controller specs, system tests, or request specs that require authenticated users and multi-tenant account context.
multi-tenant-accounts
Implement multi-tenant architecture using an Account model as the tenant boundary. Use when building SaaS applications, team-based apps, or any system where data must be isolated between organizations/accounts.
oauth21-provider
Implement an RFC-compliant OAuth 2.1 authorization server in Rails applications. Use when building apps that need to authorize third-party clients (like MCP clients, API consumers, or external integrations) using industry-standard OAuth flows with PKCE, dynamic client registration, and token management.
password-reset-flow
Implement secure password reset with Rails 8's built-in token generation. Use when building "forgot password" functionality with email verification and time-limited reset tokens.
code-pattern-extraction
Extract reusable design and implementation patterns from codebases into Skills. Use when asked to analyze code for patterns, document architectural decisions, create transferrable implementation guides, or extract knowledge into Skills. Transforms working implementations into comprehensive, reusable Skills that can be applied to new projects.
slack-mcp-server
Create MCP servers that interact with Slack APIs. Use when building agent tools for Slack canvases, posting messages, or other Slack operations via Model Context Protocol.
Didn't find tool you were looking for?