How AI coding assistants work: next-token prediction by an LLM, the context window and what the IDE sends, completion vs chat vs agent mode vs cloud coding agent, and their strengths and limits.
An AI coding assistant is a large language model that predicts the next token given a context window the IDE assembles for it: the current file around the cursor, other open tabs, repository instructions such as .github/copilot-instructions.md or AGENTS.md, and snippets retrieved from the codebase. It has no compiler inside it, so it produces plausible code, not checked code.
dotnet build and dotnet test, reads the errors and iterates, or works from an issue and opens a PR.It is excellent at boilerplate, tests and explaining code, and weak at novel design and anything newer than its training data. The trade-off: speed of first draft against the cost of verifying it.
"Underneath, a coding assistant is a large language model doing next-token prediction. It never sees my whole solution: the IDE builds a prompt from the code around my cursor, my open tabs, any repository instruction files like
copilot-instructions.mdorAGENTS.md, and snippets it retrieves from the repo, then the model continues that text. There is no compiler or runtime in that loop, so what comes back is statistically likely code, which is usually right for common patterns and confidently wrong for unusual ones.In .NET the modes matter. Inline completion is a small, low-latency model filling in the middle of a line or method, great for a mapping method or a guard clause. Chat is for 'explain this LINQ query' or 'write xUnit tests for this handler'. Agent mode goes further: it edits several files, runs
dotnet buildanddotnet test, reads the compiler errors and tries again, and GitHub's cloud coding agent can take an issue and open a pull request on its own branch. The more autonomy, the more context it can gather, but the bigger the diff I have to review.The mistake I see is treating a green build as proof. The model will invent an overload that doesn't exist, use an API from .NET 6 instead of .NET 10, or write a test that asserts what the code does rather than what it should do. So I use it as a fast first draft and keep my own judgement for the design, the edge cases and the review. It changes how fast I type, not who is accountable for the code."
| Mode | What it does | Context it uses | Best for | Watch out for |
|---|---|---|---|---|
| Inline completion | Suggests the next lines as you type | Cursor surroundings, open tabs | Boilerplate, mappings, guard clauses | Accepting without reading |
| Next edit suggestions | Predicts the next edit after a change | Recent edits in the file | Repetitive refactors | Edits in places you didn't look at |
| Chat (ask / edit) | Conversation; explains or edits selected code | Selection, referenced files, instructions | Explaining, generating tests, small edits | Answers that sound sure but are outdated |
| Agent mode (IDE) | Plans, edits many files, runs build and tests, iterates | Workspace search, terminal output, tools (MCP) | Multi-file changes with a clear goal | Large diffs, loops, touching unrelated files |
| Cloud coding agent | Works on an issue in its own environment, opens a PR | Repo, issue, instructions, CI | Well-scoped backlog items | Needs the same review as any PR |
| Good at | Bad at |
|---|---|
| Boilerplate: DTOs, mappings, DI registration | Novel architecture and trade-offs specific to your system |
| Unit test scaffolding and edge-case brainstorming | Knowing APIs released after its training cut-off |
| Explaining unfamiliar code and regex | Whole-system reasoning across many services |
| Translating between languages (VB.NET to C#) | Concurrency, security and performance subtleties |
| Writing first-draft docs and commit messages | Saying "I don't know" instead of guessing |
On [a team of 8 building an ASP.NET Core API], agent mode drafted a new CRUD slice with validator, handler and tests in about [15 minutes] instead of [half a day]. Review found [2] problems the build didn't: an async void event handler and a test that only asserted the mock was called. The time saved was real, but only because review stayed mandatory.
Checks that the candidate understands assistants as context-bound text predictors, knows the modes, and keeps accountability for correctness.
Green flags
Red flags
An LLM is a transformer trained to predict the next token (a piece of a word, roughly 3–4 characters of English or code) given the previous tokens. Generation is a loop: predict a probability distribution, sample a token, append it, repeat. Settings such as temperature control how adventurous the sampling is. Nothing in the loop checks that services.AddDbContextPool<T>() has the overload the model just wrote.
prompt tokens ──► transformer ──► probabilities for next token ──► sample ──► append ──┐
▲ │
└────────────────────────────────────────────────────────────────────────────────┘
The model only knows what is in its training data plus what is in the prompt. The IDE extension decides what goes in:
[system / instructions] copilot-instructions.md, AGENTS.md, org rules
[retrieved snippets] similar code found by search or embeddings in the repo
[open tabs] files you have open, ranked by relevance
[prefix] <cursor> [suffix] fill-in-the-middle for completions
This is why opening the interface file you are implementing improves suggestions, and why a repo instructions file that says "we use FluentValidation and TimeProvider, never DateTime.Now" changes the output.
goal ──► model plans ──► tool call (edit / build / test) ──► result back into context ──► model decides next step
▲ │
└──────────────────────────── until done or limit ──────────────┘
The model is optimised to produce likely text, not true text. Common .NET hallucinations: methods that exist on a similar type, NuGet packages with plausible names, configuration keys from an older version, and Startup.cs patterns in a .NET 10 minimal-hosting app. Training data has a cut-off, and the most common code on the internet is not always the most current or secure.
Every request costs tokens. Large contexts are slower and more expensive, and quality can drop when relevant information is buried in a long prompt. Organisations also manage data handling: business plans can exclude files from context, disable suggestions matching public code, and keep prompts out of model training.
DbContext and entity files and ask again. Compare..github/copilot-instructions.md with three house rules and check whether chat follows them.A repository instructions file is the cheapest way to improve what the assistant sees; the test below is the kind of check you write before trusting generated code.
<!-- .github/copilot-instructions.md -->
# House rules for this repo
- .NET 10, C# 14, nullable enabled, file-scoped namespaces.
- Use TimeProvider, never DateTime.Now or DateTime.UtcNow.
- Validation with FluentValidation; handlers with MediatR.
- Every async method takes a CancellationToken and passes it on.
- Tests use xUnit and FluentAssertions; assert behaviour, not mock calls.
namespace Billing.Tests;
// Generated code under test: a discount calculator the assistant wrote.
public sealed class DiscountCalculator(TimeProvider clock)
{
public decimal Apply(decimal amount, DateOnly promoEnds)
{
ArgumentOutOfRangeException.ThrowIfNegative(amount);
var today = DateOnly.FromDateTime(clock.GetUtcNow().UtcDateTime);
// Inclusive end date: the edge case assistants most often get wrong.
return today <= promoEnds ? Math.Round(amount * 0.9m, 2) : amount;
}
}
public sealed class DiscountCalculatorTests
{
// Written by a human from the requirement, not from the generated code.
[Theory]
[InlineData("2026-11-30", 90.00)] // last day of the promotion still discounts
[InlineData("2026-12-01", 100.00)] // day after does not
public void Apply_respects_inclusive_end_date(string today, double expected)
{
var clock = new FakeTimeProvider(DateTimeOffset.Parse($"{today}T10:00:00Z"));
var sut = new DiscountCalculator(clock);
sut.Apply(100m, new DateOnly(2026, 11, 30)).Should().Be((decimal)expected);
}
}
Startup.cs, Newtonsoft.Json) dominate. Instead: state the target version in instructions and verify APIs in the .NET 10 docs.The useful mental model is "a very fast junior who has read the whole internet but not our codebase and has never run anything". That person is great at drafts and terrible at judgement. What changes the quality most is not the model choice but the context: instruction files, small well-named files, clear interfaces, and good tests the agent can run. A codebase that is easy for a new developer is easy for an assistant.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Inline completion | Routine code in a familiar area | Low; needs attention per line | Security-sensitive or concurrency code |
| Chat | Explaining, tests, focused edits | Medium; prompt writing | Decisions that need system knowledge it lacks |
| Agent mode | Multi-file change with clear done criteria and tests | High review cost per change | Vague goals, no tests, unfamiliar code you can't review |
| Cloud coding agent | Small, well-specified backlog items | Reviewer time, CI minutes | Cross-cutting design, anything urgent in production |
Measure it like any tool: cycle time, review rework and escaped defects before and after, not lines generated or suggestions accepted.
A good code prompt reads like a good ticket for a capable contractor who has never seen the repo:
Result<T> type in Shared/Result.cs").Then ask for edge cases and tests first, review them, and only then ask for the implementation. When it's wrong, paste the actual compiler error or failing test instead of "try again". Rules you repeat go in an instructions file. The trade-off: a longer prompt costs a minute, a vague one costs a review cycle.
AI-generated code carries the usual risks plus some new ones:
true, MD5, or a missing [Authorize].Control it with the gates you already need (SAST, secret scanning, dependency review, human approval) plus package source mapping, lock files and allow-lists, content exclusions and a data policy. The trade-off: a little friction on new dependencies in exchange for closing the cheapest attack path.
Last updated 23 Nov 2026.