Run file-based C# apps with the .NET CLI when the user explicitly wants C#/.NET code without creating a project. Use for C# language/API experiments, one-file C# apps, small multi-file C# apps composed with `#:include`/`#:exclude`, or C# file-based apps linked with `#:ref`. Do not use for language-agnostic throwaway scripts, generic computations, Python/PowerShell-style automation, full projects, or existing app integration.
csharp-scripts is an official .NET skill for running file-based C# apps with the .NET CLI when a user explicitly wants to try C#/.NET code without scaffolding a full project. It solves the friction of quick C# experimentation: instead of creating a .csproj and solution, the user writes a single entry-point .cs file with top-level statements and runs it directly with `dotnet hello.cs`, which builds, caches, and executes automatically. It is scoped deliberately — for language/API experiments, prototypes, and small utilities — and explicitly not for language-agnostic throwaway scripts, generic computations, full projects, or integration into existing solutions.
The workflow verifies the SDK version (file-based apps require .NET 10+, with multi-file `#:include`/`#:exclude` needing SDK 10.0.300+), then writes the entry-point file and runs it, passing arguments after `--`. Its core capability is a set of `#:` directives placed at the top of the file: `#:package` for NuGet references (with version pinning), `#:property` for arbitrary MSBuild properties and expressions, `#:project` for project references, `#:ref` for compiling a referenced .cs file as a separate assembly, `#:sdk` for SDK selection (e.g. Microsoft.NET.Sdk.Web), and `#:include`/`#:exclude` for composing multi-file apps. Directives are transitive, so helper files can declare their own.
The target users are C# and .NET developers who want a fast, low-ceremony way to test ideas, prototype logic before integrating it, or build a small helper from a handful of files. It is a single-file documentation skill (MIT-licensed) that guides the agent through the modern file-based-app feature set, including guidance to place files outside existing project directories and to add a shebang for Unix executability.
File-based apps require .NET SDK 10 or later. The `#:include`, `#:exclude`, and transitive directive processing features additionally require SDK 10.0.300+; a 10.0.100 or 10.0.200 SDK can run single-file apps but not those multi-file directives.
For language-agnostic throwaway scripts or shell/Python/PowerShell-style automation, for full projects or solution integration, when adding code inside an existing .NET solution, or when the app is large enough that a .csproj with build/test/publish config is warranted.
Use `#:` directives at the top of the file: `#:package Name@Version` for NuGet references, `#:property Name=Value` for MSBuild properties (including expressions), `#:project` for project references, and `#:sdk` to override the default SDK.
Yes. Use `#:include` for helper source files sharing the same assembly and `#:exclude` to trim an include pattern; use `#:ref` when a referenced file should compile into a separate assembly like a project reference. Directives are transitive across included files.
Place them after `--`, e.g. `dotnet hello.cs -- arg1 arg2 "multi word arg"`.
Quick Setup:
.claude/skills/Repository
dotnet/skills