Marketplace clojure-review
Review Clojure and ClojureScript code changes for compliance with Metabase coding standards, style violations, and code quality issues. Use when reviewing pull requests or diffs containing Clojure/ClojureScript code.
git clone https://github.com/aiskillstore/marketplace
T=$(mktemp -d) && git clone --depth=1 https://github.com/aiskillstore/marketplace "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/metabase/clojure-review" ~/.claude/skills/aiskillstore-marketplace-clojure-review && rm -rf "$T"
skills/metabase/clojure-review/SKILL.mdClojure Code Review Skill
Metabase Clojure Style Guide
This guide covers Clojure and ClojureScript coding conventions for Metabase. See also:
CLOJURE_STYLE_GUIDE.adoc for the Community Clojure Style Guide.
Naming Conventions
General Naming:
- Acceptable abbreviations:
,acc
,i
,pred
,coll
,n
,s
,kf - Use
for all variables, functions, and constantskebab-case
Function Naming:
- Pure functions should be nouns describing the value they return (e.g.,
notage
orcalculate-age
)get-age - Functions with side effects must end with
! - Don't repeat namespace alias in function names
Destructuring:
- Map destructuring should use kebab-case local bindings even if the map uses
keyssnake_case
Documentation Standards
Docstrings:
- Every public var in
orsrc
must have docstringenterprise/backend/src - Format using Markdown conventions
- Reference other vars with
not backticks[[other-var]]
Comments:
format:TODO;; TODO (Name M/D/YY) -- description
Code Organization
Visibility:
- Make everything
unless it is used elsewhere^:private - Try to organize namespaces to avoid
(put public functions near the end)declare
Size and Structure:
- Break up functions > 20 lines
- Lines ≤ 120 characters
- No blank lines within definition forms (except pairwise
/let
)cond
Style Conventions
Keywords and Metadata:
- Prefer namespaced keywords for internal use:
not:query-type/normal:normal - Tag variables with
metadata if they're functions but wouldn't otherwise have it:arglists
Tests
Organization:
- Break large tests into separate
forms for logically separate test casesdeftest - Test names should end in
or-test-test-<number>
Performance:
- Mark pure function tests
^:parallel
Modules
OSS Modules:
- Follow
patternmetabase.<module>.* - Source in
src/metabase/<module>/
Enterprise Modules:
- Follow
patternmetabase-enterprise.<module>.* - Source in
enterprise/backend/src/metabase_enterprise/<module>/
Module Structure:
- REST API endpoints go in
or<module>.api
namespaces<module>.api.* - Put module public API in
using Potemkin imports<module>.core - Put Toucan models in
<module>.models.* - Put settings in
<module>.settings - Put schemas in
<module>.schema
Module Linters:
- Do not cheat module linters with
:clj-kondo/ignore [:metabase/modules]
REST API Endpoints
Required Elements:
- All new endpoints must have response schemas (
after route string):- <schema> - All endpoints need Malli schemas for parameters (detailed and complete)
- All new REST API endpoints MUST HAVE TESTS
Naming Conventions:
- Query parameters use kebab-case
- Request bodies use
snake_case - Routes use singular nouns (e.g.,
)/api/dashboard/:id
Behavior:
endpoints should not have side effects (except analytics)GET
forms should be small wrappers around Toucan model codedefendpoint
MBQL (Metabase Query Language)
Restrictions:
- No raw MBQL introspection outside of
,lib
, orlib-be
modulesquery-processor - Use Lib and MBQL 5 in new source code; avoid legacy MBQL
Database and Models
Naming:
- Model names and table names should be singular nouns
- Application database uses
identifierssnake_case
Best Practices:
- Use
instead of fetching entire rows for one columnt2/select-one-fn - Put correct behavior in Toucan methods, not separate helper functions
Drivers
Documentation:
- New driver multimethods must be mentioned in
docs/developers-guide/driver-changelog.md
Implementation:
- Driver implementations should pass
argument to other driver multimethodsdriver - Don't hardcode driver names in implementations
- Minimize logic inside
in JDBC-based driversread-column-thunk
Miscellaneous
Examples:
- Example data should be bird-themed if possible
Linter Suppressions:
- Use proper format for kondo suppressions
- No
(keyword form)#_:clj-kondo/ignore
Configurable Options:
- Don't define configurable options that can only be set with environment variables
- Use
:internal
insteaddefsetting
Linting and Formatting
- Lint PR:
(or whatever target branch)./bin/mage kondo-updated master- Call the command one time at the beginning, record the results, then work through the problems one at a time.
- If the solution is obvious, then please apply the fix. Otherwise skip it.
- If you fix all the issues (and verify by rerunning the kondo-updated command):
- commit the change with a succinct and descriptive commit message
- Lint File:
./bin/mage kondo <file or files>- Use the linter as a way to know that you are adhering to conventions in place in the codebase
- Lint Changes:
./bin/mage kondo-updated HEAD - Format:
./bin/mage cljfmt-files [path]
Testing
- Run a test:
./bin/mage run-tests namespace/test-name - Run all tests in a namespace:
./bin/mage run-tests namespace - Run all tests for a module:
Because the module lives in that directory../bin/mage run-tests test/metabase/notification
Note: the
./bin/mage run-tests command accepts multiple args, so you can pass
./bin/mage run-tests namespace/test-name namespace/other-test namespace/third-test
to run 3 tests, or
./bin/mage run-tests test/metabase/module1 test/metabase/module2 to run 2 modules.
Code Readability
- Check Code Readability:
./bin/mage -check-readable <file> [line-number]- Run after every change to Clojure code
- Check specific line first, then entire file if readable
REPL Usage
Note: If you have
tools available (check for tools likeclojure-mcp), always prefer those overclojure_eval. The MCP tools provide better integration, richer feedback, and avoid shell escaping issues. Only use./bin/mage -replas a fallback when clojure-mcp is not available../bin/mage -repl
- Evaluating Clojure Code:
./bin/mage -repl '<code>'- See "Sending Code to the REPL" section for more details
Sending Code to the REPL
- Send code to the metabase process REPL using:
where./bin/mage -repl '(+ 1 1)'
is your Clojure code.(+ 1 1)- See
for more details../bin/mage -repl -h - If the Metabase backend is not running, you'll see an error message with instructions on how to start it.
- See
Working with Files and Namespaces
- Load a file and call functions with fully qualified names:
To call
your.namespace/your-function on arg1 and arg2:
./bin/mage -repl --namespace your.namespace '(your-function arg1 arg2)'
DO NOT use "require", "load-file" etc in the code string argument.
Understanding the Response
The
./bin/mage -repl command returns three separate, independent outputs:
: The return value of the last expression (best for data structures)value
: Any printed output fromstdout
etc. (best for messages)println
: Any error messages (best for warnings and errors)stderr
Example call:
./bin/mage -repl '(println "Hello, world!") '\''({0 1, 1 3, 2 0, 3 2} {0 2, 1 0, 2 3, 3 1})'
Example response:
ns: user session: 32a35206-871c-4553-9bc9-f49491173d1c value: ({0 1, 1 3, 2 0, 3 2} {0 2, 1 0, 2 3, 3 1}) stdout: Hello, world! stderr:
For effective REPL usage:
- Return data structures as function return values
- Use
for human-readable messagesprintln - Print errors to stderr
Review guidelines
What to flag:
- Check compliance with the Metabase Clojure style guide (included above)
- If
exists in the working directory, also check compliance with the community Clojure style guideCLOJURE_STYLE_GUIDE.adoc - Flag all style guide violations
What NOT to post:
- Do not post comments congratulating someone for trivial changes or for following style guidelines
- Do not post comments confirming things "look good" or telling them they did something correctly
- Only post comments about style violations or potential issues
Example bad code review comments to avoid:
This TODO comment is properly formatted with author and date - nice work!
Good addition of limit 1 to the query - this makes the test more efficient without changing its behavior.
The kondo ignore comment is appropriately placed here
Test name properly ends with -test as required by the style guide.
Special cases:
- Do not post comments about missing parentheses (these will be caught by the linter)
Quick review checklist
Use this to scan through changes efficiently:
Naming
- Descriptive names (no
,tbl
)zs' - Pure functions named as nouns describing their return value
-
for all variables and functionskebab-case - Side-effect functions end with
! - No namespace-alias repetition in function names
Documentation
- Public vars in
orsrc
have useful docstringsenterprise/backend/src - Docstrings use Markdown conventions
- References use
not backticks[[other-var]] -
comments include author and date:TODO;; TODO (Name 1/1/25) -- description
Code Organization
- Everything
unless used elsewhere^:private - No
when avoidable (public functions near end)declare - Functions under 20 lines when possible
- No blank lines within definition forms (except pairwise constructs in
/let
)cond - Lines ≤ 120 characters
Tests
- Separate
forms for distinct test casesdeftest - Pure tests marked
^:parallel - Test names end in
or-test-test-<number>
Modules
- Correct module patterns (OSS:
, EE:metabase.<module>.*
)metabase-enterprise.<module>.* - API endpoints in
namespaces<module>.api - Public API in
with Potemkin<module>.core - No cheating module linters with
:clj-kondo/ignore [:metabase/modules]
REST API
- Response schemas present (
):- <schema> - Query params use kebab-case, bodies use
snake_case - Routes use singular nouns (e.g.,
)/api/dashboard/:id -
has no side effects (except analytics)GET - Malli schemas detailed and complete
- All new endpoints have tests
MBQL
- No raw MBQL manipulation outside
,lib
, orlib-be
modulesquery-processor - Uses Lib and MBQL 5, not legacy MBQL
Database
- Model and table names are singular nouns
- Uses
instead of selecting full rows for one columnt2/select-one-fn - Logic in Toucan methods, not helper functions
Drivers
- New multimethods documented in
docs/developers-guide/driver-changelog.md - Passes
argument to other driver methods (no hardcoded driver names)driver - Minimal logic in
read-column-thunk
Miscellaneous
- Example data is bird-themed when possible
- Kondo linter suppressions use proper format (not
keyword form)#_:clj-kondo/ignore
Pattern matching table
Quick scan for common issues:
| Pattern | Issue |
|---|---|
, | Pure functions should be nouns: , |
, | Missing for side effects: , |
| Should use kebab-case |
| Public var without docstring | Add docstring explaining purpose |
| Missing author/date: |
in namespace used elsewhere | Should be |
| Function > 20 lines | Consider breaking up into smaller functions |
| Use singular: |
Query params with | Use kebab-case for query params |
| New API endpoint without tests | Add tests for the endpoint |
Feedback format examples
For style violations:
This pure function should be named as a noun describing its return value. Consider
instead ofuser.get-user
For missing documentation:
This public var needs a docstring explaining its purpose, inputs, and outputs.
For organization issues:
This function is only used in this namespace, so it should be marked
.^:private
For API conventions:
Query parameters should use kebab-case. Change
touser_id.user-id