Skip to content
Skills Library
Programming · Building & coding

clojure

/clojure

Expert Clojure programming assistance covering immutable data structures, macros, software transactional memory (STM), and REPL workflows. Use when building concurrent functional systems or data transformation pipelines.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert Clojure programming assistance covering immutable data structures, macros, software transactional memory (STM), and REPL workflows. Use when building concurrent functional systems or data transformation pipelines.

Original author description

Expert Clojure programming assistance covering immutable data structures, macros, software transactional memory (STM), and REPL workflows. Use when building concurrent functional systems or data transformation pipelines.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 114 lines, 517 words
SKILL.md preview
---
name: clojure
description: Expert Clojure programming assistance covering immutable data structures, macros, software transactional memory (STM), and REPL workflows. Use when building concurrent functional systems or data transformation pipelines.
---

# Clojure

A Lisp hosted on the JVM (and JS via ClojureScript) with a focus on immutability.

## When to Use

- **Functional Programming on the JVM**: Leveraging immutable data structures, pure functions, and the vast Java library ecosystem.
- **Data-Driven & Event-Sourced Systems**: Processing complex financial, logistics, and transactional data structures effortlessly.
- **Full-Stack Clojure / ClojureScript**: Sharing code, validation schemas (Malli/Spec), and business models between backend and browser.
- **Interactive REPL-Driven Development**: Iterating and hot-reloading code live in running production-like JVM processes.

## Quick Start

```clojure
(println "Hello, World!")

(defn square [x]
  (* x x))

(map square [1 2 3]) ; (1 4 9)
```

## Core Concepts

### Persistent Immutable Data Structures

Clojure vectors, maps, and sets use structural sharing to provide immutable snapshots with O(log32 N) performance:

```clojure
;; Creating and updating immutable maps via structural sharing
(def original-user {:id 415 :name "Jane" :roles #{:member}})
(def updated-user (update original-user :roles conj :admin))

;; original-user remains completely unchanged:
;; {:id 415 :name "Jane" :roles #{:member}}
```

### Concurrency Primitives (Atoms & Software Transactional Memory)

Manages shared state transitions safely without manual lock synchronization:

```clojure
;; Atoms provide atomic, lock-free state updates via compare-and-swap
(def request-count (atom 0))

;; Thread-safe atomic increment
(swap! request-count inc)
(println "Current requests:" @request-count)
```

### Threading Macros (`->` and `->>`)

Pipelines data transformations cleanly without deeply nested function calls:

```clojure
(defn calculate-revenue [orders]
  (->> orders
       (filter :completed?)
       (map :total-cents)
       (reduce +)
       (* 0.01)))
```

## Common Patterns

### Threading Macros for Data Transformation

**Problem**: Deeply nested function calls are hard to read and mentally trace backwards.

**Solution**:
Use `->>` (thread-last) macro for sequential transformations:

```clojure
(defn process-orders [orders]
  (->> orders
       (filter #(= (:status %) "completed"))
       (map :amount)
       (reduce + 0)))

(println (process-orders [{:status "completed" :amount 50}
                          {:status "pending" :amount 20}
                          {:status "completed" :amount 30}]))
;; => 80
```

## Best Practices

**Do**:

- Embrace REPL-Driven Development: Connect your editor (Calva, CIDER) to a running nREPL and test functions interactively.
- Validate Data with Malli or Clojure Spec: Define explicit schemas for function inputs and API boundaries.
- Use Destructuring Comprehensively: Unpack nested maps and vectors cleanly in function argument vectors.
- Leverage Java Interop Directly: Invoke Java classes (`(java.time.Instant/now)`) directly without wrapper overhead.

**Don't**:

- Fight immutability: Do not introduce mutable Java arrays or global variables where immutable maps suffice.
- Hold references to lazy sequences: Realizing unbounded lazy sequences while retaining their head exhausts JVM heap memory.
- Create deep monolithic namespaces: Break namespaces into cohesive, focused modules.

## Troubleshooting

| Error                                                   | Cause                                                        | Solution                                                                  |
| :------------------------------------------------------ | :----------------------------------------------------------- | :------------------------------------------------------------------------ |
| `CompilerException java.lang.ClassCastException`        | Passing wrong data structure (e.g. sequence instead of map). | Verify types using `(type x)` in the REPL.                                |
| `ArityException: Wrong number of args`                  | Function called with more or fewer arguments than defined.   | Check function parameter vector and multi-arity definitions.              |
| `OutOfMemoryError: Java heap space with lazy sequences` | Retaining the head of an unbounded lazy sequence.            | Use `dorun` or `doseq` to consume lazy seqs without retaining references. |

## References

- [Clojure.org](https://clojure.org/)
- [ClojureDocs](https://clojuredocs.org/)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
pingqLIN/skill-0100MIT

Database snapshot: 13.11.2026 · package version 59a536a45a29 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100clojure-expert
    Expert knowledge in Clojure/ClojureScript, immutability, REPL-driven development, core.async, and functional programming on the JVM. Use when the user mentions ClojureScript, functional programming, immutability, REPL, core async, or JVM, or when the task involves Lisp Features,…
  • 100clojure-write
    Guide Clojure and ClojureScript development using REPL-driven workflow, coding conventions, and best practices. Use when writing, developing, or refactoring Clojure/ClojureScript code.
  • 100clojure-lisp-immutability
    Use this skill when building concurrent, functional data-transformation pipelines in Clojure utilizing persistent immutability and atoms.
  • 100clojure-repl
    Interact with running Clojure REPLs via nREPL. Evaluate Clojure code, query namespaces, test functions, and debug live Clojure systems. Use when working with .clj/.cljc/.cljs files and a REPL is available.
  • 100lang-clojure
    Use when writing, reviewing, testing or setting up Clojure backend code in a loops run (the clojure language pack) - toolchain, layout, race policy, coverage, idioms and footguns.
  • 100clojure-symbols
    Find and edit Clojure symbols using clj-kondo and REPL introspection. Use when finding Clojure function definitions, var usages, namespace contents, renaming Clojure symbols, replacing function bodies, or working with .clj/.cljc/.cljs files.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.