Power Tools & ParensIt's dangerous to go alone! Take this.

EN · PT-BR · em breve

clojure-template-aoc

A starter Clojure project with a REPL, tests, and the libraries puzzle solving usually needs. It's built for Advent of Code but works for any small Clojure project.

Clojure is a power tool for evolving systems, and each Advent of Code day is a small evolving system: part 2 usually changes the question part 1 asked. The setup here supports that loop. A REPL stays running, your data is there to look at, and a test tells you whether part 1 still holds after you change things for part 2.

This README is a reference. For a guided start, see the tutorial. New to setting up Clojure? Start with the setup flowchart.

Requirements

ToolVersionNotes
Java21 or newer
Clojure CLI1.12 or newer
Babashkaany recentOptional; runs the bb tasks below
EditoranyCalva for VS Code is preinstalled in the devcontainer

Or skip installing: open the repo in a devcontainer or GitHub Codespace. If you're new to installing these tools, the setup flowchart walks through each one.

Commands

Run from the repo root. Most bb tasks have a plain clojure equivalent; bb sins and bb new-day don't.

CommandEquivalentWhat it does
bb replclojure -M:nreplStart a REPL with an nREPL server that editors can connect to
bb testclojure -X:testRun all tests
bb lintclojure -M:lint and clojure -M:splintLint src/ and test/ with clj-kondo and Splint
bb sinsCheck the lint config still catches each sin in lint-fixtures/ (see Code review)
bb new-day 1Create src/aoc/day01.clj and a test that fails until you fill in the example's answer
bb tasksList the bb tasks

Other commands:

CommandWhat it does
clojure -M:1.13:nreplStart a REPL on the Clojure 1.13 alpha
clojure -M -e '(clojure-version)'Print the Clojure version

Aliases

Defined in deps.edn.

AliasAddsUse for
:testtest/ on the classpath, test-runner, and test.checkRunning tests, including property-based tests
:nrepltest/ on the classpath, and nREPLA terminal REPL your editor can connect to
:1.13Clojure 1.13.0-alpha11 instead of 1.12.7Trying 1.13 features. Combine with other aliases, e.g. -M:1.13:nrepl. alpha11 predates the 1.12.7 serialization fix (GHSA-x4c4-68gp-vrhc)
:lintclj-kondo 2026.10.26Linting. Config: .clj-kondo/config.edn
:splintSplint 1.25.0Idiom linting. Config: .splint.edn
:portalPortal 0.68.1Inspecting data in a browser, e.g. -M:portal:nrepl
:benchCriterium 0.4.6Benchmarking, e.g. (criterium.core/quick-bench ...)
:flowcore.async 1.10.874-alpha3 instead of 1.9.865, plus flow/ and flow-test/core.async.flow, which ships only in core.async alphas. Run its test with clojure -M:flow:test -d flow-test
:clerkClerk 0.18.1158Notebooks, e.g. (nextjournal.clerk/serve! {:browse true})

Aliases combine, e.g. clojure -M:portal:clerk:nrepl.

Dependencies

LibraryVersionNamespaceFor
Clojure1.12.7clojure.coreThe language
data.json2.5.2clojure.data.jsonReading and writing JSON
data.csv1.1.1clojure.data.csvReading and writing real CSV, e.g. to and from spreadsheets. Puzzle input is rarely CSV; src/howto/json_csv.clj shows the idioms that fit it
math.combinatorics0.3.2clojure.math.combinatoricsCombinations, permutations, products, subsets
math.numeric-tower0.1.1clojure.math.numeric-towergcd, lcm, exact expt and sqrt
data.priority-map1.2.1clojure.data.priority-mapPriority queues, e.g. for shortest paths
core.match1.1.1clojure.core.matchPattern matching
Medley1.10.0medley.coreSmall utility functions missing from clojure.core
instaparse1.5.0instaparse.coreParsing input with a grammar
core.async1.9.865clojure.core.asyncChannels and processes. core.async.flow needs the :flow alias
loom1.2.4loom.graph, loom.algGraph algorithms: paths, connected components, topological sort, cliques, max flow. Excludes tailrecursion/cljs-priority-map, which only ClojureScript needs. src/howto/graphs.clj also shows BFS by hand
digest1.4.100clj-commons.digestMD5, SHA and other hashes as plain functions. Java's built-in java.security.MessageDigest does the same with interop; src/howto/hashing.clj shows both
Datomic Local1.0.301datomic.client.apiA Datalog database, in memory or on disk. Free; binaries are Apache 2.0

