dotnet-run-file
Run C# files and stdin scripts instantly with dotnet run, supporting NuGet packages and SDK directives.
Install
mkdir -p .claude/skills/dotnet-run-file && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/10514" && unzip -o skill.zip -d .claude/skills/dotnet-run-file && rm skill.zipInstalls to .claude/skills/dotnet-run-file
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Run script-like CSharp programs using dotnet run file.cs. Use this skill when users want to execute CSharp code directly, write one-liner scripts via stdin, or learn about run file directives.Key capabilities
- →Execute C# code without project files
- →Process one-liner scripts via stdin
- →Apply run file directives for packages and SDKs
- →Convert run files to full projects
How it works
The skill utilizes the .NET 10 run file feature to compile and execute C# code directly, supporting directives for external dependencies and MSBuild properties.
Inputs & outputs
When to use dotnet-run-file
- →Executing quick C# snippets
- →Testing libraries without project setup
- →Converting run-file scripts to projects
About this skill
.NET Run Files
Run C# code directly without creating project files using .NET 10's dotnet run file.cs feature.
When to Use This Skill
Use this skill when the user wants to:
- Execute C# code quickly without creating a project
- Write one-liner scripts via stdin (ideal for Claude Code)
- Learn about run file directives (
#:package,#:sdk,#:property) - Create executable shell scripts in C#
- Convert a run file to a full project
Guide
For detailed examples and directives reference, load references/guide.md.
Quick Reference
Basic Execution
# Run a .cs file
dotnet run app.cs
# Run from stdin
echo 'Console.WriteLine("Hello");' | dotnet run -
# Multi-line via heredoc
dotnet run - << 'EOF'
var now = DateTime.Now;
Console.WriteLine($"Time: {now}");
EOF
Directives
#:package Humanizer@* // NuGet package (version required, wildcards ok)
#:sdk Microsoft.NET.Sdk.Web // SDK selection
#:property LangVersion preview // MSBuild property
#:project ../src/MyLib // Project reference
Convert to Project
dotnet project convert app.cs
Core Operations
1. Run a C# File
Steps:
- Create a
.csfile with your code (top-level statements supported) - Add directives at the top if needed (packages, SDK, properties)
- Execute:
dotnet run filename.cs
Example:
// hello.cs
Console.WriteLine("Hello from .NET!");
dotnet run hello.cs
2. Execute via Stdin
Purpose: Run C# code without creating files - ideal for quick scripts and AI-assisted workflows.
Patterns:
# Simple one-liner
echo 'Console.WriteLine(Math.PI);' | dotnet run -
# With package
dotnet run - << 'EOF'
#:package Humanizer@*
using Humanizer;
Console.WriteLine(TimeSpan.FromMinutes(90).Humanize());
EOF
# Heredoc for multi-line
dotnet run - << 'EOF'
using System.Text.Json;
var obj = new { Name = "Test", Value = 42 };
Console.WriteLine(JsonSerializer.Serialize(obj));
EOF
Interactive Flow
When user asks to run C# code without specifics:
- Ask what they want to accomplish
- Determine if stdin one-liner or file-based is better
- For simple tasks → use stdin pattern
- For complex tasks → create a
.csfile - Add necessary directives based on requirements
- Execute and show results
Claude Code Integration Tips
For AI-assisted workflows:
- Prefer stdin for quick calculations, data transformations, API calls
- Use heredoc syntax for multi-line code
- Output JSON for easy parsing:
dotnet run script.cs | jq .
When not to use it
- →When the application requires a complex, multi-file project structure from the start
Prerequisites
Limitations
- →Requires .NET 10 for full functionality
How it compares
It allows for immediate execution of C# snippets without the overhead of creating and managing formal project files.
Compared to similar skills
dotnet-run-file side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| dotnet-run-file (this skill) | 0 | 6mo | Review | Intermediate |
| csharp-developer | 43 | 2mo | No flags | Advanced |
| csharp-pro | 9 | 4mo | No flags | Intermediate |
| dotnet-architect | 12 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by NikiforovAll
View all by NikiforovAll →You might also like
csharp-developer
zenobi-us
Expert C# developer specializing in modern .NET development, ASP.NET Core, and cloud-native applications. Masters C# 12 features, Blazor, and cross-platform development with emphasis on performance and clean architecture.
csharp-pro
sickn33
Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.
dotnet-architect
sickn33
Expert .NET backend architect specializing in C#, ASP.NET Core, Entity Framework, Dapper, and enterprise application patterns. Masters async/await, dependency injection, caching strategies, and performance optimization. Use PROACTIVELY for .NET API development, code review, or architecture decisions.
update-roslyn-version
dotnet
Guide for updating the Roslyn language server version in the vscode-csharp repository. Use this when asked to update Roslyn, bump the Roslyn version, or upgrade the language server version.
orchardcore-module-creator
OrchardCMS
Creates new OrchardCore modules with proper structure, manifest, startup, and patterns. Use when the user needs to create a new module, add content parts, fields, drivers, handlers, or admin functionality.
component-development
FritzAndFriends
Guidance for creating Blazor components that emulate ASP.NET Web Forms controls. Use this when implementing new components or extending existing ones in the BlazorWebFormsComponents library.