This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
dotnu is a toolkit for Nushell module developers providing:
- Literate programming: Embed real command output in scripts as
# =>annotations - Dependency analysis: Analyze call chains between commands using AST parsing
- Script profiling: Measure execution timing of script blocks with
set-x
# Run all tests - ALWAYS use this command for testing
nu toolkit.nu test
# Update integration test fixtures when output changes
nu toolkit.nu test --update
# Release (bumps version in nupm.nuon and README.md, commits, tags, pushes)
nu toolkit.nu release # patch bump
nu toolkit.nu release --minor # minor bump
nu toolkit.nu release --major # major bumpImportant: Always use nu toolkit.nu test (not test-unit or test-integration separately). The combined command provides proper test output and summary.
# Check test coverage - requires both source AND test files
nu -c 'use dotnu/; ["dotnu/*.nu" "tests/test_commands.nu" "toolkit.nu"] | each { glob $in } | flatten | dotnu dependencies ...$in | dotnu filter-commands-with-no-tests'dotnu/
βββ mod.nu # Public API exports (selective)
βββ commands.nu # All implementation (all commands exported)
Export convention: All commands in commands.nu are exported by default (for internal use, testing, and development). The public API is managed through mod.nu, which selectively re-exports only the user-facing commands. To add a command to the public API, add it to the list in mod.nu.
Imports:
use dotnu/- import public API commandsuse dotnu/commands.nu *- import all commands (including internal)
mod.nu exports these public commands:
dependencies- Analyze command call chainsextract-command-code- Extract command with its dependenciesfilter-commands-with-no-tests- Find untested commandslist-module-exports- List all exported definitions (export def + export use)list-module-interface- List module's callable interface (main commands)embeds-*/embed-add- Literate programming toolsset-x/generate-numd- Script profiling
AST-based attribute detection (commands.nu:499-508): Uses nu --ide-ast to detect @test, @example decorators accurately, preventing false positives from @something inside strings.
Dependency tracking algorithm:
- Line-based parsing finds
defstatements with byte offsets - AST parsing identifies attribute decorators
- Range-based lookup associates calls with defining scopes
generatestreams recursive dependency chains
tests/
βββ test_commands.nu # Unit tests (nutest framework)
βββ assets/ # Test fixtures
β βββ b/ # Module dependency examples
β βββ module-say/ # Real-world module example
βββ output-yaml/ # Integration test outputs
Unit tests use @test decorator. Integration tests compare command output against fixture files.
- nutest: Testing framework (cloned in CI from https://github.com/vyadh/nutest.git)
- numd: Optional, for markdown integration
- std library: Uses
std/iter(scan) andstd/testing(assert)
- Naming: All commands use kebab-case
- Exports: All commands in
commands.nuare exported;mod.nucontrols public API - Internal commands: Exported from
commands.nubut not listed inmod.nu - Test detection: Commands named
test*or intest*.nufiles - Documentation:
@exampledecorators with--resultfor expected output