Skip to main content

N# CLI Reference

Updated: 2026-05-26

nlc is the N# command-line interface. It is designed to feel familiar to Go and Rust developers:

  • Build and run loops are project-first.
  • nlc check, nlc fix, nlc query, and nlc lint default to structured JSON for automation.
  • nlc format, nlc test, nlc clean, and nlc watch cover common inner-loop workflows; verify scenario-specific behavior before making release claims.
  • nlc --version prints the installed version.

Top-Level Commands

CommandPurposeKey FlagsExample
nlc build [file]Build a project or single file--backend, --release, --verbose, --timings, --outputnlc build
nlc run [file]Build and run a project or single filenonenlc run
nlc new <name>Create a csproj-free N# project scaffold--template (console, library, test, webapi)nlc new MyApp --template console
nlc initInitialize N# in the current directorynonenlc init
nlc testRun .tests.nl suites through the xUnit/NUnit-backed N# test runner--project, --filter, --verbose, --jsonnlc test --filter "should add"
nlc format [files...]Format N# source--project, --check, --diff, --stdinnlc format --diff
nlc lint [files...]Run static analysis rules--project, --json, --textnlc lint --json
nlc cleanRemove local build artifacts--project, --allnlc clean --all
nlc watch <check|build|test|lint|format>Re-run a command on file changes--project, --debounce-ms, --max-runsnlc watch check
nlc docGenerate HTML API docs--project, --output, --open, --jsonnlc doc --open
nlc completion <shell>Generate shell completion scriptsbash, zsh, fishnlc completion zsh
nlc checkFast parse + analyze without building--project, --text, --jsonnlc check --text
nlc fixAuto-apply code fixes--project, --file, --dry-run, --text, --jsonnlc fix --dry-run
nlc query <subcommand>Code intelligence for humans and toolsglobal --project, --file, --pos, --text, --json, --no-daemonnlc query def --file Program.nl --pos 12:4
nlc daemon <subcommand>Manage the background analysis daemon--projectnlc daemon status
nlc add <package>Add a NuGet dependency to project.ymlpackage specnlc add Serilog@3.1.0
nlc tidyIdentify and remove unused dependencies--projectnlc tidy
nlc remove <package>Remove a dependency from project.ymlpackage namenlc remove Serilog
nlc update [package]Update dependenciesoptional package namenlc update
nlc publishPublish framework-dependent deployment artifacts--project, --configuration, --output, current-host --runtimenlc publish -c Release --output ./dist
nlc export csharpExport N# sources without changing the IL toolchain--project, --outputnlc export csharp --project .
nlc treeShow dependency tree--project, --depth, --jsonnlc tree --json
nlc auditCheck dependencies for known vulnerabilities--projectnlc audit
nlc envShow environment and toolchain info--jsonnlc env --json
nlc doctorVerify CLI, templates/SDK restore, language server, and VS Code extension availability--json, --require-vscode, --skip-vscodenlc doctor --require-vscode
nlc restoreGenerate MSBuild compatibility config from project.yml--projectnlc restore
nlc packCreate a NuGet package from project.yml metadata--project, --outputnlc pack
nlc helpShow top-level CLI helpnonenlc help

Query Commands

CommandPurposeExample
nlc query batch --requests <file>Execute multiple semantic queries in one responsenlc query batch --requests requests.json
nlc query symbolsList project symbolsnlc query symbols --kind function
nlc query outline <file>File structure and importsnlc query outline Program.nl
nlc query diagnosticsRich diagnostics envelope; add the --clusters flag for versioned diagnostic-cluster JSON with category, recipe, risk, files, relatedDiagnostics, and nextCommandnlc query diagnostics --clusters
nlc query type --file <file> --pos <line:col>Type at a positionnlc query type --file Program.nl --pos 5:12
nlc query inspect --file <file> --pos <line:col>Symbol, type, definition, refs, and completions in one call; add --compact for token-efficient agent context (--summary is kept as an alias)nlc query inspect --compact --file Program.nl --pos 5:12
nlc query definitionGo-to-definition by position or namenlc query definition --name Person
nlc query defAlias for definitionnlc query def --file Program.nl --pos 5:12
nlc query referencesFind references to a symbolnlc query references --file Program.nl --pos 5:12
nlc query refsAlias for referencesnlc query refs --file Program.nl --pos 5:12
nlc query completionsLLM-optimized completionsnlc query completions --file Program.nl --pos 5:12
nlc query doc <query>Look up .NET API documentationnlc query doc Console.WriteLine
nlc query hoverSignature and docs at a positionnlc query hover --file Program.nl --pos 5:12
nlc query call-graphCallers and callees of a functionnlc query call-graph --function Main
nlc query implementorsConcrete types implementing an interfacenlc query implementors --name IShape
nlc query helpShow query command helpnlc query help

