clj
Run Clojure programs or start a REPL
TLDR
Start a REPL (interactive shell)
Execute a function
Run the main function of a specified namespace
Prepare a project by resolving dependencies, downloading libraries, and making/caching classpaths
Start an nREPL server with the CIDER middleware
Start a REPL for ClojureScript and open a web browser
SYNOPSIS
clj [options] [script-or-expression]
PARAMETERS
-A, --aliases <aliases>
Merge given aliases into deps.edn for classpath
-J<flag>
Pass JVM flag through to Java calls
-M, --main <alias>
Merge main alias and execute its :main-opts
-R, --resolve-aliases <aliases>
Merge aliases for runtime classpath only
-Sdeps <deps-edn>
Use specified deps.edn file
-Serr
Print full deps exceptions
-Sforce
Force re-download of all dependencies
-Spath
Print computed classpath
-Spoll
Poll Clojars/Maven for latest versions
-Srepro
Use reproducible classpath options
-Sthreads
Use parallel threads for dependency resolution
-Sverbose
Verbose output for deps processing
-T<tool>
Run tooling alias (e.g., -T:build)
-X<exec-fn>
Execute function from exec alias
-r, --repl
Start interactive REPL
DESCRIPTION
The clj command is the official command-line interface for Clojure, a functional Lisp dialect on the JVM. It enables running Clojure scripts, launching interactive REPLs, managing dependencies via deps.edn, and executing tasks with aliases. Designed for simplicity, clj supports reproducible builds, JVM customization, and integration with editors like VS Code or Emacs.
Key features include automatic dependency resolution from Maven/Clojars, runtime classpath computation, and support for multi-module projects. Use it standalone for scripts (clj script.clj) or with -M:alias for configured mains. It downloads the Clojure JAR on first run and caches deps.edn configurations.
Ideal for prototyping, automation, and development, clj replaced older tools like Leiningen for CLI usage while maintaining compatibility. Requires Java 8+ and respects $CLJ_OPTS env var for global options.
CAVEATS
Requires Java 8+; first run downloads Clojure tools (~40MB). Not for production deploys—use uberjars. Env vars like CLJ_OPTS override options.
EXAMPLES
clj -r # REPL
clj -M:run script.clj # Run with alias
clj -Spath -Sdeps project/deps.edn # Classpath
HISTORY
Introduced in 2018 with Clojure 1.10 CLI tools by Clojure/core team to simplify deps and REPLs, evolving from bootstrapped clojure script. Now at version 1.11+.


