$npx -y skills add humorless/clj-native-agent --skill clj-discoverWhen writing Clojure code with unfamiliar Java interop or macros, use this skill to explore and gather context. For Java interop, search for Clojure wrapper libraries first (via WebSearch), then explore Java classes if needed. For macros, expand them to understand what code they
| 1 | # Clojure Code Discovery |
| 2 | |
| 3 | When writing Clojure code with unfamiliar APIs, gather context before writing. This skill focuses on **Java interop** and **macros**. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | **Automatically use this skill whenever you encounter:** |
| 8 | |
| 9 | - A Java class that needs to be used from Clojure |
| 10 | - A macro whose behavior is unclear (need to see what it expands to) |
| 11 | |
| 12 | ## Workflow: Java Interop |
| 13 | |
| 14 | ### 1. Search for Clojure Wrappers First |
| 15 | |
| 16 | Before exploring the Java class directly, ask: |
| 17 | |
| 18 | > "I see you're working with `java.time.LocalDateTime`. Would you like me to search for a Clojure wrapper library? Wrappers often provide simpler, more idiomatic APIs." |
| 19 | |
| 20 | - **"Search for wrapper"** → Use WebSearch to find `clojure wrapper for <library-name>` |
| 21 | - **"Use Java directly"** → Skip to Java exploration below |
| 22 | |
| 23 | ### 2. Explore the Java Class |
| 24 | |
| 25 | If using Java directly, use brepl to reflect on the class: |
| 26 | |
| 27 | ```bash |
| 28 | brepl <<'EOF' |
| 29 | (require '[clojure.reflect :as r]) |
| 30 | |
| 31 | ; Get all public methods |
| 32 | (->> (r/reflect java.time.LocalDateTime) |
| 33 | :members |
| 34 | (filter #(instance? clojure.reflect.Method %)) |
| 35 | (map :name) |
| 36 | sort) |
| 37 | EOF |
| 38 | ``` |
| 39 | |
| 40 | Document findings: |
| 41 | - Available constructors or factory methods (e.g., `now()`, `of()`) |
| 42 | - Key methods and their return types |
| 43 | - Common patterns in your codebase |
| 44 | |
| 45 | ## Workflow: Macro Exploration |
| 46 | |
| 47 | When working with macros, expand them to understand what code they generate: |
| 48 | |
| 49 | ```bash |
| 50 | brepl <<'EOF' |
| 51 | (macroexpand-1 '(your-macro args)) ; expand one level |
| 52 | (macroexpand '(your-macro args)) ; fully expand |
| 53 | EOF |
| 54 | ``` |
| 55 | |
| 56 | Macro expansion reveals: |
| 57 | - What actual code runs when you use the macro |
| 58 | - Hidden function calls or side effects |
| 59 | - Whether the macro does what you think it does |