Browser Playground

The public website ships a WebAssembly-hosted compiler workbench. /playground is the free-form sample explorer with Monaco syntax highlighting, diagnostics, formatting, completions, hover, file tabs, share links, and browser-subset Run output. /tutorial uses the same workbench for a guided story with gated exercises.

Browser Run intentionally supports tutorial-scale code only: functions, print, simple control flow, records/classes, object initializers, selected string/numeric helpers, and selected match patterns. Local nlc remains the toolchain for full CLR execution, build, test execution, NuGet restore, filesystem workflows, and editor integration.

Examples

# Build and run
nlc build
nlc run

# Tight development loop
nlc check
nlc fix --dry-run
nlc format --check
nlc test --filter "should add"

# Watch mode
nlc watch check
nlc watch test --filter "should add"

# Installation verification
nlc doctor
nlc doctor --json --require-vscode

# Documentation and automation
nlc doc --json
nlc export csharp --project . --output ./myapp-csharp
nlc query inspect --compact --file Program.nl --pos 42:7

nlc completion bash > /etc/bash_completion.d/nlc

Build, Test, And Publish Truth

  • nlc build --release selects the Release configuration and bin/Release/<targetFramework> output layout unless --output is provided. The direct IL backend does not have a separate optimization mode yet.
  • nlc test --coverage and nlc test --coverage-report are unavailable in the native test runner today. They exit 1 with a clear text error, or with the same message in the schemaVersion 1 JSON error field when --json is present.
  • nlc publish produces framework-dependent artifacts. Without --runtime, run the output with dotnet <assembly>.dll on a compatible .NET installation.
  • nlc publish --runtime <rid> is supported only when <rid> is the current host runtime. It adds a small framework-dependent launcher beside the .dll.
  • Cross-runtime publish requests fail before building and report both the requested RID and the current host RID.
  • nlc publish --self-contained is planned, not implemented. It exits 1 with guidance instead of producing an artifact that only appears self-contained.

Exit Codes

Command Group01
build, run, new, clean, watch, doc, completionSuccessFailure
testTests passedBuild or test execution failed
formatSuccess or already formattedFormatting failed or --check found drift
lintNo issuesAt least one issue was reported
checkNo errorsErrors present or analysis failed
fixSuccessFailure, or --dry-run found pending fixes
queryQuery succeededInvalid request, missing symbol, or analysis failure
daemonCommand succeededDaemon operation failed
treeDependency tree emittedMissing project root/config or dependency resolver failure
doctorRequired install checks passedOne or more required checks failed

JSON Examples

nlc check:

{
"schemaVersion": 1,
"command": "check",
"ok": true,
"projectRoot": "/abs/path/project",
"checkedFiles": 3,
"results": [],
"summary": {
"errors": 0,
"warnings": 0,
"info": 0
}
}

nlc doc --json:

{
"schemaVersion": 1,
"command": "doc",
"ok": true,
"projectRoot": "/abs/path/project",
"outputDir": "/abs/path/project/nsharp/docs",
"result": {
"indexPath": "/abs/path/project/nsharp/docs/index.html",
"pageCount": 7,
"pages": [
{
"name": "Add",
"kind": "function",
"path": "symbols/functionaddprogram.html"
}
]
}
}

nlc lint --json:

{
"schemaVersion": 1,
"command": "lint",
"ok": false,
"projectRoot": "/abs/path/project",
"lintedFiles": 3,
"results": [
{
"code": "NL001",
"severity": "warning",
"message": "Unused variable 'value'",
"file": "Program.nl",
"line": 2,
"column": 5
}
],
"summary": {
"errors": 0,
"warnings": 1,
"info": 0
}
}

nlc tree --json:

{
"schemaVersion": 2,
"command": "tree",
"ok": true,
"projectRoot": "/abs/path/project",
"project": {
"name": "WebApi",
"targetFramework": "net10.0",
"source": "project.yml"
},
"maxDepth": 2147483647,
"capabilities": {
"directDependencies": true,
"transitiveNuGetDependencies": false
},
"dependencies": [
{
"name": "Swashbuckle.AspNetCore",
"kind": "nuget",
"version": "7.2.0",
"scope": "runtime",
"transitive": false,
"dependencies": []
}
],
"transitiveDependencies": [],
"summary": {
"direct": 1,
"transitive": 0,
"total": 1
},
"limitations": [
"project.yml output lists direct runtime dependencies only. Transitive NuGet dependencies require an MSBuild project file so dotnet can resolve the package graph."
]
}

