clojure
Use when writing, editing, reviewing, or discussing Clojure family code. Triggers: .clj, .cljs, .cljc, and .cljd files; deps.edn projects; shadow-cljs.edn; bb.edn; project.clj; build.clj; clojure.test, cljs.test, cljd.test; clojure.core forms (`defn`, `let`, `ns`, threading macros, destructuring, multimethods, protocols, transducers, specs, atoms); REPL usage; or any mention of Clojure, ClojureScript, ClojureDart, or a Clojure dialect. Covers idiomatic style, naming conventions, threading macros, collection idioms, atom-based state, dispatch, formatting, namespaces, and common anti-patterns.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install clojure-brackendev-clojureManual setup by platform
Claude Code
~/.claude/skills/clojure-brackendev-clojure/SKILL.md
Instructions
Clojure
This skill defines host-neutral Clojure family guidance. It applies to JVM Clojure (.clj), ClojureScript (.cljs), portable code (.cljc), and ClojureDart (.cljd).
Host-specific guidance lives in companion skills, which override this baseline only in named domains: host interop, host-typed exception handling, host resource cleanup, runtime-specific concurrency primitives (refs, agents, STM), alter-var-root and var rebinding semantics, host-specific aliases, host-specific test runner ergonomics, host-specific build and run tooling.
- clojure-jvm-skills -- JVM Clojure: Java interop, refs / agents / STM,
with-openover Java resources, JVM-typed exceptions,BigDecimaland the other JVM number types,alter-var-root, Clojure CLI /tools.build/clj-kondo/cljfmt/ test-runner / nREPL workflow. - clojurescript-skills -- ClojureScript on JavaScript hosts: JS interop, externs and advanced compilation, macro stage separation,
catch :default, cleanup withtry/finally(ClojureScript has nowith-open), JS-flavored numerics and truthiness, thecljs.mainworkflow. - clojuredart-skills -- ClojureDart on Flutter: Dart interop, type hints and nullability,
cljd.flutterdirectives, Dart error types andwith-open, which calls.dispose, async, FFI, REPL. - babashka-skills -- Babashka, the Clojure interpreter in a native binary: the built-in namespaces,
bb.edntasks, subprocesses, threads and process exit, records and types without Java classes, testing, pods, and packaging. - biff-skills -- the Biff 2 web framework on the JVM.
- electric-skills -- the Electric v3 full-stack reactive framework from Hyperfiddle.
- fulcro-skills -- the Fulcro 3 full-stack framework and its Pathom 3 server.
This skill does not duplicate that material. When in JVM, ClojureScript, ClojureDart, or Babashka context, defer to the host skill for its named domains and keep using this skill for everything else.
Iron Laws
These rules prevent bugs, data loss, security holes, and false reports of success. Never write code that breaks one. When existing code breaks a law, stop and report the law ID, the location, the offending code, and the correct pattern, then ask before changing code outside the current task. A law overrides any Key Rule or reference that seems to conflict with it. Host and framework skills add their own laws with the prefixes JVM, CLJS, CLJD, BIFF, ELEC, and FUL.
- CLJ-1: NEVER
defINSIDE A FUNCTION BODY.definterns a namespace-global var when the function compiles and resets its value on every call, so concurrent calls race and values leak from one call into the next. Bind locals withlet, and hold changing state in an atom (references/state-and-dispatch.md). - CLJ-2: REALIZE LAZY SEQUENCES BEFORE THEIR SCOPE CLOSES. A lazy sequence returned from the body of
with-open,binding, ortryis realized after the resource is closed, the binding has ended, or the handler has exited. On every host,(binding [*rate* 10] (map #(* % *rate*) xs))computes its values with the root*rate*, and an exception thrown while a lazy result oftryis read escapes thecatch. Realize the result inside the scope withdoall,vec, ormapv.clojure-jvm/references/errors-and-resources.mdin theclojure-jvmskill (clojure-jvm-skills) shows the JVM reader that fails with "Stream closed", andclojuredart/references/errors-and-resources.mdin theclojuredartskill (clojuredart-skills) covers ClojureDart'swith-open. Never usemaporforonly for side effects, because their effects run only when someone consumes the result. Usedoseqorrun!(references/collections.md). - CLJ-3: KEEP
swap!FUNCTIONS FREE OF SIDE EFFECTS. Theswap!docstring says the function "may be called multiple times." JVM Clojure retries it under contention. ClojureScript and ClojureDart call it once, but portable code must not depend on that. Compute the new value in the function, and act afterswap!returns (references/state-and-dispatch.md). - CLJ-4: USE THE RETURN VALUE OF EVERY TRANSIENT OPERATION. clojure.org: transients "are not designed to be bashed in-place. You must capture and use the return value in the next call." On JVM Clojure and ClojureScript, calling
assoc!twenty times in place on one transient map keeps only 8 entries (references/collections.md). - CLJ-5:
contains?CHECKS KEYS, NEVER VALUES. On a vector it tests whether an index exists:(contains? [:a :b] :a)isfalse. Test membership with a set, as in(#{:a :b} x), or withsome(references/collections.md). - CLJ-6:
caseCONSTANTS ARE LITERALS, NEVER VARS.casedoes not evaluate its test constants, so(case x limit ...)comparesxwith the symbollimit, not with its value. Usecondp =orcondto compare against runtime values (references/naming-and-functions.md). - CLJ-7: EVALUATE EACH MACRO ARGUMENT AT MOST ONCE. Every place a macro unquotes an argument becomes a copy of that expression, so an argument unquoted twice runs its side effects twice. Bind it once with an auto-gensym, as in
`(let [v# ~x] ...), unless repeating it is the macro's purpose, as in a loop body (references/macros.md). - CLJ-8: NO SIDE EFFECTS WHEN A NAMESPACE LOADS. A top-level form that opens a connection, starts a thread, or performs I/O runs whenever the namespace loads: in tests, at the REPL, on reload, and on the JVM during AOT compilation. Start resources from an explicit function, a
delay, or a component system (references/namespaces.md). - CLJ-9: NEVER USE FLOATING POINT FOR MONEY.
(+ 0.1 0.2)is0.30000000000000004on every host. Keep money in an exact decimal type from parsing to storage where the host has one, and never mix it with floating-point values. Where the host has none, use integer minor units such as cents (references/collections.md). The JVM hasBigDecimal, whichclojure-jvm/references/numbers.mdin theclojure-jvmskill (clojure-jvm-skills) covers. ClojureScript and ClojureDart have no decimal type and read0.1Mas an ordinary double, so they use integer minor units.clojurescript/references/host-semantics.mdin theclojurescriptskill (clojurescript-skills) covers JavaScript numbers, andclojuredart/references/errors-and-resources.mdin theclojuredartskill (clojuredart-skills) covers ClojureDart'sMliterals. - CLJ-10: READ UNTRUSTED TEXT ONLY WITH AN EDN READER.
clojure.core/read-stringandread"can execute code" and "should be used only with trusted sources," andevalandload-stringrun whatever they receive. Useclojure.edn/read-stringon the JVM,cljs.reader/read-stringin ClojureScript, andcljd.edn/read-stringin ClojureDart, and register only safe tag readers (references/untrusted-input.md). - CLJ-11: NEVER SPLICE INPUT INTO SQL OR SHELL COMMANDS. Pass SQL values as parameters, as in
["select * from users where id = ?" id]: a query string with?placeholders followed by the values, the shape that next.jdbc accepts and HoneySQL'sformatreturns. Map identifiers such as column names or sort directions through an allowlist. Pass the program and each argument as separate strings, never as one command string that a shell interprets, and still validate arguments that reach another program (references/untrusted-input.md). - CLJ-12: VERIFY FROM SAVED FILES, NOT REPL STATE. A form that works in the REPL proves nothing about the files, and reloading a namespace does not remove stale definitions. Write the change to the source file, then run the project's tests or lint in a fresh process, or after a full reload, before reporting success. The
clojure-replskill covers stale REPL state.
REPL-Driven Development
REPL-driven development is the primary workflow for Clojure family code. Prefer evaluating small forms in a running REPL before changing larger code paths, and let file edits follow from working REPL code, not the other way around. When the runtime has REPL tooling (an nREPL client, a socket REPL connection, or an editor integration) and no REPL is running, start one before continuing. The host skill names the dialect-specific command (nREPL on the JVM, the socket REPL on ClojureDart). When the runtime has no REPL tooling, do not stall on starting one: edit the files and verify with the project's test and lint commands.
For host-neutral REPL conventions (qualified cross-namespace calls, in-ns, and comment forms), read references/project-workflows.md. The clojure-repl skill covers finding the project's REPL, choosing a client, and evaluating safely.
Key Rules
- Prefer
clojure.stringover host string interop. Usestr/upper-casenot a host-native method. - Use keywords as map lookup functions.
(:name m)not(get m :name). - Use sets as predicates.
(remove #{1} coll)not(remove #(= % 1) coll). - Use
seqfor empty checks.(when (seq s) ...)not(when-not (empty? s) ...). - Use
whenfor single-branch side effects. Reserveiffor two branches. - Use
condporcaseover repeated=incond. Reduces duplication. - No commas in sequential collections. Commas are optional in maps.
- Prefer vectors over quoted lists.
[1 2 3]not'(1 2 3). - Do not write macros when functions work. Macros complicate debugging and composition.
- Keep functions short. Aim for under 10 LOC. Most work well under 5 LOC.
- Name side-effecting functions with
!.save-user!notsave-user. - Prefer higher-order functions over
loop/recur. Usemap,filter,reduce. - Limit positional parameters to three or four. Use an options map beyond that.
- Use
defn-for private functions. Use^:privatefor private vars. - Use
->Fooconstructors for records. Not interop syntax. Applies on every host that shipsdefrecord. ClojureDart adds a further reason: the raw interop form requires extra meta/extmap/hash arguments the factory supplies automatically. - Use
some->andsome->>for nil-safe pipelines. Short-circuits on firstnil. - Throw
ex-infowith a data map, and keep the cause when rethrowing. Pass the caught exception as the third argument so the root cause stays in the chain. Host-typed exceptions belong in the host skill. - Use the core map, parsing, and UUID functions over hand-rolled equivalents.
update-vals,update-keys,parse-long,parse-double,parse-boolean,parse-uuid,random-uuid, andabsexist on every host. See "Core functions for maps, parsing, and UUIDs" inreferences/collections.md. - Let catalog data own policy. When a catalog, registry, or configuration map describes the things a program works with, behavior and the relationships between entries come from those declarations. Code reads the declarations and never names a specific entry to decide what to do. A relationship that no entry declares means no behavior, never a hardcoded fallback, and a lookup of an undeclared entry fails instead of returning a default (Honest Code P15 and P16 state this part). One pure function answers each question about the data, and every caller asks that function instead of deriving its own answer. Validate the data when it loads. Closed-case dispatch on a fixed set of variants stays fine. The catalog-relationship and one-function-per-question parts are this package's rule, not part of a published source. See
references/data-driven-design.md. - Choose simple over easy. Simple means a construct does one job and is not entangled with another. Easy means familiar or close at hand. Before choosing a construct, name the concerns it ties together, and prefer the one that keeps apart the concerns that can change independently. Pass values to the functions that compute, and dereference an atom once at the edge. Keep domain data in plain maps and operate on it with functions in namespaces, not records that carry behavior or closures over hidden state. Use a multimethod or a small protocol when the same
caseon the same variants repeats across functions. Describe a feature with data before writing a macro or a string format. Pass collaborators as arguments, and separate a pure decision from the effect that carries it out. More small independent parts are simpler than fewer entangled ones, but never add a protocol, a multimethod, or a queue for a variation that does not exist. The distinction and the list of entangling constructs come from Rich Hickey's talk Simple Made Easy. The mapping to Clojure constructs and the exceptions are this package's rule. Seereferences/simple-design.md.
References
The Iron Laws and Key Rules are the short form. Each reference file below holds the detailed guidance and the good and bad examples for one topic. Before writing, reviewing, or refactoring Clojure code, read every reference whose topic the task touches, and read the next one when the work moves to a new topic.
| When the task involves | Read |
|---|---|
Naming functions, vars, parameters, or predicates, or designing a function: its length, arity, parameters, conditionals (when, if-let, condp, case and its literal constants), function literals, or pre and post conditions | references/naming-and-functions.md |
Threading macros, let bindings and destructuring, nil-returning lookups, or throwing and rethrowing ex-info | references/control-flow.md |
Collections, keyword and set idioms, contains?, transients, empty checks, laziness, strings, numbers and money, or the core map, parsing, and UUID functions (update-vals, parse-long, random-uuid) | references/collections.md |
| Atoms and other state, multimethods, protocols, or choosing a dispatch mechanism | references/state-and-dispatch.md |
| Catalogs, registries, or configuration data that decide behavior: declaring relationships between entries, resolving them with pure functions, validating the data when it loads, or code that branches on specific entry names | references/data-driven-design.md |
Choosing between constructs or designing a component: passing a value or an atom, plain data against records or closures over state, a repeated case against a multimethod or protocol, data against a macro or string format, passing collaborators as arguments, or separating a decision from its effect | references/simple-design.md |
| Writing or reviewing a macro | references/macros.md |
ns forms, requires and aliases, private vars, or metadata | references/namespaces.md |
| Parsing data from outside the program, or building SQL queries and shell commands | references/untrusted-input.md |
Portable .cljc code: reader conditionals (#?, #?@), platform tags, conditional requires, or a catch-all catch type for several hosts | references/reader-conditionals.md |
| Formatting, indentation, comments, or docstrings | references/formatting.md |
| Writing or reviewing tests | references/testing.md |
REPL conventions: qualified cross-namespace calls, in-ns, and comment forms | references/project-workflows.md |
Three task skills in this package cover workflows rather than style. Load clojure-repl to evaluate code in a running REPL, clojure-debug when code, a build, or a test fails with an error, and clojure-deps to check a dependency's version, releases, or documentation.
Security
Reviews (0)
More from Clojure Skills (brackendev)
View source →More Build skills
Browse category →Frequently asked questions about clojure
What does the clojure skill do?
Use when writing, editing, reviewing, or discussing Clojure family code. Triggers: .clj, .cljs, .cljc, and .cljd files; deps.edn projects; shadow-cljs.edn; bb.edn; project.clj; build.clj; clojure.test, cljs.test, cljd.test; clojure.core forms (`defn`, `let`, `ns`, threading macros, destructuring, multimethods, protocols, transducers, specs, atoms); REPL usage; or any mention of Clojure, ClojureScript, ClojureDart, or a Clojure dialect. Covers idiomatic style, naming conventions, threading macros, collection idioms, atom-based state, dispatch, formatting, namespaces, and common anti-patterns. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the clojure skill?
Run `npx @skills-hub-ai/cli install clojure-brackendev-clojure` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/clojure-brackendev-clojure/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does clojure work with?
clojure runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the clojure skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use clojure after installing it?
In Claude Code, type `/clojure-brackendev-clojure` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the clojure skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.