Layout

deps.edn               dependencies and aliases
bb.edn                 babashka tasks
docs/                  the setup flowchart and the tutorial
inputs/                your puzzle inputs (git-ignored; see below)
src/aoc/input.clj      reads inputs/dayNN.txt
src/aoc/day00.clj      a made-up example day: example, parse, part-1, part-2
src/howto/             one namespace per how-to (JSON and CSV, combinatorics, shortest paths, Datomic,
                       parsing with instaparse, hashing, core.async channels, graphs,
                       reading an error)
flow/, flow-test/      the core.async.flow how-to and its test (:flow alias only)
test/                  tests; test/howto/ checks every result shown in src/howto/
lint-fixtures/         deliberately sinful code that `bb sins` lints (not on the classpath)
.devcontainer/         devcontainer and Codespaces setup
ai/                    optional AI tooling; safe to delete (see ai/README.md)
AGENTS.md              symlink to ai/AGENTS.md, so agents find it

Inputs

Save each day's input as inputs/dayNN.txt, e.g. inputs/day01.txt. Read it with (aoc.input/slurp-day 1).

inputs/ is git-ignored except for .gitkeep. Advent of Code asks that repositories not include puzzle text or inputs (FAQ).

Devcontainer

.devcontainer/devcontainer.json uses the mcr.microsoft.com/devcontainers/java:1-21 image, installs the Clojure CLI and Babashka, downloads the dependencies, and adds Calva. In GitHub, click Use this template → Open in a codespace, or make your copy first and use Code → Codespaces → Create codespace on it.

Code review

Twelve common mistakes in Clojure code, and what catches them. A linter catches seven of them, at least partly. The other five need a person reading the code.

#SinCaught bySource
1Side effects inside a lazy sequence (map with println)clj-kondo unused-value, Splint lint/dorun-map (partly)Clojure Don'ts: Lazy Effects
2concat in a loopa reviewerClojure Don'ts: Concat
3Threading mistakes: -> vs ->>, as-> on its owna reviewerClojure Don'ts: Thread as
4read-string on inputclj-kondo discouraged-var (configured here)read-string docstring
5if with no else branchclj-kondo missing-else-branch, Splint lint/if-else-nilClojure Don'ts: Single-branch if
6def inside a functionclj-kondo inline-defStyle guide
7Optional arguments faked with & [x]a reviewerClojure Don'ts: Optional Arguments with Varargs
8A parameter that might be a value or a collectiona reviewerClojure Don'ts: The Heisenparameter
9#() misuse: needless wrappers, #([%]), %1 %2Splint lint/fn-wrapper (partly)Clojure Don'ts: Short Fn Syntax
10:refer :all, and locals that shadow clojure.coreclj-kondo refer-all, shadowed-var (turned on here)Style guide
11Java interop where Clojure has a functionSplint style/prefer-clj-string (partly)Style guide
12Datomic: querying more than one db value in one unit of worka reviewerDatomic best practices

bb sins lints lint-fixtures/twelve_sins.clj, which commits the sins a linter can see, and fails if any expected warning is missing.

One check is turned off. clj-kondo's unused-binding warning (an argument or let name you never use) is off in the day namespaces: aoc.day00, aoc.day01, and so on. That's because bb new-day writes empty stubs such as (defn part-1 [s]), so every new day would start with two warnings before you'd written anything. The trade-off is that an argument you forget to use in your own day code isn't reported either. The how-tos, the tests and everything else still get the warning. The setting is the :ns-groups and :config-in-ns entries in .clj-kondo/config.edn. To turn the check back on, delete them.

Known warnings

On newer JVMs, Datomic Local prints WARNING: A terminally deprecated method in sun.misc.Unsafe has been called. It comes from one of its dependencies (caffeine) and is harmless.

AI

AI tooling is optional and lives in ai/. The root AGENTS.md is a symlink to ai/AGENTS.md, so agents find it. The instructions ask agents to act as a tutor: answer questions and give hints, but not change your code. To opt out, delete ai/ and AGENTS.md.

License

Copyright (c) 2026 Jordan Miller. Distributed under the Eclipse Public License 2.0.

Join #adventofcode on Clojurians SlackNo account? Sign up