/relux:functionfrom relux
Adds, modifies, removes, moves, or extracts fn/pure fn declarations in Relux modules. Useful for authoring helpers, extracting repeated code, changing purity, or moving functions between inline and lib.
Ships in relux. 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.
None: SKILL.md is the whole skill.
Add, modify, remove, move, or extract fn / pure fn declarations in a
Relux module -- with discipline about purity, location, arity, and what
crosses (or does not cross) the call boundary. The same five-step core
(classify -> pick layer -> apply -> verify -> audit) handles every
operation; step 1 classifies and the rest of the workflow adapts.
User phrasings:
pure fn."lib/." / "Promote this to a library function."http_request."Agent-task signals:
pure fn body uses a shell op or impure BIF -- fails relux check.fn is referenced from a marker expression or a top-level let --
those positions only see pure fn and pure BIFs; promote if the body
permits, refactor otherwise.relux/lib/.Out of scope: marker placement on functions is relux:markers
(handoff after authoring if the new function needs a guard); tuning
timeouts or fail-patterns is inline <~Ns? pattern for one match and
relux:configure for global defaults; authoring tests is
relux:test-write; authoring effects is relux:effect-write;
reorganizing the relux/lib/ directory is a future lib-organize
leaf (not yet drafted).
Direct invocation (/relux:function). Ask the user which operation
(add / modify / remove / move / extract), the target file path, and the
function name. Without an operation plus a target, the workflow has
nothing to walk.
../../references/functions.md. The reference is the
source of truth for fn vs pure fn semantics, frame-scoped vs
shell-side state, arity-based dispatch, and the call-boundary
rules; this skill assumes that material is loaded.../../references/bifs.md. The pure-vs-impure split
at the BIF level decides what a pure fn body can call -- the
reference enumerates which built-ins are pure (usable inside
pure fn) and which are impure (force the function to be fn).
The purity rubric below assumes this material is loaded.(name, arity) within an
importing scope; a caller in any module that imports this function
is in scope.let RHS, the function must be pure fn. A fn will
not resolve in those positions.Pick the operation path based on the classification done in pre-flight. Verify and Audit are shared phases run at the end of every path.
Two axes need a pick when placing a function.
Purity. (Pure vs impure BIF lists in ../../references/bifs.md;
callable positions for each form in ../../references/functions.md.)
pure fns / pure BIFs (trim, uuid, which, etc.) -- write
pure fn.sleep, match_ok,
ctrl-keys) -- must be fn.The discipline is not "pure is nicer"; it is "if it can be pure,
future callers will need it pure." pure fn is callable from
marker / overlay / let RHS / shell positions; fn is callable
only inside a shell block. Defaulting to pure fn keeps options
open.
Location.
import lib/<path> { fn_name }. The grouping rubric
(effect-scoped vs protocol-scoped vs ask-before-creating-misc)
lives in ../../references/imports.md > Group library modules by
scope; apply it before placing the file.Use when no function with this (name, arity) exists at the target.
Pick purity using the rubric.
Pick location using the rubric.
Compose the signature. fn name(arg1, arg2) or
pure fn name(arg1, arg2). All arguments are strings (no type
system); snake_case is parse-enforced.
Before committing the parameter list, scan each argument: does it have a value most callers will use? If yes, the argument is defaultable. Two consequences:
(name, arity) with no
skip-to-named-argument syntax, so a defaultable argument stuck in
the middle cannot be omitted by a shorter arity; every caller is
forced to pass the default explicitly, which kills the point.name(a) -> name(a, b) -> name(a, b, c), each adding one
parameter, with defaults living exactly once in the delegating
arity. See ../../references/functions.md > Use arity-based dispatch
for default arguments.Compose the body. Return value is the last expression. For
pure fn, the body is let bindings followed by an expression --
no shell ops, no impure BIFs, no calls to fn. For fn, leave the
caller's shell clean (consume the prompt; match_ok() after any
command).
Don't wrap the return in a redundant let. When the result is
just an interpolation or a single function call, write it as the
last line; naming it first adds noise (see
../../references/functions.md > Arguments and returns on implicit
"").
Don't:
pure fn compose_url(host, port) {
let url := "http://${host}:${port}/api"
}
Do:
pure fn compose_url(host, port) {
"http://${host}:${port}/api"
}
The same applies when the body delegates to another function --
fn http_get(url) { http_request("GET", url) }, not
fn http_get(url) { let r := http_request("GET", url) r }. let
bindings earn their place when an intermediate value is reused, or
when naming makes a multi-step body readable; not for the final
expression.
Apply. Write the declaration. For library location, also add
import lib/<name> { fn_name } to each caller module.
Then run Verify, then Audit.
Use when a function exists and its body, arity, or purity needs to change. If the location is what should change, switch to the Move path instead.
(name, arity). A "signature change" is mechanically add a new
arity; never rewrite an existing arity's parameter list in
place -- existing callers silently bind to a different function
(or fail to resolve) the moment the parameter count changes. The
new arity coexists with the old; both remain valid call paths.
Migrating existing callers onto the new arity is a separate,
optional decision -- not a mandatory next step. Two arities
reading as "give me the simple form" and "give me the
fully-parameterized form" is the defaults pattern (see
../../references/functions.md > Use arity-based dispatch for default
arguments), not a half-finished migration. Migrate only when the
lower arity's default is itself wrong (callers are working around
it) or when pruning the lower arity earns its keep against the
cognitive cost of leaving it. Otherwise leave both in place; each
call site picks the arity that fits.fn -> pure fn): only valid if the body uses no shell
ops, no impure BIFs, and calls no fn. pure fn -> fn (a
demotion) is mechanically always allowed but breaks every
pure-only call site -- pure fn was the original choice for a
reason, and demotion silently disqualifies the function from
positions where fn cannot stand in.
Before demoting pure fn -> fn, grep for pure-context call
sites: top-level let RHS (in tests, effects, modules), marker
expressions (# skip unless ..., # run if ..., conditional
markers), overlay expressions, and bodies of other pure fns
that call this function. If any exist, demoting will break them.
Consider a wrapper instead: leave the existing pure fn
intact and add a new fn some_name(args) (different name
or different arity) that performs the shell work and calls
through to the pure helper for the value derivation part. Pure
callers keep working; impure callers use the wrapper. Propose
this shape to the user before committing the demote.../../references/functions.md > Use arity-based dispatch for default
arguments.Then run Verify, then Audit.
Use when the function should be deleted entirely.
lib/) or replace-with-equivalent (point each
caller at another existing helper), not Remove. Reclassify.Then run Verify, then Audit.
Use when the function stays in spirit but should live at a different
location (inline -> relux/lib/, library file -> another library file,
or back).
relux/lib/ typically follows the second module needing the
helper; demoting relux/lib/ -> inline follows the last cross-module
caller leaving.import lib/<name> { fn_name } to every
caller module that does not already have it; remove the import from
any caller module that no longer needs it.Then run Verify, then Audit.
Use when N (>= 2) occurrences of the same code block should be hoisted into a function.
send/
match lines is impure -> fn. A block of string composition or
value derivation is pure -> pure fn. If even one occurrence sits
in a pure-only position (marker expression, top-level let), the
function must be pure fn.wait_for_prompt, parse_pid, compose_url). Parameter names
match what varies across call sites.Then run Verify, then Audit.
relux check
relux check catches:
pure fn
body using disallowed forms).pure fn body that uses a shell op, an impure BIF,
or calls a fn).For impure functions, run an exercising test to confirm the body does the intended work:
relux run -f path/to/test_using_fn.relux
The function appears in the structured log as its own span; the
event.html viewer renders the span entry/exit and every contained
send / match / BIF call.
After every operation, re-walk the chain.
(name, arity) is in scope at any caller. Same name with
different arity is fine; same (name, arity) twice in the same scope
is a resolver error.import resolves and the
function still satisfies whatever position it is called from
(pure-only positions still get a pure fn).relux check reports no dangling references.docker, kubectl, jq,
psql, a project-specific CLI -- anything outside the POSIX
baseline you can assume on every target host), confirm the function
carries a corresponding marker (# skip unless which("docker") or
similar). Function-level markers auto-propagate to callers at
resolve time, so the marker on the function is what spares every
test from re-asserting the gate. If the marker is missing, hand off
to relux:markers (Add path against this fn) before considering
the operation done. See ../../references/functions.md > See also on
marker-guarding tool-dependent helpers.fn -> pure fn), the propagation
set grew -- the marker now also reaches let-RHS and
marker-expression callers it did not reach before. Re-check those.relux check passes against the updated file(s).relux run against a covering test confirms
the body executes as intended.(name, arity) against the updated
declarations; imports resolve.relux/lib/ if shared).relux:markers -- when the function being authored or modified needs
a # skip / # flaky / # run if guard. This skill writes the
declaration; relux:markers places the marker.relux:effect-write -- the natural caller when authoring an effect
whose shell body needs helper functions; that skill hands off here.relux:test-write -- the natural caller when authoring a test that
needs a helper or a project-local anchor function for a non-POSIX
shell; that skill hands off here.lib-organize (not yet drafted) -- the natural caller when
reorganizing the relux/lib/ directory.../../references/functions.md -- definition syntax, pure vs impure
semantics, frame-scoped vs shell-side state, arity-based dispatch,
worked-out pitfalls (leave-shell-clean, defaults-via-arity,
no-shared-shell-state).../../references/bifs.md -- pure vs impure built-ins; a pure fn body
may only call pure BIFs and other pure fns.../../references/imports.md -- import resolution from project root; how
import lib/... { ... } interacts with the relux/lib/
convention.../../references/project-layout.md -- the relux/lib/ directory
convention and discovery rules.../../references/markers.md -- function-level marker propagation,
including how purity changes the propagation set.The recurring function-language mistakes -- preferring pure fn
for value derivation, default arguments via arity dispatch, leave
the caller's shell clean, no implicit caller-state coupling --
live in ../../references/functions.md with canonical Don't/Do
examples. The pre-flight read loads them; this section captures
the skill-level discipline that has no reference home.
Three identical lines that appear in exactly one test are not a function. Extract when (a) the block appears in two or more places, (b) the variation across occurrences is parameterizable in two or three arguments, and (c) the function name reads as a meaningful summary of the block at the call site. Premature extraction trades local readability for a name the caller now has to remember -- expensive when the call site never multiplies.
lib/ for a single callerrelux/lib/ reads as "shared." Moving a helper there with one test
calling it pays a maintenance cost (extra import line, mental scope
split, harder to grep) for a hypothetical second caller that has not
arrived. Promote on the second caller, not before. The same logic
applies in reverse: demote lib/ -> inline only when the last
cross-module caller is gone.
fn directlyFor N functions sharing the same marker condition (e.g., all
requiring docker), place the marker on each fn directly. Do
not consolidate them onto a shared guarded pure fn calling
let _ := mark_<group>(). Functions auto-propagate markers to
callers at resolve time with zero runtime cost; the consolidate
pattern's guard call adds per-invocation cost on the hot path.
The consolidate pattern is for tests and effects, not function
groups -- see relux:markers > Consolidate, which explicitly
excludes function groups from that path.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub shizzard/relux --plugin relux11 skills in this plugin
/configurerelux:configureTune `Relux.toml` knobs -- shell command/prompt, match/test/suite timeouts, parallel jobs, flaky retries -- with a strong bias toward shipped defaults. Use when the user asks to change the shell Relux spawns, bump a timeout because something raced, parallelize the suite, enable flaky retries, rename the suite, or otherwise edit `Relux.toml`. Also fires when the agent encounters a `match-timeout` cancellation in `events.json` and the obvious fix is at the manifest level rather than per-test. Insist on keeping defaults unless the user has a concrete, evidenced signal -- a timeout cancellation, a known boot time, a measured wall-clock budget. Static per-test tuning via `test "name" ~30s` is the wrong tool; this skill or CI's `--timeout-multiplier` covers slow environments./editor-pluginrelux:editor-pluginInstall or update the relux editor plugin for VS Code (and Cursor / VSCodium / code-server) or JetBrains-family IDEs (IntelliJ IDEA, RustRover, CLion, PyCharm, GoLand, WebStorm). Use when the user asks for syntax highlighting on .relux files, wants to set up their editor for relux work, or upgrades an outdated plugin. Often invoked as a follow-up by relux:install after the binary is on PATH.Other plugins' skills for the same job