Skip to content

About

Plugin for Claude Code and Claude Desktop packaging a Nushell MCP server and various skills for educating models on how to use Nushell idiomatically.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

nu-fluency

A plugin that helps Claude write Nushell (nu) code idiomatically.

Installation

# 1. Ensure your Nushell version is compatible
version | get version # >= 0.117.0
# (the skills' preprocessing was tested on Claude Code 2.1.326)
# 2. Add the plugin marketplace
claude plugin marketplace add zaynram/cowork-marketplace
# 3. Install the `nu-fluency` plugin
claude plugin install nu-fluency@ramda-cowork-marketplace

On Windows, the plugin expects Git Bash to be installed, as most development setups have it. Windows without Git Bash is untested: the version-notes skills are written to run through PowerShell there (see Version notes), but nothing else has been checked in that environment.

Background

When first introducing Claude to nu, we both agreed that it seemed like an LLM's optimal shell; it's natural language semantics and first-class support for structured data bridges the gap between human and machine readable data.

This insight led to the construction of my nushell-mcp.

After testing out the MCP with Claude, he would often treat it as "bash with weird syntax", which we hypothesize is the result of POSIX convention being over-represented in his training distribution.

This highlighted a need to teach Claude about Nushell and its built-in primitives, as the default behavior of reaching for bash patterns bottlenecked the advantages of nu semantics and structured-data support.

This plugin counteracts that bias by combining authoritative tooling (nu-lint) with educational scaffolding.

MCP Server

This plugin uses the nushell-mcp server, automatically installed from its NPM package listing.

