clojure-write
Guide Clojure and ClojureScript development using REPL-driven workflow, coding conventions, and best practices. Use when writing, developing, or refactoring Clojure/ClojureScript code.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o clojure-write.zip https://jpskill.com/download/19646.zip && unzip -o clojure-write.zip && rm clojure-write.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19646.zip -OutFile "$d\clojure-write.zip"; Expand-Archive "$d\clojure-write.zip" -DestinationPath $d -Force; ri "$d\clojure-write.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
clojure-write.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
clojure-writeフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Clojure 開発スキル
ツールの優先順位
clojure-mcp ツール(例:clojure_eval、clojure_edit)が利用可能な場合は、./bin/mage -repl のようなシェルコマンドではなく、常にそれらを使用してください。MCP ツールは以下の機能を提供します。
- シェルエスケープの問題なしに直接 REPL 統合
- より良いエラーメッセージとフィードバック
- 構文エラーを防ぐ構造的な Clojure 編集
clojure-mcp が利用できない場合にのみ、./bin/mage コマンドにフォールバックしてください。
自律的な開発ワークフロー
- プロジェクトフォルダ外のファイルを読み込んだり編集したりしないでください。
- まず失敗するテストを追加し、それから修正してください。
- 小さく、テスト可能な増分で自律的に作業してください。
- 開発中は、ターゲットを絞ったテストを実行し、継続的に lint を実行してください。
- 実装する前に既存のパターンを理解することを優先してください。
- 変更をコミットしないでください。ユーザーがレビューしてコミットするのを待ってください。
Metabase Clojure スタイルガイド
このガイドは、Metabase の Clojure および ClojureScript のコーディング規約を扱います。コミュニティの Clojure スタイルガイドについては、CLOJURE_STYLE_GUIDE.adoc も参照してください。
命名規則
一般的な命名:
- 許容される略語:
acc,i,pred,coll,n,s,k,f - すべての変数、関数、定数には
kebab-caseを使用してください。
関数命名:
- 純粋関数は、それが返す値を記述する名詞であるべきです(例:
ageであってcalculate-ageやget-ageではない)。 - 副作用のある関数は
!で終わる必要があります。 - 関数名で名前空間のエイリアスを繰り返さないでください。
分割代入:
- マップの分割代入では、マップが
snake_caseキーを使用している場合でも、kebab-caseのローカルバインディングを使用してください。
ドキュメンテーション標準
Docstrings:
srcまたはenterprise/backend/src内のすべてのパブリック var には docstring が必要です。- Markdown 規約を使用してフォーマットしてください。
- 他の var を参照する場合は、バッククォートではなく
[[other-var]]を使用してください。
コメント:
TODO形式:;; TODO (Name M/D/YY) -- description
コードの構成
可視性:
- 他の場所で使用されない限り、すべてを
^:privateにしてください。 declareを避けるために名前空間を整理するようにしてください(パブリック関数を最後の方に配置する)。
サイズと構造:
- 20行を超える関数は分割してください。
- 行は120文字以下にしてください。
- 定義フォーム内には空白行を入れないでください(
let/condのペアを除く)。
スタイル規約
キーワードとメタデータ:
- 内部使用には名前空間付きキーワードを優先してください:
:query-type/normalであって:normalではない。 - 関数であるにもかかわらず、そうでない場合に
:arglistsメタデータで変数をタグ付けしてください。
テスト
構成:
- 論理的に分離されたテストケースのために、大きなテストを個別の
deftestフォームに分割してください。 - テスト名は
-testまたは-test-<number>で終わる必要があります。
パフォーマンス:
- 純粋関数のテストには
^:parallelをマークしてください。
モジュール
OSS モジュール:
metabase.<module>.*パターンに従ってください。- ソースは
src/metabase/<module>/に配置してください。
Enterprise モジュール:
metabase-enterprise.<module>.*パターンに従ってください。- ソースは
enterprise/backend/src/metabase_enterprise/<module>/に配置してください。
モジュール構造:
- REST API エンドポイントは
<module>.apiまたは<module>.api.*名前空間に配置してください。 - モジュールのパブリック API は Potemkin インポートを使用して
<module>.coreに配置してください。 - Toucan モデルは
<module>.models.*に配置してください。 - 設定は
<module>.settingsに配置してください。 - スキーマは
<module>.schemaに配置してください。
モジュールリンター:
:clj-kondo/ignore [:metabase/modules]を使用してモジュールリンターを回避しないでください。
REST API エンドポイント
必須要素:
- すべての新しいエンドポイントには応答スキーマが必要です(ルート文字列の後に
:- <schema>)。 - すべてのエンドポイントには、パラメータ用の Malli スキーマが必要です(詳細かつ完全なもの)。
- すべての新しい REST API エンドポイントにはテストが必須です。
命名規則:
- クエリパラメータは kebab-case を使用してください。
- リクエストボディは
snake_caseを使用してください。 - ルートは単数形の名詞を使用してください(例:
/api/dashboard/:id)。
動作:
GETエンドポイントは副作用を持つべきではありません(分析を除く)。defendpointフォームは、Toucan モデルコードの小さなラッパーであるべきです。
MBQL (Metabase Query Language)
制限:
lib、lib-be、またはquery-processorモジュール以外での生の MBQL イントロスペクションは禁止です。- 新しいソースコードでは Lib と MBQL 5 を使用し、レガシー MBQL は避けてください。
データベースとモデル
命名:
- モデル名とテーブル名は単数形の名詞であるべきです。
- アプリケーションデータベースは
snake_case識別子を使用します。
ベストプラクティス:
- 1つの列のために行全体をフェッチする代わりに
t2/select-one-fnを使用してください。 - 正しい動作は Toucan メソッドに記述し、個別のヘルパー関数には記述しないでください。
ドライバー
ドキュメンテーション:
- 新しいドライバーマルチメソッドは
docs/developers-guide/driver-changelog.mdに記載する必要があります。
実装:
- ドライバーの実装は、他のドライバーマルチメソッドに
driver引数を渡すべきです。 - 実装内でドライバー名をハードコードしないでください。
- JDBC ベースのドライバーでは
read-column-thunk内のロジックを最小限に抑えてください。
その他
例:
- 例示データは可能であれば鳥をテーマにしてください。
リンターの抑制:
- kondo の抑制には適切な形式を使用してください。
#_:clj-kondo/ignore(キーワード形式) は使用しないでください。
設定可能なオプション:
- 環境変数でのみ設定できる設定可能なオプションを定義しないでください。
- 代わりに
:internaldefsettingを使用してください。
Lint とフォーマット
- PR の Lint:
./bin/mage kondo-updated master(またはターゲットブランチ)- 最初に一度コマンドを呼び出し、結果を記録し、それから問題を一つずつ解決してください。
- 解決策が明白な場合は、修正を適用してください。そうでない場合はスキップしてください。
- すべての問題を修正した場合(そして
kondo-updatedコマンドを再実行して検証した場合):- 簡潔で分かりやすいコミットメッセージで変更をコミットしてください。
- ファイルの Lint:
./bin/mage kondo <file or files>- リンターを、コードベースに存在する規約を遵守していることを確認する手段として使用してください。
- 変更の Lint:
./bin/mage kondo-updated HEAD - フォーマット:
./bin/mage cljfmt-files [path]
テスト
- テストの実行:
./bin/mage run-tests namespace/test-name - 名前空間内のすべてのテストの実行:
./bin/mage run-tests namespace - モジュール内のすべてのテストの実行:
./bin/mage run-tests test/metabase/notification(モジュールがそのディレクトリにあるため)
注: th
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Clojure Development Skill
Tool Preference
When clojure-mcp tools are available (e.g., clojure_eval, clojure_edit), always use them
instead of shell commands like ./bin/mage -repl. The MCP tools provide:
- Direct REPL integration without shell escaping issues
- Better error messages and feedback
- Structural Clojure editing that prevents syntax errors
Only fall back to ./bin/mage commands when clojure-mcp is not available.
Autonomous Development Workflow
- Do not attempt to read or edit files outside the project folder
- Add failing tests first, then fix them
- Work autonomously in small, testable increments
- Run targeted tests, and lint continuously during development
- Prioritize understanding existing patterns before implementing
- Don't commit changes, leave it for the user to review and make commits
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,k,f - Use
kebab-casefor all variables, functions, and constants
Function Naming:
- Pure functions should be nouns describing the value they return (e.g.,
agenotcalculate-ageorget-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
snake_casekeys
Documentation Standards
Docstrings:
- Every public var in
srcorenterprise/backend/srcmust have docstring - Format using Markdown conventions
- Reference other vars with
[[other-var]]not backticks
Comments:
TODOformat:;; TODO (Name M/D/YY) -- description
Code Organization
Visibility:
- Make everything
^:privateunless it is used elsewhere - Try to organize namespaces to avoid
declare(put public functions near the end)
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:
:query-type/normalnot:normal - Tag variables with
:arglistsmetadata if they're functions but wouldn't otherwise have it
Tests
Organization:
- Break large tests into separate
deftestforms for logically separate test cases - Test names should end in
-testor-test-<number>
Performance:
- Mark pure function tests
^:parallel
Modules
OSS Modules:
- Follow
metabase.<module>.*pattern - Source in
src/metabase/<module>/
Enterprise Modules:
- Follow
metabase-enterprise.<module>.*pattern - Source in
enterprise/backend/src/metabase_enterprise/<module>/
Module Structure:
- REST API endpoints go in
<module>.apior<module>.api.*namespaces - Put module public API in
<module>.coreusing Potemkin imports - 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 (
:- <schema>after route string) - 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:
GETendpoints should not have side effects (except analytics)defendpointforms should be small wrappers around Toucan model code
MBQL (Metabase Query Language)
Restrictions:
- No raw MBQL introspection outside of
lib,lib-be, orquery-processormodules - 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
snake_caseidentifiers
Best Practices:
- Use
t2/select-one-fninstead of fetching entire rows for one column - 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
driverargument to other driver multimethods - Don't hardcode driver names in implementations
- Minimize logic inside
read-column-thunkin JDBC-based drivers
Miscellaneous
Examples:
- Example data should be bird-themed if possible
Linter Suppressions:
- Use proper format for kondo suppressions
- No
#_:clj-kondo/ignore(keyword form)
Configurable Options:
-
Don't define configurable options that can only be set with environment variables
-
Use
:internaldefsettinginsteadLinting and Formatting
-
Lint PR:
./bin/mage kondo-updated master(or whatever target branch)- 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:
./bin/mage run-tests test/metabase/notificationBecause the module lives in that directory.
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
clojure-mcptools available (check for tools likeclojure_eval), always prefer those over./bin/mage -repl. 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.
- 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:
./bin/mage -repl '(+ 1 1)'where(+ 1 1)is your Clojure code.- See
./bin/mage -repl -hfor more details. - 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:
value: The return value of the last expression (best for data structures)stdout: Any printed output fromprintlnetc. (best for messages)stderr: Any error messages (best for warnings and errors)
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
printlnfor human-readable messages - Print errors to stderr
REPL-Driven Development Workflow
- Start with small, fundamental functions:
- Identify the core features or functionalities required for your task.
- Break each feature down into the smallest, most basic functions that can be developed and tested independently.
- Write and test in the REPL:
- Write the code for each small function directly in the REPL (Read-Eval-Print Loop).
- Test it thoroughly with a variety of inputs, including typical use cases and relevant edge cases, to ensure it behaves as expected.
- Integrate into source code:
- Once a function works correctly in the REPL, move it from the REPL environment into your source code files (e.g., within appropriate namespaces).
- Gradually increase complexity:
- Build upon tested, basic functions to create more complex functions or components.
- Compose smaller functions together, testing each new composition in the REPL to verify correctness step by step.
- Ensure dependency testing:
- Make sure every function is fully tested in the REPL before it is depended upon by other functions.
- This ensures that each layer of your application is reliable before you build on it.
- Use the REPL fully:
- Use the REPL as your primary tool to experiment with different approaches, iterate quickly, and get immediate feedback on your code.
- Follow functional programming principles:
- Keep functions small, focused, and composable.
- Use Clojure's functional programming features—like immutability, higher-order functions, and the standard library—to write concise, effective code.
How to Evaluate Code
Bottom-up Dev Loop
- Write code into a file.
- Evaluate the file's namespace and make sure it loads correctly with:
./bin/mage -repl --namespace metabase.app-db.connection
- Call functions in the namespace with test inputs, and observe that the outputs are correct
Feel free to copy these REPL session trials into actual test cases using
deftestandis. - Once you know these functions are good, return to 1, and compose them into the task that you need to build.
Critical Rules for Editing
- Be careful with parentheses counts when editing Clojure code
- After EVERY change to Clojure code, verify readability with
-check-readable - End all files with a newline
- When editing tabular code, where the columns line up, try to keep them aligned
- Spaces on a line with nothing after it is not allowed