Skip to main content

clj-fix

Fix a Clojure project with lint, format, test, and dry (duplicate-form) steps. Applies safe lint fixes and formatting by default. Use when asked to lint, format, test, or check a Clojure project, or to fix clj-kondo warnings or cljfmt formatting in Clojure code. For ClojureScript, Electric, Fulcro, ClojureDart, and Babashka projects, prefer /cljs-fix, /electric-fix, /fulcro-fix, /cljd-fix, or /bb-fix when installed. Use --report to preview the lint and format changes without writing.

v1.0.0New

Unsigned, install at your own risk

Unverified

This skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install clojure-brackendev-clj-fix
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/clojure-brackendev-clj-fix/SKILL.md

Setup guide →
0Save

Instructions

Clojure Fix

Run lint, format, test, and duplicate-form checks on Clojure source files. The lint and format steps write by default: lint applies the safe mechanical fixes that clj-smells-fix owns, and format rewrites formatting. The test and dry steps are pure-read.

Arguments

InputTarget
(no argument)Run all four steps (lint, format, test, dry) on the project
allSame as (no argument); accepted for family consistency
lintRun lint only
formatRun format only
testRun tests only
dryRun dry only
--reportDisable all writes: report the lint fixes, and run cljfmt check instead of cljfmt fix

Step keywords are combinable (for example, /clj-fix lint test). The --report flag may appear in any position. When --report is present without an explicit step keyword, every step still runs, and the lint and format steps report their changes instead of writing them.

Mutation

The lint and format steps write by default. The format step runs cljfmt fix through the runner the Format step below selects, rewriting files in place. The lint step applies the safe mechanical fix band that clj-smells-fix owns, described in the Lint step below. With --report, neither step writes: the format step runs cljfmt check through the same runner, which exits non-zero when files would change but does not write, and the lint step reports the fixes it would apply without editing files. The test and dry steps are pure-read regardless of --report.

This skill excludes vendored, generated, and dependency-locked paths from the file set it walks. The filter combines .gitignore matches and a hardcoded floor (node_modules/, vendor/, third_party/, .bundle/, target/, build/, dist/, out/, .shadow-cljs/, cljd-out/, *.lock, package-lock.json, yarn.lock, pnpm-lock.yaml, Gemfile.lock, Cargo.lock, poetry.lock, composer.lock). This skill takes no path argument, so the filter applies to every run. When the filter excludes any path, add a single "skipped N vendored or generated paths" line to the report. Under --report, list every skipped path. The full policy is Rule 4 in the package's CONVENTIONS.md.

Steps

Parse $ARGUMENTS to determine which steps to run and whether --report is present. If no step keyword is supplied (or only all is supplied), run every step in order.

1. Lint

Run clj-kondo on the project's source and test paths with the clj-smells-fix overlay, which this package installs next to this skill. Resolve the paths from the build configuration instead of assuming directory names:

  • deps.edn: the top-level :paths, plus the :extra-paths of the :test alias.
  • Leiningen project.clj: :source-paths and :test-paths.
  • shadow-cljs.edn: :source-paths, unless shadow-cljs.edn sets :deps. With :deps, shadow-cljs takes its source paths from deps.edn, so use the deps.edn paths instead, plus the :extra-paths of the aliases that :deps {:aliases [...]} names.

Skip resource directories and paths that do not exist. If no configuration declares paths, lint the source and test directories that exist in the repository. Pass the overlay by absolute path, because the working directory is the user's project:

clj-kondo --lint <source-and-test-paths...> \
  --config <skill-dir>/../clj-smells-fix/references/clj-kondo-overlay.edn

