kemalcr/kemal/kemal-auth
Claude Code and agent skill by kemalcr/kemal
- community
Checking that the SKILL.md file is still in the repository.
User authentication and session management in Kemal, following established project patterns.
Install
npx vskill@latest install kemalcr/kemal/kemal-authSKILL.md
The same SKILL.md was published earlier as kemalcr/kemal/kemal-auth.
Kemal Authentication & Sessions
This skill provides expert guidance on implementing user authentication and session management in Kemal, strictly following patterns from `kemal-by-example/ecommerce` and `kemal-by-example/oauth-login`.
Core Mandates
- Dependencies: Always
require "kemal-session". - Session Configuration: Use
Kemal::Session.configto setsecret,cookie_name, andgc_interval:
``crystal Kemal::Session.config do |config| config.secret = ENV["KEMAL_SESSION_SECRET"]? || raise "KEMAL_SESSION_SECRET not set" config.cookie_name = "your_app_session" config.gc_interval = 2.minutes end ``
- Auth Helpers: Implement auth logic in a module (e.g.,
Ecommerce::Auth): current_user(env): Useenv.session.bigint?("user_id")to retrieve the ID and find the userrequire_user(env): Callcurrent_user(env)and redirect to/loginifnilsign_in(env, user): Setenv.session.bigint("user_id", user.id || raise "User ID required")sign_out(env): Callenv.session.destroy
- Password Hashing: Use
Crypto::Bcrypt::Passwordfor securely storing and authenticating passwords. - Error Handling: Use specific exception types (like
DB::Error) in auth helpers.
``crystal def current_user(env) : User? user_id = env.session.bigint?("user_id") return unless user_id User.find(user_id) rescue DB::Error nil end ``
Patterns from Source Code
Auth Helper Module (ecommerce/src/helpers/auth.cr)
Session Secret (Explicit Configuration)
From ecommerce and oauth-login:
User Model with Bcrypt
From ecommerce/src/models/user.cr:
Login Route Pattern
Best Practices
- Local Variables for Errors: Pass error messages as local variables directly to the
rendermacro (e.g.,error_message = "Invalid email or password."). - Security: Use
POST(neverGET) for login and logout so state changes are not triggerable via simple links — but note that usingPOSTalone does not prevent CSRF. Add real CSRF protection: validate a per-session CSRF token on state-changing requests (e.g. the `kemal-csrf` handler) and set session cookies withSameSite. Regenerate the session on login to prevent session fixation. - Session Safe Access: Use
env.session.bigint?("user_id")or similar to safely retrieve session data. - Model Methods: Implement
User.authenticate(email, password)andUser.find_by_email(email)in the model.
When to Use
- When implementing signup, login, or logout features.
- When protecting specific routes from unauthorized access.
- When managing user-specific state across requests.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/kemal-auth/SKILL.md
Popularity
- Repository stars
- 3,918
- Repository forks
- 205
- 7-day trend score
- 41
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kemalcr/kemal/kemal-auth)