kemalcr/kemal/crystal-kemal
Claude Code and agent skill by kemalcr/kemal
- community
Checking that the SKILL.md file is still in the repository.
Use when building, reviewing, debugging, testing, securing, or deploying web applications and HTTP APIs with the Kemal framework for Crystal. Covers Kemal routing, params, context, routers, filters, middleware, ECR, WebSockets, SSE, uploads, configuration, testing, and production concerns.
Install
npx vskill@latest install kemalcr/kemal/crystal-kemalSKILL.md
The same SKILL.md was published earlier as kemalcr/kemal/crystal-kemal.
Kemal development
Use this skill for Kemal-specific work. Assume normal Crystal language knowledge and follow the Crystal documentation for language semantics that are not specific to Kemal.
Core rules
- Prefer Kemal's own APIs and terminology over Ruby/Sinatra assumptions.
- Match parameters to the request encoding:
env.params.url,.query,.json,.body, and.filesare not interchangeable. - Route definition order matters: the first matching route wins.
- Use
Kemal::Routerand namespaces to structure larger applications. - Use filters for concise route-lifecycle behavior; use middleware for reusable handler-layer concerns and plugins.
- A middleware handler must call
call_nextonly when processing should continue. - Keep business logic out of ECR templates.
- Treat every request-derived value as untrusted until validated.
- Do not pass unchecked user-controlled paths to
send_file. - Configure production WebSocket origins explicitly when browser clients are expected; origin validation is not authentication.
- Add or update specs when route or middleware behavior changes.
- Prefer current Kemal repository APIs over patterns remembered from older versions.
Quick start
Add Kemal to shard.yml:
Then:
Routing
Kemal supports the common HTTP verbs plus QUERY:
Routes are matched in definition order. Check broad/wildcard routes for shadowing before adding more specific routes later.
Dynamic route parameters:
Wildcard remainder:
For QUERY (RFC 10008, since Kemal 1.13.0), use the same Kemal parameter APIs appropriate to the request body. A QUERY request with a body and no Content-Type is rejected with 400 Bad Request according to Kemal's current behavior.
Parameters
Query parameters:
JSON body (Content-Type: application/json):
Form/body parameters:
Repeated/bracketed form keys must be accessed exactly as sent, for example env.params.body["likes[]"]?.
Uploads are available through env.params.files.
Request and response context
Prefer response helpers when they express the result clearly:
Manual response control remains available through env.response for headers, status, and content type.
Use halt inside routes when route execution must stop:
Do not treat halt as generic middleware control flow.
Modular routers
Routers can contain routes, filters, WebSockets, SSE endpoints, and nested namespaces. Keep router-scoped behavior scoped unless global behavior is intentional.
Filters and middleware
Common filters include before_all, verb-specific before_* and matching after_* filters, including before_query / after_query for QUERY routes.
Typical order:
A HEAD request without its own route is served by the GET route, and it runs that route's filters as well as any registered for HEAD. before_get guards therefore apply to HEAD, and so do Kemal::Handler only / exclude rules scoped to GET.
Reusable cross-cutting behavior belongs in middleware:
Do not call call_next after intentionally short-circuiting the request.
Views
Render ECR templates with render and use a second path for layouts. Layout content is available as content; content_for / yield_content can define named slots.
Keep application and authorization logic outside templates.
Security-sensitive behavior
- Validate dynamic
send_filepaths using canonical containment inside an allowed root. - Validate upload presence, size, type/extension as appropriate, and destination path before persistence.
- Use server-controlled upload names when client filenames could affect paths.
- Keep private uploads outside automatically served public directories.
- Set explicit request/multipart size limits appropriate to the application.
- Keep secrets outside source control.
- Avoid leaking stack traces, filesystem paths, database errors, tokens, or session secrets.
- Use HTTPS in production and configure security headers at a deliberate layer.
- Treat WebSocket origin checks as an additional browser boundary, not authentication/authorization.
Testing
Use spec-kemal for application-level Kemal specs:
Run:
Test success and rejection paths, status codes, content types, parameter decoding, route ordering, middleware behavior, authorization, and upload/path validation where relevant.
Load detailed references only when relevant
For more detail, read the smallest relevant reference file instead of loading everything:
- Routing, params, context, routers, views, filters, middleware, errors, static files: `references/http-core.md`
- Sessions, uploads, WebSockets, SSE, caching: `references/realtime-state.md`
- Limits, security, configuration, tests, builds, proxies, databases, checklist: `references/operations.md`
Verification checklist
Before considering Kemal work complete:
- [ ] Route ordering does not shadow expected endpoints.
- [ ] Each route uses the intended HTTP verb, including
QUERYwhere applicable. - [ ] URL/query/JSON/form/file params use the correct
env.params.*source. - [ ] Inputs are validated at trust boundaries.
- [ ] Status codes and content types are intentional.
- [ ] Router/filter/middleware scope is correct.
- [ ] Middleware continues with
call_nextonly when intended. - [ ] Dynamic file paths and uploads cannot escape allowed storage roots.
- [ ] WebSocket origin policy is explicit when needed and auth is handled separately.
- [ ] Request and multipart limits are intentional.
- [ ] Relevant
spec-kemaltests pass. - [ ] Production build and deployment behavior are verified for the target platform.
Specialized domain skills
For targeted domain implementations with tested patterns from `kemal-by-example`, see the dedicated domain skills:
- Core Routing & Handlers: `kemal-core`
- Real-Time WebSockets: `kemal-websocket`
- Server-Sent Events (SSE): `kemal-sse`
- JSON APIs & Helpers: `kemal-json`
- Middleware & HMAC: `kemal-middleware`
- File Uploads & Security: `kemal-upload`
- Authentication & Sessions: `kemal-auth`
- SQLite Database & Models: `kemal-database`
- OAuth2 Integration: `kemal-oauth`
- Crecto ORM: `kemal-orm`
- Views & ECR Templates: `kemal-view`
Sources
Treat the current Kemal repository and official Kemal documentation as the source of truth. Use current APIs when this skill conflicts with newer project documentation.
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/crystal-kemal/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/crystal-kemal)