mostalive d60ea160c4 rewrite comments in neutral, terse style
Doc comments, inline comments, and README no longer editorialize about
the code (ActiveRecord, leak, fake, Yak before/after). They now describe
behavior only. Test A_client_can_reach_its_DbContext__the_leak renamed
to A_client_can_reach_its_DbContext. No behavior changes; all 27 tests
pass.
2026-09-15 17:26:15 +01:00

AI Code Exploration Exercise

A small C# application for practicing code exploration with a coding agent: use it to produce diagrams that reveal the structure and behavior of an unfamiliar codebase.

What this is

src/Before/ contains a small domain model (Client, Order) with an in-memory DbContext and a WebApp consumer. src/Before.Console/ is a demo console app that seeds data and queries it. tests/Before.Tests/ covers the behavior.

You do not need to read or understand the code before starting. The point is to use a coding agent to produce the diagrams.

Prerequisites

  • A coding agent with access to this repo (Claude Code, Cursor, Copilot, etc.)
  • .NET SDK 10.0
  • mmdc CLI for Mermaid rendering, or IDE Mermaid preview

Setup

  1. Clone this repo
  2. Open ai-code-exploration.sln in your IDE
  3. Build to verify everything compiles:
    dotnet build
    

Tasks

Start broad, then iterate with follow-up prompts to refine.

Task 1: Class diagram

Create a class diagram of the classes in src/Before/ using Mermaid. Iterate until it captures the structure accurately.

What to check: Are the inheritance relationships correct? Are the associations (Client → Orders, Order → Client) visible? Is the dependency between the domain classes and DbContext shown — and in which direction does it point?

Task 2: Sequence diagram — happy path

Create a sequence diagram for the flow when Client.FindByName("Jane Doe") is called.

Task 3: Sequence diagram — exception path

Create a sequence diagram for Client.FindByNameRequired("Nobody") — when the client is not found. What interactions differ from the happy path? Where is ObjectNotFoundException thrown?

Task 4 (stretch): Full initialization flow

From Program.cs (the console entry point), trace how the DbContext is created and made available to entities, and what interactions happen on Client and Order. Include the exception flow from Task 3. This will be a larger diagram — iterate and simplify as needed.

Tips

  • Start broad, then refine: "Draw me a class diagram of src/Before/" is enough to start.
  • Iterate on the prompt: If the first diagram is missing something, ask the agent to add it. You don't need to write Mermaid syntax.
  • Validate: Use mmdc to check syntax, visually check the diagram against the code.
  • Direct the agent; don't write diagrams by hand.
S
Description
Use a coding agent to explore unfamiliar codebases, or parts of them.
Readme
61 KiB
Languages
C# 100%