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.
Unsigned, install at your own risk
UnverifiedThis 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-fixManual setup by platform
Claude Code
~/.claude/skills/clojure-brackendev-clj-smells-fix/SKILL.md
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
| Input | Target |
|---|---|
| (no argument) | Fix changed files only (staged + unstaged) |
all | Fix the full codebase, sampling high-risk and high-traffic namespaces |
path/to/dir | Fix files under directory |
path/to/file.clj | Fix specific file |
--report | Disable 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-kondooverlay: redundantdoblocks (:redundant-do, unwrapped), nestedletforms (: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:requireentries (:unused-namespace, removed), and unusedletbindings 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 inwith-open, and realize any lazy result inside it withdoallorvec. On the JVM,with-opencalls.close, as aclojure.java.io/readerresult needs. In ClojureDart it calls.disposeunless the binding adds a:disposedirective such as:dispose .close, so rewrite only when the resource's cleanup method is known. ClojureScript has nowith-open, so report a ClojureScript finding without rewriting it), blocking channel operations insidegoblocks (rewrite<!!,>!!, andalts!!to<!,>!, andalts!only when the call is lexically inside thegobody, not inside a nestedfn,#(),for,letfn,reify, or a function the block calls, where the parking form throws "used not in (go ...) block"), load-time side effects insidedefbodies when every caller is in scope and can be rewritten in the same pass (wrap the right-hand side indelayand update every caller to dereference it with@orderef).
Reported only, never auto-applied:
- Stage 1 finding: direct
clojure.lang.RTusage (: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
casetest constant (:case-symbol-test, reported at:info).casenever 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
SMELLandHINTfindings: maintainability or style improvements that depend on intent. - Any Stage 2
DEFECTfinding 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
| Tier | Meaning |
|---|---|
DEFECT | Correctness, resource leak, race condition, macro double-evaluation, blocking inside go, load-time side effects |
SMELL | Maintainability or design cost with concrete evidence |
HINT | Local 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 --shortgit diff --name-onlygit 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:linereference 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
doallin REPL utilities, one-off scripts, or small bounded sequences is the explicit intent. Only flag (and only consider auto-fixing)doallin production code paths where laziness was the appropriate default.with-redefsin tests is the canonical Clojure seam for stubbing boundaries. Do not flag it as "Misuse of Dynamic Scope" inside a test namespace.:refer :allforclojure.testis project convention in many Clojure codebases. Auto-fix only when the project's other test files use:referwith explicit symbols.core.asyncchannels 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 JVMpromiseorfuture, or a ClojureScript promise would suffice, and never auto-fix this finding.Refs in Dependency Vectorapplies only to the dependency vector of a React effect hook, such asreagent.hooks/use-effector 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 :allofclojure.coreis 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
--configmerges 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/configmetadata on thensform) 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-kondoexits non-zero, output is still on stdout. Parse stdout regardless of exit code; non-zero exit is expected when findings exist. --configaccepts a file path or an EDN expression, and clj-kondo merges repeated--configoptions. 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-fileoption 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.RTcheck never reports in.cljsfiles or in the:cljsbranch of a.cljcfile. The other overlay linters apply in every dialect. - ClojureDart (
.cljd) files need ClojureDart's clj-kondo configuration. Import it before linting withclj-kondo --copy-configs --dependencies --lint "$(clojure -Spath)", which copiestensegritics/clojuredarthooks forcljd.flutterand thedart:corenames. Static calls on Dart classes (for exampleDateTime/now) still report "Unresolved namespace" even with that configuration. clj-kondo lints.cljdfiles as Clojure, so it reports a reader conditional in a.cljdfile 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 andclojure.java.ioreaders, do not apply to.cljdcode. :refer :allexpansion requires reading every symbol the namespace actually uses. When the namespace references symbols through reader-conditional branches, macros, oreval, the expansion may miss entries. In that case, route the finding to suggestions rather than auto-fixing.- Auto-fixes that touch a
:requireform must preserve the rest of the form (other entries, metadata, comments). Re-format with the project'scljfmtconfiguration after the rewrite to avoid drift.
Security
Reviews (0)
More from Clojure Skills (brackendev)
View source →More Build skills
Browse category →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.