prompts/skills/clojure-docstring/SKILL.md
Guidelines for writing effective Clojure docstrings with markdown formatting, wikilinks, code examples, and tables. Always use this skill when writing or reviewing docstrings in Clojure code, or when asked about docstring formatting and style. Triggers on (1) writing new functions/vars/namespaces with docstrings, (2) updating existing docstrings, (3) questions about docstring best practices, (4) reviewing code with docstrings.
npx skillsauth add ramblurr/nix-devenv clojure-docstringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Write clear, scannable docstrings using markdown formatting. All docstrings are interpreted as Markdown on cljdoc and Codox.
Use backticks around function arguments and special keywords to improve readability:
(defn conj!
[coll x]
"Adds `x` to the transient collection, and return `coll`. The 'addition'
may happen at different 'places' depending on the concrete type."
,,,)
Cross-reference functions, namespaces, and Java classes using double-bracket syntax. Works in both Codex and cljdoc:
(defn unlisten!
"Removes registered listener from connection. See also [[listen!]]."
[conn key]
(swap! (:listeners (meta conn)) dissoc key))
For cross-namespace links, fully qualify:
(defn my-func
"Does something. See [[datascript.core/listen!]] for the underlying mechanism."
[conn]
,,,)
(defn query
"Executes query. See [[datascript.query]] namespace for details."
[db q]
,,,)
(defn parse-instant
"Parses timestamp string. Uses [[java.time.Instant]] internally."
[s]
,,,)
Show the function in context with code blocks:
(defn register
"Registers a dataloader controller with the application.
Usage:
```clojure
(def app
(-> (app-state/constructor)
(dataloader/register :current-user
{:target [:user]
:loader (fn [req]
(api/get-current-user))
:params (fn [prev route]
true)})))
The dataloader will automatically fetch data when params change." [app key config] ,,,)
### 4. Document Options Maps with Tables
Use markdown tables when a function accepts an options map with multiple keys:
```clojure
(defn router
"Creates a router from raw route data and optionally options map.
Options:
| key | description
| -----------------|-------------
| `:path` | Base-path for routes
| `:routes` | Initial resolved routes (default `[]`)
| `:data` | Initial route data (default `{}`)
| `:spec` | Spec to validate route data (default `nil`)
| `:syntax` | Path parameter syntax (default `:bracket`)
| `:expand` | Function to expand route data (default `identity`)
| `:coerce` | Function to coerce parameters (default `nil`)
| `:compile` | Function to compile routes (default `identity`)
| `:conflicts` | Function to handle route conflicts (default `nil`)
Example:
```clojure
(router
[[\"api\" {:middleware [wrap-api]}]
[\"admin\" {:middleware [wrap-admin]}]]
{:path \"/v1\"})
```"
([data]
(router data nil))
([data opts]
,,,))
For public functions, docstrings should contain these fields in order:
(defn process-data
"Processes incoming data and applies transformations.
The processor validates input, applies filters based on `opts`, and
returns transformed results. Invalid data is logged and skipped.
Options:
| key | description
|-------------|-------------
| `:filters` | Vector of filter functions to apply
| `:validate` | Enable validation (default `true`)
Example:
```clojure
(process-data items {:filters [remove-nil remove-empty]
:validate true})
```"
[items opts]
,,,)
For namespaces, use markdown sections with an optional "## Related Namespaces" section at the end:
(ns myapp.data.query
"Query execution and optimization.
## Query Processing
Queries are parsed, optimized, and executed against the database.
Use [[prepare-query]] to parse and validate before execution.
## Performance
Query results are cached by default. See `:cache` option to disable.
## Related Namespaces
- [[myapp.data.schema]] - Schema definitions
- [[myapp.data.index]] - Index management")
For private functions, docstrings are optional. Add them only for complex/complicated functions, especially when defining input/output constraints:
(defn- validate-config
"Validates configuration map.
Input: Map with required keys `:host`, `:port`, `:timeout`.
Output: Validated config map or throws ExceptionInfo."
[config]
,,,)
**text**) entirelyProjects with exemplary docstring work:
Credit: Content adapted from 4 Small Steps Towards Awesome Clojure Docstrings by Martin Klepsch.
testing
Use this OCP when executing or preparing to execute commands that change a live or important system, service reloads/restarts, package changes, deployments, migrations, firewall/network/access changes, credential rotation, NixOS switch/test/boot/deploy, or incident mitigation. It guides safe operations with a persisted ledger for scope, preflight, baseline, rollback, validation, and evidence.
development
Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
documentation
Naming conventions for workflow documents in prompts/. Use when creating plans, PRDs, research reports, idea capture or other workflow documents. Triggers on (1) creating new planning documents, (2) naming PRDs or research reports, (3) questions about document organization in prompts/.
testing
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.