You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
“Use the repl” means to use the **Evaluate Clojure Code** tool from Calva Backseat Driver. It connects you to the the same REPL as the user is connected to via Calva.
10
+
“Use the repl” means to use the **Evaluate Clojure Code** tool from Calva Backseat Driver. It connects you to the same REPL as the user is connected to via Calva.
11
11
12
12
- Always stay inside Calva's REPL instead of launching a second one from the terminal.
13
13
- If there is no REPL connection, ask the user to connect the REPL instead of trying to start and connect it yourself.
@@ -36,12 +36,67 @@ Docstrings belong immediately after the function name and before the argument ve
36
36
37
37
- Define functions before they are used—prefer ordering over `declare` except when truly necessary.
### Align Data Structure Elements for Bracket Balancing
42
+
**Always align multi-line elements vertically in all data structures: vectors, maps, lists, sets, all code (since Clojure code is data). Misalignment causes the bracket balancer to close brackets incorrectly, creating invalid forms.**
**Never edit code files when the REPL is unavailable.** When REPL evaluation returns errors indicating that the REPL is unavailable, stop immediately and inform the user. Let the user restore REPL before continuing.
89
+
90
+
#### Why This Matters
91
+
-**Interactive Programming requires a working REPL** - You cannot verify behavior without evaluation
92
+
-**Guessing creates bugs** - Code changes without testing introduce errors
93
+
39
94
## Structural Editing and REPL-First Habit
40
95
- Develop changes in the REPL before touching files.
41
96
- When editing Clojure files, always use structural editing tools such as **Insert Top Level Form**, **Replace Top Level Form**, **Create Clojure File**, and **Append Code**, and always read their instructions first.
42
97
43
98
### Creating New Files
44
-
- Use the **Create Clojure File** tool, with initial content
99
+
- Use the **Create Clojure File** tool with initial content
45
100
- Follow Clojure naming rules: namespaces in kebab-case, file paths in matching snake_case (e.g., `my.project.ns` → `my/project/ns.clj`).
46
101
47
102
### Reloading Namespaces
@@ -51,22 +106,6 @@ After editing files, reload the edited namespace in the REPL so updated definiti
51
106
(require 'my.namespace :reload)
52
107
```
53
108
54
-
### Keeping Brackets Balanced
55
-
If tools or the compiler signal bracket imbalance, stop and ask for help rather than guessing—use the human-input tool.
56
-
57
-
## Interactive Programming with REPL
58
-
59
-
When evaluating code during development, always show the complete code being evaluated in a code block before using evaluation tools. The code block should start with the appropriate `(in-ns ...)` form and contain the exact code being evaluated, so the human can run the same code in their REPL.
60
-
61
-
Example:
62
-
```clojure
63
-
(in-ns 'my.namespace)
64
-
(let [test-data {:name"example"}]
65
-
(process-data test-data))
66
-
```
67
-
68
-
This applies to all REPL-driven development, whether using Calva, Joyride, or other Clojure evaluation tools.
69
-
70
109
## Code Indentation Before Evaluation
71
110
Consistent indentation is crucial to help the bracket balancer.
72
111
@@ -121,7 +160,7 @@ You can also use "inline def" when showing the user code in the chat, to make it
121
160
122
161
## Return values > print side effects
123
162
124
-
Prefer using the repl and return values from your evaluations, over printing things to stdout.
163
+
Prefer using the REPL and return values from your evaluations, over printing things to stdout.
125
164
126
165
## Reading from `stdin`
127
166
- When Clojure code uses `(read-line)`, it will prompt the user through VS Code.
@@ -272,9 +311,9 @@ Iterate with real data before editing files.
272
311
```
273
312
274
313
#### Benefits
275
-
- Verified behaviour before committing changes
314
+
- Verified behavior before committing changes
276
315
- Incremental development with immediate feedback
277
-
- Tests that capture known-good behaviour
316
+
- Tests that capture known-good behavior
278
317
- Start new work with failing tests to lock in intent
279
318
280
319
### Test Naming and Messaging
@@ -307,3 +346,4 @@ Guidelines:
307
346
## Happy Interactive Programming
308
347
309
348
Remember to prefer the REPL in your work. Keep in mind that the user does not see what you evaluate. Nor the results. Communicate with the user in the chat about what you evaluate and what you get back.
0 commit comments