Tooluck logoTooluck
SKILL.md

aot-trimming

Agent skill fromAaronontheweb/dotnet-skills

Guidelines for making .NET libraries and applications trimming-safe and Native AOT compatible. Covers the trimming/AOT model, the MSBuild properties that enable analysis (IsTrimmable, IsAotCompatible, PublishTrimmed, PublishAot), the trimming attributes (RequiresUnreferencedCode, RequiresDynamicCode, DynamicallyAccessedMembers, UnconditionalSuppressMessage), IL2xxx/IL3xxx warning codes, and a pattern playbook: source generators and UnsafeAccessor, generated-interception diagnostic suppressors, intentional runtime scanning boundaries, trimming-safe islands and feature switches, migration analyzers, and temporary warning-approval baselines. Use when introducing trimming/AOT support, resolving IL2xxx/IL3xxx warnings, or making reflection-heavy code trimming-safe in C# / .NET codebases. For System.Text.Json AOT scenarios, see also the serialization skill.

How to install aot-trimming

install aot-trimming
# 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/aot-trimming/

# into

~/.claude/skills/aot-trimming/ (all projects)

.claude/skills/aot-trimming/ (one project)

skills/aot-trimming/SKILL.md

MITFull file
1# .NET Trimming and Native AOT
2
3## When to Use
4
5- Adding trimming (`PublishTrimmed`) or Native AOT (`PublishAot`) support to a library or application
6- Resolving `IL2xxx` (trimming) and `IL3xxx` (AOT/single-file) warnings
7- Making reflection-heavy code trimming-safe
8- Replacing runtime reflection, assembly scanning, or `Reflection.Emit` with compile-time alternatives
9- Reviewing a codebase or PR for trimming/AOT compatibility, including generated interceptors and analyzer suppressors
10- Designing public APIs that must carry trimming annotations
11
12## Core Goals
13
14- Produce code that survives the linker's reachability analysis and runs under Native AOT (no JIT).
15- Express what the compiler cannot see — which members reflection needs — using the trimming attributes.
16- Keep trimming-safe and trimming-unsafe code separated so unsafe paths are explicit and contained.
17
18## Core Model
19
20### Trimming vs Native AOT
21
22- **Trimming** (`PublishTrimmed`) runs ILLink reachability analysis: only statically reachable code is kept. Reflection the analyzer cannot see is trimmed away and produces warnings.
23- **Native AOT** (`PublishAot`) makes trimming mandatory and removes the JIT. `Reflection.Emit` is unsupported, constructing *unknown* generic instantiations at runtime is not guaranteed, `Expression.Compile()` may fall back to interpretation, and reflection works only over members the linker preserved.
24- Both run the same static analysis:
25…

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

nexu-io /

open-design
107k

The 1st Collaborative AI Design Agent Workspace. Local-first and open source. Create motion, prototypes, websites, apps, dashboards, presentations, images, and videos with your team and AI agents. Share work, exchange feedback, and iterate together in one workspace.

40 skills

tt-a1i /

archify
95k

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

CCCXOC1 skill

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates