-Dguardrails.mode=:pro
Guardrails Analyzer is written in Clojure and runs on the JVM. It should work on any operating system that is well-supported by the Clojure tools deps system.
If you are using Windows then we recommend using Windows Subsystem for Linux.
Clojure 1.12+ with CLI tools
Java 21+
The Guardrails library in your project
For Guardrails Analyzer to work, the >defn macro must expand in a way that registers specs and
function metadata with the analyzer. This requires setting the JVM system property at startup:
-Dguardrails.mode=:pro
You can also use :all instead of :pro. Add this to your dev alias in deps.edn:
{:aliases
{:dev {:jvm-opts ["-Dguardrails.mode=:pro"]}}}
This property must be set at JVM startup. Setting it later via System/setProperty
after the JVM has started will not affect macros that have already expanded.
|
Add the Guardrails Analyzer dependency and mode setting to your deps.edn:
{:aliases
{:dev {:extra-deps {com.fulcrologic/guardrails-analyzer {:mvn/version "CURRENT"}}
:jvm-opts ["-Dguardrails.mode=:pro"]}}}
In your normal development REPL, load your application code first, then start the analyzer:
;; Load your application code first
(require 'my.app.main)
;; Start the analyzer
(require '[com.fulcrologic.guardrails-analyzer.checkers.repl :as ga])
(ga/start)
The daemon auto-launches if not already running.
From your editor: Use the editor’s check commands (e.g. IntelliJ’s "Check Namespace" action). Results appear as annotations in your editor.
From the REPL: Two styles of check are available:
;; Return problems as data (no IDE required)
(ga/check-ns 'my.app.core)
;; => [{:file "..." :line 42 :column 3 :severity "error" :message "..."}]
(ga/check-file "src/main/my/app/core.clj")
;; => [{:file "..." :line 10 :column 1 :severity "warning" :message "..."}]
;; Push results to your editor as diagnostics
(ga/check-ns! 'my.app.core)
(ga/check-file! "src/main/my/app/core.clj")
The check-ns / check-file variants return a compact vector of problems directly — useful
from a pure REPL with no editor, for scripting, or for building lightweight editor integrations
(e.g. Vim, Emacs). The ! variants push results through the daemon to your connected editor.
If you prefer to run the analyzer in a separate REPL that you don’t work in directly:
(require '[com.fulcrologic.guardrails-analyzer.checkers.repl :as ga])
(ga/start {:src-dirs ["src/main" "src/dev"]
:main-ns 'my.app.main})
In this mode, the analyzer auto-reloads changed code when the editor triggers a refresh-and-check.
The daemon is a shared background process that bridges the analyzer to your editor via LSP and WebSocket.
It auto-launches when you call start, or you can start it manually:
clojure -M -m com.fulcrologic.guardrails-analyzer.daemon.main
One daemon serves all projects. Port file: ~/.guardrails/daemon.port. Logs: ~/.guardrails/.
The analyzer needs specs registered in the JVM to check your code. In :pro or :all mode,
loading a namespace registers its specs. Make sure your code is loaded before checking:
Dev REPL: Load your app normally, then start the analyzer.
Dedicated REPL: Use :main-ns to auto-load at startup.
Your project should avoid doing things as top-level namespace side-effects, because that could interfere with
the analyzer’s ability to reload your namespaces and might otherwise run things you do not want. We assume you’re
using something like mount or component and that namespaces can be (re)loaded without causing harm.
|
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 |