Skip to content
Back to skills

Clojure Editing

ASecurity

Whole-form Clojure edits with the bundled form CLI — use when adding, replacing, or deleting a defn or any whole form in a .clj/.cljs/.cljc/.edn file, when brackets or parens are unbalanced, when a file no longer parses, or when checking a file after a hand edit.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsbash

Works with

  • claude code
  • cli

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add just-sultanov/clojure-skills --skill clojure-editing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clojure Editing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clojure Editing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/just-sultanov-clojure-editing/badge)](https://www.skillsdirectory.com/skills/just-sultanov-clojure-editing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clojure-editing
description: Whole-form Clojure edits with the bundled form CLI — use when adding, replacing, or deleting a defn or any whole form in a .clj/.cljs/.cljc/.edn file, when brackets or parens are unbalanced, when a file no longer parses, or when checking a file after a hand edit.
allowed-tools: Bash(bb ${CLAUDE_SKILL_DIR}/scripts/form.clj *)
---

# Clojure editing

Owns whole-form edits: the agent sends the text of one form read from the
file, and the tool owns brackets, layout, and validity. Token edits stay in
Edit; linting, renaming, and multi-file refactors belong to clj-kondo,
clojure-lsp, and the project's own tools.

## Requirements

- **Babashka on `PATH`.** The script has no `:deps`; it uses the Babashka
  built-ins and was tested with 1.13.230.
- **A POSIX filesystem.** File modes, symlinks, and `ATOMIC_MOVE` are part of
  the safety contract; Windows is not supported.
- **`cljfmt` is optional.** When it is on `PATH`, the edit is formatted; when
  it is missing, formatting is skipped with a warning. `--no-format` skips it
  explicitly.
- **Claude Code pre-approves the command.** The `allowed-tools` line matches
  the expanded `bb …` command; other harnesses ask before running it.

## Ground rules

- **One form, one call.** Address exactly one form; an ambiguous address is an
  error, never a first-match pick.
- **Copy the address from the file text.** `--at` compares written forms, not
  reader values ([addressing.md](references/addressing.md)).
- **Never balance brackets by hand.** If a call fails, the address or the
  payload is wrong; fix that instead of editing around the tool.
- **Do not `cd` into the skill.** File arguments and diff paths belong to the
  caller's directory; invoke the script by absolute path.
- **Formatting is the last step.** cljfmt runs only on a file that was already
  clean; `--no-format` skips it.
- **A refusal is a decision.** `--force` drops only the comments or `#_` the
  edit would remove; it never overrides an ambiguous address or a pair side.
- **Check after a token edit.** `form check` is the cheapest way to prove that
  a hand edit still parses and keeps pair parity.

## Locate the script

The skill directory is:

- `${CLAUDE_SKILL_DIR}` in Claude Code;
- the `Base directory for this skill:` line in OpenCode;
- the parent of the `SKILL.md` path in Pi's `location="…"`;
- otherwise the directory two levels above `scripts/form.clj`.

Call it as `bb "$SKILL_DIR/scripts/form.clj" …`, with `$SKILL_DIR` the resolved
absolute directory written literally into every command. No harness exports
`$SKILL_DIR`; the name is a placeholder for the path above. A wrapper — a
`SKILL_DIR=` prefix on the line, or the `form()` shorthand from the Examples —
is not covered by the `allowed-tools` pre-approval, which matches only the
expanded `bb …` command. The bit is not executable and must not be: APM hashes
bytes, not modes.

## Workflow

### 1. Read and check the file

Read the file with the harness's file-reading tool and keep the exact text of
the form you will address. Run `form check <file>` when the file is unfamiliar
or was just edited by hand. Done when the check exits 0 or every finding is
understood.

### 2. Name the address

Pick the narrowest address that still names one form:

- `--var f` for a top-level definition or `ns`;
- `--at '(<form>)'` for an exact form copied from the file text;
- `--line N` when the line holds one form and the text is hard to copy;
- `--in` to descend: a name resolves like `--var`, anything else is an address,
  and every level must match once.

Done when the address resolves to exactly one form; a `2` exit means zero or
several matches and the message lists the candidates.

### 3. Preview

Run the same command with `--dry-run` first when the payload is large or the
layout matters. It prints the same diff and writes nothing. Done when the diff
shows only the intended form.

### 4. Edit

```bash
bb "$SKILL_DIR/scripts/form.clj" replace src/app/core.clj \
  --in handler --at '(send-email (:user req) (:msg req))' \
  --with '(retry 3 %0)'
```

`replace` takes exactly one form and reinserts the anchor with `%0`; `remove`
takes no payload. How `%0`/`%%` expand and what a payload carries is in
[payloads.md](references/payloads.md). Done when the command exits 0,
`matched:` names the intended form, and the diff is the intended change.

### 5. Re-check

Run `form check` again after an edit made outside the tool, and after any token
Edit. Done when it exits 0.

## Commands

| Command   | Meaning                                                       |
| --------- | ------------------------------------------------------------- |
| `check`   | parse, UTF-8, BOM, EOL, and pair parity for one or more files |
| `replace` | replace one form with one form                                |
| `insert`  | insert forms before or after the anchor, as siblings          |
| `append`  | add forms at the end of the anchor collection                 |
| `remove`  | remove the anchor, or a whole pair when the anchor is its key |

`append` extends the addressed collection, so address the vector or map you
want to grow (`--at '[a 1 b 2]'`, `--at '(:require …)'`), not its parent.

## When it fails

- A `2` exit is an address problem: zero or several matches, and the message
  lists the candidates. Narrow the address.
- A `3` exit is usage: a flag the operation does not take.
- A `4` exit is I/O, or a file that changed under the tool; nothing was
  written. Re-read the file and retry.
- A `5` exit is a refusal: move the comment or `#_` into the payload, or pass
  `--force`.
- `unchanged` means the text did not change; nothing was written.
  `dry-run: not written` means the diff is the report.

Recovery per message and the full exit-code table are in
[results.md](references/results.md).

## Checklist

- [ ] The address matched exactly one form, and `matched:` shows the intended
      one.
- [ ] The diff touches only the intended span (or cljfmt's formatting).
- [ ] `form check` on the result exits 0, or the remaining finding predates
      the edit.
- [ ] No `--force` was used to get past an ambiguity or a pair side.
- [ ] The file kept its EOL, BOM, final newline, mode, and any symlink.

## Related skills

- `clojure-style` — whether the new form is idiomatic.
- `clojure-tooling` — cljfmt and clj-kondo configuration.
- `clojure-repl` — reloading the edited namespace.

## References

| File                                      | Read when                                                                  |
| ----------------------------------------- | -------------------------------------------------------------------------- |
| [commands.md](references/commands.md)     | building any call: invocation, dialects, command synopsis, flags, examples |
| [addressing.md](references/addressing.md) | choosing or narrowing `--at`, `--line`, `--var`, `--in`                    |
| [payloads.md](references/payloads.md)     | writing a payload: `%0`, `%%`, what a payload carries, the guard           |
| [pairs.md](references/pairs.md)           | maps and binding vectors: sides, parity                                    |
| [layout.md](references/layout.md)         | where an insert lands, what a removal takes with it                        |
| [results.md](references/results.md)       | reading output, exit codes, recovering from a failure                      |
| [project.md](references/project.md)       | embedding the rules in a product repo's `AGENTS.md`                        |

Files in this skill

  • SKILL.md7.4 KB
  • references/addressing.md4.6 KB
  • references/commands.md5.4 KB
  • references/layout.md3.9 KB
  • references/pairs.md1.6 KB
  • references/payloads.md2.9 KB
  • references/project.md1.2 KB
  • references/results.md7.7 KB
  • scripts/bb.edn327 B
  • scripts/form.clj72.7 KB
  • scripts/form_test.clj12.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.