wshaddix/dotnet-skills/csharp-scripts
Claude Code and agent skill by wshaddix/dotnet-skills
- community
Checking that the SKILL.md file is still in the repository.
Run single-file C# programs as scripts for quick experimentation, prototyping, and concept testing. Use when the user wants to write and execute a small C# program without creating a full project.
Install
npx vskill@latest install wshaddix/dotnet-skills/csharp-scriptsSKILL.md
C# Scripts
When to Use
- Testing a C# concept, API, or language feature with a quick one-file program
- Prototyping logic before integrating it into a larger project
When Not to Use
- The user needs a full project with multiple files or project references
- The user is working inside an existing .NET solution and wants to add code there
- The program is too large or complex for a single file
Inputs
| Input | Required | Description | |
|---|---|---|---|
| C# code or intent | Yes | The code to run, or a description of what the script should do |
Workflow
Step 1: Check the .NET SDK version
Run dotnet --version to verify the SDK is installed and note the major version number. File-based apps require .NET 10 or later. If the version is below 10, follow the fallback for older SDKs instead.
Step 2: Write the script file
Create a single .cs file using top-level statements. Place it outside any existing project directory to avoid conflicts with .csproj files.
Guidelines:
- Use top-level statements (no
Mainmethod, class, or namespace boilerplate) - Place
usingdirectives at the top of the file - Place type declarations (classes, records, enums) after all top-level statements
Step 3: Run the script
Builds and runs the file automatically. Cached so subsequent runs are fast. Pass arguments after --:
Step 4: Add NuGet packages (if needed)
Use the #:package directive at the top of the file to reference NuGet packages. Always specify a version:
Step 5: Clean up
Remove the script file when the user is done. To clear cached build artifacts:
Unix shebang support
On Unix platforms, make a .cs file directly executable:
- Add a shebang as the first line of the file:
``csharp #!/usr/bin/env dotnet Console.WriteLine("I'm executable!"); ``
- Set execute permissions:
``bash chmod +x hello.cs ``
- Run directly:
``bash ./hello.cs ``
Use LF line endings (not CRLF) when adding a shebang. This directive is ignored on Windows.
Source-generated JSON
File-based apps enable native AOT by default. Reflection-based APIs like JsonSerializer.Serialize<T>(value) fail at runtime under AOT. Use source-generated serialization instead:
Converting to a project
When a script outgrows a single file, convert it to a full project:
Fallback for .NET 9 and earlier
If the .NET SDK version is below 10, file-based apps are not available. Use a temporary console project instead:
Replace the generated Program.cs with the script content and run with dotnet run. Add NuGet packages with dotnet add package <name>. Remove the directory when done.
Validation
- [ ]
dotnet --versionreports 10.0 or later (or fallback path is used) - [ ] The script compiles without errors (can be checked explicitly with
dotnet build <file>.cs) - [ ]
dotnet <file>.csproduces the expected output - [ ] Script file and cached artifacts are cleaned up after the session
Common Pitfalls
| Pitfall | Solution | |
|---|---|---|
.cs file is inside a directory with a .csproj | Move the script outside the project directory, or use dotnet run --file file.cs | |
#:package without a version | Specify a version: #:package PackageName@1.2.3 or @* for latest | |
| Reflection-based JSON serialization fails | Use source-generated JSON with JsonSerializerContext (see Source-generated JSON) | |
| Unexpected build behavior or version errors | File-based apps inherit global.json, Directory.Build.props, Directory.Build.targets, and nuget.config from parent directories. Move the script to an isolated directory if the inherited settings conflict |
More info
See https://learn.microsoft.com/en-us/dotnet/core/sdk/file-based-apps for a full reference on file-based apps.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/csharp-scripts/SKILL.md
Popularity
- Repository stars
- 86
- Repository forks
- 14
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wshaddix/dotnet-skills/csharp-scripts)