- Use
iffor single condition checks, notcond - Only use
condfor multiple condition branches - Prefer
if-letandwhen-letfor binding and testing a value in one step - Consider
whenfor conditionals with single result and no else branch - consider
cond->, andcond->>
- Minimize code points by avoiding unnecessary
letbindings - Only use
letwhen a value is used multiple times or when clarity demands it - Inline values used only once rather than binding them to variables
- Use threading macros (
->,->>) to eliminate intermediate bindings
- Use destructuring in function parameters when accessing multiple keys
- Example:
[{:keys [::zloc ::match-form] :as ctx}]for namespaced keys instead of separateletbindings - Example:
[{:keys [zloc match-form] :as ctx}]for regular keywords
- Track actual values instead of boolean flags where possible
- Use early returns with
whenrather than deeply nested conditionals - Return
nilfor "not found" conditions rather than objects with boolean flags
- Do not include comments in generated code, unless specifically asked to.
- Minimize nesting levels by using proper control flow constructs
- Use threading macros (
->,->>) for sequential operations
- Functions should generally do one thing
- Pure functions preferred over functions with side effects
- Return useful values that can be used by callers
- smaller functions make edits faster and reduce the number of tokens
- reducing tokens makes me happy
- Prefer
clojure.stringfunctions over Java interop for string operations- Use
str/ends-with?instead of.endsWith - Use
str/starts-with?instead of.startsWith - Use
str/includes?instead of.contains - Use
str/blank?instead of checking.isEmptyor.trim
- Use
- Follow Clojure naming conventions (predicates end with
?) - Favor built-in Clojure functions that are more expressive and idiomatic
- Always reload namespaces with
:reloadflag:(require '[namespace] :reload) - Always change into namespaces that you are working on
- Always reload namespaces before running tests with
:reloadflag:(require '[namespace] :reload) - Test both normal execution paths and error conditions
-
Prefer the idiomatic
clojure.java.shell/shfor executing shell commands -
Always handle potential errors from shell command execution
-
Use explicit working directory for relative paths:
(shell/sh "cmd" :dir "/path") -
For testing builds and tasks, run
clojure -X:testinstead of running tests piecemeal -
When capturing shell output, remember it may be truncated for very large outputs
-
Consider using shell commands for tasks that have mature CLI tools like diffing or git operations
-
Context Maintenance:
- Use
clojure_evalwith:reloadto ensure you're working with the latest code - always switch into
(in-ns ...)the namespace that you are working on - Keep function and namespace references fully qualified when crossing namespace boundaries
- Use