StemCode for .NET Developers: AI Coding with C# and ASP.NET Core.

Learn how .NET developers can set up StemCode for C#, ASP.NET Core, Visual Studio, csharp-ls, dotnet build, dotnet test, Entity Framework Core, refactoring, and AI code review.

PUBLISHED 2026-09-21STEMCODE DEVELOPER GUIDELOCAL-FIRST AI CODING
PROJECT INSTRUCTIONS / AGENTS.MD

Give StemCode durable repository instructions before asking it to edit.

Add an AGENTS.md file at the repository root for persistent project instructions. StemCode loads AGENTS.md or .agent/AGENTS.md from the workspace into the model context, so this is the right place for architecture boundaries, generated-file rules, coding conventions, validation expectations, and manual setup notes that should apply across sessions.

Keep AGENTS.md practical and repository-specific

Prefer concrete rules the agent can act on: where important source lives, what it must not edit, which patterns it should preserve, and which checks it should run after a change.

# .NET Project Instructions

This is a .NET / C# project.

Important source and configuration:
- *.sln and *.csproj
- src/
- tests/
- Directory.Build.props and Directory.Packages.props when present

Follow these rules:
- Use the repository's existing C# style, architecture, dependency injection, and error-handling patterns.
- Do not modify bin/, obj/, generated files, or package caches.
- Keep ASP.NET Core controllers/endpoints thin when the project already separates application logic.
- Preserve async and CancellationToken conventions across request-scoped work.
- Do not add NuGet packages unless the task requires them.
- After changes, run the smallest relevant dotnet build and dotnet test scope before broader validation.

Commit the file with the project so the same instructions are reviewable and shared by everyone using StemCode in the repository.

01 / WHY STEMCODE FOR .NET

Use AI across the solution, not only inside one C# file.

Professional .NET development involves much more than generating code. A typical task can require tracing dependency injection, understanding application and domain boundaries, reviewing Entity Framework queries, running builds, investigating tests, checking Git changes, and moving between Visual Studio and the terminal.

StemCode is designed around that complete engineering loop. It works against the repository you already use, can inspect multiple projects, use Language Server Protocol code intelligence, make tracked edits, run approved shell commands, and review the resulting diff.

GOOD FIT FOR .NET TEAMS

C#, ASP.NET Core, Web APIs, worker services, Clean Architecture, modular monoliths, microservices, Entity Framework Core, xUnit, NUnit, MSTest, Visual Studio, VS Code, and normal Git workflows can all remain part of the same development process.

02 / SETUP

Install StemCode and open your existing .NET repository.

StemCode ships as a self-contained CLI. Installing the CLI does not require the .NET SDK, although your application will still need its normal SDK and runtime to build and test.

npmnpm install -g stemcode
pnpmpnpm add -g stemcode

Then start StemCode from the solution or repository root:

cd MyDotNetSolution
stemcode

The first run guides you through selecting a provider and model. After the workspace opens, initialize repository-level StemCode files with:

/init

This gives the repository a reviewable place for shared commands, development conventions, architecture notes, and test strategy. See the workspace documentation for the full configuration model.

03 / C# CODE INTELLIGENCE

Connect StemCode to semantic C# navigation.

Text search is useful, but large C# solutions benefit from semantic information about definitions, references, symbols, diagnostics, and implementations. StemCode supports LSP-powered code intelligence and includes built-in detection for C# language servers.

Install csharp-ls

dotnet tool install --global csharp-ls

Refresh language-server detection inside StemCode:

/lsp refresh

Check all detected language servers:

/lsp

Or inspect candidates for a particular source file:

/lsp file src/MyCompany.Application/Orders/OrderService.cs
Why this matters

A repository-aware AI agent becomes more useful when it can combine normal repository search with C# symbol information. That is especially helpful when interfaces, partial classes, generic types, extension methods, and multiple projects make plain text navigation ambiguous.

04 / ASP.NET CORE

Trace a feature before asking the agent to change it.

One of the highest-value uses of StemCode is understanding an unfamiliar ASP.NET Core feature before editing anything. Instead of opening controllers, handlers, repositories, and tests manually, ask for the end-to-end flow.

EXAMPLE PROMPT

Trace order creation

Trace the complete order creation flow from the HTTP endpoint through validation, application services or handlers, domain logic, persistence, transactions, and emitted events. Identify the most important classes and methods.

Then narrow the investigation:

Find every place OrderStatus is modified and explain the valid state transitions.

Once the repository is understood, move to implementation with a prompt that explicitly asks StemCode to inspect existing patterns first:

Add support for cancelling an order before shipment.

Before editing:
- find the existing API conventions
- identify authorization rules
- inspect the application and domain flow
- find persistence changes
- identify relevant tests

Then implement the feature, run the relevant tests, and review the final diff.
05 / BUILD AND TEST

Keep the real dotnet toolchain in the loop.

The goal is not to replace the .NET SDK. It is to let the agent use the same build and test commands your team already trusts.

BUILD

Compile the solution.

dotnet restore
dotnet build
TEST

Run targeted validation.

dotnet test tests/MyCompany.Application.Tests

For large repositories, ask StemCode to start with the smallest useful validation scope:

Run the smallest relevant test project first. If it passes, run the broader solution tests.

Add a reusable .NET validation command

