clojure-guardrails

Enforce runtime validation for Clojure functions using Guardrails and Malli schemas.

1|Updated Sep 5, 2025
One-click install
npx skills add https://github.com/Ramblurr/nix-devenv --skill clojure-guardrails
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clojure-guardrails
Source: https://github.com/Ramblurr/nix-devenv/tree/main/prompts/skills/clojure-guardrails
Command: npx skills add https://github.com/Ramblurr/nix-devenv --skill clojure-guardrails

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps Clojure developers ensure the correctness and robustness of their functions by providing a powerful system for defining and enforcing specifications at runtime.

Core Features & Use Cases

  • Function Specification: Define detailed input and output types, constraints, and predicates for Clojure functions using the Guardrails library and Malli schemas.
  • Runtime Validation: Automatically catch type mismatches, constraint violations, and unexpected return values, preventing bugs before they reach production.
  • Use Case: When defining a complex API endpoint in Clojure, use Guardrails to specify that a user ID must be a UUID, an email must match a regex pattern, and the function should return a user record or nil.

Quick Start

Use the clojure-guardrails skill to define a function with input and output specifications.

Frequently Asked Questions about clojure-guardrails

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce runtime validation for Clojure functions using Malli schemas?

You can enforce runtime validation for Clojure functions by using the Guardrails library with Malli schemas, applying `>defn` and `>fdef` macros to specify input and output types. This automatically catches type mismatches and constraint violations during execution.

What is the best way to specify complex function signatures in Clojure?

Specifying complex function signatures in Clojure is done using Gspec syntax with Guardrails macros like `>defn` and `>def`. This allows you to define detailed input and output constraints, ensuring data integrity across complex API endpoints.

Can I use Guardrails to validate API contracts and return values in Clojure?

Yes, Guardrails can validate API contracts in Clojure by enforcing runtime checks on function inputs and outputs. You can specify that an email matches a regex pattern or a function returns a user record, catching unexpected return values before production.

How do Clojure Guardrails and Malli compare for runtime checks?

Clojure Guardrails provides the macro system like `>defn` for defining function specifications, while Malli supplies the actual schema definitions for data validation. Together, they offer a combined system for precise runtime checks and data integrity enforcement.

When do I need runtime checks and function specs in Clojure?

You need runtime checks and function specs in Clojure when defining complex API endpoints or enforcing data integrity constraints. Using Guardrails with Malli schemas ensures that inputs like UUIDs and regex patterns are validated before the function executes.

Why should I use `>defn` instead of `defn` for Clojure function validation?

You should use `>defn` instead of `defn` when you need to enforce runtime validation alongside function definition. It integrates Malli schemas directly into the function signature, automatically checking input and output types against your specifications.