mcpField
N
nushell

nushell

github.com/nushellDevelopment1.3k77 installsUpdated 4d ago
Repository

About nushell

This skill provides practical guidance for using Nushell, a structured-data shell, including syntax, common pitfalls, and reference files. It also explains when to use Nushell over Bash and how to work with its persistent MCP REPL.

Key features

  1. 01Structured-data pipelines
  2. 02Syntax and common-error guidance
  3. 03Data format querying and conversion
  4. 04Guidance on Nushell versus Bash
  5. 05Persistent MCP REPL usage

Use cases

  1. 01Querying JSON output from CLI tools
  2. 02Exploring tabular or structured data
  3. 03Running stateful Nushell code through MCP

MCP support

The skill describes a Nushell MCP server with `evaluate`, `list_commands`, and `command_help` operations. Its `evaluate` operation runs code in a persistent REPL where variables and history remain available.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/nushell/nu_scripts --skill nushell

After installing, type/nushellin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
advanced.md
bash-equivalents.md
commands.md
data-analysis.md
http-transport.md
types-and-syntax.md

Details

From the project README

Using Nushell

Nushell is a structured-data shell. Commands pass tables, records, and lists through pipelines - not text.

Two execution paths:

  • MCP server: mcp__nushell__evaluate - persistent REPL (variables survive across calls)
  • Bash tool: nu -c '<code>' - one-shot (use single quotes for outer wrapper)

Critical Rules

NEVER use bare print in MCP stdio mode. Output will be lost (returns empty []). Use print -e "msg" for stderr, or just return the value (implicit return).

String interpolation uses parentheses, NOT curly braces:

# WRONG:  $"hello {$name}"
# CORRECT: $"hello ($name)"
$"($env.HOME)/docs"    $"2 + 2 = (2 + 2)"    $"files: (ls | length)"

Gotcha: $"(some text)" errors - parens are evaluated as code. Escape literal parens: \(text\).

No bash syntax: cmd1; cmd2 not &&, o+e>| not 2>&1, $env.VAR not $VAR, (cmd) not $(cmd).

Common Mistakes

MistakeFix
$"hello {$name}"$"hello ($name)"
print "msg" in MCPprint -e "msg" or return value
command 2>&1command o+e>| ...
$HOME/path$env.HOME or $"($env.HOME)/path"
export FOO=bar$env.FOO = "bar"
Mutating in closureUse reduce, generate, or each
\u001b for ANSIansi strip to remove, char --unicode '1b' for ESC
where ($in.a > 1) and ($in.b > 2)Second $in rebinds to bool. Use bare cols: where a > 1 and b > 2
where not ($in.col | cmd)not breaks $in. Use where ($in.col | cmd) == false
where col | cmd (no parens)Parsed as two pipeline stages. Use where ($in.col | cmd)

When to Use Nushell

Always prefer Nushell for:

  • Any structured data (JSON, YAML, TOML, CSV, Parquet, SQLite) - unifies all formats
  • CLI tools with --json flags - pipe JSON output directly into Nushell for querying (e.g. ^gh pr list --json title,state | from json)
  • Ad-hoc data analysis and exploration - faster than Python setup
  • Initial data science/analytics - histograms, tabular output, basic aggregations
  • Polars plugin for large datasets - DataFrames without Python overhead

Use Bash only when: bash-specific tooling, MCP unavailable, or bash-syntax integrations.

Reference Files

Read the relevant file(s) based on what you need:

FileRead when you need...
commands.mdCommand reference tables (filters, strings, conversions, filesystem, math, dates)
types-and-syntax.mdType system, string types, operators, variables, control flow, cell-paths
data-analysis.mdFormat conversion, HTTP, Polars, SQLite, aggregation patterns
advanced.mdCustom commands, modules, error handling, jobs, external commands, env config
bash-equivalents.mdComplete Bash-to-Nushell translation table
http-transport.mdDifferences when using HTTP transport instead of stdio

MCP Server Quick Notes

  • mcp__nushell__evaluate - run code; mcp__nushell__list_commands - discover; mcp__nushell__command_help - help
  • State persists between calls. $history stores prior results (access $history.0, etc.)
  • Use | to text or | to json for large outputs. Use ansi strip for color removal.

Comments

Markdown supported