Teams can turn the normal restore, build, and targeted test loop into a project command under .stemcode/commands. After this file is committed, developers can run it in StemCode as /dotnet-validate.

---
name: dotnet-validate
description: Restore, build, and test the .NET solution
args: ["solution", "testProject"]
---

Validate the .NET workspace using the real dotnet toolchain.

Run these commands in order:

1. dotnet restore $solution
2. dotnet build $solution --no-restore
3. dotnet test $testProject --no-build

If a command fails, stop, summarize the failure, identify the most
relevant files or projects, and explain the next fix before editing.

Important allow-list checks

Build commands may touch package caches, generated assets, and test outputs, so keep permission prompts explicit. Before a validation-heavy session, inspect the current rules:

/permissions
/rules
/allow shell "dotnet restore *"
/allow shell "dotnet build *"
/allow shell "dotnet test *"

The important tool categories for this workflow are repository file read/search, C# language-server inspection, shell execution for dotnet restore, dotnet build, and dotnet test, and file writes only when you ask StemCode to implement a fix.

Use failures as repository context

Run the failing test, trace the failure back to production code, and explain the root cause before changing anything.
06 / ENTITY FRAMEWORK CORE

Review persistence behavior, not only syntax.

Entity Framework issues often cross repositories, projections, navigation properties, mapping, API serialization, and transaction boundaries. StemCode can inspect the full feature rather than one LINQ expression at a time.

QUERY REVIEW

Look for expensive data access.

Review the order loading flow for N+1 queries, unnecessary Includes, broad entity loading, client-side work, and places where projections would be more appropriate.

MIGRATIONS

Check deployment impact.

Review the new EF Core migration for destructive changes, backwards compatibility, long-running operations, or rollout sequencing risks.

07 / REFACTORING

Plan risky C# refactors before modifying dozens of files.

Semantic navigation becomes particularly valuable when a change affects an interface with many callers or implementations.

Find every implementation and caller of IPaymentService. Explain what would be affected if authorization and capture were split into separate abstractions.

For higher-risk work, switch to a planning profile:

/profile plan

Then ask for a staged migration:

Create a step-by-step refactoring plan that keeps the solution buildable between steps. Do not modify files yet.
08 / VISUAL STUDIO

Keep Visual Studio for deep IDE work and add repository-wide AI.

StemCode also has a Visual Studio integration powered by the local CLI. That lets .NET developers keep familiar debugging, profiling, solution management, and editor workflows while using StemCode for repository exploration and agent tasks.

REVIEW

Inspect current work.

Review my changes for regressions, async and cancellation issues, public API compatibility, authorization mistakes, and missing tests.

INVESTIGATE

Follow difficult code paths.

Explain this exception path and identify where cancellation, transaction state, or error context is being lost.

09 / PROJECT MEMORY

Teach StemCode your .NET architecture once.

Repository memory under the .stemcode directory can keep long-lived engineering context reviewable and versionable.

Example architecture notes

The solution follows Clean Architecture.

Domain does not depend on Application or Infrastructure.
Application depends on persistence abstractions.
Infrastructure contains Entity Framework implementations.
Controllers delegate business behavior to application handlers.

Example C# conventions

All asynchronous public methods accept CancellationToken.
Use records for immutable request and response DTOs.
Do not place business logic in ASP.NET Core controllers.
Prefer existing validation and error-result conventions.
10 / GIT AND CODE REVIEW

Use StemCode as an additional .NET review pass.

Before opening a pull request, ask StemCode to review the current Git diff with stack-specific concerns in mind.

Review the current Git diff as a senior .NET reviewer.

Focus on:
- correctness and regressions
- nullable-reference handling
- async/await and CancellationToken propagation
- concurrency
- Entity Framework behavior
- dependency-injection lifetimes
- public API compatibility
- authorization and security
- missing tests

You can also pipe a diff into a review profile:

git diff | stemcode --stdin --profile review
USE AI AS PART OF THE LOOP

A strong workflow is: understand → plan → implement → build → test → debug → review. The compiler, tests, Git diff, and developer remain authoritative checkpoints.

11 / FAQ

StemCode for .NET developers: common questions.

Can StemCode work with ASP.NET Core?

Yes. StemCode operates against the repository, so it can inspect and modify ASP.NET Core projects alongside class libraries, workers, infrastructure projects, and tests.

Can StemCode run dotnet test?

Yes. StemCode can execute approved shell commands, including the normal dotnet build and test commands used by your repository.

Does StemCode replace Visual Studio?

No. Visual Studio remains useful for debugging, profiling, solution management, and deep IDE features. StemCode adds repository-aware AI analysis and automation around those workflows.

Can StemCode understand C# references and implementations?

StemCode supports LSP-powered code intelligence. Installing a compatible C# language server such as csharp-ls gives it richer semantic navigation.

Can teams share StemCode project conventions?

Yes. Workspace commands and selected memory files under .stemcode can be reviewed and committed with the repository when the team wants shared agent context.

NEXT STEP

Put StemCode to work in a real repository.

Install StemCode, open the project you already work in, and begin with a repository-understanding task before asking the agent to change code. That gives the model better context and keeps the workflow reviewable.

INSTALL

Start with the CLI.

npm install -g stemcode
cd your-project
stemcode
LEARN

Go deeper.

Read the full StemCode documentation for providers, permissions, LSP integrations, memory, MCP, CI review, and advanced workspace configuration.

READ THE DOCS →