string-perf-patterns

string-perf-patterns is a skill for Claude Code, Codex from lewing/helix.mcp. It costs 0 tokens per session (732 once invoked), scanned A, original, MIT.

Guidance for processing large amounts of text efficiently in C# and .NET. It focuses on avoiding extra full-size strings and temporary arrays when reading, searching, or extracting lines.

In plain words
What is it for?
Use it when writing or reviewing .NET code that normalizes line endings, takes the beginning or end of text, or matches patterns in multi-megabyte strings.
Why use it?
It helps prevent unnecessary memory use and slow processing when code handles large logs, API responses, or search content.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/lewing/helix.mcp/string-perf-patterns
Any agent
npx skills add lewing/helix.mcp --skill string-perf-patterns
Clone the repo
git clone --depth 1 https://github.com/lewing/helix.mcp

Made for: Claude Code, Codex.

Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 732 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00732
Opus 5 $0.00000 $0.00366
Sonnet 5 $0.00000 $0.00146
Haiku 4.5 $0.00000 $0.00073

Measured 3d ago against content hash a04aa74332f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

string-perf-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.copilot/skills/string-perf-patterns/SKILL.md · 76 lines

How it starts

The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SKILL: String Performance Patterns in .NET

When to apply

When writing or reviewing C# code that processes text content — especially log files, API responses, or search operations that may handle multi-MB strings.

Patterns to avoid

1. Chained .Replace() for line-ending normalization

// BAD — 2 intermediate full-size strings
var normalized = content.Replace("\r\n", "\n").Replace("\r", "\n");

Fix: Use a span-based line enumerator, or string.Create with a single-pass copy that normalizes as it goes. For search operations, consider handling mixed line endings during iteration instead of pre-normalizing.

2. Split() + Join() for tail/head operations

// BAD — allocates string[] of all lines just to get last N
var lines = content.Split('\n');
return string.Join('\n', lines[^tailLines..]);

Fix: Reverse-scan for Nth \n using ReadOnlySpan<char>:

var span = content.AsSpan();
int pos = span.Length;
for (int i = 0; i < tailLines && pos > 0; i++)
{
    pos = span[..pos].LastIndexOf('\n');
    if (pos < 0) { pos = 0; break; }
}
return pos > 0 ? content[(pos + 1)..] : content;

3. Substring allocation in pattern matching

// BAD — allocates new string every call
name.EndsWith(pattern[1..], StringComparison.OrdinalIgnoreCase);

Fix: Use spans:

name.AsSpan().EndsWith(pattern.AsSpan(1), StringComparison.OrdinalIgnoreCase);

4. Triple-iteration for categorization

// BAD — 3 passes over same list
Binlogs = files.Where(f => IsBinlog(f)).Select(Map).ToList();
TestResults = files.Where(f => IsTest(f)).Select(Map).ToList();
Other = files.Where(f => !IsBinlog(f) && !IsTest(f)).Select(Map).ToList();

Fix: Single-pass loop:

var binlogs = new List<FileInfo_>();
var testResults = new List<FileInfo_>();
var other = new List<FileInfo_>();
foreach (var f in files)
{
    var mapped = new FileInfo_ { Name = f.Name, Uri = f.Uri };
    if (IsBinlog(f.Name)) binlogs.Add(mapped);
    else if (IsTest(f.Name)) testResults.Add(mapped);
    else other.Add(mapped);
}

Read the full file on GitHub · 76 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 76 lines · 0 tokens per session scan A a04aa74332f7

Subscribe to this mod's changes

string-perf-patterns is a skill published in the GitHub repository lewing/helix.mcp (4 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 732 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.