Then apply the safe mechanical fix band that clj-smells-fix owns: the clj-kondo findings with a deterministic, local rewrite. These are redundant do blocks (:redundant-do, unwrapped), nested let forms (:redundant-let, merged into the outer binding vector), :refer :all (:refer-all, expanded to explicit refers for the symbols the namespace uses), :use (:use, rewritten as :require :refer), unused :require entries (:unused-namespace, removed), and unused let bindings whose initializers have no side effects (:unused-binding, removed). Unused function parameters and destructuring bindings are reported, not rewritten. Direct clojure.lang.RT usage has no safe general rewrite, so report it with the replacement its message names, without applying it. A symbol used as a case test constant (:case-symbol-test, which the overlay reports at :info) can be deliberate, so report it for review and never rewrite it. Apply the false-positive guardrails the clj-smells-fix skill defines, and skip a linter the project's .clj-kondo/config.edn sets to :off as that skill's Gotchas describe, so the two skills stay in agreement. When this step rewrites a file and the format step is not also running, format each rewritten file with the Fix command of the runner that the Format step below selects, passing only those files as paths, so the edits match the project's formatting. When no runner is available, say in the report that the rewritten files were not formatted.

With --report, do not write. Instead, list the fixes this step would apply.

Report pass if no :error or :warning finding remains after the safe fixes are applied, and fail if one remains, because it needs manual attention. List :info findings, such as the overlay's :case-symbol-test, for review without failing the step. clj-kondo lints .cljd files as Clojure and reports a reader conditional there as the error "Reader conditionals are only allowed in .cljc files". ClojureDart reads conditionals in .cljd files, so list that finding without counting it as a failure. Show the clj-kondo output and the fixes applied (or, under --report, the fixes that would be applied).

2. Format

Run cljfmt with the first runner the project supports, checking the rows in order, and check each condition before running its command. Without a :cljfmt alias, clojure -M:cljfmt fix treats fix as a script path and fails with "fix (No such file or directory)", after the warning "Specified aliases are undeclared and are not being used: [:cljfmt]" when the run rebuilds the classpath.

RunnerWhenFixCheck
Project aliasdeps.edn defines a :cljfmt aliasclojure -M:cljfmt fixclojure -M:cljfmt check
Leiningen pluginproject.clj lists dev.weavejester/lein-cljfmt in :pluginslein cljfmt fixlein cljfmt check
Standalone binarycommand -v cljfmt succeedscljfmt fixcljfmt check
Clojure CLI toolclojure -Ttools list shows a cljfmt toolclojure -Tcljfmt fixclojure -Tcljfmt check

Without --report, run the Fix command. With --report, run the Check command, which writes nothing.

Outside Leiningen, cljfmt formats src, test, and project.clj unless its configuration sets :paths. When the project's source or test paths differ, pass the paths that the Lint step resolved: as arguments to the alias, the binary, or lein cljfmt (for example clojure -M:cljfmt fix src dev test), and as an option to the Clojure CLI tool, which takes no positional paths (clojure -Tcljfmt fix :paths '["src" "dev" "test"]'). cljfmt stops with "No such file:" when a path does not exist. Without paths, lein cljfmt formats the project's :source-paths and :test-paths. cljfmt's default :file-pattern does not match .cljd, so it skips ClojureDart files unless the configuration sets one, such as {:file-pattern #re "\\.(?:clj[csxd]?|bb)$"} in .cljfmt.edn. /cljd-fix covers that case.

cljfmt reads its configuration from .cljfmt.edn or cljfmt.edn in the project directory or a parent. lein cljfmt reads the :cljfmt map in project.clj instead, and reads .cljfmt.edn as well only when that map sets :load-config-file? true. cljfmt ignores .cljfmt.clj and cljfmt.clj with a warning unless --read-clj-config-files is passed, because it reads those files as Clojure code, which can run code. When the project has only a .clj configuration file, ask the user before passing that flag. The alias and the binary accept it, and the Clojure CLI tool never reads a .clj configuration file. Never fail a project for the name of its configuration file.

