/xref slash commandDrop this file into .claude/commands/xref.md in any Clojure project to add /xref as a Claude Code slash command.
Add the :xref alias to your ~/.clojure/deps.edn (or project deps.edn):
:xref {:extra-deps {com.github.danlentz/clj-xref {:mvn/version "0.1.1"}}
:main-opts ["-m" "clj-xref.cli"]
:ns-default clj-xref.tool}
The alias serves both clj -M:xref <cmd> (CLI subcommands used below) and clj -T:xref generate (tool invocation for database generation).
Ensure .clj-xref/ is in .gitignore.
Copy the following into .claude/commands/xref.md:
Query the cross-reference database for the current Clojure project. Built on clj-kondo static analysis.
/xref init — generate/regenerate the xref database
/xref who-calls ns/fn — who calls this function?
/xref calls-who ns/fn — what does this function call?
/xref who-implements ns/Protocol — who implements this protocol?
/xref who-dispatches ns/multi — defmethod dispatch values
/xref who-macroexpands ns/macro — where is this macro expanded?
/xref unused — find dead code
/xref ns-deps ns — namespace dependencies
/xref ns-dependents ns — reverse namespace dependencies
/xref apropos pattern — search vars by name pattern
/xref graph ns/fn — transitive call graph
All commands are run via the CLI:
clojure -M:xref <command> [args]
The database is auto-generated on first query if .clj-xref/xref.edn doesn't exist.
When working on code changes in this session, use xref proactively:
who-calls to find all callers that need updatingcalls-who to see dependencieswho-calls to verify nothing depends on itinit to regenerate, or use incremental mode:clojure -M:xref init
After significant code changes, regenerate the database:
clojure -M:xref init
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |