FredDotNet 1.4.0

dotnet add package FredDotNet --version 1.4.0
                    
NuGet\Install-Package FredDotNet -Version 1.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FredDotNet" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FredDotNet" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="FredDotNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FredDotNet --version 1.4.0
                    
#r "nuget: FredDotNet, 1.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FredDotNet@1.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FredDotNet&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=FredDotNet&version=1.4.0
                    
Install as a Cake Tool

Fred

CI

Find | gREp | seD | AWK for .NET

A high-performance text processing toolkit designed as file editing infrastructure for AI coding tools. Four engines (find, grep, sed, AWK) with a compile-once, execute-many pattern. Thread-safe. No subprocess overhead.

Why Fred?

AI coding assistants (Claude Code, Copilot, VS Code extensions) need to find files, search code, and make targeted edits across entire codebases. Shelling out to Unix tools is slow, fragile, and platform-dependent. Fred provides the same capabilities as a native .NET library with compiled, reusable, thread-safe script objects.

Quick Start

Library

using FredDotNet;

// Compile once, reuse many times (thread-safe)
var sed  = SedEngine.Compile("s/oldMethod/newMethod/g");
var grep = GrepEngine.Compile("TODO", ignoreCase: true);
var awk  = AwkEngine.Compile("{ print $1, $3 }");
var find = FindEngine.Compile(new[] { "src", "-name", "*.cs", "-type", "f" });

// Execute
var (output, exitCode) = sed.Execute(input);
var (output, exitCode) = grep.Execute(input);
var (output, exitCode) = awk.Execute(input);
List<string> files     = find.Execute();

// Compose into pipelines
string result = FredPipeline.Create()
    .Find("src", "-name", "*.cs", "-type", "f")
    .Grep("TODO", ignoreCase: true)
    .Sed("s/TODO/DONE/g")
    .Execute("");

CLI

# Individual tools (Unix-compatible)
echo "hello" | ned 's/hello/goodbye/'
echo "hello" | nrep -i "hello"
echo "a 1"   | nawk '{ print $2 }'
nfind . -name "*.cs" -type f

# Unified tool with in-place editing
fred . -name "*.cs" -containing "oldMethod" --sed -i 's/oldMethod/newMethod/g'

# Dry-run (preview changes as unified diff)
fred . -name "*.cs" --sed --dry-run 's/TODO/DONE/g'

# JSON structured output
fred . -name "*.cs" --grep "TODO" --json

MCP Server (for AI tool integration)

Fred includes a Model Context Protocol server for direct integration with AI coding tools:

# Run the MCP server
dotnet run --project fred-mcp

# Or publish as a single-file binary
dotnet publish fred-mcp -c Release -r linux-x64 --self-contained

Tools exposed: find, grep, sed, awk, pipeline

Features:

  • LRU caching of compiled scripts (64 entries) and find results (16 entries)
  • Repeat calls hit the cache -- zero recompilation, zero filesystem re-walking
  • In-place editing with backup and dry-run support
  • Structured JSON results with file paths and line numbers

Claude Code configuration:

{
  "mcpServers": {
    "fred": {
      "command": "/path/to/fred-mcp"
    }
  }
}

Architecture

FredDotNet/              # Core library
  FredDotNet.cs          # Sed engine + Grep engine + RegexTranslator
  AwkEngine.cs           # AWK interpreter (lexer, parser, interpreter)
  FindEngine.cs          # Find engine (directory walker, predicates)
  Pipeline.cs            # Composable pipeline builder
  LruCache.cs            # Generic thread-safe LRU cache
  UnifiedDiff.cs         # Diff generation
  FredResult.cs          # Structured result DTOs

Compile-Once Pattern

Every engine follows the same pattern:

Engine Static class Compile Script Thread-safe via
Find FindEngine .Compile(args) FindScript Immutable + per-call EvalContext
Grep GrepEngine .Compile(pattern) GrepScript Fully immutable
Sed SedEngine .Compile(script) SedScript Per-call SedExecutionContext
AWK AwkEngine .Compile(program) AwkScript Fresh AwkInterpreter per call

Performance

  • No LINQ on hot paths
  • Compiled regex caching (ConcurrentDictionary)
  • Grep streams line-at-a-time with ring buffer for context (O(beforeContext) memory)
  • Find uses Directory.EnumerateFileSystemEntries (lazy enumeration)
  • BRE/ERE regex translation shared between sed and grep via RegexTranslator

Testing

dotnet build Fred.sln    # 0 errors, 0 warnings
dotnet test Fred.sln     # 926 tests
Test suite Tests What it validates
FredDotNet.Tests 457 Library unit tests
ned.Tests 36 sed CLI tests
SedValidation.Tests 103 ned vs /usr/bin/sed oracle
GrepValidation.Tests 120 nrep vs /usr/bin/grep oracle
AwkValidation.Tests 106 nawk vs /usr/bin/awk oracle
FindValidation.Tests 104 nfind vs /usr/bin/find oracle

Oracle tests run both the .NET tool and the real Unix binary on identical input, then assert byte-for-byte identical output and exit codes.

Building

git clone https://github.com/user/fred.git
cd fred
dotnet build Fred.sln
dotnet test Fred.sln

Publishing single-file binaries

dotnet publish fred -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true
dotnet publish fred-mcp -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 102 4/19/2026
1.3.0 98 4/19/2026
1.2.0 113 4/13/2026
1.2.0-preview.1 56 4/10/2026
1.1.0 118 4/10/2026
1.0.0 116 4/9/2026