When no runner is available, report SKIPPED, show this alias to add under :aliases in deps.edn, and name the cljfmt README (https://github.com/weavejester/cljfmt) for the other installation methods:

:cljfmt {:replace-deps {dev.weavejester/cljfmt {:mvn/version "0.16.6"}}
         :main-opts ["-m" "cljfmt.main"]}

:replace-deps runs cljfmt without the project's dependencies, which a formatter does not need, so a project dependency that conflicts with cljfmt's own or cannot be resolved does not stop the format step.

Report pass if exit code is 0, fail otherwise. Show any formatting changes (under fix) or the diff (under check).

3. Test

Run the project's own test command:

ProjectCommand
deps.edn :test alias with :exec-fn (Cognitect test-runner)clojure -X:test
deps.edn :test alias with :main-opts (for example Kaocha or the test-runner main)clojure -M:test
Kaocha binstubbin/kaocha
Leiningenlein test

When the project defines none of these, report SKIPPED and say which test configuration is missing. Report pass if exit code is 0, fail otherwise. Show the test output.

4. Dry

Scan for duplicate top-level forms with dry4clj. This step is advisory. It reports duplication candidates for review but never fails the run and never halts the pipeline.

Determine the project's production source directories from its build configuration instead of assuming a directory name:

  • deps.edn: the top-level :paths (the :dry4clj alias is defined here). Tests usually live under a separate alias's :extra-paths, so scanning :paths excludes them.
  • Leiningen project.clj: :source-paths (tests live under :test-paths).
  • shadow-cljs.edn: :source-paths, unless shadow-cljs.edn sets :deps. With :deps, shadow-cljs takes its source paths from deps.edn, so use the deps.edn paths instead, plus the :extra-paths of the aliases that :deps {:aliases [...]} names.

Scan the production source paths only and exclude test paths. If no configuration declares source paths, scan the source directories that exist in the repository, excluding any test directory. Do not assume src.

Check that deps.edn defines a :dry4clj alias before running the scan. When it does not, report SKIPPED and show the alias to add under :aliases:

:dry4clj {:extra-deps {io.github.unclebob/dry4clj {:git/url "https://github.com/unclebob/dry4clj.git"
                                                   :git/sha "5994ef2bcaaae8d12bcd0afb4f091ae09083228c"}}
          :main-opts  ["-m" "dry4clj.core"]}

Run dry4clj with EDN output over the resolved paths:

clojure -M:dry4clj --edn <source-paths...>

Do not pass --threshold, --min-lines, or --min-nodes. Scoping to production source removes the dominant noise, which is repeated test scaffolding; tightening the score or size knobs either hides real matches or has no effect on exact-structure duplicates.

dry4clj exits 0 after a completed scan, and the EDN output never prints a clean-state message, so do not use the exit code or any text match to detect duplicates. A non-zero exit means the scan itself failed (for example, a file the reader cannot parse) and is reported as ERROR. Parse the EDN map {:candidates [...]} and classify the result:

ResultCondition
PASS:candidates is empty.
REVIEW:candidates has one or more entries. List them and continue.
ERRORThe command fails or its output cannot be parsed. Report the cause, and do not report PASS.
SKIPPEDNo production source path can be identified, or deps.edn defines no :dry4clj alias.

dry4clj reads source without resolving namespace aliases, so an alias-qualified auto-resolved keyword such as ::str/ok stops the scan with "Invalid token" and a non-zero exit. Plain auto-resolved keywords such as ::ok read correctly. Report the file and the error as ERROR, keep the step advisory, and do not rewrite source to work around the reader.

For REVIEW, sort candidates by exact matches first (:score equal to 1.0), then by descending min(:left-nodes, :right-nodes), then by descending :score. Report the scanned source paths, the candidate count, and the highest-priority candidates with their score, node counts, and both file ranges. Note that each candidate needs source inspection before extraction, and that test directories were excluded because repeated test scaffolding is often intentional.

Report

After running all requested steps, print a summary:

Clojure Fix Results:
  Lint:   PASS/FAIL/SKIPPED
  Format: PASS/FAIL/SKIPPED
  Test:   PASS/FAIL/SKIPPED
  Dry:    PASS/REVIEW/ERROR/SKIPPED

If --report was passed, append (report mode: lint and format changes reported, not written) after the summary. If a lint, format, or test step fails, stop and report the failure; do not continue to subsequent steps.

Gotchas

  • A regular expression in .cljfmt.edn, such as an :extra-indents key or a :file-pattern, must use the #re tag: {:extra-indents {#re ".*" [[:inner 0]]}}. #".*" is not valid EDN, and cljfmt stops with "No dispatch macro for: "" before it formats anything. When the project's file uses #", report the format step as failed, show the #re form of each expression, and do not edit the configuration file without the user's confirmation.
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

More from Clojure Skills (brackendev)

View source →
clojure-debugUse when a Clojure, ClojureScript, or ClojureDart program, REPL evaluation, build, or test fails with an error: a stack trace, an exception, a compiler or macroexpansion error, or `ex-info` data in output. Triggers: "Syntax error compiling", "Syntax error macroexpanding", "Syntax error reading source", "Execution error", "Error printing return value", "Unable to resolve symbol", "Could not locate ... on classpath", "did not conform to spec", "Full report at", `ExceptionInfo`, `CompilerException`, `ex-data`, `ex-cause`, `*e`, a `NullPointerException` or `ClassCastException` in Clojure code, or a failing test that reports an error rather than a failed assertion. Covers keeping the original evidence, separating the error phase and wrapper exceptions from the root cause, reading `ex-data`, finding the first application frame, reproducing the failure, and verifying a focused fix.0 installsclj-smells-fixFix Clojure code against the clj-smells catalog of Clojure-specific code smells. Auto-applies Stage 1 mechanical findings and Stage 2 DEFECT-tier findings, and reports SMELL and HINT findings. Use when asked to find or fix Clojure code smells, or to fix namespace problems such as `:refer :all`, `:use`, or unused requires. Use --report to disable writes.0 installsclojure-replUse when evaluating Clojure, ClojureScript, or ClojureDart code in a running REPL: checking how a function behaves, reproducing a bug interactively, reloading a changed namespace, inspecting live application state, or running a test namespace from the REPL. Triggers: nREPL, `.nrepl-port`, `.shadow-cljs/nrepl.port`, `clj-nrepl-eval`, clojure-mcp, `clojure_eval`, `list_nrepl_ports`, `shadow/repl`, the ClojureDart socket REPL, `:reload`, "try it in the REPL", "evaluate this", or REPL-driven development. Covers finding and verifying the right REPL, choosing a client, evaluating small forms with bounded output, reloading, and confirming REPL results against the saved source.0 installsclojureUse when writing, editing, reviewing, or discussing Clojure family code. Triggers: .clj, .cljs, .cljc, and .cljd files; deps.edn projects; shadow-cljs.edn; bb.edn; project.clj; build.clj; clojure.test, cljs.test, cljd.test; clojure.core forms (`defn`, `let`, `ns`, threading macros, destructuring, multimethods, protocols, transducers, specs, atoms); REPL usage; or any mention of Clojure, ClojureScript, ClojureDart, or a Clojure dialect. Covers idiomatic style, naming conventions, threading macros, collection idioms, atom-based state, dispatch, formatting, namespaces, and common anti-patterns.0 installsclojure-depsUse when choosing, checking, or researching a dependency of a Clojure, ClojureScript, or ClojureDart project: which version the project uses, what the latest release is, whether a newer version is compatible, or how a library's API works in the installed version. Triggers: `deps.edn` `:deps` and `:extra-deps` coordinates, `:mvn/version`, `:git/tag`, `:git/sha`, `project.clj` `:dependencies`, `shadow-cljs.edn` `:dependencies`, Clojars, Maven Central, cljdoc, `find-versions`, "latest version of", "which version", "is this outdated", "add a library", or "how do I use" a Clojure library. Covers reading the resolved version, finding source and documentation for that exact version, looking up releases, and separating the latest release from a compatible one.0 installs

More Build skills

Browse category →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.635 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.535 installsfrontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.346 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.246 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.173 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions145 installs

Frequently asked questions about clj-fix

What does the clj-fix skill do?

Fix a Clojure project with lint, format, test, and dry (duplicate-form) steps. Applies safe lint fixes and formatting by default. Use when asked to lint, format, test, or check a Clojure project, or to fix clj-kondo warnings or cljfmt formatting in Clojure code. For ClojureScript, Electric, Fulcro, ClojureDart, and Babashka projects, prefer /cljs-fix, /electric-fix, /fulcro-fix, /cljd-fix, or /bb-fix when installed. Use --report to preview the lint and format changes without writing. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the clj-fix skill?

Run `npx @skills-hub-ai/cli install clojure-brackendev-clj-fix` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/clojure-brackendev-clj-fix/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does clj-fix work with?

clj-fix runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the clj-fix skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use clj-fix after installing it?

In Claude Code, type `/clojure-brackendev-clj-fix` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the clj-fix skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.