/nushell:nustro-completion-build <tool> [what matters most, e.g. "packages with descriptions"]from Nushell
Teach Tab a CLI in Nustro: builds completions/<tool>.nu the way brew.nu and git.nu work - every subcommand and flag, flag values, live positionals from the tool's own data, measured in ms, carapace as fallback.
Ships in Nushell. 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; scripts run unread.
Run as /nushell:nustro-completion-build <tool> [hint], or from the shell
as agent completion <tool> [hint]. Input: $0 is the tool; anything after
it is a hint about what to get right first. Skill files: ${CLAUDE_SKILL_DIR}
(scripts in scripts/, catalogues in references/). The repo:
${CLAUDE_PROJECT_DIR}. Its engine is modules/nu-complete/engine.nu; the
two finished examples are
completions/brew.nu (data read from files the tool maintains, a SQLite
cache built in the background) and completions/git.nu (one cheap command
per source, memoised for seconds). Read both before writing anything: the
new module must look like them.
The deliverable is completions/<tool>.nu, wired in conf/completions.nu,
verified headless, its costs measured, documented in docs/concepts/completion.md.
Not a nu_scripts-style pile of export extern lines: those give flags but
never positionals, never carapace fallback, and never the smart menu.
| Slot | Must offer | Never |
|---|---|---|
tool ⌶ | subcommands with one-line descriptions, aliases included | files |
tool sub -⌶ | that subcommand's flags plus the global ones, -s and --long | only the root flags |
tool sub --flag ⌶, --flag=⌶ | the flag's values: an enum from help, or a live list | files, unless the flag takes a path |
tool sub ⌶ (positional) | what the argument is: branches, formulae, containers, hosts, targets, scripts, with a description column | every file in the directory, unless the argument is a path |
| anything the spec has no opinion on | carapace's answer (fallback: "external") | nothing |
Speed is part of correctness: the menu source runs on every keystroke. A source answers in single-digit milliseconds from memo or disk; the one-off build of a big list runs in a background job; nothing spawns the tool's Ruby/Python/JVM on the Tab path.
Work through every step. Do not skip verification because the module "looks right": a completer that errors is silent, Nushell just shows files.
nu ${CLAUDE_SKILL_DIR}/scripts/discover.nu <tool> --online
Read recommended: it orders the sources that exist for this tool.
existing.spec set means extend that file, do not start over. Load
references/discovery.md for what each source looks like and how to read
it; it also lists what is installed on this machine.
Run the drafts the discovery named and save each to /tmp or the
session scratchpad (never into the repo):
| Source | Command | Gives |
|---|---|---|
cobra program (cobra.ok) | nu scripts/cobra-tree.nu <tool> --depth 3 | every subcommand incl. hidden, flags, enum values of valued flags, whether each leaf positional is dynamic (positional.directive, sample) |
| shipped or generated fish file | nu scripts/fish-spec.nu <tool> or <tool> <gen> fish | nu scripts/fish-spec.nu --stdin <tool> | subcommands, flags with arg/files/values, and the dynamic sources verbatim (dynamic: ["(__fish_complete_directories)"], (brew formulae)) |
| help text (always) | nu scripts/help-tree.nu <tool> --depth 3 | subcommands, flags with types and [possible values], positional names from the usage line (args), aliases |
native nushell generator (native.nushell) | run it, read it | a clap tool's complete static surface as externs; mine it for enums and types, do not install it |
zsh file (shipped.zsh) | read the _<tool>_<name>() bodies | the command behind each dynamic helper |
| carapace | carapace <tool> nushell <tool> sub "" | an oracle for coverage, and a fallback |
nu_scripts (nu_scripts.url) | WebFetch it | ready nu-complete <tool> <x> closures to copy |
--depth/--at "pr list" bound the walk; cobra tools spawn ~60 ms per
node (gh at depth 3 is ~60 s), clap tools are instant. Merge into one
picture: subcommand tree, per node flags (name, short, description,
takes-value, values), per node positionals (name, rest, optional) with a
hint of what they are.
For each positional / valued flag decide, in this order:
values from help, fish -a "a b c", cobra probe): a literal list.references/sources.md has the catalogue with paths and
measured costs (git refs, brew API cache, cargo metadata, npm
package.json, ssh config, kube contexts, launchd, tmux …).git for-each-ref,
cargo metadata --no-deps, docker ps --format json, just --summary.
Memoise with nu-complete cache "<tool>:<what>:<scope>" <ttl> { … }.nu-complete cache-dir
in a job spawn, serve names without descriptions until it is ready,
regenerate when the source is newer (nu-complete stale). brew.nu is the
pattern; copy it.__complete (50 ms + whatever it does), clap COMPLETE=fish,
carapace --macro tools.<x>.<Y> "". Acceptable for slots hit rarely.gh pr list, registries): only if the hint asked for it;
memoise minutes, never on the root slot."files" when the argument is a path; [] when the slot should
offer nothing (an id the user types).fallback: "external" asks
carapace.Every closure returns {value, description} records (a description
column is what makes the menu readable), reads $ctx.args for flags that
narrow the slot (--cask), and never runs the tool's slow path. Measure
each source with timeit before accepting it; write the number in a
comment.
Aliases: the engine has no alias notion. Add the alias as its own
subcommand node copied from the target (co: ($subs.checkout | update description "alias of pr checkout")).
completions/<tool>.nuUse the template in references/module-template.md and its gotchas list
(it exists because each item cost an hour once). Rules from CLAUDE.md
apply: no hard-coded home directory ($nu.home-dir, $env.HOMEBREW_PREFIX?),
%open for files, which guards, comments say why and quote measured
costs. Big static trees (hundreds of flags) go to
completions/data/<tool>.json written by the draft script's --json
output and loaded lazily, with the generating command in the module header;
small ones are a literal record in the module. flags of a node may be a
closure when the list is slow to get.
use <tool>.nu * in conf/completions.nu, next to brew and git, with a
one-line comment of what completes.nu-check config.nu and nu -l -c 'nustro doctor' both clean.nu -l -c '"<tool> " | commandline complete --detailed | first 5'
nu -l -c '"<tool> sub " | commandline complete --detailed | select value description | first 5'
nu -l -c '"<tool> sub --" | commandline complete --detailed | length'
nu -l -c 'timeit { "<tool> sub " | commandline complete --detailed }'
The inner call, not the completer wrapper, when a slot returns files
unexpectedly: nu -l -c 'nu-complete run (nu-complete <tool> spec) [<tool> sub ""]'
shows the error the try swallows.nu ${CLAUDE_SKILL_DIR}/scripts/verify.nu <tool> # auto cases
nu ${CLAUDE_SKILL_DIR}/scripts/verify.nu <tool> --cases cases.nuon --oracle carapace
carapace_only lists what carapace knows that the spec does not: each
entry is either a flag to add or a slot to leave to the fallback.nu -l -c 'nustro startup-time' must stay within noise of before
(record both numbers). A module that costs more than ~3 ms to parse is
too big for a literal: move data to JSON.nu --ide-complete does not run @complete: never use it as evidence.docs/concepts/completion.md: a row in the tools table (add the table if it is
not there yet) and the new costs.use <tool>.nu *.recommended empty beyond
help): a spec with subcommands from help and fallback: "external" is
still worth it; say what is missing.rg, fd): flags with
values are the whole job; enums from help; positional "files".uv, rustup,
npm --help exits 1): the scripts already read both streams.references/discovery.md (opens in a new tab)references/module-template.md (opens in a new tab)references/sources.md (opens in a new tab)scripts/cobra-tree.nu (opens in a new tab)scripts/discover.nu (opens in a new tab)scripts/fish-spec.nu (opens in a new tab)scripts/help-tree.nu (opens in a new tab)scripts/verify.nu (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub alfoldimate/nustro --plugin nushell