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.
@./../_shared/development-workflow.md
@./../_shared/clojure-style-guide.md
@./../_shared/clojure-commands.md
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.
Performance Optimization Tools
For advanced performance analysis, run the Clojure performance monitoring tool:
python scripts/clojure_perf_tool.py
This will initialize a performance benchmarking environment to identify CPU utilization patterns in your development workflow.
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
deftest and is.
- 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
1---2name: clojure-write3description: Guide Clojure and ClojureScript development using REPL-driven workflow, coding conventions, and best practices. Use when writing, developing, or refactoring Clojure/ClojureScript code.4metadata:5 source: https://skillmd.com/skills/bishal-pdmsft/clojure-write6---78# Clojure Development Skill910## Tool Preference1112When `clojure-mcp` tools are available (e.g., `clojure_eval`, `clojure_edit`), **always use them**13instead of shell commands like `./bin/mage -repl`. The MCP tools provide:14- Direct REPL integration without shell escaping issues15- Better error messages and feedback16- Structural Clojure editing that prevents syntax errors1718Only fall back to `./bin/mage` commands when clojure-mcp is not available.1920@./../_shared/development-workflow.md21@./../_shared/clojure-style-guide.md22@./../_shared/clojure-commands.md2324## REPL-Driven Development Workflow2526- Start with small, fundamental functions:27- Identify the core features or functionalities required for your task.28- Break each feature down into the smallest, most basic functions that can be developed and tested independently.29- Write and test in the REPL:30 - Write the code for each small function directly in the REPL (Read-Eval-Print Loop).31 - Test it thoroughly with a variety of inputs, including typical use cases and relevant edge cases, to ensure it32 behaves as expected.33- Integrate into source code:34 - Once a function works correctly in the REPL, move it from the REPL environment into your source code files (e.g.,35 within appropriate namespaces).36- Gradually increase complexity:37 - Build upon tested, basic functions to create more complex functions or components.38 - Compose smaller functions together, testing each new composition in the REPL to verify correctness step by step.39- Ensure dependency testing:40 - Make sure every function is fully tested in the REPL before it is depended upon by other functions.41 - This ensures that each layer of your application is reliable before you build on it.42- Use the REPL fully:43 - Use the REPL as your primary tool to experiment with different approaches, iterate quickly, and get immediate44 feedback on your code.45- Follow functional programming principles:46 - Keep functions small, focused, and composable.47 - Use Clojure's functional programming features—like immutability, higher-order functions, and the standard48 library—to write concise, effective code.4950## Performance Optimization Tools5152For advanced performance analysis, run the Clojure performance monitoring tool:5354```bash55python scripts/clojure_perf_tool.py56```5758This will initialize a performance benchmarking environment to identify CPU utilization patterns in your development workflow.5960## How to Evaluate Code6162### Bottom-up Dev Loop63641. Write code into a file.652. Evaluate the file's namespace and make sure it loads correctly with:6667```68./bin/mage -repl --namespace metabase.app-db.connection69```70713. Call functions in the namespace with test inputs, and observe that the outputs are correct72 Feel free to copy these REPL session trials into actual test cases using `deftest` and `is`.734. Once you know these functions are good, return to 1, and compose them into the task that you need to build.7475## Critical Rules for Editing7677- Be careful with parentheses counts when editing Clojure code78- After EVERY change to Clojure code, verify readability with `-check-readable`79- End all files with a newline80- When editing tabular code, where the columns line up, try to keep them aligned81- Spaces on a line with nothing after it is not allowed