Skip to main content

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.

v1.0.0New

Unsigned, install at your own risk

Unverified

This 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-clojure
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/clojure-brackendev-clojure/SKILL.md

Setup guide →
0Save

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-open over Java resources, JVM-typed exceptions, BigDecimal and 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 with try/finally (ClojureScript has no with-open), JS-flavored numerics and truthiness, the cljs.main workflow.
  • clojuredart-skills -- ClojureDart on Flutter: Dart interop, type hints and nullability, cljd.flutter directives, Dart error types and with-open, which calls .dispose, async, FFI, REPL.
  • babashka-skills -- Babashka, the Clojure interpreter in a native binary: the built-in namespaces, bb.edn tasks, 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.

  1. CLJ-1: NEVER def INSIDE A FUNCTION BODY. def interns 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 with let, and hold changing state in an atom (references/state-and-dispatch.md).
  2. CLJ-2: REALIZE LAZY SEQUENCES BEFORE THEIR SCOPE CLOSES. A lazy sequence returned from the body of with-open, binding, or try is 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 of try is read escapes the catch. Realize the result inside the scope with doall, vec, or mapv. clojure-jvm/references/errors-and-resources.md in the clojure-jvm skill (clojure-jvm-skills) shows the JVM reader that fails with "Stream closed", and clojuredart/references/errors-and-resources.md in the clojuredart skill (clojuredart-skills) covers ClojureDart's with-open. Never use map or for only for side effects, because their effects run only when someone consumes the result. Use doseq or run! (references/collections.md).
  3. CLJ-3: KEEP swap! FUNCTIONS FREE OF SIDE EFFECTS. The swap! 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 after swap! returns (references/state-and-dispatch.md).
  4. 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).
  5. CLJ-5: contains? CHECKS KEYS, NEVER VALUES. On a vector it tests whether an index exists: (contains? [:a :b] :a) is false. Test membership with a set, as in (#{:a :b} x), or with some (references/collections.md).
  6. CLJ-6: case CONSTANTS ARE LITERALS, NEVER VARS. case does not evaluate its test constants, so (case x limit ...) compares x with the symbol limit, not with its value. Use condp = or cond to compare against runtime values (references/naming-and-functions.md).
  7. 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).
  8. 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).
  9. CLJ-9: NEVER USE FLOATING POINT FOR MONEY. (+ 0.1 0.2) is 0.30000000000000004 on 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 has BigDecimal, which clojure-jvm/references/numbers.md in the clojure-jvm skill (clojure-jvm-skills) covers. ClojureScript and ClojureDart have no decimal type and read 0.1M as an ordinary double, so they use integer minor units. clojurescript/references/host-semantics.md in the clojurescript skill (clojurescript-skills) covers JavaScript numbers, and clojuredart/references/errors-and-resources.md in the clojuredart skill (clojuredart-skills) covers ClojureDart's M literals.
  10. CLJ-10: READ UNTRUSTED TEXT ONLY WITH AN EDN READER. clojure.core/read-string and read "can execute code" and "should be used only with trusted sources," and eval and load-string run whatever they receive. Use clojure.edn/read-string on the JVM, cljs.reader/read-string in ClojureScript, and cljd.edn/read-string in ClojureDart, and register only safe tag readers (references/untrusted-input.md).
  11. 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's format returns. 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).
  12. 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-repl skill 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

  1. Prefer clojure.string over host string interop. Use str/upper-case not a host-native method.
  2. Use keywords as map lookup functions. (:name m) not (get m :name).
  3. Use sets as predicates. (remove #{1} coll) not (remove #(= % 1) coll).
  4. Use seq for empty checks. (when (seq s) ...) not (when-not (empty? s) ...).
  5. Use when for single-branch side effects. Reserve if for two branches.
  6. Use condp or case over repeated = in cond. Reduces duplication.
  7. No commas in sequential collections. Commas are optional in maps.
  8. Prefer vectors over quoted lists. [1 2 3] not '(1 2 3).
  9. Do not write macros when functions work. Macros complicate debugging and composition.
  10. Keep functions short. Aim for under 10 LOC. Most work well under 5 LOC.
  11. Name side-effecting functions with !. save-user! not save-user.
  12. Prefer higher-order functions over loop/recur. Use map, filter, reduce.
  13. Limit positional parameters to three or four. Use an options map beyond that.
  14. Use defn- for private functions. Use ^:private for private vars.
  15. Use ->Foo constructors for records. Not interop syntax. Applies on every host that ships defrecord. ClojureDart adds a further reason: the raw interop form requires extra meta/extmap/hash arguments the factory supplies automatically.
  16. Use some-> and some->> for nil-safe pipelines. Short-circuits on first nil.
  17. Throw ex-info with 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.
  18. 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, and abs exist on every host. See "Core functions for maps, parsing, and UUIDs" in references/collections.md.
  19. 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.
  20. 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 case on 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. See references/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 involvesRead
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 conditionsreferences/naming-and-functions.md
Threading macros, let bindings and destructuring, nil-returning lookups, or throwing and rethrowing ex-inforeferences/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 mechanismreferences/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 namesreferences/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 effectreferences/simple-design.md
Writing or reviewing a macroreferences/macros.md
ns forms, requires and aliases, private vars, or metadatareferences/namespaces.md
Parsing data from outside the program, or building SQL queries and shell commandsreferences/untrusted-input.md
Portable .cljc code: reader conditionals (#?, #?@), platform tags, conditional requires, or a catch-all catch type for several hostsreferences/reader-conditionals.md
Formatting, indentation, comments, or docstringsreferences/formatting.md
Writing or reviewing testsreferences/testing.md
REPL conventions: qualified cross-namespace calls, in-ns, and comment formsreferences/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.

This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from Clojure Skills (brackendev)

View source →
clojure-debugUse when a Clojure, ClojureScript, or ClojureDart program, REPL evaluation, build, or test fails with an error: a stack trace, an exception, a compiler or macroexpansion error, or `ex-info` data in output. Triggers: "Syntax error compiling", "Syntax error macroexpanding", "Syntax error reading source", "Execution error", "Error printing return value", "Unable to resolve symbol", "Could not locate ... on classpath", "did not conform to spec", "Full report at", `ExceptionInfo`, `CompilerException`, `ex-data`, `ex-cause`, `*e`, a `NullPointerException` or `ClassCastException` in Clojure code, or a failing test that reports an error rather than a failed assertion. Covers keeping the original evidence, separating the error phase and wrapper exceptions from the root cause, reading `ex-data`, finding the first application frame, reproducing the failure, and verifying a focused fix.0 installsclj-fixFix a Clojure project with lint, format, test, and dry (duplicate-form) steps. Applies safe lint fixes and formatting by default. Use when asked to lint, format, test, or check a Clojure project, or to fix clj-kondo warnings or cljfmt formatting in Clojure code. For ClojureScript, Electric, Fulcro, ClojureDart, and Babashka projects, prefer /cljs-fix, /electric-fix, /fulcro-fix, /cljd-fix, or /bb-fix when installed. Use --report to preview the lint and format changes without writing.0 installsclj-smells-fixFix Clojure code against the clj-smells catalog of Clojure-specific code smells. Auto-applies Stage 1 mechanical findings and Stage 2 DEFECT-tier findings, and reports SMELL and HINT findings. Use when asked to find or fix Clojure code smells, or to fix namespace problems such as `:refer :all`, `:use`, or unused requires. Use --report to disable writes.0 installsclojure-replUse when evaluating Clojure, ClojureScript, or ClojureDart code in a running REPL: checking how a function behaves, reproducing a bug interactively, reloading a changed namespace, inspecting live application state, or running a test namespace from the REPL. Triggers: nREPL, `.nrepl-port`, `.shadow-cljs/nrepl.port`, `clj-nrepl-eval`, clojure-mcp, `clojure_eval`, `list_nrepl_ports`, `shadow/repl`, the ClojureDart socket REPL, `:reload`, "try it in the REPL", "evaluate this", or REPL-driven development. Covers finding and verifying the right REPL, choosing a client, evaluating small forms with bounded output, reloading, and confirming REPL results against the saved source.0 installsclojure-depsUse when choosing, checking, or researching a dependency of a Clojure, ClojureScript, or ClojureDart project: which version the project uses, what the latest release is, whether a newer version is compatible, or how a library's API works in the installed version. Triggers: `deps.edn` `:deps` and `:extra-deps` coordinates, `:mvn/version`, `:git/tag`, `:git/sha`, `project.clj` `:dependencies`, `shadow-cljs.edn` `:dependencies`, Clojars, Maven Central, cljdoc, `find-versions`, "latest version of", "which version", "is this outdated", "add a library", or "how do I use" a Clojure library. Covers reading the resolved version, finding source and documentation for that exact version, looking up releases, and separating the latest release from a compatible one.0 installs

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.635 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.535 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.346 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.246 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.173 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions145 installs

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.