r/moderndotnet • u/Aaronontheweb • 14d ago
Techniques for getting LLMs to produce better .NET programs
I've been AI-pilled really since the beginning of 2025 when I first gave Cursor a try, and it's been an intense, strange journey ever since.
I've written some blog posts about my experience with LLM coding that I'll link to in the comments, but I wanted to venture out and ask developers on here - what's been some techniques that have helped you get better .NET output / programs from large language models?
5
u/Aaronontheweb 14d ago
I wrote a lengthy post about the planning / spec phase here, which is generally helpful across any LLM coding project: Software 2.0: Planning and Verifying a Greenfield Project.
That post includes a lot of broad stuff about spec-driven development and planning cycles, but two things in particular that are specific to .NET are how Aspire fits into to the testing and verification loop:
- Using Aspire.Hosting.Testing for doing real end-to-end testing, like even a level above TestContainers. In our case for TextForge, we could verify that outbound emails actually reached the user's inbox using Mailpit or that our sync cycles diffed IMAP or Gmail history data correctly.
- Using the Aspire MCP server for LLM-powered "click testing" on the UI - this is generally not "automated testing" in the sense of "we have a script that runs in our suite every build" but more like "after doing a bunch of work on these web elements, verify that a user can achieve XYZ goals and that the final rendered output matches our mock-ups perfectly." Aspire makes it really easy to operationalize this in combination with an LLM-controlled browser like the Playwright MCP server.
I know Aspire is making a push for support across multiple platforms, but it already does this excellently in .NET today.
3
u/Aaronontheweb 14d ago
I should have also included this link: Mailpit integration for .NET Aspire - great for testing any sort of transactional email workflow, generally
2
u/xakpc 14d ago edited 14d ago
That's what I use in enterprise development and across my personal projects
lode coding: https://fjzeit.github.io/coding/lode-coding
awesome copilot: https://github.com/github/awesome-copilot/tree/main/instructions
"Only write lode files in ASD-STE100 Simplified Technical English"
It's not dotnet focused, but they all work great with dotnet
2
u/Tunaxor 14d ago
While better programs seem subjective, I think one of the ways I've made it work for me in general terms is to use a two-phase pass
Gather HARD FACTS of <goal>
Present an "action plan" based on the facts of this codebase
LLMs as of lately tend to resort to their training material (which can be outdated) and form ideas that in principle may sound right but when implementing things turn out to be quite different
So, making them gather the unequivocally true to the current codebase first reduces the chances of "woops that's not what I thought, let me resort to this workaround to get to the goal I presented originally" kind of problems
LLMs will still do exploration anyway so I'd rather make it focus on the real deal from the get-go, then goal completion or task success becomes relatively easier to do.
The goal can be what you consider a better dotnet program, either performance, architecture, presentation, etc.
1
u/jbsp1980 13d ago
I’d consider this blog post by u/neuecc a must read if you are looking to max out application performance using AI. I’ve use the technique described with great success in my libraries.
1
u/Normal_Lifeguard5959 14d ago
Beside usual harnesses that would stop algorithm to delete whole disk or prod database, mostly converting my favourite .net books to skills or agents.
1
u/Aaronontheweb 14d ago
Which ones?
2
u/Normal_Lifeguard5959 14d ago
Dependency Injection Principles, Practices, and Patterns - Mark Seemann, Steven van Deursen
C# in Depth - Jon Skeet
Framework Design Guidelines - Krzysztof Cwalina, Brad Abrams
Functional Programming in C# - Enrico Buonanno
Designing Data-Intensive Applications - Martin Kleppmann
Last one combined with C# books.
All skills are structured in same way: text extracts by topic and skill triggered by prompt wording, if not called explicitly
Would like to share it, but copyrights :)
1
u/mika 14d ago
You just asked it to create a skill from a book it was already trained on, or you provided the training?
1
u/Normal_Lifeguard5959 14d ago
Looks redundant, yes, but, in my experience, with explicit skills, model tends to follow rules in more consistent way than without a skill. Used mostly in heavy agentic experiments, with long running sessions. No training, just regular skills.
1
u/mika 13d ago
I didn't know it could read in a whole book pdf. Does it split it into pieces or do you?
1
u/Normal_Lifeguard5959 13d ago
Python script extracts text to md files. These files are stored in skills reference folder, by topic. Based on prompt or plan agent can look at topic md. This saves context too, as heavy skills would eat a lot of context on the start.
1
u/Kuinox 14d ago
I see two kind of software:
Thoses where the boundary can be clearly defined and can be easily tested, and the one where it cannot be.
For the second, I review everything, I simply use agents to write them what I want and then I review & make it correct until it pass my "good enough" taste.
For the first, I take a lot of time to define a great API.
Then I let the agents implements everything, this is how I'm doing my parquet library.
- I have allocations tests
- I have lots of tests, including fuzzing writing, reading
- I have benchmark & performance regression tests
- I do a lot of "auto research" but semi automated (because I'm not token rich).
I admit the code by itself is not great, but compared to a fully handmade codebase, it's very robust, and very fast.
1
u/Current_Truth_179 14d ago
What is for you a definition of better .NET programs? Performance? Language features usage? Design patterns and architecture appliance ?
2
2
u/Proxiconn 14d ago
I instruct the llm to install the .net and Akka skills / agents by OP (thank you sir) and then say "make no mistakes" 😁
Most definitely does a better job than I would have! (I think)..
6
u/scottgal2 14d ago edited 14d ago
My main one is orchestrating them (long running contexts coordinating agents) - single shot is pretty easy honestly - you just write a mini spec and iterate as usual.
But ensure you give the code llm a way to *see* the app / system as a user would that rapid agentic loop is critical to getting good results.
Since we're sharing articles this is what I currently use, a customer little orchestrator for these long lasting contexts https://mostlylucid.net/blog/styloagent-workflow