This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SharpPad is a web-based C# code editor and execution platform similar to LinqPad, built with ASP.NET Core 9.0 and Monaco Editor. It combines Roslyn compiler services with modern web technologies to provide real-time code execution, IntelliSense, AI chat integration, and NuGet package management. The platform now includes both web and desktop versions.
- SharpPad/: Main ASP.NET Core 9.0 web application that serves the UI and provides API endpoints
- MonacoRoslynCompletionProvider/: .NET 9.0 library that handles all Roslyn-based code analysis, compilation, and IntelliSense features
- SharpPad.Desktop/: Avalonia-based desktop application that hosts the web UI in a WebView with native menus and system integration
- Frontend: Monaco Editor with custom C# language provider, responsive UI with resizable panels
- Backend API: RESTful endpoints for code execution, completion, chat proxy, and file management
- Code Analysis Engine: Roslyn-based workspace management with NuGet integration and dynamic assembly loading
- AI Integration: GPT chat and code completion with configurable models and endpoints
# Build entire solution
dotnet build SharpPad.sln
# Build specific projects
dotnet build SharpPad/SharpPad.csproj
dotnet build MonacoRoslynCompletionProvider/MonacoRoslynCompletionProvider.csproj
# Release build
dotnet build -c ReleaseWeb Application:
# Run web version in development mode
dotnet run --project SharpPad/SharpPad.csproj
# Run with specific environment
ASPNETCORE_ENVIRONMENT=Development dotnet run --project SharpPad/SharpPad.csprojDesktop Application:
# Run desktop version
dotnet run --project SharpPad.Desktop/SharpPad.Desktop.csproj
# Build desktop releases
# Windows
.\build-desktop.ps1 -Configuration Release
# macOS/Linux
./build-desktop.sh --configuration Release# Build and run with Docker Compose
docker compose up -d
# Rebuild and restart
docker compose build sharppad && docker compose down && docker compose up -d
# Stop services
docker compose down# Run all tests (if test projects exist)
dotnet test
# Test specific project
dotnet test SharpPad/SharpPad.csproj- Compiles and executes C# code with real-time output streaming
- Uses isolated
AssemblyLoadContextfor memory management - Supports NuGet package integration during runtime
/complete: IntelliSense autocompletion/signature: Method signature help/hover: Symbol information on hover/codeCheck: Syntax and semantic validation/format: Code formatting/addPackages: NuGet package management
- Proxy for AI/GPT chat completion with streaming support
- Supports custom endpoints and authorization tokens
- Optimized for real-time responses with Server-Sent Events
- editor/editor.js: Monaco Editor integration with C# language support
- fileSystem/fileManager.js: File and folder management using localStorage
- chat/chat.js: AI chat interface with streaming responses
- execution/runner.js: Code execution interface
- utils/apiService.js: Centralized API communication
- Responsive design supporting desktop and mobile
- Resizable panels (editor, output, file list, chat)
- Context menus for file operations
- Theme switching (dark/light)
- Multi-model AI integration
- WebServerManager: Embedded ASP.NET Core server with automatic port assignment
- MainWindow: Avalonia XAML window with WebView integration and native menus
- MainWindowViewModel: MVVM pattern with commands for file operations
- WebView Integration: Uses
AvaloniaWebView.WebViewfor rendering web content
- Native menu bar with keyboard shortcuts
- Embedded web server reads configuration from SharpPad's
appsettings.json - Automatic path resolution to SharpPad project's
wwwrootdirectory - Cross-platform support (Windows, macOS, Linux)
- Packages downloaded asynchronously from nuget.org
- Cached locally in
/app/NugetPackages/packages/ - Supports .NET 8.0, .NET Standard 2.0/2.1 frameworks
- Dynamic assembly loading with
AssemblyLoadContext
- Concurrent package downloads
- Assembly reference caching with
ConcurrentDictionary - Workspace pooling and reuse
- Automatic garbage collection and cleanup
The project follows specific coding standards defined in .cursorrules:
- Simplicity: Write simple, direct code (fewer lines = less debt)
- Readability: Ensure code is easy to read and understand
- Maintainability: Write code that's easy to maintain and update
- Performance: Consider performance without over-optimization
- Use early returns to avoid nested conditions
- Prefer descriptive naming (event handlers prefixed with "handle")
- Use constants over functions where applicable
- Favor functional and immutable styles
- Minimize code changes - only modify relevant parts
- Place composite functions before their components
- Add function comments describing purpose
- Use JSDoc for JavaScript (unless TypeScript)
ASPNETCORE_ENVIRONMENT: Set to Development/ProductionASPNETCORE_URLS: Default is http://+:5090
wwwroot/: Frontend assets and Monaco Editor filesNugetPackages/packages/: NuGet package cacheKingOfTool/: Example code snippets and configurationsSharpPad.Desktop/: Desktop application projectDll/: Pre-loaded assemblies (FreeSql, CSRedisCore, RestSharp, etc.)
appsettings.json: Web server configuration (Kestrel endpoints, logging)NuGet.config: Multiple NuGet sources (official, regional mirrors)docker-compose.yml: Container deployment with health checksbuild-desktop.ps1/.sh: Cross-platform desktop build scripts
The application is containerized with:
- Multi-stage Docker build for optimization
- Volume persistence for NuGet packages
- Health checks and resource limits
- Proper permission handling for package directories
Ctrl + Enter: Run codeAlt + C: Clear outputCtrl + J: Code completionCtrl + K, Ctrl + D: Format codeCtrl + S: Save codeCtrl + Shift + Space: Manual GPT auto-completionCtrl + Shift + K: AI code editingCtrl + D: Duplicate line
Alt + L: Clear chat history (when cursor is in chat box)
- File management is client-side using localStorage
- Code execution happens in isolated contexts for safety
- AI integration supports multiple providers and custom endpoints
- The application targets .NET 9.0 with C# Latest support
- Monaco Editor provides full IDE-like experience in the browser
- Desktop version embeds web server and uses WebView for rendering
- Configuration is centralized in SharpPad's
appsettings.jsonfor both web and desktop versions - Both projects support hot-reload during development
- don't modify SharpPad.csproj To Web