/replicant:replicantfrom replicant
Builds Replicant views as pure functions of state using hiccup, handles event handlers and life-cycle hooks as data, tests views with lookup, and redefines views in a running app from the REPL.
Ships in replicant. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Replicant renders hiccup to the DOM, or to a string. The app renders its whole UI again each time its state changes, and Replicant changes only what differs from the last render. This skill is about building views with Replicant as an agent with a REPL: what holds for a view, where Replicant's traps are, how to test a view as data, and how to work on the view of a running app. Replicant's own user guide covers the library, and its API reference the functions.
This skill stands on the clojure skill, in the clojure plugin. The loop a view's event handlers dispatch to is the uniflow skill's, in the uniflow plugin. Its reference Uniflow with Replicant, references/uniflow-with-replicant.md in the uniflow skill, wires Replicant's dispatch into the loop, with the data Replicant hands over and the placeholders it fills in.
Replicant's source and changelog are on Codeberg, and its releases on Clojars as no.cjohansen/replicant. Where a version matters, this skill says which, so check the version in the project's dependencies.
A view takes data and returns hiccup. It reads nothing but its arguments: no atoms, no fetching, no state of its own, since Replicant has no component state. What it does is data in its event handlers. The app calls replicant.dom/render with its root element and the whole view each time the state changes, and Replicant compares the new hiccup with the hiccup it rendered last. A part whose hiccup is equal to last time's is skipped, so rendering everything again costs little.
Values the view computes from the state, such as a count or a grouping, go in pure functions of their own, a props or view-model function the view calls. They are tested with data, and the view keeps to layout.
Since a view is data in and data out, a view in a .cljc file can be checked in any REPL, including a clj or bb one: call it, read the hiccup, and render it to a string. The browser is needed only for what happens in the DOM.
(defn add-button [{:ui/keys [busy?]}]
[:button.primary {:class (when busy? "busy")
:style {:max-width 200 :font-weight 600}
:disabled busy?
:on {:click [[:todo/ax.submit [:db/get :ui/draft]]]}}
"Add"])
(replicant.string/render (add-button {:ui/busy? true}))
;; => "<button style=\"max-width: 200px; font-weight: 600;\" disabled class=\"busy primary\">Add</button>"
(replicant.string/render (add-button {:ui/busy? false}))
;; => "<button style=\"max-width: 200px; font-weight: 600;\" class=\"primary\">Add</button>"
The string leaves out event handlers, keys and life-cycle hooks.
| Attribute | What it takes |
|---|---|
:class | A keyword, a string without spaces, or a collection of them, added to the classes in the tag (:button.primary) |
:style | A map with keyword keys, dash-cased as in CSS. A number is pixels where CSS takes a length |
:on | Event handlers by the browser's event name, in lower case: {:click …, :input …} |
:replicant/key | An element's identity among its siblings with the same tag |
:replicant/on-mount, :replicant/on-update, :replicant/on-unmount, :replicant/on-render | Life-cycle hooks |
:replicant/mounting, :replicant/unmounting | Attributes for while the element is added and removed, for transitions |
:value, :checked, :selected | The value of a controlled form field. :default-value, :default-checked and :default-selected set where an uncontrolled one starts |
:innerHTML | HTML that takes the place of the children |
An attribute that is nil or false is left out, and a nil child is fine, so when works in both places. A tag that is a qualified keyword, such as :ui/button, is an alias: a function registered with replicant.alias/defalias. The guide's Hiccup and Aliases pages have the rest.
In a development build, one without :advanced or :simple optimizations, Replicant reports mistakes in the browser console: a :class string with spaces, a :style string, :className, an event attribute such as :onClick, event names and style keys with the wrong case, and an attribute map wrapped in a conditional. Read the console after changing a view.
An event handler under :on is a function or data. Replicant adds a function with addEventListener and calls it with the JS event. Data, such as [[:todo/ax.submit [:db/get :ui/draft]]], goes to the one dispatch function the app registered with replicant.dom/set-dispatch!, together with a map of dispatch data about the event. In a Uniflow app the data is a vector of actions, and the dispatch function hands them to the loop, as Uniflow with Replicant shows. Write handlers as data:
What to know about data handlers:
Cannot use non-function event handler when replicant.core/*dispatch* is not bound to a function, and one with a data hook throws Cannot use non-function life-cycle hook ….{:replicant.event/handler f :replicant.event/wrap-handler? true} gets the dispatch data instead of the event, and can dispatch data with the registered function in it after looking at the event. Uniflow with Replicant lists what the dispatch data holds.Replicant reuses the element in the same place with the same tag and key, and changes it into what the new hiccup says. Siblings with the same tag that move, come and go, and have hooks, transitions or state in the DOM, such as an input's value or focus, need :replicant/key. A changed key makes a new element. Keys and life-cycle hooks has the details and the traps.
Replicant releases before 2026.11.1 can lose the update of a keyed element that moves to an earlier place among its siblings. When a render moves a keyed element forward and changes it, Replicant records it as it was before the change. A later render that gives it that earlier content back then leaves the DOM as it is. Rendering keys a b, then b a, then a b, with each item showing its position, leaves the second item showing the old position:
(defn numbered-list [ids]
[:ol (map-indexed (fn [i id]
[:li {:replicant/key id} (str id ": " (inc i))])
ids)])
;; (numbered-list ["a" "b"]) draws a: 1, b: 2
;; (numbered-list ["b" "a"]) draws b: 1, a: 2
;; (numbered-list ["a" "b"]) draws a: 1, b: 1
Rows numbered by position then show stale numbers after a few reorders. The bug needs the moved element's own content to change with the move. Numbering kept out of the row, such as an ol's own numbers or a CSS counter, works with the plain key, since the row's content stays the same:
[:ol (for [id ids]
[:li {:replicant/key id} id])]
When the row must show what changes with the move, the workaround is to put that in the key, so an element whose content changes is a new element, drawn anew:
[:li {:replicant/key (str id "-" position)} (str id ": " position)]
That gives up what the key is for: every row that moves is removed and created again, so it loses focus and what was typed in it, its transitions start over, and its hooks see an unmount and a mount instead of a move.
Issue #81 has the details, and Replicant's changelog lists the fix under 2026.11.1. In a project on 2026.11.1 or later, the plain key is enough. When the view's hiccup is right and the DOM is not, reduce the case to a few keyed elements, rendered into an element of your own, before looking for the cause in the app.
A view test calls the view with a state, selects elements in the hiccup with lookup, and checks what they show and the actions their handlers carry. Running those actions through the app's action handler, and calling the view again with the next state, tests an interaction without a browser. View tests has the pattern.
The view, Replicant and the DOM are in the page that runs the app, so evaluate there for anything that touches the DOM. With shadow-cljs, every tab is a runtime of its own, and the REPL evaluates in one of them: the shadow-cljs skill, in the shadow-cljs plugin, says which one, and how an agent opens a page of its own. The backseat-driver skill, which comes with Backseat Driver, covers evaluating on a given runtime.
for, are realized by Replicant while it renders, so an exception in them shows up there, far from its cause. (pr-str (my-view state)) realizes them in the REPL, where the exception comes back.defn in its own namespace. In a development build the app's render looks the view up each time it calls it, so the next render draws the new one, unless the app holds the view as a value it took at startup. Renders follow state changes, so call the app's own render function to see it now. When the file is saved, the build reloads the namespace, and the app draws the change when it renders after a reload, as a shadow-cljs app does from a function marked ^:dev/after-load, or at the next state change.defalias is evaluated again, the next render creates the root and everything in it anew: inputs lose focus and what was typed in them, and mount hooks run again..-textContent of a querySelector result, and click with .click. Keys, handlers and hooks don't show in the DOM, only what they do.replicant.dom/unmount on it, and render again.replicant.dom/render catches an exception thrown while it renders, logs it to the browser console as Caught exception during rendering, and keeps its picture of the DOM from before, so the next renders of that root can fail too. The REPL gets no error, so read the console, and start the root over. Replicant's changelog lists, under 2026.11.1, that the exception reaches the caller and the next render starts the root over.When the work shows that this skill is wrong, or leaves out something it should have said, tell the human what you found. They can open an issue on awesome-backseat-driver, where the skill is maintained. The installed skill is a copy that the plugin's next update replaces, so the fix belongs there, not in this file.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub betterthantomorrow/awesome-backseat-driver --plugin replicantOther plugins' skills for the same job