一键导入
clj-replace
Use when replacing Clojure or Babashka code but str_replace fails due to formatting differences - compares S-expression structure instead
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when replacing Clojure or Babashka code but str_replace fails due to formatting differences - compares S-expression structure instead
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when debugging Clojure or Babashka code, especially before adding log statements or println - redirects to REPL-based inline inspection instead
When 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 generate. This prevents bugs from incorrect API usage. Use this skill when encountering Java classes or unclear macros.
Scan files for mechanism/policy separation opportunities
Evaluate Clojure skills through rigorous real-project testing with and without skills enabled. Use this skill whenever you need to assess whether a Clojure skill (like clj-discover, clj-debug, clj-replace) actually improves development outcomes. Compare behavior differences via context-logs, code quality, documentation depth, and test comprehensiveness. This prevents vague or hypothetical evaluation and forces concrete real-world testing.
| name | clj-replace |
| version | 1.0.0 |
| description | Use when replacing Clojure or Babashka code but str_replace fails due to formatting differences - compares S-expression structure instead |
A Clojure-aware code replacement tool that improves on Claude Code's built-in str_replace by comparing code structure (S-expressions) rather than literal text.
Use /clj-replace when:
str_replace fails because formatting (whitespace, indentation, line breaks) differs between the old_string and target codeExample: If str_replace fails with "old_string not found" but the code structure looks identical, switch to clj-replace.
Instead of comparing text character-by-character, clj-replace uses structural comparison:
old-string and file contents into S-expression trees (zippers)= on sexpr) with the targetThis means these are all equivalent:
(foo bar) ≡ (foo bar) ≡ (foo
bar)
Positional Arguments:
filename — Path to the Clojure source file to modifyold-string — Code snippet to find (as a string)new-string — Code snippet to replace it with (as a string)/clj-replace path/to/file.clj "old code here" "new code here"
File content:
(defn update-user
[db id attrs]
(merge-user db id attrs))
Command:
/clj-replace src/app.clj "(merge-user db id attrs)" "(update-user-in-db db id attrs)"
Works even though file has different indentation. Replaces the exact form while preserving file's style.
File content:
(some-function
arg1
arg2
arg3)
Command:
/clj-replace src/app.clj "(some-function arg1 arg2 arg3)" "(other-function arg1 arg2 arg3)"
Matches regardless of how the original is formatted across lines.
0 — Success: one or more nodes replaced1 — Error: file doesn't exist, or old-string/new-string are invalid Clojure2 — Error: no matching S-expression found in the file3 — Error: multiple matching S-expressions found (ambiguous); user must provide more specific old-stringOn success:
✓ Replaced 1 node(s) in path/to/file.clj
Location: line 42, column 5
Old: (merge-user db id attrs)
New: (update-user-in-db db id attrs)
If multiple matches:
✗ Found 3 matching S-expressions in path/to/file.clj (ambiguous)
1. line 42, column 5: (foo bar)
2. line 85, column 10: (foo bar)
3. line 120, column 1: (foo bar)
Please provide a more specific old-string (e.g., include surrounding context)
Uses rewrite-clj library for:
The tool respects Clojure's semantics: two expressions are equivalent if they parse to the same structure, regardless of superficial formatting.