Skip to main content

clj-smells-fix

Fix 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.

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-smells-fix
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

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

Setup guide →
0Save

Instructions

Clojure Smells Fix

Review Clojure code against the clj-smells catalog, a community catalog of 34 Clojure-specific code smells with descriptions, examples, and source citations. The skill pairs clj-kondo static analysis with LLM-assisted detection for smells static analysis cannot catch, then applies the safe subset of findings to source files.

Catalog Source

Pinned to upstream commit 51abf4b (2026-06-11). The smell digest in references/clj-smells-catalog.md reflects this snapshot. Update both the pin and the digest when upstream revises the catalog.

Arguments

InputTarget
(no argument)Fix changed files only (staged + unstaged)
allFix the full codebase, sampling high-risk and high-traffic namespaces
path/to/dirFix files under directory
path/to/file.cljFix specific file
--reportDisable all writes; produce the report only

Examples:

/clj-smells-fix
/clj-smells-fix src/api
/clj-smells-fix src/api/auth.clj
/clj-smells-fix all
/clj-smells-fix --report
/clj-smells-fix src/api --report

The --report flag may appear in any position.

Mutation

The skill applies findings in two narrow bands. Everything else is reported.

Auto-fixed by default:

  • Stage 1 mechanical findings from the clj-kondo overlay: 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 actually 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.
  • Stage 2 DEFECT-tier findings with a local, well-defined rewrite: macro double-evaluation (bind the argument once in a let), unwrapped resource handles (wrap the handle in with-open, and realize any lazy result inside it with doall or vec. On the JVM, with-open calls .close, as a clojure.java.io/reader result needs. In ClojureDart it calls .dispose unless the binding adds a :dispose directive such as :dispose .close, so rewrite only when the resource's cleanup method is known. ClojureScript has no with-open, so report a ClojureScript finding without rewriting it), blocking channel operations inside go blocks (rewrite <!!, >!!, and alts!! to <!, >!, and alts! only when the call is lexically inside the go body, not inside a nested fn, #(), for, letfn, reify, or a function the block calls, where the parking form throws "used not in (go ...) block"), load-time side effects inside def bodies when every caller is in scope and can be rewritten in the same pass (wrap the right-hand side in delay and update every caller to dereference it with @ or deref).

Reported only, never auto-applied:

  • Stage 1 finding: direct clojure.lang.RT usage (:discouraged-java-method). No safe general rewrite exists, so the skill reports the call sites with the replacement each finding's message names.
  • Stage 1 finding: a symbol used as a case test constant (:case-symbol-test, reported at :info). case never evaluates the symbol, which is a defect when the author meant the symbol's value and correct when the symbol itself is the constant, so Stage 2 decides from the code and the skill never rewrites it.
  • Stage 2 SMELL and HINT findings: maintainability or style improvements that depend on intent.
  • Any Stage 2 DEFECT finding outside the list above, where the fix would require changing call sites across the codebase, changing public API shape, or introducing a new dependency. The report describes the suggested change.

With --report, the skill produces the same report but writes nothing. Every finding appears as a suggestion. The fixes it would otherwise apply automatically are listed as deferred suggestions in a "Would apply" section, which takes the place of "Applied fixes".

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). Naming a vendored path directly through <path> or <glob> bypasses the filter for that target. 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.

Severity Tiers

TierMeaning
DEFECTCorrectness, resource leak, race condition, macro double-evaluation, blocking inside go, load-time side effects
SMELLMaintainability or design cost with concrete evidence
HINTLocal idiom, readability, or style improvement

A single smell name (for example "Production doall") can land in different tiers depending on context. Assign tier based on impact, not by smell name alone. Default tier guidance is in references/clj-smells-catalog.md.

Fix Workflow

Run all stages for every invocation.

1. Determine Scope

Parse $ARGUMENTS for --report (any position) and for a scope keyword or path.

Use Bash for changed-file discovery:

  • git status --short
  • git diff --name-only
  • git diff --cached --name-only

Filter to .clj, .cljc, .cljs, and .cljd files. Apply the path filter described in the Mutation section, and also skip resource directories. If the user provided no scope and no files changed, ask what to fix rather than widening silently to all.

Build a scope summary (for example changed files: src/api.clj, src/db.clj) for the report header.

2. Stage 1: clj-kondo First Pass

Check whether clj-kondo is available on PATH:

command -v clj-kondo

If clj-kondo is missing, record a warning in the report (Stage 1 skipped: clj-kondo not on PATH) and proceed to Stage 2.

If available, run with the overlay configuration:

clj-kondo --lint <scope> \
  --config <skill-dir>/references/clj-kondo-overlay.edn \
  --config '{:output {:format :json}}'

Parse the JSON output. Each clj-kondo finding maps to a catalog smell as documented in references/clj-smells-catalog.md. Promote verified findings to the report with clj-kondo as evidence.

clj-kondo (with overlay) detects the Stage 1 findings. Unless --report is set, apply via Edit the rewrite that the Mutation section lists for each finding's linter. Send the findings that the Mutation section marks as reported only, such as direct clojure.lang.RT usage and symbol case test constants, to the suggestions list. Report a symbol case test constant as a DEFECT suggestion when the symbol names a local or a var whose value the code evidently meant to match, and drop it when the code matches symbols as data, as in (case op + ... - ...) over operator symbols.

Record each applied edit in the report under "Applied fixes" with file:line and a one-line summary.

3. Stage 2: LLM Pass

