AI Coding Assistants
EggMapper ships short, tested guidance for AI coding assistants (Claude Code, Cursor, GitHub Copilot, Codex and others), so they write working mapping code on the first try and spend fewer tokens finding out what the API looks like.
Guidance files
| File | Size | Use |
|---|---|---|
llms.txt | about 1,200 tokens | Quick start, API card, configuration, AutoMapper differences, errors and their fixes |
llms-full.txt | about 2,500 tokens | Full reference: every member and map option, enums, DI, projection, compile-time tiers |
Every runtime API example in both files is compiled against the current EggMapper API by the unit tests, so API names and signatures in the guidance cannot drift from the library.
Rules to paste into your project
Add this block to the instructions file your assistant reads: CLAUDE.md, AGENTS.md, .cursor/rules/eggmapper.mdc or .github/copilot-instructions.md.
## Object mapping: EggMapper
- API reference for AI: https://eggspot.github.io/EggMapper/llms.txt (full: llms-full.txt). Read it before writing mapping code.
- Put maps in Profile classes; register them with services.AddEggMapper(typeof(SomeProfile).Assembly).
- Map with mapper.Map<TSource, TDestination>(source); lists with mapper.MapList<TSource, TDestination>(items).
- Inject IMapper<TSource, TDestination> on hot paths.
- Keep one MapperConfiguration (singleton); never create one per request.
- ProjectTo needs both type arguments: query.ProjectTo<TSource, TDestination>(config).
- Configure members with ForMember(d => d.X, o => o.MapFrom(s => ...)) or o.Ignore().
- Not available: ForCtorParam, ForSourceMember, IncludeMembers, Include<,>, As<>, nested ForPath (d => d.A.B), mapper.ConfigurationProvider.
- Keep one test that calls config.CompileMappings() and config.AssertConfigurationIsValid().
- Reference EggMapper.Analyzers: EGG1004 build warnings name the ForMember fix for each unmapped member; apply them.
- On a mapping error, apply the CreateMap or ForMember the message names instead of guessing.
The validation test
One test catches unmapped destination members and broken MapFrom expressions before anything runs, so an assistant gets the error from the test run instead of from production:
[Fact]
public void MapperConfiguration_IsValid()
{
var config = new MapperConfiguration(cfg => cfg.AddMaps(typeof(OrderProfile).Assembly));
config.CompileMappings();
config.AssertConfigurationIsValid();
}
Unmapped members at build time
With dotnet add package EggMapper.Analyzers, every destination member of a CreateMap that has no source member becomes a build warning (EGG1004) carrying the fix, so an assistant sees and repairs an unfinished map in the same dotnet build it already runs:
warning EGG1004: Destination member 'OrderDto.CustomerName' has no source member in CreateMap<Order, OrderDto>().
Fix: .ForMember(d => d.CustomerName, o => o.MapFrom(s => s.CustmerName)) or .ForMember(d => d.CustomerName, o => o.Ignore()).
Coming from AutoMapper
Assistants trained on AutoMapper code mostly write valid EggMapper code. The differences they need to know are listed in llms.txt and in the Migration Guide.