It provides a curated set of nu utilities to Claude including but not limited to: nu_exec (one-shot nu pipeline execution) and nu_repl (persistent nu REPL sessions piggybacking off of Nushell's built-in nu --mcp).

Peer Dependency: Nu-Lint

The commands packaged in this plugin prefer to delegate diagnostics to nu-lint.

nu-lint is a deterministic community linter for Nushell whose rules are grouped into replace-external-tools, translate-bash-syntax, adopt-nu-syntax, parse-structured-data, catch-runtime-failures, and more.

Most rules have auto-fixes, and the rules themselves respect the nuance of diverging from the status quo in the age of LLM.

Installation

The bundled configs use the rule group names nu-lint introduced in 1.7.0 and 1.8.0, so nu-lint 1.8.0 or newer is required. An older nu-lint (1.3 to 1.6) silently ignores the groups and lints with its defaults, and nu-lint 1.7.x refuses the configs. Check with nu-lint --version, and when it reports an older version, reinstall with the command below: an update tool such as cargo install-update may leave a git install behind.

# `--git <url>` - Build from latest source code
# `--locked` - Pins the lockfile's dependency versions.
cargo install --git https://codeberg.org/wvhulle/nu-lint --locked

/audit-pipeline and the lint hook find nu-lint the same way, through scripts/lint.nu: on PATH, then in $CARGO_HOME/bin, ~/.cargo/bin or ~/.local/share/cargo/bin (under %USERPROFILE% on Windows), then on Windows inside the default WSL distribution, on its PATH or in the same two cargo folders under its home. The code reaches nu-lint on stdin, never through a shell, so no snippet needs quoting, and inside WSL the config path is converted with wslpath. /audit-pipeline runs through the Nushell MCP server, which a host may start with the MCP SDK's short default list of environment variables (HOME, USERPROFILE and PATH among them, not CARGO_HOME), so a nu-lint that sits only under a custom $CARGO_HOME reaches the hook but not /audit-pipeline: put its bin folder on PATH instead.

The hook system is inert by default, and will not warn or error when nu-lint is unavailable. The only downside is losing out on deterministic diagnostics.

Native LSP Integration

The plugin declares an LSP configuration with Nushell's built-in language server.

// .claude-plugin/plugin.json
{
    // ...
    "lspServers": {
        "nushell": {
            "command": "nu",
            "args": [
                "--lsp"
            ],
            "extensionToLanguage": {
                ".nu": "nu",
                ".nuon": "nu"
            },
            "restartOnCrash": true,
            "maxRestarts": 3
        }
    }
}

After plugin installation and the language server connects, Claude sees inline diagnostics, hover info, and auto-fixes any time it edits a Nushell file.

Components

Type Count Purpose
Skills 11 /nushell-idioms, /env-snapshot, /audit-pipeline, /command-help; model-only: inspect-shape, nushell-{records,env-scoping,strings,control-flow,modules,performance}
Agents 1 Fallback review agent for /audit-pipeline when nu-lint is not installed or cannot be found (experimental)
Hooks 2 Pre-Bash nudge toward nu equivalents; post-nu_exec/nu_repl_write hook that runs nu-lint on the executed code
LSP 1 nu --lsp via lspServers in .claude-plugin/plugin.json
Configs 2 configs/hook.nu-lint.toml, configs/strict.nu-lint.toml

Skills

User-Invocable

  • /nushell-idioms — (entry point) deep syntax lookup reference (cheat-sheet.md), bash → nu equivalents, pointers to nu-lint.
  • /env-snapshot [keys...] — $env | select --optional <keys> with sensible defaults.
  • /audit-pipeline [<snippet or .nu path>] [--read-only] — runs nu-lint on the snippet (or on the code Claude last wrote) and applies fixes; --read-only only reports, with nu-lint rules explain per rule. Falls back to the experimental agent, which only suggests fixes, when nu-lint is not installed or cannot be found.
  • /command-help <name> — inline help lookup via nu_doc_help.

Model-Only

  • inspect-shape — runs an expression through nu_exec and returns its detailed type, length and first rows. Structural intuition.
  • nushell-records — records, tables, cell paths, record each / record where.
  • nushell-env-scoping — $env, do --env, with-env, for vs each propagation, automatic env vars.
  • nushell-strings — parse templates, str namespace, interpolation, from <format>.
  • nushell-control-flow — for/each/reduce/any/all/take while, conditionals, try/catch vs ?.
  • nushell-modules — module/use/export def/export-env/main.
  • nushell-performance — closure-entry cost model, profile-first workflow, probe kit (skills/nushell-performance/scripts/probe.nu).

Version notes

scripts/version-notes.nuon lists known Nushell bugs and behavior that depends on an experimental option. The idioms, control-flow, env-scoping and performance skills run scripts/version-notes.nu when they load and show only the notes that apply to the installed nu; the full table is nushell-diagnostics.md. The command runs through Bash, or through PowerShell on Windows without Git Bash (untested), and each skill allows it for both. It needs nu on PATH: without it those four skills fail to load. After editing the data, run nu --no-config-file scripts/version-notes.nu render --write (check fails when the table is stale or an option note names an option the running nu lacks).

Hooks

Pre-tool-use hook on Bash calls. When the command does text processing that nu does structurally (jq, sed, awk, cut, xargs, find, read loops, or grep/wc/sort/uniq in a pipeline), it adds a short note naming the nu equivalents. It never blocks or changes the permission decision; the command runs either way. Cases live in hooks/tests/nu-over-bash.nu (nu --no-config-file hooks/tests/nu-over-bash.nu).

Post-tool-use hook on MCP nu_exec and nu_repl_write calls, registered for both PostToolUse and PostToolUseFailure, so a call that errors is linted too. Reads the tool's pipeline (or input) argument from stdin (JSON), lints it through scripts/lint.nu with the narrow configs/hook.nu-lint.toml (inside WSL too), and surfaces findings as a block reason iff there are diagnostics surfaced.

Cases live in hooks/tests/lint-pipeline.nu, with a stub nu-lint (nu --no-config-file hooks/tests/lint-pipeline.nu).

The hook config is intentionally conservative (replace-external-tools, translate-bash-syntax, adopt-nu-syntax, parse-structured-data and migrate-deprecated-syntax as warnings, remove-dead-code as hints, a few stylistic rules turned off and a few bash-habit rules turned on), so it fires on bash-translation patterns and skips stylistic noise.

For broader analysis, use /audit-pipeline (which uses the strict.nu-lint.toml config).

Conventions

The hook + nu-lint catches most of these mechanically, but for completeness they are also enumerated here.

  1. When a let chain forms, ask whether each step is carrying state or expressing a transform. Transforms collapse into pipeline stages.
  2. Records are nu's primary data structure.
  3. Env mutations propagate through keyword blocks (e.g. for/while/loop, match, if/else if/else), and certain commands with flags (do --env, and def --env for commands; collect --keep-env does not, despite its help text). The closures used in each/items/reduce and bare do/collect do not propagate environment mutations.
  4. Optional access (<cell-path>?) postfix on cell paths returns null. Prefer it over try/catch for safe property/nested property access without errors.
  5. NUON string quoting is context-dependent. Assert via in-nu equality checks, not raw NUON comparison.
  6. The last expression in a closure or pipeline is its return value, akin to rust. Don't print what you're returning.

Tests

  • nu --no-config-file hooks/tests/nu-over-bash.nu runs the Bash-nudge hook cases.
  • nu --no-config-file hooks/tests/lint-pipeline.nu runs the lint hook and runner cases with a stub nu-lint.
  • claude plugin eval . --tag triggers --ablation none --runs 1 runs the skill trigger round-trip cases in tests/triggers/: each skill has a prompt that must invoke it and a nearby prompt that must not. tests/README.md has the details.
  • vale skills/ lints the skill prose (.vale.ini).

License

MIT.

About

Plugin for Claude Code and Claude Desktop packaging a Nushell MCP server and various skills for educating models on how to use Nushell idiomatically.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages