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
| Tool | Version | Notes |
|---|---|---|
| Java | 21 or newer | |
| Clojure CLI | 1.12 or newer | |
| Babashka | any recent | Optional; runs the bb tasks below |
| Editor | any | Calva 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.
| Command | Equivalent | What it does |
|---|---|---|
bb repl | clojure -M:nrepl | Start a REPL with an nREPL server that editors can connect to |
bb test | clojure -X:test | Run all tests |
bb lint | clojure -M:lint and clojure -M:splint | Lint src/ and test/ with clj-kondo and Splint |
bb sins | Check the lint config still catches each sin in lint-fixtures/ (see Code review) | |
bb new-day 1 | Create src/aoc/day01.clj and a test that fails until you fill in the example's answer | |
bb tasks | List the bb tasks |
Other commands:
| Command | What it does |
|---|---|
clojure -M:1.13:nrepl | Start a REPL on the Clojure 1.13 alpha |
clojure -M -e '(clojure-version)' | Print the Clojure version |
Aliases
Defined in deps.edn.
| Alias | Adds | Use for |
|---|---|---|
:test | test/ on the classpath, test-runner, and test.check | Running tests, including property-based tests |
:nrepl | test/ on the classpath, and nREPL | A terminal REPL your editor can connect to |
:1.13 | Clojure 1.13.0-alpha11 instead of 1.12.7 | Trying 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) |
:lint | clj-kondo 2026.10.26 | Linting. Config: .clj-kondo/config.edn |
:splint | Splint 1.25.0 | Idiom linting. Config: .splint.edn |
:portal | Portal 0.68.1 | Inspecting data in a browser, e.g. -M:portal:nrepl |
:bench | Criterium 0.4.6 | Benchmarking, e.g. (criterium.core/quick-bench ...) |
:flow | core.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 |
:clerk | Clerk 0.18.1158 | Notebooks, e.g. (nextjournal.clerk/serve! {:browse true}) |
Aliases combine, e.g. clojure -M:portal:clerk:nrepl.
Dependencies
| Library | Version | Namespace | For |
|---|---|---|---|
| Clojure | 1.12.7 | clojure.core | The language |
| data.json | 2.5.2 | clojure.data.json | Reading and writing JSON |
| data.csv | 1.1.1 | clojure.data.csv | Reading 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.combinatorics | 0.3.2 | clojure.math.combinatorics | Combinations, permutations, products, subsets |
| math.numeric-tower | 0.1.1 | clojure.math.numeric-tower | gcd, lcm, exact expt and sqrt |
| data.priority-map | 1.2.1 | clojure.data.priority-map | Priority queues, e.g. for shortest paths |
| core.match | 1.1.1 | clojure.core.match | Pattern matching |
| Medley | 1.10.0 | medley.core | Small utility functions missing from clojure.core |
| instaparse | 1.5.0 | instaparse.core | Parsing input with a grammar |
| core.async | 1.9.865 | clojure.core.async | Channels and processes. core.async.flow needs the :flow alias |
| loom | 1.2.4 | loom.graph, loom.alg | Graph 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 |
| digest | 1.4.100 | clj-commons.digest | MD5, 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 Local | 1.0.301 | datomic.client.api | A 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.
| # | Sin | Caught by | Source |
|---|---|---|---|
| 1 | Side effects inside a lazy sequence (map with println) | clj-kondo unused-value, Splint lint/dorun-map (partly) | Clojure Don'ts: Lazy Effects |
| 2 | concat in a loop | a reviewer | Clojure Don'ts: Concat |
| 3 | Threading mistakes: -> vs ->>, as-> on its own | a reviewer | Clojure Don'ts: Thread as |
| 4 | read-string on input | clj-kondo discouraged-var (configured here) | read-string docstring |
| 5 | if with no else branch | clj-kondo missing-else-branch, Splint lint/if-else-nil | Clojure Don'ts: Single-branch if |
| 6 | def inside a function | clj-kondo inline-def | Style guide |
| 7 | Optional arguments faked with & [x] | a reviewer | Clojure Don'ts: Optional Arguments with Varargs |
| 8 | A parameter that might be a value or a collection | a reviewer | Clojure Don'ts: The Heisenparameter |
| 9 | #() misuse: needless wrappers, #([%]), %1 %2 | Splint lint/fn-wrapper (partly) | Clojure Don'ts: Short Fn Syntax |
| 10 | :refer :all, and locals that shadow clojure.core | clj-kondo refer-all, shadowed-var (turned on here) | Style guide |
| 11 | Java interop where Clojure has a function | Splint style/prefer-clj-string (partly) | Style guide |
| 12 | Datomic: querying more than one db value in one unit of work | a reviewer | Datomic 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.