2.6 KiB
AI Code Exploration Exercise
A small C# application in the Active Record style, for practicing using coding agents to explore unfamiliar codebases.
What this is
The src/Before/ folder contains a small domain model (Client, Order) backed by a fake EF Core DbContext. The src/Before.Console/ project is a demo console app that seeds data and queries it.
You do not need to read or understand the code before starting. The point is to use a coding agent to produce diagrams that reveal the structure and behavior.
Prerequisites
- A coding agent with access to this repo (Claude Code, Cursor, Copilot, etc.)
- .NET SDK 10.0 (to build and run)
mmdcCLI for Mermaid rendering, or IDE Mermaid preview
Setup
- Clone this repo
- Open
ai-code-exploration.slnin your IDE - Build to verify everything compiles:
dotnet build - On windows: npm install @mermaid-js/mermaid-cli (global install failed)
- Verify mermaid runs
./node-modules/.bin/mmdc
Tasks
Use a coding agent to create diagrams of this codebase. Start broad, then iterate with follow-up prompts to refine.
Task 1: Class diagram (sanity check)
Prompt your agent to create a class diagram of the classes in src/Before/ using Mermaid. Iterate until you're satisfied it captures the structure accurately.
What to check: Are the inheritance relationships correct? Are the associations (Client → Orders, Order → Client) visible? Is the DbContext leak (domain objects reaching persistence) shown?
Task 2: Sequence diagram — happy path
Prompt your agent to create a sequence diagram for the flow when Client.FindByName("Jane Doe") is called.
Task 3: Sequence diagram — exception path
Prompt your agent to 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 database gets initialized and what interactions happen on Client and Order entities. 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
mmdcto check syntax, visually check the diagram against the code. - The skill is directing the agent, not writing diagrams by hand.