/zero-csharp:zero-csharpfrom zero-csharp
Builds and publishes C# or F# programs using ZeroCSharp.Sdk for targets without .NET runtime (Linux, Windows, macOS, iOS, Android, UEFI, WebAssembly, DOS, C64, microcontrollers, GPUs). Activates when zero-mode or bflat projects are detected.
Ships in zero-csharp. 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.
None: SKILL.md is the whole skill.
The language is ordinary C# 15 (preview) or F#. What's different is underneath: no runtime, no GC,
almost no BCL except what zerocore and lib/ reimplement with .NET's names and results. This file
holds only the rules you can't get wrong and the commands. For everything else, read the docs and
samples in the repository (below) before writing code: don't guess an API from .NET memory.
The docs and samples are in the public repo https://github.com/OnurGumus/zero-csharp.
zerocore/, lib/, docs/), use it.Z="$HOME/.cache/zero-csharp"; U=https://github.com/OnurGumus/zero-csharp
if [ ! -d "$Z/.git" ]; then # none yet, or a broken one: clone beside it, then rename
mkdir -p "$(dirname "$Z")" && T=$(mktemp -d "$Z.XXXXXX") &&
git clone -q --depth 1 "$U" "$T" &&
if [ -d "$Z/.git" ]; then : # another session got there first
else rm -rf "$Z"; mv "$T" "$Z"; fi
[ -n "$T" ] && rm -rf "$T" "$Z/$(basename "$T")" # ours, wherever a race put it
elif [ -z "$(find "$Z/.git/HEAD" "$Z/.git/FETCH_HEAD" -mmin -1440 2>/dev/null)" ]; then
# A read-only copy: follow master even if it was rewritten.
git -C "$Z" fetch -q --depth 1 origin master && git -C "$Z" reset -q --hard FETCH_HEAD ||
echo "zero-csharp docs: refresh failed, $Z may be stale"
fi
[ -d "$Z/docs" ] || echo "zero-csharp docs: no copy in $Z, use the published pages"
Without bash (PowerShell, cmd): git clone --depth 1 <url> <dir> the first time, and
git -C <dir> fetch --depth 1 origin master then git -C <dir> reset --hard FETCH_HEAD
after that. Check that <dir>/docs exists before going on.https://onurgumus.github.io/zero-csharp/<dir>/<page>.html
(same paths as docs/*.md).master can be ahead of the released package. Version numbers in the docs' project snippets and in
sdk/version.props may not be on nuget.org yet. Use the version dotnet new writes, or the newest
on nuget.org (dotnet package search ZeroCSharp.Sdk --exact-match). If a property, target or API
from the docs isn't in that version, tell the user it needs a newer SDK. Don't work around it.
Find answers with grep -rn in docs/ and samples/. Every C# block in the docs is a verified
region of a file in samples/ (<!-- sample: samples/X.cs region -->), so open that sample for the full,
compiling code. samples/*.fs are the F# versions. lib/ and zerocore/ sources with their ///
comments are the API reference.
| Need | Read |
|---|---|
Install, templates, every MSBuild property, [DllImport]/[LibraryImport] | docs/get-started/install-with-dotnet.md |
| .NET habit → what to use here (table), what compiles but behaves differently | docs/get-started/coming-from-dotnet.md |
| Arenas, scopes, lifetimes | docs/concepts/memory.md, docs/how-to/free-memory-yourself.md, keep-a-string.md |
unsafe, SAFETY: comments, C# memory safety rules | docs/concepts/safety-rules.md |
| What's missing, known issues | docs/concepts/limits.md |
| Strings, cultures, formatting, input | docs/concepts/strings.md, docs/how-to/format-text.md, read-input.md |
Collections, LINQ (AsQuery()), regex | docs/how-to/choose-a-collection.md, query-data.md, match-patterns.md |
Errors (Catch.Run, unions) | docs/how-to/recover-from-errors.md |
| Guard messages, debug checks | docs/how-to/catch-arena-mistakes.md, debug-a-program.md |
| Files, paths, streams, processes, env | docs/how-to/read-and-write-files.md, work-with-paths-and-directories.md, use-streams.md, start-programs.md, use-the-environment.md |
| JSON, XML (readers and source-generated serializers) | docs/how-to/read-and-write-json.md, serialize-json.md, read-and-write-xml.md, serialize-xml.md |
| Network, TLS, crypto | docs/how-to/use-the-network.md, use-https.md, use-cryptography.md |
Fibers, async/await, channels, threads, Parallel.For | docs/how-to/use-fibers.md, run-in-parallel.md |
| Dates, clock, random | docs/how-to/work-with-dates-and-times.md, use-the-clock-and-random-numbers.md |
| SIMD, tensors, GPU kernels | docs/how-to/use-simd.md, use-tensors.md, run-code-on-the-gpu.md |
| Windows/games (SDL 3), C libraries | docs/how-to/make-a-game-window.md |
Libraries, packages, native .so/.dll/.dylib | docs/how-to/create-a-library.md, build-a-native-library.md |
| F# (printf, collections, CE builders, task/async/MailboxProcessor, scopes, what's missing) | docs/how-to/write-fsharp.md |
| One target in depth | docs/concepts/targets.md (all targets; the only page for Linux, Windows, macOS, iOS simulator, Android), and docs/how-to/build-for-{c64,cx16,dos,dotnet,uefi,webassembly,microcontrollers}.md (microcontrollers covers pico2 and r4, plus use-pico2-hardware.md). For iOS and Android with dotnet, see install-with-dotnet.md |
| A walk through one program | docs/tutorial/ |
ZERO0nn build error | grep -rn ZERO0nn docs/ sdk/ZeroCSharp.Sdk/Sdk/ |
new is never freed outside an object scope: no GC. That also covers boxing, string +,
$"..." kept as a string, Console.ReadLine() and capturing lambdas. That's fine once, but in a
loop, a request handler or a frame it leaks. Put short-lived work in an arena or
OpenObjectScope(), read lines with In.ReadLine(span), format with Str.Format(arena, ...),
StrBuilder or TryFormat, and use static lambdas that take state.
This is the mistake nothing catches. In one test (SDK 0.17.0, December 2026), a program with
Console.ReadLine() in its input loop built, gave the right output, and needed 274 MB for 1M
input lines where the In.ReadLine version needed 1.7 MB. So correct output proves nothing here. Run every program that loops
over input on a large input, and check that peak memory stays flat (/usr/bin/time -l on macOS,
/usr/bin/time -v on Linux).unsafe, and each unsafe { } block gets a // SAFETY: comment that says why
nothing uses the memory afterwards.throw ends the program. catch and the finally blocks on the way out never run. Return
outcomes as a C# 15 union or a status. Wrap code that throws by design (I/O) in Catch.Run,
or Catch.RunAsync in async code, where C# catch doesn't run either.typeof(T).Name doesn't exist. JSON and XML serialization go through source
generators ([JsonSerializable], new XmlSerializer(typeof(T))).zero03, plus [DllImport]/
[LibraryImport] to C, which is unmarshalled (numbers, pointers, enums, structs of them). Never
set TargetFramework (ZERO001).Thread. Use Task/async on fibers (one thread), Task.RunOnThread for a blocking call,
and Parallel.For for CPU work. Arenas and lib/ collections are single-thread: give each thread
its own.ArenaList<T>, Dict<K,V>, RefList, StrDict, RefDict, made
with Create(arena)) for anything rebuilt often, except on the C64 (below). new ArenaList<int>() is an uncreated list whose
Add returns false. .NET's List<T>/Dictionary also work.lib/Seq.cs: start from .AsQuery().IEquatable<T>. Generic variance aborts (an IEnumerable<string>
used as an IEnumerable<object>); array covariance (string[] as object[]) works.
IsSupported is decided at build time (ZeroInstructionSet).double or collections there.
On the C64, build-for-c64.md's cost table is the most useful thing to read. $"..." passed to
an API without an interpolated-string handler (e.g. Console.Error.WriteLine($"...")) goes
through String.Format, about 30 KB. Console.Write/WriteLine, Str.Format and
StrBuilder.Append have handlers and don't.
StrDict/Dict grows it leaves
its old table in the arena, and the arena's blocks have overhead. In a test, a StrDict word
counter ran out of memory at about 120 distinct words, and plain arrays with a hand-written
hash table held more. Measure capacity: feed growing inputs in VICE until it stops, and report
the limit. Prefer fixed arrays sized from the heap you have.#if of their own. Branch on build-time
constants such as Mos6502.IsSupported (System.Runtime.Intrinsics.Mos, true on the C64 and X16),
and the untaken branch isn't linked. OperatingSystem.Is* are run-time calls, and all return
false on the C64 (docs/concepts/limits.md, build-for-several-targets.md).Arena.Sprintf or an arena { } builder instead
of Str.Format. try ... with catches inside async/task (they run on Catch.Run), but
outside them it never catches, so use Catch.result there. [<Safety>] for unsafe calls,
and each printf call site leaves heap memory each time it runs: 40 B with no values, about 100 B
with up to three, 200 B with four, 600 B with eight (write-fsharp.md, "What printf leaves
behind"). Use Console.Write in long loops, which leaves nothing. Arena sizes are unativeint (4096un).
Read write-fsharp.md before writing F#.dotnet build is the judge. An editor can flag C# 15 features that the pinned compiler accepts.Needs the .NET SDK 10.0.400+ (older → ZERO014). It builds on Linux x64/arm64, Windows x64 and Apple Silicon Macs. On an Intel Mac everything works except linking a program.
dotnet new install ZeroCSharp.Templates
dotnet new zero -o App # C#; -lang F# for F#
# others: zerolib (library), zeropico (microcontroller), zerosdl (window/game),
# zerogpu (Metal kernels), zerollama (language model)
cd App
dotnet build # bin/Debug/zero03/App, unoptimized, debuggable
dotnet run -- args
dotnet publish # Release, optimized and stripped, into the publish folder
dotnet build -p:ZeroTarget=<target> # bin/<cfg>/zero03/<target>/...
ZeroTarget | Output | Run with / notes |
|---|---|---|
linux-x64, linux-arm64, win-x64, osx-arm64 | native exe | cross-builds from any of the host OSes |
iossimulator-arm64 | console exe | dotnet run uses xcrun simctl (Mac + Xcode) |
android-arm64 | console exe | dotnet run copies via adb to /data/local/tmp/zero |
uefi-x64, uefi-arm64 | .efi | QEMU + OVMF, or a USB stick |
c64 | .prg (+ .prg.elf) | VICE (below); first build downloads compilers; on a Mac it needs docker; not from Linux arm64 (no llvm-mos build there) |
cx16 | .prg (+ .BNK) | x16emu; needs SDK 0.18.0+; not from Linux arm64 |
pico2, r4 | Pico 2: .uf2 (copy to the board), .elf, qemu/*.elf; R4: QEMU only so far | dotnet run runs it in QEMU; first build downloads ~400 MB of tools; on a Mac Docker must run; start with dotnet new zeropico |
dotnet | bin/<cfg>/net11.0/App.dll, framework-dependent | dotnet bin/Debug/net11.0/App.dll; .NET debugger, profilers; docs/how-to/build-for-dotnet.md |
<ZeroTargets>linux-x64;win-x64;c64;dotnet</ZeroTargets>
(docs/how-to/build-for-several-targets.md). dotnet build builds them all, but dotnet run
and dotnet publish take one target. Publish each with its own folder, because native targets
share bin/Release/zero03/publish/ and the second publish replaces the first:
dotnet publish -p:ZeroTarget=win-x64 -o publish/win-x64.-p:ZeroGpu=Metal on osx-arm64 (needs Xcode). Cuda is experimental and untested on real
hardware.<OutputType>Library</OutputType><NativeLib>Shared</NativeLib>.dotnet run doesn't start VICE):
x64sc -autostartprgmode 1 -warp -limitcycles 200000000 -keybuf-delay 50 -keybuf 'line one\nline two\n_\n' -exitscreenshot out.png App.prg.
The _ types ←, and a line holding only ← (with its RETURN, the final \n) is end of input. Then read the screenshot.obj/**/bitcode/mos/link.log ("overflowed by N bytes").llvm-nm from ~/.cache/zerocsharp/tools/llvm-mos-*/bin/ on the .prg.elf; look at
__heap_start.exec .../ilc: no such file or directory means Docker ran an amd64 ubuntu:24.04.
Build with DOCKER_DEFAULT_PLATFORM=linux/arm64 and tell the user (SDK bug)../setup.sh --wasm|--dos, then ./build.sh --wasm|--dos <Sample>). See build-for-webassembly.md and
build-for-dos.md.ZeroOptimizeFor (Speed/Size), ZeroStripSymbols,
ZeroInstructionSet, ZeroLinkLibrary items, ZeroDllImports. The full table is in
install-with-dotnet.md.Arena.DebugChecks and guard pages find mistakes
(catch-arena-mistakes.md).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
zero-mode, no-runtime, bflat, csharp, fsharp, cross-compilation
npx claudepluginhub onurgumus/zero-csharp --plugin zero-csharpOther plugins' skills for the same job