agentleFS
kuhumcstkuhumcst/DanNet/.claude/skills/clojure-style/SKILL.md

clojure-style

Skill29 starsChanged 4 months agoMITView on GitHub

Simon's Clojure/ClojureScript code style. Use whenever writing, editing, refactoring, or reviewing Clojure code — any change to .clj, .cljs, .cljc, or .edn files, code proposed in chat, or REPL experiments that will end up in a file. Consult it before cleanups and "tidying" passes too; those have their own rules here.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 8 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If a function needs internal section comments or does two describable things, split it.

    line 24
  2. Very specific:

    Prefer map/filter/reduce/into over explicit loop/recur.

    line 26
  3. Very specific:

    Keep the core pure; push side effects to the edges and mark them with !

    line 28
  4. Very specific:

    Use a transducer (comp of xforms with into) when a pipeline is reused or performance-critical.

    line 29
  5. Distinctive:

    Every public var gets a docstring.

    line 60
  6. Distinctive:

    Keep docstring lines ≤ 80 characters.

    line 69
  7. Distinctive:

    Prefer multi-arity over options maps.

    line 73
  8. Very specific:

    Never remove an :as binding just because the body doesn't reference it — it documents what the parameter IS.

    line 77
  9. Very specific:

    Use declare for mutual recursion rather than reordering a namespace.

    line 80
  10. Very specific:

    Only defns may be private (defn-), and only pure single-caller helpers with no standalone meaning.

    line 86
  11. Distinctive:

    Do not introduce new private vars outside that rule, and do not privatize existing vars during cleanups.

    line 89
  12. Very specific:

    Document complex regexes; mark known limitations with TODO.

    line 99
  13. Distinctive:

    When in doubt, the comment is too long.

    line 100
  14. Distinctive:

    No blanket no-magic-numbers rule.

    line 104
  15. Very specific:

    Use delay for expensive dev data so loading the namespace stays cheap.

    line 125
  16. Distinctive:

    Verify one specific aspect per evaluation.

    line 126
  17. Very specific:

    Never use better-cond's special keywords (:let, :when-let, :when) inside a rum/defc body.

    line 138

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Clojure Style

Guiding principle

Perfection is attained not when there is nothing more to add, but when there is nothing left to take away (Saint-Exupéry). When improving code, look for something to remove before adding anything. Prefer the smallest diff that does the job: surgical edits, clean and lean git history, no drive-by refactors of the surrounding namespace.

Compose small functions

Model the code on the Clojure standard library: many small, single-purpose functions with an obvious data-in/data-out contract, combined through composition rather than accumulated into large bodies.

  • Build features by composing existing vars — threading (->, ->>), comp, partial, seq functions — before writing new ones.
  • If a function needs internal section comments or does two describable things, split it. A helper with a good name beats a comment.
  • Prefer map/filter/reduce/into over explicit loop/recur; reach for loop only when the seq library genuinely doesn't fit.
  • Keep the core pure; push side effects to the edges and mark them with !.
  • Use a transducer (comp of xforms with into) when a pipeline is reused or performance-critical; otherwise plain threading reads better.
;; prefer
(->> documents
     (filter valid?)
     (map normalize)
     (group-by :category))

Name like clojure.core

Consistency with the standard library and with the surrounding namespace beats novelty. A reader who knows clojure.core should be able to guess what a name means.

  • Conventional parameter names: f, g, pred, coll, xs, x, s, m, k, v, n, acc, opts — and project conventions like conn, ident. Match the parameter names already used by sibling functions.
  • Systematic affixes: ->tokenizer-xf (constructor), node->hiccup (transform, arrow shows direction), persist-results! (side effect), valid? (predicate), -xf (transducer).
  • Simple verbs for transforms (keywordize), plural nouns for extraction (attribute-objects).
  • Namespaces: reverse-domain (dk.cst.project-name), kebab-case, a real docstring on the ns form, requires grouped logically (core libraries first), standard aliases (str, walk, io, json).

Docstrings

Every public var gets a docstring; it is part of the API.

  • Structure: a 1-2 line summary first; any further description goes in a separate paragraph after a blank line. Never one long run-on paragraph.
  • Mention every parameter in the first line, wrapped in backticks: "Convert xml (String, File, or InputStream) into Hiccup data."
  • Present tense, active voice ("Convert", not "Converts").
  • Multi-arity functions get one docstring on the name, not per arity.
  • Include a short example for non-obvious usage.
  • Keep docstring lines ≤ 80 characters; aim for the same in code.

Parameters and arities

  • Prefer multi-arity over options maps; the simple arity delegates to the fuller one. An options map only when there are genuinely many optional parameters.
  • Destructure vector parameters directly: (defn process-pair [[a b]] ...).
  • Never remove an :as binding just because the body doesn't reference it — it documents what the parameter IS. Treat an unused :as as deliberate in every review or cleanup.
  • Use declare for mutual recursion rather than reordering a namespace.

Private vars

Nothing with standalone meaning is private.

  • Only defns may be private (defn-), and only pure single-caller helpers with no standalone meaning.
  • def and defonce are never made private.
  • Do not introduce new private vars outside that rule, and do not privatize existing vars during cleanups.

Comments

Comments state intent and non-obvious mechanism — nothing else.

  • Match the comment density of the surrounding code.
  • Derivations, magic-number arithmetic, and iteration history belong in git history, not comments.
  • Document complex regexes; mark known limitations with TODO.
  • When in doubt, the comment is too long.

Constants

No blanket no-magic-numbers rule. Name a literal only when two call sites must agree or something silently breaks; a single-use literal stays inline, next to its only use, where the reader can see it.

REPL workflow

Development is REPL-driven; artifacts should reflect that.

  • New defs/defns go directly in the relevant namespace — never inside a comment block, and not in a scratch/user namespace.
  • Example and exploratory calls go in a rich (comment ...) block in the relevant namespace, ending with #_. so parinfer leaves the closing paren runnable:
(comment
  (parse sample-xml {:file-meta {:path :absolute}})
  ;; => [:root {} ...]
  #_.)
  • Use delay for expensive dev data so loading the namespace stays cheap.
  • Verify one specific aspect per evaluation; short focused evals over exhaustive test sweeps.

Use sparingly

Reader conditionals (#?) only in genuinely cross-platform code; complex destructuring only for tree/Hiccup shapes; metadata only when something actually consumes it; dynamic vars only for infrastructure (connections, servers). Most code should use the simpler alternative.

No better-cond inside rum/defc bodies

Never use better-cond's special keywords (:let, :when-let, :when) inside a rum/defc body. The CLJ expansion is correct, but rum/daiquiri's hiccup compilation macroexpands the CLJS body in an environment that loses the better-cond refer, so cond silently degrades to clojure.core/cond: the keyword becomes a truthy test and the binding vector is rendered as the branch. SSR looks fine while the browser renders garbage, so the bug is invisible from the backend. Hoist the bindings into a plain let above the cond instead. Plain defns are unaffected (e.g. transform-val* uses better-cond in CLJC without issue).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.