For each file in scope, evaluate against the smells in references/clj-smells-catalog.md that clj-kondo cannot detect. Apply these rules:

  • Read the file (or diff hunk when scoped to changes).
  • For each candidate smell, verify the pattern against the actual code, not assumptions.
  • Skip smells that are intentional in context (see False-Positive Guardrails below).
  • Every finding requires a file:line reference and a concrete code excerpt.
  • Prefer fewer high-confidence findings over many weak ones.

Classify each finding by tier and by whether it falls within the auto-fix band described in the Mutation section. Apply each DEFECT-tier finding within the band via Edit unless --report is set. Record applied edits in the report. Defer everything else (DEFECT findings outside the band, all SMELL findings, all HINT findings) to the report as suggestions.

4. Aggregate and Report

Use this structure unless the user asked for a shorter variant:

## Clojure Smells Fix: [scope]

### Applied fixes

**[file:line]** -- [smell name]
[one-line description of the rewrite]

(under --report, title this section "Would apply" and list the same entries as deferred suggestions; omit the section when no fixes apply)

### Suggestions

**[file:line]** -- [DEFECT|SMELL|HINT] [smell name]
[evidence: short code excerpt or clj-kondo line]
[why it matters in this context]
[suggested fix]

### Verdict

- **Smell density:** None / Low / Moderate / High
- **Detection coverage:** clj-kondo: [available|missing], LLM pass: [N files reviewed]
- **One-sentence summary:** [single sentence]

| Metric | Count |
|--------|-------|
| Files reviewed | N |
| Applied fixes | N |
| DEFECT (reported) | N |
| SMELL | N |
| HINT | N |
| clj-kondo findings | N |

If no smells found, say so explicitly and still emit the metric table.

False-Positive Guardrails

  • doall in REPL utilities, one-off scripts, or small bounded sequences is the explicit intent. Only flag (and only consider auto-fixing) doall in production code paths where laziness was the appropriate default.
  • with-redefs in tests is the canonical Clojure seam for stubbing boundaries. Do not flag it as "Misuse of Dynamic Scope" inside a test namespace.
  • :refer :all for clojure.test is project convention in many Clojure codebases. Auto-fix only when the project's other test files use :refer with explicit symbols.
  • core.async channels are appropriate when the use case requires fan-out, batching, backpressure, or long-running pipelines. Flag "Overengineering with core.async" only when a plain function, a callback, a JVM promise or future, or a ClojureScript promise would suffice, and never auto-fix this finding.
  • Refs in Dependency Vector applies only to the dependency vector of a React effect hook, such as reagent.hooks/use-effect or rumext's hooks. Do not flag it anywhere else, including plain Clojure, Reagent components that do not use hooks, and re-frame subscriptions.
  • Macros that capture forms, control evaluation order, or generate top-level definitions cannot be replaced with functions. Flag "Unnecessary Macros" only when the macro body is a straightforward expression a function would compute, and never auto-fix it.
  • :refer :all of clojure.core is implicit and never a finding.
  • Mark uncertain findings as uncertain. Do not auto-fix any finding the model is uncertain about; route it to the suggestions list instead.

Gotchas

  • --config merges the overlay over the project's .clj-kondo/config.edn, so the overlay's levels take precedence, and a linter the project sets to :off (for example :linters {:redundant-do {:level :off}}) reports findings again. Namespace-local configuration (:clj-kondo/config metadata on the ns form) is merged after command-line configuration, so it still overrides the overlay for that namespace. Treat such a linter as disabled: do not apply or report its findings, and note in the report that the project config disables it.
  • When clj-kondo exits non-zero, output is still on stdout. Parse stdout regardless of exit code; non-zero exit is expected when findings exist.
  • --config accepts a file path or an EDN expression, and clj-kondo merges repeated --config options. Pass the overlay by absolute path, because the working directory at fix time is the user's project, not the skill directory. clj-kondo has no --config-file option and ignores it without an error, so that spelling silently runs without the overlay.
  • clj-kondo checks Java methods only in Clojure code, so the clojure.lang.RT check never reports in .cljs files or in the :cljs branch of a .cljc file. The other overlay linters apply in every dialect.
  • ClojureDart (.cljd) files need ClojureDart's clj-kondo configuration. Import it before linting with clj-kondo --copy-configs --dependencies --lint "$(clojure -Spath)", which copies tensegritics/clojuredart hooks for cljd.flutter and the dart:core names. Static calls on Dart classes (for example DateTime/now) still report "Unresolved namespace" even with that configuration. clj-kondo lints .cljd files as Clojure, so it reports a reader conditional in a .cljd file as the syntax error "Reader conditionals are only allowed in .cljc files", although ClojureDart reads conditionals there. Report those findings as clj-kondo limits and never rewrite them. JVM-only smells, such as RT usage and clojure.java.io readers, do not apply to .cljd code.
  • :refer :all expansion requires reading every symbol the namespace actually uses. When the namespace references symbols through reader-conditional branches, macros, or eval, the expansion may miss entries. In that case, route the finding to suggestions rather than auto-fixing.
  • Auto-fixes that touch a :require form must preserve the rest of the form (other entries, metadata, comments). Re-format with the project's cljfmt configuration after the rewrite to avoid drift.
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-fixFix 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.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-smells-fix

What does the clj-smells-fix skill do?

Fix 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. 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-smells-fix skill?

Run `npx @skills-hub-ai/cli install clojure-brackendev-clj-smells-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-smells-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-smells-fix work with?

clj-smells-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-smells-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-smells-fix after installing it?

In Claude Code, type `/clojure-brackendev-clj-smells-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-smells-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.