nlc tree is active for csproj-free projects: it reads direct runtime dependencies from project.yml. When a minimal MSBuild project file is present and dotnet list package succeeds, it also includes transitive NuGet packages; otherwise it still returns direct dependencies with a limitations[] note. Tree JSON schema version 2 replaces the earlier raw packages wrapper with stable dependencies, transitiveDependencies, capabilities, and limitations fields.

Lint Rules

CodeSeverityDescription
NL001errorUnused variable
NL002errorMissing import
NL703errorCircular file import; diagnostic includes the import cycle path and a dependency-inversion/shared-file suggestion
NL003errorUnnecessary null check on value type
NL004errorAsync function without await
NL006errorUnreachable code
NL010errorUnused import
NL011errorEmpty catch block
NL012errorUnused parameter
NL016errorRedundant null check
NL020errorShadowed variable

Inline Lint Suppression

Specific lints can be suppressed on the next line or the current line:

// nlc:ignore NL001
unusedVar := 42

This currently applies to CLI lint consumers such as nlc lint, nlc check, and nlc fix.

Go/Rust Parity Audit

Scoring: 5 means essentially at parity for the workflow, 3 means usable but incomplete, 1 means missing.

Build & Run

FeatureGoRustN# ScoreNotes
Build projectgo buildcargo build5nlc build works for project roots
Run projectgo run .cargo run5nlc run supports project execution
Build single filego build file.gon/a5nlc build file.nl
Cross-compileGOOS=linux go buildcargo build --target1Unsupported in nlc publish; cross-runtime requests fail with guidance
Release buildimplicitcargo build --release4nlc build --release selects Release configuration/output layout; no separate IL optimizer yet
Cleango cleancargo clean5nlc clean, nlc clean --all
Verbose output-v-v4nlc build --verbose is available; short -v alias is not
Build timingshell time / --timings--timings4nlc build --timings emits phase timings; no JSON timing schema yet

Type Check

FeatureGoRustN# ScoreNotes
Fast checkgo vetcargo check5nlc check is project-aware and fast
JSON outputn/an/a5Default structured envelope
Human outputdefaultdefault5nlc check --text
Single filego vet file.gon/a4nlc check --project is strong; single-file check is still less direct
Watch modeexternalexternal5nlc watch check

Auto-Fix / Format

FeatureGoRustN# ScoreNotes
Auto-fixgofmt -wcargo clippy --fix4nlc fix supports current fixable diagnostics
Dry runn/apartial5nlc fix --dry-run
Fix categoriesformatting onlylint + format3Current fix catalog is still small
Format allgofmt -w .cargo fmt5nlc format
Check onlygofmt -dcargo fmt --check5nlc format --check
Stdingofmtrustfmt --stdin5nlc format --stdin
Diff outputgofmt -dcargo fmt --check5nlc format --diff

Test / Lint / Tooling

FeatureGoRustN# ScoreNotes
Run testsgo test ./...cargo test5nlc test runs .tests.nl suites
Run single test-runname filter5nlc test --filter
Verbose-v-- --nocapture4nlc test --verbose shows individual test results
Table-driven testsstruct slices#[case]5test "desc" with (params) [cases] { }
Test skipt.Skip()#[ignore]5test "desc" skip "reason" { }
Setup blocksTestMain#[fixture]4setup { } — one per file, runs before each test
JSON output-jsoncargo test -- --format json4nlc test --json structured envelope
Test coverage-coverexternal toolsPlannednlc test --coverage exits 1 with unsupported-feature guidance today
Benchmark-benchcargo benchn/aNo built-in runner by design: use BenchmarkDotNet directly on the compiled N# assembly. nlc build --perf-report and nlc query perf provide stable performance-fact envelopes.
Lintgo vetcargo clippy5nlc lint with --json/--text; lints also in nlc check
Suppress lint//nolint#[allow]5// nlc:ignore NL001
API docsgodoccargo doc4nlc doc now generates project HTML docs
Shell completionscommoncommon5`nlc completion bash

Known Gaps

These remain intentionally out of scope for this pass:

  • Cross-runtime and self-contained publish
  • A separate IL optimizer for release builds
  • Dependency tree visualization, including nested package-to-package edges for csproj-free project.yml dependency trees without an MSBuild project file
  • Native coverage reporting
  • Built-in cross-language benchmark execution
  • Machine-readable build timing reports