Clojure REPL Evaluation

VerifiedCaution

Evaluate Clojure code via nREPL using clj-nrepl-eval. Check compilation, test function behavior, and interact with a running REPL session.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude Code
#clojure#nrepl#repl-driven-development#code-evaluation#interactive-testing

Recommended for

Automated summary

Evaluates Clojure code against an nREPL server through the clj-nrepl-eval command so you can check compilation, test functions, and debug interactively.

Strengths

  • Discovers nREPL servers running in the current directory (Clojure, Babashka, shadow-cljs) and lets the user pick the port
  • Session state persists across evaluations per host:port pair, so a namespace can be required once and reused in later calls
  • Ships concrete, copy-ready patterns: require with :reload, multiple expressions, heredoc, and stdin piping

Limitations

  • Assumes clj-nrepl-eval is installed and an nREPL server is running or can be started; without that the skill cannot do anything
  • The AskUserQuestion step and multiline heredoc commands may trigger permission approval prompts
  • Describes no structured parsing of evaluation errors and no automatic REPL restart; the supplied SKILL.md is also truncated at the end
When to use it

Reach for it when an nREPL server is running or can be started and you want to reload namespaces and validate edits without leaving your working session.

When not to use it

Skip it on non-Clojure projects or in environments where no REPL can exist (CI, one-shot builds), where conventional automated tests fit better.

Security analysis

Caution
Quality score85/100

The skill is not malicious and contains no exfiltration, obfuscation, destructive commands, or safety-disabling instructions. However, it relies on bash and live nREPL evaluation, which are powerful capabilities allowing arbitrary code execution in the user's project environment, so it warrants caution rather than safe.

Findings
  • •Evaluates arbitrary Clojure code in a live nREPL session, which can perform filesystem, network, or process actions with the REPL process's privileges.
  • •Uses shell commands and localhost networking without sandboxing or explicit confirmation before each evaluation.
  • •Session state persists across evaluations, so side effects can carry over unexpectedly until reset or server restart.
  • •Declares no allowed-tools while depending on bash and AskUserQuestion, creating a tool-permission mismatch.
How this analysis is made

Examples

