📄 CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

GitBrowser is an ASP.NET Core Blazor web application that provides single-user GitHub-like views for self-hosted git repositories. The project targets .NET 10.0 (preview) and uses Blazor for the frontend with a familiar GitHub-style interface for browsing files, commits, and repository contents.

Build and Development Commands

Build the project

dotnet build

Run the application (development)

dotnet run --project GitBrowser

The application runs on:

  • HTTP: http://localhost:5186
  • HTTPS: https://localhost:7270

Format code

Code formatting is handled automatically via CSharpier.MsBuild during build. To manually format:

dotnet csharpier format .

Project Configuration

SDK and Framework

  • Targets .NET 10.0 (RC2, preview SDK)
  • Uses Central Package Management (CPM) - package versions are defined in Directory.Packages.props
  • Package lock files are enabled (RestorePackagesWithLockFile)
  • Implicit usings are disabled - all namespaces must be explicitly imported

Code Style

  • EditorConfig enforces consistent formatting:
    • C# files: 4 spaces, max 120 chars per line
    • XML/JSON/config: 2 spaces
    • HTML/Razor: 2 spaces
    • CSS: 2 spaces
    • Line endings: LF (Unix-style)

Architecture

Project Structure

  • GitBrowser/ - Main web application project
    • Components/ - Blazor components
      • Pages/ - Routable page components (Home, Error, NotFound)
      • Layout/ - Layout components (MainLayout, NavMenu)
      • Routes.razor - Routing configuration
      • App.razor - Root application component
      • _Imports.razor - Global Razor imports
    • wwwroot/ - Static assets (CSS, favicon)
    • Program.cs - Application entry point and configuration

Application Setup (Program.cs)

  • Uses ASP.NET Core minimal hosting model
  • Razor Components are registered as services
  • Static Assets pipeline enabled (replaces traditional static files)
  • Antiforgery protection enabled
  • Status code pages configured for 404 handling
  • HSTS enabled in production
  • Blazor navigation exceptions disabled via BlazorDisableThrowNavigationException

Blazor Configuration

  • Uses static rendering (no interactive render modes configured yet)
  • Routes are defined in Components/Routes.razor
  • Main layout in Components/Layout/MainLayout.razor
  • Scoped CSS is supported (e.g., MainLayout.razor.css)

Important Notes

  • No implicit usings: Always add explicit using statements for all namespaces
  • Package versions must be managed in Directory.Packages.props (CPM enabled)
  • When adding new packages, update packages.lock.json via dotnet restore
  • The project uses .NET 10.0 RC which requires the specific SDK version in global.json