Tooluck logoTooluck
SKILL.md

type-design-performance

Agent skill fromAaronontheweb/dotnet-skills

Design .NET types for performance. Seal classes, use readonly structs, prefer static pure functions, avoid premature enumeration, and choose the right collection types.

How to install type-design-performance

install type-design-performance
# install the dotnet-skills pack with the skills CLI
npx skills add Aaronontheweb/dotnet-skills

# or add only this skill to Claude Code: copy the folder

skills/csharp-type-design-performance/

# into

~/.claude/skills/csharp-type-design-performance/ (all projects)

.claude/skills/csharp-type-design-performance/ (one project)

skills/csharp-type-design-performance/SKILL.md

MITFull file
1# Type Design for Performance
2
3## When to Use This Skill
4
5Use this skill when:
6- Designing new types and APIs
7- Reviewing code for performance issues
8- Choosing between class, struct, and record
9- Working with collections and enumerables
10
11---
12
13## Core Principles
14
151. **Seal your types** - Unless explicitly designed for inheritance
162. **Prefer readonly structs** - For small, immutable value types
173. **Prefer static pure functions** - Better performance and testability
184. **Defer enumeration** - Don't materialize until you need to
195. **Return immutable collections** - From API boundaries
20
21---
22
23## Seal Classes by Default
24
25Sealing classes enables JIT devirtualization and communicates API intent.
26
27```csharp
28// DO: Seal classes not designed for inheritance
29public sealed class OrderProcessor
30{
31 public void Process(Order order) { }
32}
33
34// DO: Seal records (they're classes)
35public sealed record OrderCreated(OrderId Id, CustomerId CustomerId);
36
37// DON'T: Leave unsealed without reason
38public class OrderProcessor // Can be subclassed - intentional?
39{
40 public virtual void Process(Order order) { } // Virtual = slower
41}
42```
43
44**Benefits:**
45- JIT can devirtualize method calls
46- Communicates "this is not an extension point"
47- Prevents accidental breaking changes
48
49---
50
51## Readonly Structs for Value Types
52
53Structs should be `readonly` when immutable. This prevents defensive copies.
54
55```csharp
56// DO: Readonly struct for immutable value types
57…

Excerpt shown under the repository's MIT license.

More skills in dotnet-skills

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Leonxlnx /

taste-skill
113k

Agent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages

CCCXCU1 skill

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates