Skip to content

Instantly share code, notes, and snippets.

@humorless
Last active March 5, 2026 14:04
Show Gist options
  • Select an option

  • Save humorless/c8fd31d3b085c8493c8be1155d15cbf9 to your computer and use it in GitHub Desktop.

Select an option

Save humorless/c8fd31d3b085c8493c8be1155d15cbf9 to your computer and use it in GitHub Desktop.
CLAUDE.md extension for a new Clojure empty project (which is created by "Clojure Stack Lite")

Dev Workflow

  • After editing source files, use brepl to require the changed namespace with :reload and test interactively, rather than relying solely on curl or bb test.

Interactive Development Techniques

  • Call handlers directly — Ring handlers are pure functions (request map → response map). Test them in brepl without going through HTTP or middleware: (handlers/home-handler {}), (handlers/inspect-handler {}). Inspect response structure with (keys resp) before dumping the full body.
  • Verify routes with Reitit — Use reitit.core/match-by-path to check route matching interactively without a browser: (reitit.core/match-by-path (reitit.ring/router app-routes/routes) "/"). Useful for verifying newly added routes before integration testing.
  • Compose and inspect HoneySQL queries — Build queries incrementally as data and preview the generated SQL with (honey.sql/format query {:quoted true}) before sending to the database. This lets you verify correctness without executing against the DB.
  • Reflect on Java objects — When interacting with unfamiliar Java objects or Interop, use (clojure.reflect/reflect obj) to inspect available methods and types instead of guessing. For a cleaner view of public methods, use: (->> (clojure.reflect/reflect obj) :members (filter :exception-types)(map :name) sort)
  • Debugging — When investigating a bug, start with (ex-message *e) and (ex-data *e). If state seems stale, use (integrant.repl/reset) to sync the system. Call functions directly to inspect return values, query the DB with (db/exec! ds ...), and check the Integrant system via (keys integrant.repl.state/system).

Balanced REPL Exploration (Token Optimization)

  • Incremental Inspection — Always start with low-token queries: use (keys ...) to see structure, (count ...) for size, or (take 5 ...) for samples.
  • Escalation Path — If sampling is insufficient to diagnose the issue, you are encouraged to retrieve specific nested data or full objects, but do so purposefully (e.g., (get-in ...)).
  • State Verification — After modifying code, use brepl to call the affected functions directly. If the output is a massive data structure, summarize the key changes for the session instead of printing the whole thing.

Global Claude Code Instructions

Clojure Projects

When working in a Clojure project (identified by deps.edn or project.clj in the project root):

  1. Load /brepl at session start before writing or modifying any Clojure code.
  2. Default workflow — use brepl: For new features, refactoring, and exploratory work, use brepl to evaluate code, call functions directly, and verify changes interactively. Do not write tests unless asked.
  3. Bug fixes — write a test: When fixing a bug, write a failing test that reproduces the bug first, then fix the code and confirm the test passes.
  4. Post edit sync: After editing source files, use brepl to require the changed namespace with :reload and verify interactively.
  5. Pre-commit Check: Before finalizing a task or preparing a commit, always proactively ask if you should add or update tests for the new/modified logic to ensure long-term stability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment