Back to Skills

optimizing-io-operations

verified

Optimizes standard I/O and file operations for high-performance data processing in .NET. Use when building high-throughput file processing or competitive programming solutions.

View on GitHub

Marketplace

dotnet-claude-plugins

christian289/dotnet-with-claudecode

Plugin

wpf-dev-pack

development

Repository

christian289/dotnet-with-claudecode
5stars

wpf-dev-pack/skills/optimizing-io-operations/SKILL.md

Last Verified

January 23, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/christian289/dotnet-with-claudecode/blob/main/wpf-dev-pack/skills/optimizing-io-operations/SKILL.md -a claude-code --skill optimizing-io-operations

Installation paths:

Claude
.claude/skills/optimizing-io-operations/
Powered by add-skill CLI

Instructions

# .NET High-Performance I/O

A guide for APIs optimizing large-scale data input/output.

**Quick Reference:** See [QUICKREF.md](QUICKREF.md) for essential patterns at a glance.

## 1. Core APIs

| API | Purpose |
|-----|---------|
| `Console.OpenStandardInput()` | Buffered stream input |
| `Console.OpenStandardOutput()` | Buffered stream output |
| `BufferedStream` | Stream buffering |
| `FileOptions.Asynchronous` | Async file I/O |

---

## 2. High-Speed Standard I/O

### 2.1 Basic Pattern

```csharp
// Use buffer stream directly for large I/O
using var inputStream = Console.OpenStandardInput();
using var outputStream = Console.OpenStandardOutput();
using var reader = new StreamReader(inputStream, bufferSize: 65536);
using var writer = new StreamWriter(outputStream, bufferSize: 65536);

// Disable buffer flush for performance improvement
writer.AutoFlush = false;

string? line;
while ((line = reader.ReadLine()) is not null)
{
    writer.WriteLine(ProcessLine(line));
}

// Manual flush at the end
writer.Flush();
```

### 2.2 For Algorithm Problem Solving

```csharp
using System.Text;

// High-speed input
using var reader = new StreamReader(
    Console.OpenStandardInput(),
    Encoding.ASCII,
    bufferSize: 65536);

// High-speed output
using var writer = new StreamWriter(
    Console.OpenStandardOutput(),
    Encoding.ASCII,
    bufferSize: 65536);

var sb = new StringBuilder();

// Collect large output in StringBuilder and write at once
for (int i = 0; i < 100000; i++)
{
    sb.AppendLine(i.ToString());
}

writer.Write(sb);
writer.Flush();
```

---

## 3. File I/O Optimization

### 3.1 Buffer Size Optimization

```csharp
// Use larger buffer than default (4KB)
const int bufferSize = 64 * 1024; // 64KB

using var fileStream = new FileStream(
    path,
    FileMode.Open,
    FileAccess.Read,
    FileShare.Read,
    bufferSize: bufferSize);
```

### 3.2 Async File I/O

```csharp
// Open file with async option
using var fileStream = new FileStream(
    path,
    File

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
4651 chars