Clojure REPL — use when starting a REPL or socket REPL, attaching to a running one, loading or reloading namespaces, inspecting runtime state, adding a library interactively, or debugging an exception at the REPL.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Clojure Repl?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/just-sultanov-clojure-repl)
---
name: clojure-repl
description: Clojure REPL — use when starting a REPL or socket REPL, attaching to a running one, loading or reloading namespaces, inspecting runtime state, adding a library interactively, or debugging an exception at the REPL.
license: EPL-1.0
---
# Clojure REPL
Owns the interactive session: launching `clojure.main` or a socket REPL,
loading and reloading namespaces, inspecting state, adding a library to a
running JVM, and diagnosing an exception. Dependency files, aliases, and
builds belong to `clojure-deps`; version gates, including the 1.12 `add-lib`
requirement, belong to `clojure-versions`; nREPL and editor integrations are
out of scope. The text is adapted from the Clojure REPL guide
(<https://clojure.org/guides/repl>) and the Clojure REPL sources under EPL 1.0;
see [NOTICE.md](NOTICE.md).
## Ground rules
- **The REPL is the running program.** Evaluate in the namespace and on the
classpath the program uses. A definition that exists only at the prompt is
not part of the program.
- **No destructive commands.** The REPL has no confirmation and no undo.
Deleting data, stopping a service, or touching production belongs in a
reviewed tool, not at a prompt.
## Workflow
### 1. Establish the session context
Record the runtime version, the JDK, the current namespace, the classpath
source, and the command that starts the REPL. Read the project `deps.edn` and
the alias the project uses for development.
```bash
clojure -M -e '*clojure-version*'
clojure -M -e '(System/getProperty "java.version")'
clojure -Spath | tr ':' '\n' | head
```
Done when version, JDK, classpath source, startup command, and development
alias are written down.
### 2. Start or attach
Use plain `clj` or `clj -M` for a REPL in the `user` namespace, `clj -M:dev`
for an alias that adds paths, deps, or JVM options, or `clojure.main` from
`java -cp` when the CLI is not available. For a remote or long-running
process, start a socket REPL and connect to the port. Details and options are
in [start.md](references/start.md).
Done when `(ns-name *ns*)` returns the expected namespace and
`(clojure-version)` matches the project target; at a terminal the prompt shows
the same namespace, and for a socket the same forms return over the connection.
### 3. Load the project
Require the namespace, then enter it. `require` loads the file and records
the lib; `in-ns` switches without referring `clojure.core`, so use `ns` in the
source and `in-ns` plus `refer-clojure` at the prompt only when needed. The
load-and-enter order is in [reload.md](references/reload.md).
```clojure
(require '[my.app.core :as core])
(in-ns 'my.app.core)
```
Done when `*ns*` is the target namespace and a var from the project resolves
to a value, not to a "No such namespace" error.
### 4. Reload after an edit
Reload the namespace after every source change:
```clojure
(require 'my.app.core :reload)
```
Use `:reload-all` when a shared dependency changed, and restart the JVM after
changing a protocol, record, or type. Reloading replaces vars, not state.
Read [reload.md](references/reload.md) before trusting a reload of a stateful
namespace.
Done when the changed var's value or source reflects the file and a call
exercises the change.
### 5. Inspect state
Look up the var before guessing: `doc`, `dir`, `source`, `apropos`, and
`find-doc` cover documentation and names; `*1`, `*2`, `*3`, and `*e` hold the
last results; `tap>` carries values out of deep code. Read
[inspect.md](references/inspect.md) for the full set.
Done when the value, docstring, or source you needed is printed, and the
expression that produced it is small enough to keep.
### 6. Add a library interactively
In Clojure 1.12 and later, add a lib to the running JVM without a restart:
```clojure
(add-lib 'org.clojure/data.json {:mvn/version "2.5.2"})
(require '[clojure.data.json :as json])
```
`add-libs` resolves a set together, and `sync-deps` adds libs already
declared in `deps.edn`. An added lib is not persistent: record it in
`deps.edn` and restart before the code depends on it. Read
[add-lib.md](references/add-lib.md).
Done when the namespace loads in this session and the coordinate is either in
`deps.edn` or deliberately discarded.
### 7. Debug an exception
Start from the exception, not from the stack trace: `*e`, `(pst *e)`,
`(ex-data *e)`, and `(Throwable->map *e)` separate a data error from a
compilation error. Then shrink the failing form until it runs in `-e`, and
write the test that keeps it fixed. Launcher errors need a report target to
be visible. Read [debug.md](references/debug.md).
Done when you can name the failing form, its inputs, and the phase that
failed, and a test or a minimal `-e` command reproduces the failure.
### 8. Clean up and shut down
Unmap temporary vars, stop socket servers and taps, and leave the JVM:
```clojure
(ns-unmap 'my.app.core 'debug-state)
(clojure.core.server/stop-servers)
```
Ctrl-D ends a `clojure.main` REPL; `:repl/quit` closes a socket client;
`(System/exit 0)` is the last resort, because it ends the whole process. The
leaving rules are in [start.md](references/start.md). Done
when the process exits with status 0 and `git status` shows no debug
leftovers.
## Checklist
- [ ] The session runs on the project's Clojure, JDK, and classpath.
- [ ] The current namespace is the one under change, not `user`.
- [ ] Every edited file was reloaded, or the JVM was restarted.
- [ ] No stale var, protocol instance, or `defonce` value is in play.
- [ ] The value, docstring, or source was read from the session, not memory.
- [ ] An added lib is recorded in `deps.edn` or was intentionally dropped.
- [ ] The failing input is reproduced by a test or a minimal `-e` command.
- [ ] The exception phase and `ex-data` were read, not guessed.
- [ ] Temps, taps, servers, and agent threads are cleaned up.
- [ ] The session exited and the diff contains no debug leftovers.
## Related skills
- `clojure-deps` — `deps.edn`, aliases, exec modes, and the classpath a REPL
starts with.
- `clojure-versions` — the 1.12 gate for `add-lib`, the 1.12.7–1.12.8
serialization controls, and the JDK baseline.
- `clojure-testing` — the reproduction test: structure, fixtures, runners,
and reading a failing test.
- `clojure-style` — naming for any helper the session leaves behind.
- `clojure-tooling` — the editor and clojure-lsp setup, which is separate
from the terminal REPL this skill drives.
## References
| File | Read when |
| ----------------------------------- | ------------------------------------------------------ |
| [start.md](references/start.md) | launching, applying an alias, or opening a socket REPL |
| [reload.md](references/reload.md) | reloading a namespace, or state survives a reload |
| [inspect.md](references/inspect.md) | looking up docs, namespace contents, or REPL vars |
| [add-lib.md](references/add-lib.md) | adding a library to a running 1.12+ REPL |
| [debug.md](references/debug.md) | an exception, a silent launcher failure, or a repro |