DO

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.zip

Installs 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.
192 chars✓ has a “when” trigger
Intermediate

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

You give it
C# code file or stdin string
You get back
Execution result of the C# code

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:

  1. Create a .cs file with your code (top-level statements supported)
  2. Add directives at the top if needed (packages, SDK, properties)
  3. 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:

  1. Ask what they want to accomplish
  2. Determine if stdin one-liner or file-based is better
  3. For simple tasks → use stdin pattern
  4. For complex tasks → create a .cs file
  5. Add necessary directives based on requirements
  6. 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

.NET 10

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.

SkillInstallsUpdatedSafetyDifficulty
dotnet-run-file (this skill)06moReviewIntermediate
csharp-developer432moNo flagsAdvanced
csharp-pro94moNo flagsIntermediate
dotnet-architect124moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

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.

43151

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.

953

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.

1241

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.

211

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.

13

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.

12

Search skills

Search the agent skills registry