Verify an edited namespace compiles
Discover the nREPL ports for this project, then evaluate (require 'app.core :reload) to check that my edited src/app/core.clj compiles.
Exercise a function in the REPL
Using the running nREPL port, require my.parser with :reload and then evaluate (my.parser/parse "1,2,3") to see what it returns.
Start a REPL when none is found
No nREPL server was discovered in this directory. Start one using the nREPL alias from deps.edn and tell me which port it came up on.

name: clojure-eval description: Evaluate Clojure code via nREPL using clj-nrepl-eval. Use this when you need to test code, check if edited files compile, verify function behavior, or interact with a running REPL session.

Clojure REPL Evaluation

When to Use This Skill

Use this skill when you need to:

  • Verify that edited Clojure files compile and load correctly
  • Test function behavior interactively
  • Check the current state of the REPL
  • Debug code by evaluating expressions
  • Require or load namespaces for testing
  • Validate that code changes work before committing

How It Works

The clj-nrepl-eval command evaluates Clojure code against an nREPL server. Session state persists between evaluations, so you can require a namespace in one evaluation and use it in subsequent calls. Each host:port combination maintains its own session file.

Instructions

0. Discover and select nREPL server

First, discover what nREPL servers are running in the current directory:

clj-nrepl-eval --discover-ports

This will show all nREPL servers (Clojure, Babashka, shadow-cljs, etc.) running in the current project directory.

Then use the AskUserQuestion tool:

  • If ports are discovered: Prompt user to select which nREPL port to use:

    • question: "Which nREPL port would you like to use?"
    • header: "nREPL Port"
    • options: Present each discovered port as an option with:
      • label: The port number
      • description: The server type and status (e.g., "Clojure nREPL server in current directory")
    • Include up to 4 discovered ports as options
    • The user can select "Other" to enter a custom port number
  • If no ports are discovered: Prompt user how to start an nREPL server:

    • question: "No nREPL servers found. How would you like to start one?"
    • header: "Start nREPL"
    • options:
      • label: "deps.edn alias", description: "Find and use an nREPL alias in deps.edn"
      • label: "Leiningen", description: "Start nREPL using 'lein repl'"
    • The user can select "Other" for alternative methods or if they already have a server running on a specific port

IMPORTANT: IF you start a REPL do not supply a port let the nREPL start and return the port that it was started on.

1. Evaluate Clojure Code

Evaluation automatically connects to the given port

Use the -p flag to specify the port and pass your Clojure code.

Recommended: Pass code as a command-line argument:

clj-nrepl-eval -p <PORT> "(+ 1 2 3)"

For multiple expressions (single line):

clj-nrepl-eval -p <PORT> "(def x 10) (+ x 20)"

Alternative: Using heredoc (may require permission approval for multiline commands):

clj-nrepl-eval -p <PORT> <<'EOF'
(def x 10)
(+ x 20)
EOF

Alternative: Via stdin pipe:

echo "(+ 1 2 3)" | clj-nrepl-eval -p <PORT>

2. Display nREPL Sessions

Discover all nREPL servers in current directory:

clj-nrepl-eval --discover-ports

Shows all running nREPL servers in the current project directory, including their type (clj/bb/basilisp) and whether they match the current working directory.

Check previously connected sessions:

clj-nrepl-eval --connected-ports

Shows only connections you have made before (appears after first evaluation on a port).

3. Common Patterns

Require a namespace (always use :reload to pick up changes):

clj-nrepl-eval -p <PORT> "(require '[my.namespace :as ns] :reload)"

Test a function after requiring:

clj-nrepl-eval -p <PORT> "(ns/my-function arg1 arg2)"

Check if a file compiles:

clj-nrepl-eval -p <PORT> "(require 'my.namespace :reload)"

Multiple expressions:

clj-nrepl-eval -p <PORT> "(def x 10) (* x 2) (+ x 5)"

Complex multiline code (using heredoc):

clj-nrepl-eval -p <PORT> <<'EOF'
(def x 10)
(* x 2)
(+ x 5)
EOF

Note: Heredoc syntax may require permission approval.

With custom timeout (in milliseconds):

clj-nrepl-eval -p <PORT> --timeout 5000 "(long-running-fn)"

Reset the session (clears all state):

clj-nrepl-eval -p <PORT> --reset-session
clj-nrepl-eval -p <PORT> --reset-session "(def x 1)"

Available Options

  • -p, --port PORT - nREPL port (required)
  • -H, --host HOST - nREPL host (default: 127.0.0.1)
  • -t, --timeout MILLISECONDS - Timeout (default: 120000 = 2 minutes)
  • -r, --reset-session - Reset the persistent nREPL session
  • -c, --connected-ports - List previously connected nREPL sessions
  • -d, --discover-ports - Discover nREPL servers in current directory
  • -h, --help - Show help message

Important Notes

  • Prefer command-line arguments: Pass code as quoted strings: clj-nrepl-eval -p <PORT> "(+ 1 2 3)" - works with existing permissions
  • Heredoc for complex code: Use heredoc (<<'EOF' ... EOF) for truly multiline code, but note it may require permission approval
  • Sessions persist: State (vars, namespaces, loaded libraries) persists across invocations until the nREPL server restarts or --reset-session is used
  • Automatic delimiter repair: The tool automatically repairs missing or mismatched parentheses
  • Always use :reload: When requiring namespaces, use :reload to pick up recent changes
  • Default timeout: 2 minutes (120000ms) - increase for long-running operations
  • Input precedence: Command-line arguments take precedence over stdin

Typical Workflow

  1. Discover nREPL servers: clj-nrepl-eval --discover-ports
  2. Use AskUserQuestion tool to prompt user to select a port
  3. Require namespace:
    clj-nrepl-eval -p <PORT> "(require '[my.ns :as ns] :reload)"
    
  4. Test function:
    clj-nrepl-eval -p <PORT> "(ns/my-fn ...)"
    
  5. Iterate: Make changes, re-require with :reload, test again

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/clojure-repl-evaluation-mte1lfzl' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/clojure-repl-evaluation-mte1lfzl/download' --output '.skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md.part' && mv '.skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md.part' '.skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md' && test -s '.skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/clojure-eval' && cp -R '.skill-downloads/clojure-repl-evaluation-mte1lfzl' '.claude/skills/clojure-eval'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/clojure-repl-evaluation-mte1lfzl'

openskills read 'clojure-repl-evaluation-mte1lfzl'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/clojure-repl-evaluation-mte1lfzl/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills